2021-03-04 15:47:38 -05:00
|
|
|
export default function (server) {
|
2020-06-18 14:22:31 -04:00
|
|
|
// Scope resources
|
2020-06-04 16:53:37 -04:00
|
|
|
|
2020-08-17 14:43:12 -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',
|
2020-08-17 14:43:12 -04:00
|
|
|
});
|
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
|
|
|
|
2021-01-21 16:43:11 -05:00
|
|
|
server.create('user', { id: 'authenticateduser' });
|
|
|
|
|
|
2020-06-18 15:51:40 -04:00
|
|
|
// Auth
|
2021-03-24 18:36:34 -04:00
|
|
|
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 },
|
2021-11-03 09:53:03 -07:00
|
|
|
'withAccountsAndUsersAndManagedGroups'
|
2021-03-04 15:47:38 -05:00
|
|
|
);
|
2021-03-24 18:36:34 -04:00
|
|
|
const orgAuthMethods = server.createList(
|
2021-03-04 15:47:38 -05:00
|
|
|
'auth-method',
|
|
|
|
|
3,
|
|
|
|
|
{ scope: orgScope },
|
2021-11-03 09:53:03 -07:00
|
|
|
'withAccountsAndUsersAndManagedGroups'
|
2021-03-04 15:47:38 -05:00
|
|
|
);
|
2021-03-24 18:36:34 -04: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
|
|
|
|
2020-06-18 14:22:31 -04:00
|
|
|
// Other resources
|
2021-03-04 15:47:38 -05:00
|
|
|
server.schema.scopes.where({ type: 'project' }).models.forEach((scope) => {
|
2020-09-10 16:19:27 -04:00
|
|
|
server.createList('host-catalog', 2, { scope }, 'withChildren');
|
2021-07-12 16:03:06 -04:00
|
|
|
server.createList('credential-store', 3, { scope }, 'withAssociations');
|
2021-07-20 16:09:59 -04:00
|
|
|
server.createList('target', 2, { scope }, 'withAssociations');
|
2021-08-09 09:09:18 -04:00
|
|
|
// 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
|
|
|
}
|