chore: 🤖 implement remove sources abilities on targets

This commit is contained in:
Randall Morey committed 2021-09-27 16:55:19 -04:00
1 parent add826007d
commit 3ecb8b8ea9
6 files changed
+97 -37

No files matched your search

+14
View File
@@ -12,4 +12,18 @@ export default class TargetAbility extends ModelAbility {
get canConnect() {
return this.hasAuthorizedAction('authorize-session');
}
/**
* @type {boolean}
*/
get canRemoveHostSources() {
return this.hasAuthorizedAction('remove-host-sources');
}
/**
* @type {boolean}
*/
get canRemoveCredentialSources() {
return this.hasAuthorizedAction('remove-credential-sources');
}
}
@@ -14,4 +14,26 @@ module('Unit | Abilities | Target', function (hooks) {
model.authorized_actions = [];
assert.notOk(service.can('connect 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 remove crednetial 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));
});
});