Skip to content

Commit

Permalink
add a couple more tests for capabilities function
Browse files Browse the repository at this point in the history
  • Loading branch information
Madalyn Parker committed Oct 30, 2018
1 parent 94b42bf commit 8873339
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion ui/tests/unit/models/capabilities-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module('Unit | Model | capabilities', function(hooks) {
assert.notOk(model.get('canList'));
});

test('it does not require sudo on sys/leases/revoke if update capability is present', function(assert) {
test('it does not require sudo on sys/leases/revoke if update capability is present and path is not fully a sudo prefix', function(assert) {
let model = run(() =>
this.owner.lookup('service:store').createRecord('capabilities', {
path: 'sys/leases/revoke',
Expand All @@ -95,4 +95,32 @@ module('Unit | Model | capabilities', function(hooks) {
assert.notOk(model.get('canDelete'));
assert.notOk(model.get('canList'));
});

test('it requires sudo on prefix path even if capability is present', function(assert) {
let model = run(() =>
this.owner.lookup('service:store').createRecord('capabilities', {
path: SUDO_PATH_PREFIXES[0] + '/aws',
capabilities: ['update', 'read'],
})
);
assert.notOk(model.get('canRead'));
assert.notOk(model.get('canCreate'));
assert.notOk(model.get('canUpdate'), 'should still require sudo');
assert.notOk(model.get('canDelete'));
assert.notOk(model.get('canList'));
});

test('it does not require sudo on prefix path if both update and sudo capabilities are present', function(assert) {
let model = run(() =>
this.owner.lookup('service:store').createRecord('capabilities', {
path: SUDO_PATH_PREFIXES[0] + '/aws',
capabilities: ['sudo', 'update', 'read'],
})
);
assert.ok(model.get('canRead'));
assert.notOk(model.get('canCreate'));
assert.ok(model.get('canUpdate'), 'should not require sudo');
assert.notOk(model.get('canDelete'));
assert.notOk(model.get('canList'));
});
});

0 comments on commit 8873339

Please sign in to comment.