Skip to content

Commit 1ef9ed4

Browse files
Merge remote-tracking branch 'remotes/from/ce/main'
2 parents 2dc6f89 + 02dd079 commit 1ef9ed4

File tree

19 files changed

+561
-26
lines changed

19 files changed

+561
-26
lines changed

ui/app/components/secret-engine/card/lease-duration.hbs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Copyright (c) HashiCorp, Inc.
33
SPDX-License-Identifier: BUSL-1.1
44
}}
5-
<Hds::Card::Container @level="mid" @hasBorder={{true}} class="has-padding-m has-top-bottom-margin" ...attributes>
5+
<Hds::Card::Container
6+
@level="mid"
7+
@hasBorder={{true}}
8+
class="has-padding-m has-top-bottom-margin"
9+
data-test-card-container="lease-duration"
10+
...attributes
11+
>
612
<Hds::Text::Display @size="300" @tag="h2" class="has-bottom-margin-s hds-foreground-strong">Lease Duration</Hds::Text::Display>
713

814
<Hds::Layout::Flex @align="start" @gap="16" class="has-bottom-margin-m">

ui/app/components/secret-engine/card/metadata.hbs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Copyright (c) HashiCorp, Inc.
33
SPDX-License-Identifier: BUSL-1.1
44
}}
5-
<Hds::Card::Container @level="mid" @hasBorder={{true}} class="has-padding-m has-top-bottom-margin-12" ...attributes>
5+
<Hds::Card::Container
6+
@level="mid"
7+
@hasBorder={{true}}
8+
class="has-padding-m has-top-bottom-margin-12"
9+
data-test-card-container="metadata"
10+
...attributes
11+
>
612
<Hds::Text::Display @size="300" @tag="h2" class="has-bottom-margin-s hds-foreground-strong">Metadata</Hds::Text::Display>
713

814
<div class="flex gap-16 is-flex-column has-top-padding-s">
@@ -13,6 +19,7 @@
1319
<Hds::Layout::Flex @gap="8">
1420
<Hds::Form::TextInput::Field
1521
@value={{@model.secretsEngine.path}}
22+
aria-label="Secret engine path"
1623
autocomplete="off"
1724
disabled
1825
class="path-input-text"
@@ -31,6 +38,7 @@
3138
<Hds::Layout::Flex @gap="8">
3239
<Hds::Form::TextInput::Field
3340
@value={{@model.secretsEngine.accessor}}
41+
aria-label="Secret engine accessor"
3442
autocomplete="off"
3543
disabled
3644
name="Accessor"

ui/app/components/secret-engine/card/security.hbs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Copyright (c) HashiCorp, Inc.
33
SPDX-License-Identifier: BUSL-1.1
44
}}
5-
<Hds::Card::Container @level="mid" @hasBorder={{true}} class="has-padding-m has-top-bottom-margin" ...attributes>
5+
<Hds::Card::Container
6+
@level="mid"
7+
@hasBorder={{true}}
8+
class="has-padding-m has-top-bottom-margin"
9+
data-test-card-container="security"
10+
...attributes
11+
>
612
<Hds::Form::Toggle::Group as |G|>
713
<G.Legend>
814
<Hds::Text::Display
@@ -12,13 +18,13 @@
1218
>Security</Hds::Text::Display>
1319
</G.Legend>
1420
{{! TODO: Confirm with design to see if we want these two fields to be disabled }}
15-
<G.ToggleField name="local" checked={{@model.secretsEngine.local}} disabled as |F|>
16-
<F.Label>Local</F.Label>
17-
<F.HelperText>Secrets stay in one cluster and are not replicated.</F.HelperText>
21+
<G.ToggleField name="local" checked={{@model.secretsEngine.local}} disabled data-test-input="local" as |F|>
22+
<F.Label data-test-label="local">Local</F.Label>
23+
<F.HelperText data-test-helper-text="local">Secrets stay in one cluster and are not replicated.</F.HelperText>
1824
</G.ToggleField>
19-
<G.ToggleField name="seal-wrap" checked={{@model.secretsEngine.seal_wrap}} disabled as |F|>
20-
<F.Label>Seal wrap</F.Label>
21-
<F.HelperText>Wrap secrets with an additional encryption layer using a seal.</F.HelperText>
25+
<G.ToggleField name="seal-wrap" checked={{@model.secretsEngine.seal_wrap}} disabled data-test-input="seal_wrap" as |F|>
26+
<F.Label data-test-label="seal_wrap">Seal wrap</F.Label>
27+
<F.HelperText data-test-helper-text="seal_wrap">Wrap secrets with an additional encryption layer using a seal.</F.HelperText>
2228
</G.ToggleField>
2329
</Hds::Form::Toggle::Group>
2430
</Hds::Card::Container>

ui/app/components/secret-engine/card/version.hbs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Copyright (c) HashiCorp, Inc.
33
SPDX-License-Identifier: BUSL-1.1
44
}}
5-
<Hds::Card::Container @level="mid" @hasBorder={{true}} class="has-padding-m has-top-bottom-margin" ...attributes>
5+
<Hds::Card::Container
6+
@level="mid"
7+
@hasBorder={{true}}
8+
class="has-padding-m has-top-bottom-margin"
9+
data-test-card-container="version"
10+
...attributes
11+
>
612
<Hds::Text::Display @size="300" @tag="h2" class="has-bottom-margin-s hds-foreground-strong">Version</Hds::Text::Display>
713

814
<Hds::Layout::Grid @columnMinWidth="10%" @gap="12" {{style height="100%" grid-template-rows="min-content"}} as |LG|>
@@ -15,17 +21,21 @@
1521
<Hds::Text::Body
1622
@tag="p"
1723
class="hds-border-strong has-side-padding-8 border-radius-4 is-inline-block has-bottom-margin-s"
24+
data-test-engine-type
1825
>{{@model.secretsEngine.type}}</Hds::Text::Body>
1926
{{! TODO: Verify if we want to display the full version or chop down ie. v0.17.1 vs v0.17.1-0.230942309423094... }}
20-
<Hds::Text::Body @tag="p">{{@model.secretsEngine.running_plugin_version}}</Hds::Text::Body>
27+
<Hds::Text::Body
28+
@tag="p"
29+
data-test-engine-current-version
30+
>{{@model.secretsEngine.running_plugin_version}}</Hds::Text::Body>
2131
</LG.Item>
2232
</Hds::Layout::Grid>
2333

2434
{{#if (gt @model.versions.length 1)}}
2535
<Hds::Separator />
2636

2737
<Hds::Layout::Flex @isInline="true">
28-
<Hds::Form::Select::Field name="plugin-version" as |F|>
38+
<Hds::Form::Select::Field name="plugin-version" data-test-versions-dropdown as |F|>
2939
<F.Label>Update version to:</F.Label>
3040
<F.Options>
3141
<option value="">Select version</option>

ui/app/components/secret-engine/page-header.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
<div class="tabs-container box is-marginless is-fullwidth is-paddingless">
2727
<nav class="tabs" aria-label={{@model.secretsEngine.id}}>
2828
<ul>
29-
<li>
29+
<li data-test-tab="general-settings">
3030
<LinkTo @route="vault.cluster.secrets.backend.configuration.general-settings" @model={{@model.secretsEngine.id}}>
3131
General settings
3232
</LinkTo>
3333
</li>
3434
{{! If engine is not configurable, hide plugin settings link }}
3535
{{#if (get (engines-display-data @model.secretsEngine.type) "isConfigurable")}}
36-
<li>
36+
<li data-test-tab="plugin-settings">
3737
<LinkTo
3838
@route="vault.cluster.secrets.backend.configuration.plugin-settings"
3939
@model={{@model.secretsEngine.id}}

ui/app/components/secret-engine/page/general-settings.hbs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Copyright (c) HashiCorp, Inc.
33
SPDX-License-Identifier: BUSL-1.1
44
}}
5-
65
<SecretEngine::PageHeader @model={{@model}} />
76

87
{{#if this.saveGeneralSettings.isRunning}}
@@ -46,11 +45,11 @@
4645
{{/if}}
4746

4847
{{#if this.showUnsavedChangesModal}}
49-
<Hds::Modal id="unsavedChangesModal" @onClose={{this.closeUnsavedChangesModal}} as |M|>
50-
<M.Header>
48+
<Hds::Modal id="unsavedChangesModal" @onClose={{this.closeUnsavedChangesModal}} data-test-modal="unsaved-changes" as |M|>
49+
<M.Header data-test-modal-header="unsaved-changes">
5150
Unsaved changes
5251
</M.Header>
53-
<M.Body>
52+
<M.Body data-test-modal-body="unsaved-changes">
5453
<p class="hds-typography-body-300 hds-foreground-primary">You've made changes to the following
5554
<Hds::Text::Display>{{@model.secretsEngine.id}}</Hds::Text::Display>
5655
settings:</p>
@@ -64,8 +63,19 @@
6463
</M.Body>
6564
<M.Footer>
6665
<Hds::ButtonSet>
67-
<Hds::Button type="button" @text="Save changes" {{on "click" (perform this.saveGeneralSettings)}} />
68-
<Hds::Button type="button" @text="Discard changes" @color="secondary" {{on "click" this.discardChanges}} />
66+
<Hds::Button
67+
type="button"
68+
@text="Save changes"
69+
data-test-button="save"
70+
{{on "click" (perform this.saveGeneralSettings)}}
71+
/>
72+
<Hds::Button
73+
type="button"
74+
@text="Discard changes"
75+
@color="secondary"
76+
data-test-button="discard"
77+
{{on "click" this.discardChanges}}
78+
/>
6979
</Hds::ButtonSet>
7080
</M.Footer>
7181
</Hds::Modal>

ui/app/components/secret-engine/ttl-picker-v2.hbs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
SPDX-License-Identifier: BUSL-1.1
44
}}
55

6-
<Hds::Form::Field @layout="vertical" @isInvalid={{this.errorMessage}} as |F|>
7-
<F.Label>{{this.formField.label}}</F.Label>
8-
<F.HelperText>{{this.formField.helperText}}</F.HelperText>
6+
<Hds::Form::Field @layout="vertical" @isInvalid={{this.errorMessage}} data-test-ttl-picker-v2 as |F|>
7+
<F.Label data-test-form-field-label={{@ttlKey}}>{{this.formField.label}}</F.Label>
8+
<F.HelperText data-test-help-text={{@ttlKey}}>{{this.formField.helperText}}</F.HelperText>
99
<F.Control>
1010
<Hds::SegmentedGroup as |SG|>
1111
<SG.TextInput
@@ -14,9 +14,18 @@
1414
@value={{this.time}}
1515
{{on "input" this.setTtlTime}}
1616
name="{{@ttlKey}}-time"
17+
aria-label={{concat this.formField.label "time"}}
1718
autocomplete="off"
19+
data-test-input={{@ttlKey}}
1820
/>
19-
<SG.Select @width="100px" name="{{@ttlKey}}-unit" {{on "input" this.setUnit}} as |S|>
21+
<SG.Select
22+
@width="100px"
23+
name="{{@ttlKey}}-unit"
24+
{{on "input" this.setUnit}}
25+
aria-label={{concat this.formField.label "unit"}}
26+
data-test-select={{@ttlKey}}
27+
as |S|
28+
>
2029
<S.Options>
2130
{{#each this.unitOptions as |unit|}}
2231
<option value={{unit.value}} selected={{eq unit.value this.selectedUnit}}>{{unit.label}}</option>
@@ -26,6 +35,6 @@
2635
</Hds::SegmentedGroup>
2736
</F.Control>
2837
{{#if this.errorMessage}}
29-
<F.Error>{{this.errorMessage}}</F.Error>
38+
<F.Error data-test-message-error>{{this.errorMessage}}</F.Error>
3039
{{/if}}
3140
</Hds::Form::Field>

ui/app/templates/vault/cluster/secrets/backend/list.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,16 @@
6363
{{! TODO: Hook dropdown actions to the appropriate routes & actions }}
6464
<Hds::Dropdown as |D|>
6565
<D.ToggleButton @text="Manage" @color="secondary" data-test-manage-dropdown />
66-
<D.Interactive @icon="settings" @route="vault.cluster.secrets.backend.configuration.index">Configure</D.Interactive>
66+
<D.Interactive
67+
@icon="settings"
68+
@route="vault.cluster.secrets.backend.configuration.index"
69+
data-test-manage-dropdown-item="Configure"
70+
>Configure</D.Interactive>
6771
<D.Interactive
6872
{{on "click" (fn (mut this.engineToDisable) this.backendModel)}}
6973
@color="critical"
7074
@icon="trash"
75+
data-test-manage-dropdown-item="Delete"
7176
>Delete</D.Interactive>
7277
</Hds::Dropdown>
7378

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: BUSL-1.1
4+
*/
5+
6+
import { settled, click, fillIn, visit, currentRouteName } from '@ember/test-helpers';
7+
import { module, test } from 'qunit';
8+
import { setupApplicationTest } from 'ember-qunit';
9+
10+
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
11+
import { login } from 'vault/tests/helpers/auth/auth-helpers';
12+
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
13+
import { GENERAL } from 'vault/tests/helpers/general-selectors';
14+
import { SELECTORS } from 'vault/tests/helpers/secret-engine/general-settings-selectors';
15+
import { create } from 'ember-cli-page-object';
16+
import consoleClass from 'vault/tests/pages/components/console/ui-panel';
17+
18+
const consoleComponent = create(consoleClass);
19+
20+
module('Acceptance | Enterprise | keymgmt-configuration-workflow', function (hooks) {
21+
setupApplicationTest(hooks);
22+
23+
hooks.beforeEach(function () {
24+
return login();
25+
});
26+
27+
test('it should display keymgmt configuration and tune keymgmt in the general settings form', async function (assert) {
28+
await consoleComponent.runCommands([
29+
// delete any previous mount with same name
30+
'delete sys/mounts/keymgmt',
31+
]);
32+
const keymgmtType = 'keymgmt';
33+
await mountSecrets.visit();
34+
await settled();
35+
await mountBackend(keymgmtType, keymgmtType);
36+
await click(SELECTORS.manageDropdown);
37+
await click(SELECTORS.manageDropdownItem('Configure'));
38+
assert
39+
.dom(GENERAL.hdsPageHeaderTitle)
40+
.hasText(`${keymgmtType} configuration`, 'displays configuration title');
41+
assert.dom(GENERAL.tab('general-settings')).hasText(`General settings`);
42+
assert.dom(GENERAL.cardContainer('version')).exists('version card exists');
43+
assert.dom(SELECTORS.versionCard.engineType).hasText(keymgmtType, 'shows keymgmt engine type');
44+
assert.dom(GENERAL.cardContainer('metadata')).exists('metadata card exists');
45+
assert.dom(GENERAL.inputByAttr('path')).hasValue(`${keymgmtType}/`, 'show path value');
46+
assert.dom(GENERAL.cardContainer('lease-duration')).exists('lease-duration card exists');
47+
assert.dom(GENERAL.cardContainer('security')).exists('security card exists');
48+
49+
// fill in values to tune
50+
await fillIn(GENERAL.inputByAttr('default_lease_ttl'), 10);
51+
await fillIn(GENERAL.selectByAttr('default_lease_ttl'), 'm');
52+
await fillIn(GENERAL.inputByAttr('max_lease_ttl'), 15);
53+
await fillIn(GENERAL.selectByAttr('max_lease_ttl'), 'd');
54+
await fillIn(GENERAL.textareaByAttr('description'), 'Some awesome description.');
55+
await click(GENERAL.submitButton);
56+
57+
// after submitting go to list and back to configuration
58+
await visit(`/vault/secrets/${keymgmtType}/list`);
59+
await visit(`/vault/secrets/${keymgmtType}/configuration`);
60+
61+
// confirm that submitted values were saved and prepopulated with those saved values
62+
assert
63+
.dom(GENERAL.textareaByAttr('description'))
64+
.hasValue('Some awesome description.', 'description was tuned');
65+
assert.dom(GENERAL.inputByAttr('default_lease_ttl')).hasValue('10', 'default ttl value was tuned');
66+
assert
67+
.dom(GENERAL.selectByAttr('default_lease_ttl'))
68+
.hasValue('m', 'default ttl value was tuned and shows correct unit');
69+
assert.dom(GENERAL.inputByAttr('max_lease_ttl')).hasValue('15', 'max ttl value was tuned');
70+
assert
71+
.dom(GENERAL.selectByAttr('max_lease_ttl'))
72+
.hasValue('d', 'max ttl value was tuned and shows correct unit');
73+
74+
// navigate back to keymgmt list view to delete the engine from the manage dropdown
75+
await visit(`/vault/secrets/${keymgmtType}/list`);
76+
await click(SELECTORS.manageDropdown);
77+
await click(SELECTORS.manageDropdownItem('Delete'));
78+
await click(GENERAL.confirmButton);
79+
assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backends');
80+
await consoleComponent.runCommands([
81+
// cleanup after
82+
'delete sys/mounts/keymgmt',
83+
]);
84+
});
85+
});

ui/tests/helpers/general-selectors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const GENERAL = {
1313
breadcrumbs: '[data-test-breadcrumbs]',
1414
headerContainer: 'header.page-header',
1515
title: '[data-test-page-title]',
16+
hdsPageHeaderTitle: '.hds-page-header__title',
17+
hdsPageHeaderDescription: '.hds-page-header__description',
1618

1719
/* ────── Tabs & Navigation ────── */
1820
tab: (name: string) => `[data-test-tab="${name}"]`,
@@ -73,6 +75,7 @@ export const GENERAL = {
7375
toggleInput: (attr: string) => `[data-test-toggle-input="${attr}"]`,
7476
textToggle: '[data-test-text-toggle]',
7577
filter: (name: string) => `[data-test-filter="${name}"]`,
78+
textareaByAttr: (attr: string) => `textarea[name="${attr}"]`,
7679

7780
/* ────── Code Blocks / Editor ────── */
7881
codemirror: `[data-test-component="code-mirror-modifier"]`,
@@ -159,6 +162,11 @@ export const GENERAL = {
159162

160163
/* ────── Modals & Flyouts ────── */
161164
flyout: '[data-test-flyout]',
165+
modal: {
166+
container: (title: string) => `[data-test-modal=${title}]`,
167+
header: (title: string) => `[data-test-modal-header=${title}]`,
168+
body: (title: string) => `[data-test-modal-body=${title}]`,
169+
},
162170

163171
/* ────── Misc ────── */
164172
icon: (name: string) => (name ? `[data-test-icon="${name}"]` : '[data-test-icon]'),

0 commit comments

Comments
 (0)