Files
threshold-ui/ui/admin/tests/unit/abilities/scope-test.js
T

49 lines
1.4 KiB
JavaScript
Raw Normal View History

/**
2026-01-28 17:09:06 -08:00
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | Scope', function (hooks) {
setupTest(hooks);
let features;
2026-02-24 13:48:34 -05:00
let abilitiesService;
let store;
hooks.beforeEach(function () {
store = this.owner.lookup('service:store');
2026-02-24 13:48:34 -05:00
abilitiesService = this.owner.lookup('service:abilities');
features = this.owner.lookup('service:features');
});
test('can attach storage policy when authorized', function (assert) {
features.enable('ssh-session-recording');
const scopeModel = store.createRecord('scope', {
authorized_actions: ['attach-storage-policy'],
});
2026-02-24 13:48:34 -05:00
assert.true(abilitiesService.can('attachStoragePolicy scope', scopeModel));
});
test('cannot attach storage policy when unauthorized', function (assert) {
features.enable('ssh-session-recording');
const scopeModel = store.createRecord('scope', {
authorized_actions: [],
});
2026-02-24 13:48:34 -05:00
assert.false(abilitiesService.can('attachStoragePolicy scope', scopeModel));
});
test('can detach storage policy when authorized', function (assert) {
features.enable('ssh-session-recording');
const scopeModel = store.createRecord('scope', {
authorized_actions: ['detach-storage-policy'],
});
2026-02-24 13:48:34 -05:00
assert.true(abilitiesService.can('detachStoragePolicy scope', scopeModel));
});
});