2024-01-09 11:39:28 -08:00
|
|
|
/**
|
2026-01-28 17:09:06 -08:00
|
|
|
* Copyright IBM Corp. 2021, 2026
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2024-01-09 11:39:28 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
|
|
|
|
|
|
module('Unit | Abilities | Scope', function (hooks) {
|
|
|
|
|
setupTest(hooks);
|
|
|
|
|
|
2026-02-24 13:48:34 -05:00
|
|
|
let abilitiesService;
|
2024-01-09 11:39:28 -08:00
|
|
|
|
|
|
|
|
hooks.beforeEach(function () {
|
2026-02-24 13:48:34 -05:00
|
|
|
abilitiesService = this.owner.lookup('service:abilities');
|
2024-01-09 11:39:28 -08:00
|
|
|
});
|
|
|
|
|
test('it exists', function (assert) {
|
|
|
|
|
const ability = this.owner.lookup('ability:scope');
|
|
|
|
|
assert.ok(ability);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('it reflects when a given scope may attach a policy in global scope', function (assert) {
|
|
|
|
|
const model = {
|
|
|
|
|
authorized_actions: ['attach-storage-policy'],
|
|
|
|
|
};
|
2026-02-24 13:48:34 -05:00
|
|
|
assert.true(abilitiesService.can('attachStoragePolicy scope', model));
|
2024-01-09 11:39:28 -08:00
|
|
|
model.authorized_actions = [];
|
2026-02-24 13:48:34 -05:00
|
|
|
assert.false(abilitiesService.can('attachStoragePolicy scope', model));
|
2024-01-09 11:39:28 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('it reflects when a given scope may remove a policy in org scope', function (assert) {
|
|
|
|
|
const model = {
|
|
|
|
|
authorized_actions: ['detach-storage-policy'],
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-24 13:48:34 -05:00
|
|
|
assert.true(abilitiesService.can('detachStoragePolicy scope', model));
|
2024-01-09 11:39:28 -08:00
|
|
|
model.authorized_actions = [];
|
2026-02-24 13:48:34 -05:00
|
|
|
assert.false(abilitiesService.can('detachStoragePolicy scope', model));
|
2024-01-09 11:39:28 -08:00
|
|
|
});
|
|
|
|
|
});
|