-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change capabilities logic for sudo prefixes #5647
Changes from 5 commits
94b42bf
b8e34fe
8873339
f797aee
be82e78
3ae8d52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,4 +81,46 @@ module('Unit | Model | capabilities', function(hooks) { | |
assert.notOk(model.get('canDelete')); | ||
assert.notOk(model.get('canList')); | ||
}); | ||
|
||
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', | ||
capabilities: ['update', 'read'], | ||
}) | ||
); | ||
assert.ok(model.get('canRead')); | ||
assert.notOk(model.get('canCreate'), 'sudo requires the capability to be set as well'); | ||
assert.ok(model.get('canUpdate'), 'should not require sudo if it has update'); | ||
assert.notOk(model.get('canDelete')); | ||
assert.notOk(model.get('canList')); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add another test for the paths in the SUDO_PREFIX arg too to make sure they are requiring sudo? So for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a couple. Do they look right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yassss - perfect! |
||
|
||
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')); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this doesn't have to do with sudo, just that
create
wasn't in the capabilities list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in every test so I just left it