Skip to content

Commit

Permalink
fix nav-to-nearest mixin when there are no ancestors (#6198)
Browse files Browse the repository at this point in the history
  • Loading branch information
meirish authored Feb 9, 2019
1 parent be968f0 commit b16527d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ui/app/mixins/with-nav-to-nearest-ancestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default Mixin.create({
navToNearestAncestor: task(function*(key) {
let ancestors = utils.ancestorKeysForKey(key);
let errored = false;
let nearest = ancestors.pop();
let nearest = ancestors && ancestors.pop();
while (nearest) {
try {
let transition = this.transitionToRoute('vault.cluster.secrets.backend.list', nearest);
Expand Down
23 changes: 23 additions & 0 deletions ui/tests/acceptance/secrets/backend/kv/secret-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,29 @@ module('Acceptance | secrets/secret/create', function(hooks) {
'navigates to the ancestor created earlier'
);
});
test('first level secrets redirect properly upon deletion', async function(assert) {
let enginePath = `kv-${new Date().getTime()}`;
let secretPath = 'test';
// mount version 1 engine
await mountSecrets.visit();
await mountSecrets.selectType('kv');
await withFlash(
mountSecrets
.next()
.path(enginePath)
.version(1)
.submit()
);

await listPage.create();
await editPage.createSecret(secretPath, 'foo', 'bar');
await showPage.deleteSecret();
assert.equal(
currentRouteName(),
'vault.cluster.secrets.backend.list-root',
'redirected to the list page on delete'
);
});

// https://github.com/hashicorp/vault/issues/5994
test('version 1: key named keys', async function(assert) {
Expand Down
5 changes: 5 additions & 0 deletions ui/tests/pages/secrets/backend/kv/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { code } from 'vault/tests/pages/helpers/codemirror';

export default create({
...Base,
deleteBtn: clickable('[data-test-secret-delete] button'),
confirmBtn: clickable('[data-test-confirm-button]'),
rows: collection('data-test-row-label'),
toggleJSON: clickable('[data-test-secret-json-toggle]'),
toggleIsPresent: isPresent('[data-test-secret-json-toggle]'),
Expand All @@ -12,4 +14,7 @@ export default create({
editor: {
content: code('[data-test-component="json-editor"]'),
},
deleteSecret() {
return this.deleteBtn().confirmBtn();
},
});

0 comments on commit b16527d

Please sign in to comment.