diff --git a/addons/api/mirage/factories/auth-method.js b/addons/api/mirage/factories/auth-method.js index 2ce4b4053..daf57061b 100644 --- a/addons/api/mirage/factories/auth-method.js +++ b/addons/api/mirage/factories/auth-method.js @@ -23,15 +23,18 @@ export default factory.extend({ type: (i) => types[i % types.length], /** - * Adds accounts (with associated users) to auth method. + * Adds accounts (with associated users) to auth method and managed groups. */ - withAccountsAndUsers: trait({ + withAccountsAndUsersAndManagedGroups: trait({ afterCreate(authMethod, server) { const { scope, type } = authMethod; + console.log('This is the test'); server.createList('user', 5, { scope }).map((user) => { const { id } = server.create('account', { scope, type, authMethod }); user.update({ accountIds: [id] }); }); + // We need to get the authmethod ID + // server.createList('managed-group', 2, { scope, authMethodId: id }) }, }), }); diff --git a/addons/api/mirage/factories/managed-groups.js b/addons/api/mirage/factories/managed-groups.js index 762d915d4..9cbb76b54 100644 --- a/addons/api/mirage/factories/managed-groups.js +++ b/addons/api/mirage/factories/managed-groups.js @@ -2,11 +2,8 @@ import factory from '../generated/factories/managed-groups'; import permissions from '../helpers/permissions'; import { trait } from 'ember-cli-mirage'; -const types = ['password', 'OIDC']; - export default factory.extend({ id: (i) => `managed-groups-id-${i}`, - type: (i) => types[i % types.length], authorized_actions: () => permissions.authorizedActionsFor('managed-groups') || [ diff --git a/addons/api/mirage/generated/factories/managed-groups.js b/addons/api/mirage/generated/factories/managed-groups.js index 47d90f846..e67558ebf 100644 --- a/addons/api/mirage/generated/factories/managed-groups.js +++ b/addons/api/mirage/generated/factories/managed-groups.js @@ -11,7 +11,15 @@ export default Factory.extend({ created_time: () => date.recent(), updated_time: () => date.recent(), version: () => datatype.number(), - type: 'OIDC', - auth_method_id: () => datatype.number(), - member_ids: () => datatype.array(), + type: 'oidc', + attributes: function () { + switch (this.type) { + case 'oidc': + return { + filter: random.words(), + }; + default: + return; + } + }, }); diff --git a/addons/api/mirage/scenarios/default.js b/addons/api/mirage/scenarios/default.js index 180a332c7..9ede6cb26 100644 --- a/addons/api/mirage/scenarios/default.js +++ b/addons/api/mirage/scenarios/default.js @@ -24,13 +24,13 @@ export default function (server) { 'auth-method', 1, { scope: globalScope }, - 'withAccountsAndUsers' + 'withAccountsAndUsersAndManagedGroups' ); const orgAuthMethods = server.createList( 'auth-method', 3, { scope: orgScope }, - 'withAccountsAndUsers' + 'withAccountsAndUsersAndManagedGroups' ); // Assign primary auth methods per scope // TODO make this generic @@ -44,7 +44,7 @@ export default function (server) { server.createList('role', 1, { scope: globalScope }, 'withPrincipals'); server.createList('role', 5, { scope: orgScope }, 'withPrincipals'); - server.createList('managed-group', 2, { scope: globalScope }, 'withMembers'); + // server.createList('managed-group', 2, { scope: globalScope }, 'withMembers'); // Other resources server.schema.scopes.where({ type: 'project' }).models.forEach((scope) => {