From a5ab96c1ab4588f5132d897e1fcbebe349e00b38 Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Thu, 19 Apr 2018 15:00:16 -0500 Subject: [PATCH] use an array to lookup capabilities paths so that commas aren't an issue --- ui/app/adapters/capabilities.js | 2 +- ui/tests/acceptance/policies-acl-old-test.js | 17 +++++++++++++++++ ui/tests/unit/adapters/capabilities-test.js | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ui/app/adapters/capabilities.js b/ui/app/adapters/capabilities.js index 5c110f2bab29..ffdc51aae165 100644 --- a/ui/app/adapters/capabilities.js +++ b/ui/app/adapters/capabilities.js @@ -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'); } diff --git a/ui/tests/acceptance/policies-acl-old-test.js b/ui/tests/acceptance/policies-acl-old-test.js index 659b916cd4ac..cffe00147422 100644 --- a/ui/tests/acceptance/policies-acl-old-test.js +++ b/ui/tests/acceptance/policies-acl-old-test.js @@ -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'); + }); +}); diff --git a/ui/tests/unit/adapters/capabilities-test.js b/ui/tests/unit/adapters/capabilities-test.js index 9f1ef284676c..1b46bbc8dbbb 100644 --- a/ui/tests/unit/adapters/capabilities-test.js +++ b/ui/tests/unit/adapters/capabilities-test.js @@ -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'); });