From 4d5ce5d9127d5692d30425ef6f2cc01e8144c58b Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Thu, 28 Jun 2018 15:28:53 -0500 Subject: [PATCH 1/2] fix cubbyhole and add acceptance test for it --- .../vault/cluster/secrets/backend/create.js | 4 ++ .../vault/cluster/secrets/backend/list.js | 1 + .../cluster/secrets/backend/secret-edit.js | 1 + .../secrets/backend/cubbyhole/secret-test.js | 40 +++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js diff --git a/ui/app/routes/vault/cluster/secrets/backend/create.js b/ui/app/routes/vault/cluster/secrets/backend/create.js index 09b76c3d907b..8c6aed126034 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/create.js +++ b/ui/app/routes/vault/cluster/secrets/backend/create.js @@ -13,6 +13,10 @@ var SecretProxy = Ember.Object.extend(KeyMixin, { let backendModel = this.store.peekRecord('secret-engine', backend); return this.store.createRecord(backendModel.get('modelTypeForKV'), this.toModel()); }, + + willDestroy() { + this.store = null; + }, }); export default EditBase.extend({ diff --git a/ui/app/routes/vault/cluster/secrets/backend/list.js b/ui/app/routes/vault/cluster/secrets/backend/list.js index 49ce0b0163f8..b2f36c71a2c8 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/list.js +++ b/ui/app/routes/vault/cluster/secrets/backend/list.js @@ -40,6 +40,7 @@ export default Ember.Route.extend({ aws: 'role-aws', pki: tab === 'certs' ? 'pki-certificate' : 'role-pki', // secret or secret-v2 + cubbyhole: 'secret', kv: backendModel.get('modelTypeForKV'), generic: backendModel.get('modelTypeForKV'), }; diff --git a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js index 7d8102d33202..9d399b493493 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js +++ b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js @@ -51,6 +51,7 @@ export default Ember.Route.extend(UnloadModelRoute, { ssh: 'role-ssh', aws: 'role-aws', pki: secret && secret.startsWith('cert/') ? 'pki-certificate' : 'role-pki', + cubbyhole: 'secret', kv: backendModel.get('modelTypeForKV'), generic: backendModel.get('modelTypeForKV'), }; diff --git a/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js b/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js new file mode 100644 index 000000000000..41280ffe9af5 --- /dev/null +++ b/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js @@ -0,0 +1,40 @@ +import { test } from 'qunit'; +import moduleForAcceptance from 'vault/tests/helpers/module-for-acceptance'; +import editPage from 'vault/tests/pages/secrets/backend/kv/edit-secret'; +import showPage from 'vault/tests/pages/secrets/backend/kv/show'; +import listPage from 'vault/tests/pages/secrets/backend/list'; + +import { create } from 'ember-cli-page-object'; + +import apiStub from 'vault/tests/helpers/noop-all-api-requests'; + +moduleForAcceptance('Acceptance | secrets/cubbyhole/create', { + beforeEach() { + this.server = apiStub({ usePassthrough: true }); + return authLogin(); + }, + afterEach() { + this.server.shutdown(); + }, +}); + +test('it creates and can view a secret with the cubbyhole backend', function(assert) { + const kvPath = `cubbyhole-kv-${new Date().getTime()}`; + listPage.visitRoot({ backend: 'cubbyhole' }); + andThen(() => { + assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.list-root', 'navigates to the list page'); + }); + + listPage.create(); + editPage.createSecret(kvPath, 'foo', 'bar'); + andThen(() => { + let capabilitiesReq = this.server.passthroughRequests.findBy('url', '/v1/sys/capabilities-self'); + assert.equal( + JSON.parse(capabilitiesReq.requestBody).paths, + `cubbyhole/${kvPath}`, + 'calls capabilites with the correct path' + ); + assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.show', 'redirects to the show page'); + assert.ok(showPage.editIsPresent, 'shows the edit button'); + }); +}); From 98fdfb4610d39b12cb2c5acd34c53f8812cbb5ff Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Thu, 28 Jun 2018 15:41:22 -0500 Subject: [PATCH 2/2] remove unused import --- ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js b/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js index 41280ffe9af5..c9af92d770dc 100644 --- a/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js +++ b/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js @@ -3,9 +3,6 @@ import moduleForAcceptance from 'vault/tests/helpers/module-for-acceptance'; import editPage from 'vault/tests/pages/secrets/backend/kv/edit-secret'; import showPage from 'vault/tests/pages/secrets/backend/kv/show'; import listPage from 'vault/tests/pages/secrets/backend/list'; - -import { create } from 'ember-cli-page-object'; - import apiStub from 'vault/tests/helpers/noop-all-api-requests'; moduleForAcceptance('Acceptance | secrets/cubbyhole/create', {