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

* add backendConfigurationLink and amend Secret Engine List view

* add test coverage that can be backported

* changelog

* clean up extra space
This commit is contained in:
Angel Garbarino 2024-05-21 08:20:29 -06:00 committed by GitHub
parent 2e0db217c2
commit 89fc3bbdcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 59 additions and 7 deletions

3
changelog/27131.txt Normal file
View file

@ -0,0 +1,3 @@
```release-note:bug
ui: Fix configuration link from Secret Engine list view for Ember engines.
```

View file

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

View file

@ -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
/>

View file

@ -3,7 +3,7 @@
* 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';
@ -11,8 +11,12 @@ 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 () {
@ -20,7 +24,7 @@ module('Acceptance | settings', function (hooks) {
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}`;
@ -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}/configuration`, 'navigates to the config page');
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 for non-ember engine'
);
// clean up
await runCmd(deleteEngineCmd(path));
});
});