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

UI: [VAULT-17461] add mount configuration as toggle for pki #23166

Merged
merged 7 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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/23166.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Update pki mount configuration details to match the new mount configuration details pattern
```
16 changes: 1 addition & 15 deletions ui/lib/pki/addon/components/page/pki-configuration-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,7 @@
</Toolbar>
{{/if}}

<h2
class="title is-4 has-bottom-margin-xs has-border-bottom-light has-bottom-padding-s
{{if (or @hasConfig (and (eq @crl 403) (eq @urls 403))) 'has-top-margin-xl' 'has-top-margin-m'}}"
>
Mount Configuration
</h2>
<InfoTableRow @label="Secret engine type" @value={{@mountConfig.engineType}} />
<InfoTableRow @label="Path" @value={{@mountConfig.path}} />
<InfoTableRow @label="Accessor" @value={{@mountConfig.accessor}} />
<InfoTableRow @label="Local" @value={{@mountConfig.local}} />
<InfoTableRow @label="Seal wrap" @value={{@mountConfig.sealWrap}} />
<InfoTableRow @label="Default lease TTL" @value={{@mountConfig.config.defaultLeaseTtl}} />
<InfoTableRow @label="Max lease TTL" @value={{@mountConfig.config.maxLeaseTtl}} />
<InfoTableRow @label="Allowed managed keys" @value={{or @mountConfig.config.allowedManagedKeys "None"}} />
<div class="has-top-margin-l"></div>
<div class="has-top-margin-m"></div>

{{#if this.showDeleteAllIssuers}}
<ConfirmationModal
Expand Down
7 changes: 7 additions & 0 deletions ui/lib/pki/addon/routes/configuration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { withConfig } from 'pki/decorators/check-issuers';
import { hash } from 'rsvp';
import { PKI_DEFAULT_EMPTY_STATE_MSG } from 'pki/routes/overview';

@withConfig()
export default class ConfigurationIndexRoute extends Route {
Expand All @@ -32,4 +33,10 @@ export default class ConfigurationIndexRoute extends Route {
issuerModel: this.store.createRecord('pki/issuer'),
});
}

setupController(controller, resolvedModel) {
super.setupController(controller, resolvedModel);

controller.notConfiguredMessage = PKI_DEFAULT_EMPTY_STATE_MSG;
}
}
32 changes: 23 additions & 9 deletions ui/lib/pki/addon/templates/configuration/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@

<PkiPageHeader @backend={{this.model.engine}} />

<Page::PkiConfigurationDetails
@acme={{this.model.acme}}
@cluster={{this.model.cluster}}
@urls={{this.model.urls}}
@crl={{this.model.crl}}
@mountConfig={{this.model.mountConfig}}
@backend={{this.model.engine.id}}
@canDeleteAllIssuers={{this.model.issuerModel.canDeleteAllIssuers}}
@hasConfig={{this.model.hasConfig}}
{{#if this.model.hasConfig}}
<Page::PkiConfigurationDetails
@acme={{this.model.acme}}
@cluster={{this.model.cluster}}
@urls={{this.model.urls}}
@crl={{this.model.crl}}
@mountConfig={{this.model.mountConfig}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this arg?

@backend={{this.model.engine.id}}
@canDeleteAllIssuers={{this.model.issuerModel.canDeleteAllIssuers}}
@hasConfig={{this.model.hasConfig}}
/>
{{else}}
<EmptyState @title="PKI not configured" @message={{this.notConfiguredMessage}}>
<LinkTo @route="configuration.create">
Configure PKI
</LinkTo>
</EmptyState>
{{/if}}

<SecretsEngineMountConfig
@model={{this.model.mountConfig}}
class="has-top-margin-m has-bottom-margin-xl"
data-test-mount-config
/>
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,12 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
unifiedCrl: true,
unifiedCrlOnExistingPaths: true,
});
this.mountConfig = {
id: 'pki-test',
engineType: 'pki',
path: '/pki-test',
accessor: 'pki_33345b0d',
local: false,
sealWrap: true,
config: this.store.createRecord('mount-config', {
defaultLease: '12h',
maxLeaseTtl: '400h',
allowedManagedKeys: true,
}),
};
});

test('shows the correct information on cluster config', async function (assert) {
await render(hbs`<Page::PkiConfigurationDetails @cluster={{this.cluster}} @hasConfig={{true}} />,`, {
owner: this.engine,
});

assert
.dom(SELECTORS.rowValue("Mount's API path"))
.hasText('https://pr-a.vault.example.com/v1/ns1/pki-root', 'mount API path row renders');
Expand All @@ -74,7 +60,7 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook

test('shows the correct information on global urls section', async function (assert) {
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);

Expand All @@ -86,7 +72,7 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
.hasText('example.com', 'issuing certificate value renders');
this.urls.issuingCertificates = null;
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert
Expand All @@ -102,7 +88,7 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook

test('shows the correct information on crl section', async function (assert) {
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);

Expand All @@ -128,7 +114,7 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
this.crl.autoRebuild = false;
this.crl.enableDelta = false;
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('Auto-rebuild')).hasText('Off', 'it renders falsy auto build');
Expand All @@ -148,7 +134,7 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
this.crl.disable = true;
this.crl.ocspDisable = true;
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('CRL building')).hasText('Disabled', 'disabled renders');
Expand All @@ -167,7 +153,7 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
this.version = this.owner.lookup('service:version');
this.version.version = '1.13.1+ent';
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('Cross-cluster revocation')).hasText('Yes');
Expand All @@ -182,74 +168,11 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
this.version = this.owner.lookup('service:version');
this.version.version = '1.13.1';
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('Cross-cluster revocation')).doesNotExist();
assert.dom(SELECTORS.rowValue('Unified CRL')).doesNotExist();
assert.dom(SELECTORS.rowValue('Unified CRL on existing paths')).doesNotExist();
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these test since the mount config now lives in the route template. There are also component tests for the SecretsEngineMountConfig component!

test('shows the correct information on mount configuration section', async function (assert) {
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);

assert
.dom(SELECTORS.rowLabel('Secret engine type'))
.hasText('Secret engine type', 'engine type row label renders');
assert.dom(SELECTORS.rowValue('Secret engine type')).hasText('pki', 'engine type row value renders');
assert.dom(SELECTORS.rowLabel('Path')).hasText('Path', 'path row label renders');
assert.dom(SELECTORS.rowValue('Path')).hasText('/pki-test', 'path row value renders');
assert.dom(SELECTORS.rowLabel('Accessor')).hasText('Accessor', 'accessor row label renders');
assert.dom(SELECTORS.rowValue('Accessor')).hasText('pki_33345b0d', 'accessor row value renders');
assert.dom(SELECTORS.rowLabel('Local')).hasText('Local', 'local row label renders');
assert.dom(SELECTORS.rowValue('Local')).hasText('No', 'local row value renders');
assert.dom(SELECTORS.rowLabel('Seal wrap')).hasText('Seal wrap', 'seal wrap row label renders');
assert
.dom(SELECTORS.rowValue('Seal wrap'))
.hasText('Yes', 'seal wrap row value renders Yes if sealWrap is true');
assert.dom(SELECTORS.rowLabel('Max lease TTL')).hasText('Max lease TTL', 'max lease label renders');
assert.dom(SELECTORS.rowValue('Max lease TTL')).hasText('400h', 'max lease value renders');
assert
.dom(SELECTORS.rowLabel('Allowed managed keys'))
.hasText('Allowed managed keys', 'allowed managed keys label renders');
assert
.dom(SELECTORS.rowValue('Allowed managed keys'))
.hasText('Yes', 'allowed managed keys value renders');
});

test('shows mount configuration when hasConfig is false', async function (assert) {
this.urls = 403;
this.crl = 403;

await render(
hbs`<Page::PkiConfigurationDetails @mountConfig={{this.mountConfig}} @hasConfig={{false}} />,`,
{ owner: this.engine }
);

assert
.dom(SELECTORS.rowLabel('Secret engine type'))
.hasText('Secret engine type', 'engine type row label renders');
assert.dom(SELECTORS.rowValue('Secret engine type')).hasText('pki', 'engine type row value renders');
assert.dom(SELECTORS.rowLabel('Path')).hasText('Path', 'path row label renders');
assert.dom(SELECTORS.rowValue('Path')).hasText('/pki-test', 'path row value renders');
assert.dom(SELECTORS.rowLabel('Accessor')).hasText('Accessor', 'accessor row label renders');
assert.dom(SELECTORS.rowValue('Accessor')).hasText('pki_33345b0d', 'accessor row value renders');
assert.dom(SELECTORS.rowLabel('Local')).hasText('Local', 'local row label renders');
assert.dom(SELECTORS.rowValue('Local')).hasText('No', 'local row value renders');
assert.dom(SELECTORS.rowLabel('Seal wrap')).hasText('Seal wrap', 'seal wrap row label renders');
assert
.dom(SELECTORS.rowValue('Seal wrap'))
.hasText('Yes', 'seal wrap row value renders Yes if sealWrap is true');
assert.dom(SELECTORS.rowLabel('Max lease TTL')).hasText('Max lease TTL', 'max lease label renders');
assert.dom(SELECTORS.rowValue('Max lease TTL')).hasText('400h', 'max lease value renders');
assert
.dom(SELECTORS.rowLabel('Allowed managed keys'))
.hasText('Allowed managed keys', 'allowed managed keys label renders');
assert
.dom(SELECTORS.rowValue('Allowed managed keys'))
.hasText('Yes', 'allowed managed keys value renders');
});
});