feat: 🎸 API managed groups mock mirage
Add API managed groups mock in mirage
This commit is contained in:
1 parent
148b40195e
commit
52b5739cdc
6 files changed
+67
No files matched your search
@@ -514,6 +514,14 @@ export default function () {
|
||||
this.del('/credential-libraries/:id');
|
||||
this.patch('/credential-libraries/:id');
|
||||
|
||||
// managed-groups
|
||||
this.get(
|
||||
'/managed-groups',
|
||||
({ managedGroups }, { queryParams: { auth_method_id: authMethodId } }) => {
|
||||
return managedGroups.where({ authMethodId });
|
||||
}
|
||||
);
|
||||
|
||||
/* Uncomment the following line and the Response import above
|
||||
* Then change the response code to simulate error responses.
|
||||
* this.get('/scopes', () => new Response(505));
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import factory from '../generated/factories/managed-groups';
|
||||
import permissions from '../helpers/permissions';
|
||||
|
||||
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') || [
|
||||
'no-op',
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
],
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date, datatype } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedManagedGroupsFactory
|
||||
* A managed group is a resource that represents a collection of accounts.
|
||||
*/
|
||||
export default Factory.extend({
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
version: () => datatype.number(),
|
||||
type: Math.random() < 0.5 ? 'password' : 'OIDC',
|
||||
auth_method_id: () => datatype.number(),
|
||||
member_ids: () => datatype.array(),
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Model, belongsTo } from 'ember-cli-mirage';
|
||||
|
||||
export default Model.extend({
|
||||
scope: belongsTo(),
|
||||
});
|
||||
@@ -44,6 +44,13 @@ 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 },
|
||||
'withAccountsAndUsers'
|
||||
);
|
||||
|
||||
// Other resources
|
||||
server.schema.scopes.where({ type: 'project' }).models.forEach((scope) => {
|
||||
server.createList('host-catalog', 2, { scope }, 'withChildren');
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
modelName: 'managed-groups',
|
||||
|
||||
_hashForModel() {
|
||||
const json = ApplicationSerializer.prototype._hashForModel.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
return json;
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user