UI: VAULT-15385 VAULT-15386 VAULT-15487 Hide create role button, show mount configuration when pki not configured, update overview page so it's responsive (#20164)

This commit is contained in:
Kianna 2023-04-14 10:32:43 -07:00 committed by GitHub
parent d324aa0d15
commit 045de8a0b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 75 deletions

View File

@ -38,6 +38,10 @@
.selectable-card-container.has-grid.has-two-col-grid {
grid-template-columns: 2fr 2fr;
grid-template-rows: none;
@include until($mobile) {
grid-template-columns: 1fr;
}
}
.selectable-card-container.has-grid.has-three-col-grid {
grid-template-columns: 1fr 1fr 1fr;

View File

@ -1,55 +1,65 @@
<Toolbar>
<ToolbarActions>
{{#if @canDeleteAllIssuers}}
<button
type="button"
class="toolbar-link"
{{on "click" (fn (mut this.showDeleteAllIssuers) true)}}
data-test-delete-all-issuers-link
>
Delete all issuers
<Icon @name="chevron-right" />
{{#if @hasConfig}}
<Toolbar>
<ToolbarActions>
{{#if @canDeleteAllIssuers}}
<button
type="button"
class="toolbar-link"
{{on "click" (fn (mut this.showDeleteAllIssuers) true)}}
data-test-delete-all-issuers-link
>
Delete all issuers
<Icon @name="chevron-right" />
</button>
<div class="toolbar-separator"></div>
{{/if}}
<ToolbarLink @route="configuration.tidy" data-test-tidy-toolbar>
Tidy
</ToolbarLink>
<ToolbarLink @route="configuration.edit">
Edit configuration
</ToolbarLink>
</ToolbarActions>
</Toolbar>
</button>
<div class="toolbar-separator"></div>
{{/if}}
<ToolbarLink @route="configuration.tidy" data-test-tidy-toolbar>
Tidy
</ToolbarLink>
<ToolbarLink @route="configuration.edit">
Edit configuration
</ToolbarLink>
</ToolbarActions>
</Toolbar>
{{#if (not (eq @urls 403))}}
<h2 class="title is-4 has-bottom-margin-xs has-top-margin-m has-border-bottom-light has-bottom-padding-s">
Global URLs
</h2>
<InfoTableRow @label="Issuing certificates" @value={{or @urls.issuingCertificates "None"}} />
<InfoTableRow
@label="CRL distribution points"
@value={{if @urls.crlDistributionPoints @urls.crlDistributionPoints "None"}}
/>
{{/if}}
{{#if (not (eq @urls 403))}}
<h2 class="title is-4 has-bottom-margin-xs has-top-margin-m has-border-bottom-light has-bottom-padding-s">
Global URLs
</h2>
<InfoTableRow @label="Issuing certificates" @value={{or @urls.issuingCertificates "None"}} />
<InfoTableRow
@label="CRL distribution points"
@value={{if @urls.crlDistributionPoints @urls.crlDistributionPoints "None"}}
/>
{{/if}}
{{#if (not (eq @crl 403))}}
<h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
Certificate Revocation List (CRL)
</h2>
<InfoTableRow @label="Expiry" @value={{@crl.expiry}} />
<InfoTableRow @label="Auto-rebuild" @value={{if @crl.autoRebuild "On" "Off"}} />
{{#if (not (eq @crl 403))}}
<h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
Certificate Revocation List (CRL)
</h2>
<InfoTableRow @label="Expiry" @value={{@crl.expiry}} />
<InfoTableRow @label="Auto-rebuild" @value={{if @crl.autoRebuild "On" "Off"}} />
<h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
Online Certificate Status Protocol (OCSP)
</h2>
<InfoTableRow @label="Responder APIs" @value={{if @crl.ocspDisable "Disabled" "Enabled"}} />
<InfoTableRow @label="Interval" @value={{@crl.ocspExpiry}} />
<h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
Online Certificate Status Protocol (OCSP)
</h2>
<InfoTableRow @label="Responder APIs" @value={{if @crl.ocspDisable "Disabled" "Enabled"}} />
<InfoTableRow @label="Interval" @value={{@crl.ocspExpiry}} />
{{/if}}
{{else}}
<Toolbar>
<ToolbarActions>
<ToolbarLink @route="configuration.create" data-test-configure-pki-button>
Configure
</ToolbarLink>
</ToolbarActions>
</Toolbar>
{{/if}}
<h2
class="title is-4 has-bottom-margin-xs has-border-bottom-light has-bottom-padding-s
{{if (and (eq @crl 403) (eq @urls 403)) 'has-top-margin-m' 'has-top-margin-xl'}}"
{{if (or @hasConfig (and (eq @crl 403) (eq @urls 403))) 'has-top-margin-xl' 'has-top-margin-m'}}"
>
Mount Configuration
</h2>

View File

@ -9,19 +9,11 @@
@isEngine={{true}}
/>
{{#if this.model.hasConfig}}
<Page::PkiConfigurationDetails
@urls={{this.model.urls}}
@crl={{this.model.crl}}
@mountConfig={{this.model.mountConfig}}
@currentPath={{this.model.engine.id}}
@canDeleteAllIssuers={{this.model.issuerModel.canDeleteAllIssuers}}
/>
{{else}}
<Toolbar />
<EmptyState @title="PKI not configured" @message={{this.message}}>
<LinkTo @route="configuration.create">
Configure PKI
</LinkTo>
</EmptyState>
{{/if}}
<Page::PkiConfigurationDetails
@urls={{this.model.urls}}
@crl={{this.model.crl}}
@mountConfig={{this.model.mountConfig}}
@currentPath={{this.model.engine.id}}
@canDeleteAllIssuers={{this.model.issuerModel.canDeleteAllIssuers}}
@hasConfig={{this.model.hasConfig}}
/>

View File

@ -8,15 +8,16 @@
}}
@isEngine={{true}}
/>
<Toolbar>
<ToolbarActions>
<ToolbarLink @type="add" @route="roles.create" data-test-pki-role-create-link>
Create role
</ToolbarLink>
</ToolbarActions>
</Toolbar>
{{#if this.model.hasConfig}}
<Toolbar>
<ToolbarActions>
<ToolbarLink @type="add" @route="roles.create" data-test-pki-role-create-link>
Create role
</ToolbarLink>
</ToolbarActions>
</Toolbar>
{{#if this.model.roles.length}}
{{#each this.model.roles as |pkiRole|}}
<LinkedBlock class="list-item-row" @params={{array "roles.role.details" pkiRole.id}} @linkPrefix={{this.mountPoint}}>
@ -65,6 +66,7 @@
</EmptyState>
{{/if}}
{{else}}
<Toolbar />
<EmptyState @title="PKI not configured" @message={{this.message}}>
<LinkTo @route="configuration.create">
Configure PKI

View File

@ -43,7 +43,7 @@ module('Acceptance | pki configuration test', function (hooks) {
test('it shows the delete all issuers modal', async function (assert) {
await authPage.login(this.pkiAdminToken);
await visit(`/vault/secrets/${this.mountPath}/pki/configuration`);
await click(SELECTORS.emptyStateLink);
await click(SELECTORS.configuration.configureButton);
assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`);
await isSettled();
await click(SELECTORS.configuration.generateRootOption);
@ -69,7 +69,7 @@ module('Acceptance | pki configuration test', function (hooks) {
test('it shows the correct empty state message if certificates exists after delete all issuers', async function (assert) {
await authPage.login(this.pkiAdminToken);
await visit(`/vault/secrets/${this.mountPath}/pki/configuration`);
await click(SELECTORS.emptyStateLink);
await click(SELECTORS.configuration.configureButton);
assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`);
await click(SELECTORS.configuration.generateRootOption);
await fillIn(SELECTORS.configuration.typeField, 'exported');
@ -128,7 +128,7 @@ module('Acceptance | pki configuration test', function (hooks) {
test('it shows the correct empty state message if roles and certificates exists after delete all issuers', async function (assert) {
await authPage.login(this.pkiAdminToken);
await visit(`/vault/secrets/${this.mountPath}/pki/configuration`);
await click(SELECTORS.emptyStateLink);
await click(SELECTORS.configuration.configureButton);
assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`);
await click(SELECTORS.configuration.generateRootOption);
await fillIn(SELECTORS.configuration.typeField, 'exported');

View File

@ -14,6 +14,7 @@ export const SELECTORS = {
cancelButton: '[data-test-pki-config-cancel]',
saveButton: '[data-test-pki-config-save]',
doneButton: '[data-test-done]',
configureButton: '[data-test-configure-pki-button]',
// pki-generate-root
...GENERATE_ROOT,
generateRootOption: '[data-test-pki-config-option="generate-root"]',

View File

@ -44,7 +44,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}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
@ -56,7 +56,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}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert
@ -72,7 +72,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}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
@ -84,7 +84,7 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
.hasText('Off', 'auto-rebuild value renders off if auto rebuild is false');
this.crl.autoRebuild = true;
await render(
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert
@ -100,7 +100,36 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
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}} />,`,
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @mountConfig={{this.mountConfig}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.engineTypeLabel).hasText('Secret engine type', 'engine type row label renders');
assert.dom(SELECTORS.engineTypeRowVal).hasText('pki', 'engine type row value renders');
assert.dom(SELECTORS.pathLabel).hasText('Path', 'path row label renders');
assert.dom(SELECTORS.pathRowVal).hasText('/pki-test', 'path row value renders');
assert.dom(SELECTORS.accessorLabel).hasText('Accessor', 'accessor row label renders');
assert.dom(SELECTORS.accessorRowVal).hasText('pki_33345b0d', 'accessor row value renders');
assert.dom(SELECTORS.localLabel).hasText('Local', 'local row label renders');
assert.dom(SELECTORS.localRowVal).hasText('No', 'local row value renders');
assert.dom(SELECTORS.sealWrapLabel).hasText('Seal wrap', 'seal wrap row label renders');
assert
.dom(SELECTORS.sealWrapRowVal)
.hasText('Yes', 'seal wrap row value renders Yes if sealWrap is true');
assert.dom(SELECTORS.maxLeaseTtlLabel).hasText('Max lease TTL', 'max lease label renders');
assert.dom(SELECTORS.maxLeaseTtlRowVal).hasText('400h', 'max lease value renders');
assert
.dom(SELECTORS.allowedManagedKeysLabel)
.hasText('Allowed managed keys', 'allowed managed keys label renders');
assert.dom(SELECTORS.allowedManagedKeysRowVal).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 }
);