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

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

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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/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
16 changes: 8 additions & 8 deletions ui/tests/acceptance/dashboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,16 @@ 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) {
await runCommands(['write sys/mounts/kv1 type=kv', 'write kv1/foo bar=baz']);
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').hasTextContaining('kv', 'dropdown shows kv2 mount');
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 });
});
});
Loading