feat: 🎸 add No scopes add to roles/role/scopes route (#2338)

* feat: 🎸 add No scopes add to roles/role/scopes route

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13878

* feat: 🎸 add new role ability

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13878

* refactor: 💡 fix permission for setting grant scopes on role

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13878
This commit is contained in:
Cameron Perera authored and Lisbet Alvarez committed 2024-07-15 17:23:00 -07:00
1 parent 2bc314d271
commit 85bce84356
9 files changed
+67 -7

No files matched your search

+7
View File
@@ -27,6 +27,13 @@ export default class RoleAbility extends ModelAbility {
return this.hasAuthorizedAction('set-grants');
}
/**
* @type {boolean}
*/
get canSetGrantScopes() {
return this.hasAuthorizedAction('set-grant-scopes');
}
/**
* @type {boolean}
*/
+1
View File
@@ -18,6 +18,7 @@ export default factory.extend({
'set-grants',
'add-principals',
'remove-principals',
'set-grant-scopes',
],
// eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects
grant_strings: () => [
-5
View File
@@ -38,11 +38,6 @@ export default ApplicationSerializer.extend({
if (!json.principals.length) delete json.principals;
// default grant scopes
if (json.grant_scope_ids.length === 0) {
json.grant_scope_ids = ['this'];
}
return json;
},
});
@@ -75,4 +75,14 @@ module('Unit | Abilities | Role', function (hooks) {
});
assert.true(service.can('read account', account));
});
test('can set grant scopes based on authorized_actions', function (assert) {
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['set-grant-scopes'],
};
assert.true(service.can('setGrantScopes role', model));
model.authorized_actions = [];
assert.false(service.can('setGrantScopes role', model));
});
});