Skip to content
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

use an array to lookup capabilities paths so that commas aren't an issue #4398

Merged
merged 2 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/app/adapters/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default ApplicationAdapter.extend({
},

findRecord(store, type, id) {
return this.ajax(this.buildURL(type), 'POST', { data: { path: id } }).catch(e => {
return this.ajax(this.buildURL(type), 'POST', { data: { paths: [id] } }).catch(e => {
if (e instanceof DS.AdapterError) {
Ember.set(e, 'policyPath', 'sys/capabilities-self');
}
Expand Down
17 changes: 17 additions & 0 deletions ui/tests/acceptance/policies-acl-old-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ test('policies', function(assert) {
);
});
});

test('it properly fetches policies when the name ends in a ,', function(assert) {
const policyString = 'path "*" { capabilities = ["update"]}';
const policyName = `symbol,.`;

page.visit({ type: 'acl' });
// new policy creation
click('[data-test-policy-create-link]');
fillIn('[data-test-policy-input="name"]', policyName);
andThen(() => {
find('.CodeMirror').get(0).CodeMirror.setValue(policyString);
});
click('[data-test-policy-save]');
andThen(() => {
assert.equal(find('[data-test-policy-edit-toggle]').length, 1, 'shows the edit toggle');
});
});
2 changes: 1 addition & 1 deletion ui/tests/unit/adapters/capabilities-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ test('calls the correct url', function(assert) {

adapter.findRecord(null, 'capabilities', 'foo');
assert.equal('/v1/sys/capabilities-self', url, 'calls the correct URL');
assert.deepEqual({ path: 'foo' }, options.data, 'data params OK');
assert.deepEqual({ paths: ['foo'] }, options.data, 'data params OK');
assert.equal('POST', method, 'method OK');
});