Files
threshold-ui/addons/api/mirage/scenarios/default.js
T

55 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-03-04 15:47:38 -05:00
export default function (server) {
// Scope resources
2020-06-04 16:53:37 -04:00
// creates a global scope
const globalScope = server.create('scope', {
id: 'global',
type: 'global',
2021-03-04 15:47:38 -05:00
name: 'Global',
});
2021-03-04 15:47:38 -05:00
const orgScope = server.createList(
'scope',
3,
{
type: 'org',
scope: { id: globalScope.id, type: globalScope.type },
},
'withChildren'
)[0];
2020-06-18 15:51:40 -04:00
server.create('user', { id: 'authenticateduser' });
2020-06-18 15:51:40 -04:00
// Auth
const globalAuthMethods = server.createList(
2021-03-04 15:47:38 -05:00
'auth-method',
2021-11-12 10:26:30 -05:00
1,
2021-03-04 15:47:38 -05:00
{ scope: globalScope },
'withAccountsAndUsersAndManagedGroups'
2021-03-04 15:47:38 -05:00
);
const orgAuthMethods = server.createList(
2021-03-04 15:47:38 -05:00
'auth-method',
3,
{ scope: orgScope },
'withAccountsAndUsersAndManagedGroups'
2021-03-04 15:47:38 -05:00
);
// Assign primary auth methods per scope
// TODO make this generic
2021-03-26 12:47:49 -04:00
globalScope.update({ primaryAuthMethodId: globalAuthMethods[0].id });
orgScope.update({ primaryAuthMethodId: orgAuthMethods[1].id });
2020-05-19 18:10:39 -04:00
2020-09-01 12:03:36 -04:00
// Groups and Users
2020-10-26 11:17:03 -04:00
server.createList('group', 1, { scope: globalScope }, 'withMembers');
2020-09-09 16:24:48 -04:00
server.createList('group', 5, { scope: orgScope }, 'withMembers');
2020-08-12 13:41:23 -04:00
// Role
2020-10-26 11:17:03 -04:00
server.createList('role', 1, { scope: globalScope }, 'withPrincipals');
2020-09-10 11:03:44 -04:00
server.createList('role', 5, { scope: orgScope }, 'withPrincipals');
2020-06-22 21:39:38 -04:00
// Other resources
2021-03-04 15:47:38 -05:00
server.schema.scopes.where({ type: 'project' }).models.forEach((scope) => {
server.createList('host-catalog', 2, { scope }, 'withChildren');
2021-07-12 16:03:06 -04:00
server.createList('credential-store', 3, { scope }, 'withAssociations');
server.createList('target', 2, { scope }, 'withAssociations');
// Sessions have target data. Create it after targets.
server.createList('session', 4, { scope }, 'withAssociations');
2020-07-28 11:06:06 -04:00
});
2020-05-19 18:10:39 -04:00
}