Files
threshold-ui/addons/api/tests/unit/abilities/target-test.js
T
Dharini Jeeva 069a864cbb chore: 🤖 add abilities for injected app cred sources (#1285)
* chore: 🤖 add abilities for injected app cred sources
2022-08-30 12:01:59 -07:00

78 lines
2.7 KiB
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | Target', function (hooks) {
setupTest(hooks);
test('it reflects when a given target may connect based on authorized_actions', function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['authorize-session'],
};
assert.ok(service.can('connect target', model));
model.authorized_actions = [];
assert.notOk(service.can('connect target', model));
});
test('it reflects when a given target may add host sources', function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['add-host-sources'],
};
assert.ok(service.can('addHostSources target', model));
model.authorized_actions = [];
assert.notOk(service.can('addHostSources target', model));
});
test('it reflects when a given target may remove host sources', function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['remove-host-sources'],
};
assert.ok(service.can('removeHostSources target', model));
model.authorized_actions = [];
assert.notOk(service.can('removeHostSources target', model));
});
test('it reflects when a given target may add brokered credential sources', function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['add-credential-sources'],
};
assert.ok(service.can('addBrokeredCredentialSources target', model));
model.authorized_actions = [];
assert.notOk(service.can('addBrokeredCredentialSources target', model));
});
test('it reflects when a given target may remove credential sources', function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['remove-credential-sources'],
};
assert.ok(service.can('removeCredentialSources target', model));
model.authorized_actions = [];
assert.notOk(service.can('removeCredentialSources target', model));
});
test('it reflects when a given ssh target may add injected application credential sources', function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['add-credential-sources'],
isSSH: true,
};
assert.ok(
service.can('addInjectedApplicationCredentialSources target', model)
);
model.authorized_actions = [];
assert.notOk(
service.can('addInjectedApplicationCredentialSources target', model)
);
});
});