UI - fix cubbyhole (#4851)

* fix cubbyhole and add acceptance test for it
This commit is contained in:
Matthew Irish 2018-06-28 15:54:02 -05:00 committed by GitHub
parent 16a2bc7ca2
commit e3ddddf3a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 0 deletions

View File

@ -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({

View File

@ -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'),
};

View File

@ -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'),
};

View File

@ -0,0 +1,37 @@
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 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');
});
});