Allow Dashboard's QA card to search for nested KVv2 secrets (#25001)

* improve overview test

* add new component for KVv2 dashboard quick actions card

* add changelog

* revert carry over test change from ember data work.

* redo test

* remove the check for v2 because test suite is strange on return value CI vs locally
This commit is contained in:
Angel Garbarino
2024-01-23 11:31:46 -07:00
committed by GitHub
parent 58ef5fe47b
commit 00157f02e4
5 changed files with 41 additions and 27 deletions

3
changelog/25001.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
ui: Allows users to search within KV v2 directories from the Dashboard's quick action card.
```

View File

@@ -40,25 +40,34 @@
/>
{{#if this.searchSelectParams.model}}
<h4 class="title is-6" data-test-card-subtitle="param">{{this.searchSelectParams.title}}</h4>
<SearchSelect
class="is-flex-grow-1"
@selectLimit="1"
@models={{array this.searchSelectParams.model}}
@placeholder={{this.searchSelectParams.placeholder}}
@disallowNewItems={{true}}
@onChange={{this.handleActionSelect}}
@fallbackComponent="input-search"
@disabled={{not this.searchSelectParams.model}}
@nameKey={{this.searchSelectParams.nameKey}}
@queryObject={{this.searchSelectParams.queryObject}}
@objectKeys={{this.searchSelectParams.objectKeys}}
@passObject={{true}}
@shouldRenderName={{this.searchSelectParams.nameKey}}
data-test-search-select="params"
/>
{{! use special input to allow searching for KVv2 secrets inside a directory }}
{{#if (eq this.selectedEngine.type "kv")}}
<KvSuggestionInput
@label="Secret Path"
@value={{this.paramValue}}
@mountPath={{this.selectedEngine.id}}
@onChange={{fn (mut this.paramValue)}}
/>
{{else}}
<h4 class="title is-6" data-test-card-subtitle="param">{{this.searchSelectParams.title}}</h4>
<SearchSelect
class="is-flex-grow-1"
@selectLimit="1"
@models={{array this.searchSelectParams.model}}
@placeholder={{this.searchSelectParams.placeholder}}
@disallowNewItems={{true}}
@onChange={{this.handleActionSelect}}
@fallbackComponent="input-search"
@disabled={{not this.searchSelectParams.model}}
@nameKey={{this.searchSelectParams.nameKey}}
@queryObject={{this.searchSelectParams.queryObject}}
@objectKeys={{this.searchSelectParams.objectKeys}}
@passObject={{true}}
@shouldRenderName={{this.searchSelectParams.nameKey}}
data-test-search-select="params"
/>
{{/if}}
<div>
<Hds::Button
@text={{this.searchSelectParams.buttonText}}

View File

@@ -330,16 +330,17 @@ module('Acceptance | landing page dashboard', function (hooks) {
await consoleComponent.runCommands(deleteEngineCmd(databaseBackend));
});
test('shows the correct actions and links associated with kv v1', async function (assert) {
await runCommands(['write sys/mounts/kv type=kv', 'write kv/foo bar=baz']);
test('does not show kv1 mounts', async function (assert) {
// delete before in case you are rerunning the test and it fails without deleting
await consoleComponent.runCommands(deleteEngineCmd('kv1'));
await consoleComponent.runCommands([`write sys/mounts/kv1 type=kv`]);
await settled();
await visit('/vault/dashboard');
await selectChoose(SELECTORS.searchSelect('secrets-engines'), 'kv');
await fillIn(SELECTORS.selectEl, 'Find KV secrets');
assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist();
assert.dom(SELECTORS.subtitle('param')).hasText('Secret path');
assert.dom(SELECTORS.actionButton('Read secrets')).exists({ count: 1 });
await consoleComponent.runCommands(deleteEngineCmd('kv'));
await click('[data-test-component="search-select"] .ember-basic-dropdown-trigger');
assert
.dom('.ember-power-select-option')
.doesNotHaveTextContaining('kv1', 'dropdown does not show kv1 mount');
await consoleComponent.runCommands(deleteEngineCmd('kv1'));
});
});

View File

@@ -12,6 +12,7 @@ export const SELECTORS = {
cardHeader: (name) => `[data-test-dashboard-card-header="${name}"]`,
tableRow: (name) => `[data-test-dashboard-table="${name}"] tr`,
searchSelect: (name) => `[data-test-search-select="${name}"]`,
kvSearchSelect: `[data-test-kv-suggestion-input]`,
actionButton: (action) => `[data-test-button="${action}"]`,
title: (name) => `[data-test-title="${name}"]`,
subtitle: (name) => `[data-test-card-subtitle="${name}"]`,

View File

@@ -143,7 +143,7 @@ module('Integration | Component | dashboard/quick-actions-card', function (hooks
await selectChoose(SELECTORS.searchSelect('secrets-engines'), 'kv-v2-test');
assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist();
await fillIn(SELECTORS.selectEl, 'Find KV secrets');
assert.dom(SELECTORS.subtitle('param')).hasText('Secret path');
assert.dom(SELECTORS.kvSearchSelect).exists('Shows option to search fo KVv2 secret');
assert.dom(SELECTORS.actionButton('Read secrets')).exists({ count: 1 });
});
});