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

Account for engine paths in Secret Engine list view for configuration links #27131

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions changelog/27131.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fix configuration link from Secret Engine list view for Ember engines.
```
7 changes: 7 additions & 0 deletions ui/app/models/secret-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ export default class SecretEngineModel extends Model {
return `vault.cluster.secrets.backend.list-root`;
}

get backendConfigurationLink() {
if (isAddonEngine(this.engineType, this.version)) {
return `vault.cluster.secrets.backend.${this.engineType}.configuration`;
}
return `vault.cluster.secrets.backend.configuration`;
}

get localDisplay() {
return this.local ? 'local' : 'replicated';
}
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/vault/cluster/secrets/backends.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
/>
<dd.Interactive
@text="View configuration"
@route="vault.cluster.secrets.backend.configuration"
@route={{backend.backendConfigurationLink}}
@model={{backend.id}}
data-test-engine-config
/>
Expand Down
54 changes: 48 additions & 6 deletions ui/tests/acceptance/settings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
* SPDX-License-Identifier: BUSL-1.1
*/

import { currentURL, find, visit, settled } from '@ember/test-helpers';
import { currentURL, find, visit, settled, click } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { v4 as uuidv4 } from 'uuid';

import backendListPage from 'vault/tests/pages/secrets/backends';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import authPage from 'vault/tests/pages/auth';
import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands';
import { GENERAL } from 'vault/tests/helpers/general-selectors';

module('Acceptance | settings', function (hooks) {
const { searchSelect } = GENERAL;

module('Acceptance | secret engine mount settings', function (hooks) {
setupApplicationTest(hooks);

hooks.beforeEach(function () {
this.uid = uuidv4();
return authPage.login();
});

test('settings', async function (assert) {
test('it allows you to mount a secret engine', async function (assert) {
const type = 'consul';
const path = `settings-path-${this.uid}`;

Expand All @@ -44,9 +48,47 @@ module('Acceptance | settings', function (hooks) {
);
await settled();
assert.strictEqual(currentURL(), `/vault/secrets`, 'redirects to secrets page');
const row = backendListPage.rows.filterBy('path', path + '/')[0];
await row.menu();
// cleanup
await runCmd(deleteEngineCmd(path));
});

test('it navigates to ember engine configuration page', async function (assert) {
const type = 'ldap';
const path = `ldap-${this.uid}`;

await visit('/vault/settings/mount-secret-backend');
await runCmd(mountEngineCmd(type, path), false);
await visit('/vault/secrets');
await click(searchSelect.trigger('filter-by-engine-name'));
await click(searchSelect.option(searchSelect.optionIndex(path)));
await click(GENERAL.menuTrigger);
await backendListPage.configLink();
assert.strictEqual(
currentURL(),
`/vault/secrets/${path}/${type}/configuration`,
'navigates to the config page for ember engine'
);
// clean up
await runCmd(deleteEngineCmd(path));
});

test('it navigates to non-ember engine configuration page', async function (assert) {
const type = 'ssh';
const path = `ssh-${this.uid}`;

await visit('/vault/settings/mount-secret-backend');
await runCmd(mountEngineCmd(type, path), false);
await visit('/vault/secrets');
await click(searchSelect.trigger('filter-by-engine-name'));
await click(searchSelect.option(searchSelect.optionIndex(path)));
await click(GENERAL.menuTrigger);
await backendListPage.configLink();
assert.strictEqual(currentURL(), `/vault/secrets/${path}/configuration`, 'navigates to the config page');
assert.strictEqual(
currentURL(),
`/vault/secrets/${path}/configuration`,
'navigates to the config page for non-ember engine'
);
// clean up
await runCmd(deleteEngineCmd(path));
});
});
Loading