chore: 🤖 more realistic mock grants for dynamic host catalogs
This commit is contained in:
3 files changed
+23
-23
No files matched your search
@@ -11,6 +11,11 @@ const pluginTypes = ['aws', 'azure', 'foobar'];
|
||||
let pluginTypeCounter = 1;
|
||||
|
||||
export default factory.extend({
|
||||
id: (i) => `host-catalog-id-${i}`,
|
||||
|
||||
// Cycle through available types
|
||||
type: (i) => types[i % types.length],
|
||||
|
||||
authorized_actions: () =>
|
||||
permissions.authorizedActionsFor('host-catalog') || [
|
||||
'no-op',
|
||||
@@ -18,18 +23,15 @@ export default factory.extend({
|
||||
'update',
|
||||
'delete',
|
||||
],
|
||||
authorized_collection_actions: () => {
|
||||
authorized_collection_actions: function () {
|
||||
const isStatic = this.type === 'static';
|
||||
return {
|
||||
hosts: ['create', 'list'],
|
||||
// only static catalogs allow host create at this time
|
||||
hosts: isStatic ? ['create', 'list'] : ['list'],
|
||||
'host-sets': ['create', 'list'],
|
||||
};
|
||||
},
|
||||
|
||||
id: (i) => `host-catalog-id-${i}`,
|
||||
|
||||
// Cycle through available types
|
||||
type: (i) => types[i % types.length],
|
||||
|
||||
plugin: function (i) {
|
||||
if (this.type === 'plugin') {
|
||||
return {
|
||||
|
||||
@@ -2,19 +2,17 @@ import factory from '../generated/factories/host-set';
|
||||
import permissions from '../helpers/permissions';
|
||||
|
||||
export default factory.extend({
|
||||
authorized_actions: () =>
|
||||
permissions.authorizedActionsFor('host-set') || [
|
||||
'no-op',
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
'add-hosts',
|
||||
'remove-hosts',
|
||||
],
|
||||
id: (i) => `host-set-id-${i}`,
|
||||
type() {
|
||||
return this.hostCatalog?.type || factory.attrs.type;
|
||||
},
|
||||
authorized_actions: function () {
|
||||
const isStatic = this.type === 'static';
|
||||
const defaults = ['no-op', 'read', 'update', 'delete'];
|
||||
// Only static allows host management at this time.
|
||||
if (isStatic) defaults.push('add-hosts', 'remove-hosts');
|
||||
return permissions.authorizedActionsFor('host-set') || defaults;
|
||||
},
|
||||
plugin() {
|
||||
if (this.type === 'plugin') {
|
||||
return this.hostCatalog.plugin;
|
||||
|
||||
@@ -2,17 +2,17 @@ import factory from '../generated/factories/host';
|
||||
import permissions from '../helpers/permissions';
|
||||
|
||||
export default factory.extend({
|
||||
authorized_actions: () =>
|
||||
permissions.authorizedActionsFor('host') || [
|
||||
'no-op',
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
],
|
||||
id: (i) => `host-id-${i}`,
|
||||
type() {
|
||||
return this.hostCatalog?.type || factory.attrs.type;
|
||||
},
|
||||
authorized_actions: function () {
|
||||
const isStatic = this.type === 'static';
|
||||
const defaults = ['no-op', 'read'];
|
||||
// Only static allows update/delete at this time.
|
||||
if (isStatic) defaults.push('update', 'delete');
|
||||
return permissions.authorizedActionsFor('host') || defaults;
|
||||
},
|
||||
plugin() {
|
||||
if (this.type === 'plugin') {
|
||||
return this.hostCatalog.plugin;
|
||||
|
||||
Reference in new issue
Block a user