Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: [VAULT-21527] Mirage setup #24000

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class App extends Application {
engines = {
configUi: {
dependencies: {
services: ['auth', 'flash-messages', 'namespace', 'router', 'version'],
services: ['auth', 'flash-messages', 'namespace', 'router', 'store', 'version'],
},
},
openApiExplorer: {
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/config-ui/addon/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class ConfigUiEngine extends Engine {
modulePrefix = modulePrefix;
Resolver = Resolver;
dependencies = {
services: ['auth', 'flash-messages', 'namespace', 'router', 'version'],
services: ['auth', 'store', 'flash-messages', 'namespace', 'router', 'version'],
};
}

Expand Down
131 changes: 131 additions & 0 deletions ui/mirage/handlers/custom-messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

export default function (server) {
server.get('/sys/config/ui/custom-messages', (schema, request) => {
if (request.queryParams.authenticated === 'true') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this by trying to fetch from this endpoint in the custom-message route and noticed that queryParams properties get returned as strings.

return {
data: {
'key-info': {
'01234567-89ab-cdef-0123-456789abcdef': {
title: 'Authenticated custom message title',
type: 'modal',
authenticated: true,
start_time: '2023-10-15T02:36:43.986212308Z',
end_time: '2024-10-15T02:36:43.986212308Z',
active: true,
},
'76543210-89ab-cdef-0123-456789abcdef': {
title: 'Authenticated custom message title two',
type: 'banner',
authenticated: true,
start_time: '2021-10-15T02:36:43.986212308Z',
end_time: '2021-11-15T02:36:43.986212308Z',
active: false,
},
},
keys: ['01234567-89ab-cdef-0123-456789abcdef', '76543210-89ab-cdef-0123-456789abcdef'],
},
};
}

return {
data: {
'key-info': {
'8d6ba39-5c23-50af-3d79-76c26a2845f49': {
title: 'Unauthenticated custom message title',
type: 'modal',
authenticated: false,
start_time: '2023-10-15T02:36:43.986212308Z',
end_time: '2024-10-15T02:36:43.986212308Z',
active: true,
},
'281e580-da16-89c5-4666-16480e4b7c11d': {
title: 'Unauthenticated custom message title two',
type: 'banner',
authenticated: false,
start_time: '2021-10-15T02:36:43.986212308Z',
end_time: '2021-11-15T02:36:43.986212308Z',
active: false,
},
},
keys: ['8d6ba39-5c23-50af-3d79-76c26a2845f49', '281e580-da16-89c5-4666-16480e4b7c11d'],
},
};
});

server.post('/sys/config/ui/custom-messages', () => {
return {
id: '01234567-89ab-cdef-0123-456789abcdef',
data: {
active: true,
start_time: '2023-10-15T02:36:43.986212308Z',
end_time: '2024-10-15T02:36:43.986212308Z',
type: 'modal',
authenticated: false,
},
};
});

server.get('/sys/internal/ui/unauthenticated-messages', () => {
return {
data: {
'key-info': {
'01234567-89ab-cdef-0123-456789abcdef': {
title: 'Unauthenticated Title One',
message:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nulla augue, placerat quis risus blandit, molestie imperdiet massa. Sed blandit rutrum odio quis varius. Fusce purus orci, maximus ac libero.',
type: 'modal',
authenticated: false,
start_time: '2023-10-15T02:36:43.986212308Z',
end_time: '2024-10-15T02:36:43.986212308Z',
options: {},
},
'76543210-89ab-cdef-0123-456789abcdef': {
title: 'Unauthenticated Title Two',
message:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nulla augue, placerat quis risus blandit, molestie imperdiet massa. Sed blandit rutrum odio quis varius. Fusce purus orci, maximus ac libero.',
type: 'banner',
authenticated: false,
start_time: '2021-10-15T02:36:43.986212308Z',
end_time: '2031-10-15T02:36:43.986212308Z',
options: {},
},
},
keys: ['01234567-89ab-cdef-0123-456789abcdef', '76543210-89ab-cdef-0123-456789abcdef'],
},
};
});

server.get('/sys/internal/ui/authenticated-messages', () => {
return {
data: {
'key-info': {
'6543210-89ab-cdef-0123-456780abcieh': {
title: 'Authenticated Title One',
message:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nulla augue, placerat quis risus blandit, molestie imperdiet massa. Sed blandit rutrum odio quis varius. Fusce purus orci, maximus ac libero.',
type: 'modal',
authenticated: true,
start_time: '2023-10-15T02:36:43.986212308Z',
end_time: '2024-10-15T02:36:43.986212308Z',
options: {},
},
'00123858-89ab-cdef-0123-789037ejhdgt': {
title: 'Authenticated Title One',
message:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nulla augue, placerat quis risus blandit, molestie imperdiet massa. Sed blandit rutrum odio quis varius. Fusce purus orci, maximus ac libero.',
type: 'banner',
authenticated: true,
start_time: '2021-10-15T02:36:43.986212308Z',
end_time: '2031-10-15T02:36:43.986212308Z',
options: {},
},
},
keys: ['6543210-89ab-cdef-0123-456780abcieh', '00123858-89ab-cdef-0123-789037ejhdgt'],
},
};
});
}
2 changes: 2 additions & 0 deletions ui/mirage/handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// individual lookup done in mirage config
import base from './base';
import chrootNamespace from './chroot-namespace';
import customMessages from './custom-messages';
import clients from './clients';
import db from './db';
import hcpLink from './hcp-link';
Expand All @@ -31,4 +32,5 @@ export {
mfaLogin,
oidcConfig,
reducedDisclosure,
customMessages,
};