Refactor auth-method and managhed-group factory. This work is not finish.

This commit is contained in:
Carlos Alcaide Corvo committed 2021-11-05 10:42:09 -07:00
1 parent 101e6653d4
commit ef73f8dacd
4 files changed
+19 -11

No files matched your search

+5 -2
View File
@@ -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 })
},
}),
});
@@ -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') || [
@@ -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;
}
},
});
+3 -3
View File
@@ -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) => {