Icu 13880 create manage scopes route and view with keyword values (#2342)
* feat: 🎸 manage scopes route and page ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13880 * Update addons/core/translations/resources/en-us.yaml Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * Update ui/admin/app/abilities/role.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * Update ui/admin/app/components/form/role/manage-scopes/index.hbs Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> --------- Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
1 parent
85bce84356
commit
89e072401c
18 files changed
+536
-16
No files matched your search
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Abilities | role', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
let canService;
|
||||
let store;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
canService = this.owner.lookup('service:can');
|
||||
store = this.owner.lookup('service:store');
|
||||
});
|
||||
|
||||
test('can setGrantScopes on role when authorized and scope is global type', function (assert) {
|
||||
const globalScope = store.createRecord('scope', { id: 'global' });
|
||||
const role = store.createRecord('role', {
|
||||
authorized_actions: ['set-grant-scopes'],
|
||||
scope: globalScope,
|
||||
});
|
||||
assert.true(canService.can('setGrantScopes role', role));
|
||||
role.authorized_actions = [];
|
||||
assert.false(canService.can('setGrantScopes role', role));
|
||||
});
|
||||
|
||||
test('can setGrantScopes on role when authorized and scope is org type', function (assert) {
|
||||
const globalScope = store.createRecord('scope', { id: 'global' });
|
||||
const orgScope = store.createRecord('scope', {
|
||||
type: 'org',
|
||||
scope: globalScope,
|
||||
});
|
||||
const role = store.createRecord('role', {
|
||||
authorized_actions: ['set-grant-scopes'],
|
||||
scope: orgScope,
|
||||
});
|
||||
assert.true(canService.can('setGrantScopes role', role));
|
||||
role.authorized_actions = [];
|
||||
assert.false(canService.can('setGrantScopes role', role));
|
||||
});
|
||||
|
||||
test('cannot setGrantScopes on role when authorized and scope is project type', function (assert) {
|
||||
const globalScope = store.createRecord('scope', { id: 'global' });
|
||||
const orgScope = store.createRecord('scope', {
|
||||
type: 'org',
|
||||
scope: globalScope,
|
||||
});
|
||||
const projectScope = store.createRecord('scope', {
|
||||
type: 'project',
|
||||
scope: orgScope,
|
||||
});
|
||||
const role = store.createRecord('role', {
|
||||
authorized_actions: ['set-grant-scopes'],
|
||||
scope: projectScope,
|
||||
});
|
||||
assert.false(canService.can('setGrantScopes role', role));
|
||||
role.authorized_actions = [];
|
||||
assert.false(canService.can('setGrantScopes role', role));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user