* chore: 🤖 upgrade faker js from v7 to v8 ✅ Closes: ICU-10373 * refactor: 💡 remove deprecated modules from factories * test: 💍 fix failing tests --------- Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com>
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import factory from '../generated/factories/managed-group';
|
|
import { faker } from '@faker-js/faker';
|
|
import permissions from '../helpers/permissions';
|
|
import generateId from '../helpers/id';
|
|
import {
|
|
TYPE_AUTH_METHOD_OIDC,
|
|
TYPE_AUTH_METHOD_LDAP,
|
|
} from 'api/models/auth-method';
|
|
|
|
export default factory.extend({
|
|
authorized_actions: () =>
|
|
permissions.authorizedActionsFor('managed-group') || [
|
|
'no-op',
|
|
'read',
|
|
'update',
|
|
'delete',
|
|
],
|
|
|
|
id: () => generateId('mg_'),
|
|
|
|
type() {
|
|
return this.authMethod?.type;
|
|
},
|
|
|
|
attributes() {
|
|
switch (this.type) {
|
|
case TYPE_AUTH_METHOD_OIDC:
|
|
return {
|
|
filter: `"${faker.word.noun()}" in "${faker.system.directoryPath()}"`,
|
|
};
|
|
case TYPE_AUTH_METHOD_LDAP: {
|
|
const num = faker.number.int({ min: 2, max: 4 });
|
|
const names = [];
|
|
for (let i = 0; i < num; i++) {
|
|
names.push(faker.word.noun());
|
|
}
|
|
return {
|
|
group_names: names,
|
|
};
|
|
}
|
|
}
|
|
},
|
|
});
|