Skip to content

Commit

Permalink
Allow Dashboard's QA card to search for nested KVv2 secrets (#25001)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Monkeychip authored Jan 23, 2024
1 parent 58ef5fe commit 00157f0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 27 deletions.
3 changes: 3 additions & 0 deletions changelog/25001.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Allows users to search within KV v2 directories from the Dashboard's quick action card.
```
45 changes: 27 additions & 18 deletions ui/app/templates/components/dashboard/quick-actions-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
17 changes: 9 additions & 8 deletions ui/tests/acceptance/dashboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
});

0 comments on commit 00157f0

Please sign in to comment.