Files
threshold-ui/addons/api/mirage/factories/credential.js
T

37 lines
886 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2022-07-21 13:48:16 -07:00
import factory from '../generated/factories/credential';
import { faker } from '@faker-js/faker';
2022-07-21 13:48:16 -07:00
import permissions from '../helpers/permissions';
import generatedId from '../helpers/id';
2022-09-20 17:31:16 -07:00
const types = ['username_password', 'ssh_private_key', 'json'];
2022-08-17 13:20:21 -05:00
2022-07-21 13:48:16 -07:00
export default factory.extend({
2022-08-17 13:20:21 -05:00
type: (i) => types[i % types.length],
id() {
switch (this.type) {
case 'ssh_private_key':
return generatedId('credspk_');
case 'username_password':
return generatedId('credup_');
2022-09-20 17:31:16 -07:00
case 'json':
return generatedId('credjson_');
2022-08-17 13:20:21 -05:00
}
},
2022-07-21 13:48:16 -07:00
authorized_actions: () =>
permissions.authorizedActionsFor('credential') || [
'no-op',
'read',
'update',
'delete',
],
attributes() {
return {
username: faker.random.word(),
2022-07-21 13:48:16 -07:00
};
},
2022-07-28 17:49:51 -07:00
});