vault/ui/tests/integration/components/pki/pki-issuer-details-test.js
claire bontempo 43258c28fa
UI: HDS adoption replace <Modal> (#23382)
* UI: Part 1 - hds adoption replace <Modal> (#23363)

* replace policy-form modal

* replace clients/attribution modal

* clients/config modal

* scope form odal

* remove button type

* include toolbar to match other example templates

* rotate credentials modal

* add toolbar button class for hds buttons

* transformation-edit modal

* add back test selector

* add route arg to button!

* update link status

* fix link-status tests

* remove prevent default

* update db tests

* update tests

* use page alert for hcp link status banner

* fix scopy button selector

* fix sidebar test

* change to neutral banner

* UI: Part 2 - hds adoption replace <Modal>  (#23398)

* upgrade HDS library (adds support for snippet containers

* cleanup flight icons

* replace transit key action modals

* re-add deps as devDeps

* remove line

* address transit tests

* UI: Part 3 - hds adoption replace <Modal> (#23415)

* cleanup css

* cleanup extra type attr

* masked input download modal

* use Hds::Button in  download button"

* fix size of modal

* tiny icon fix

* refactor download button to always render download icon

* update tests

* UI: Part 3.5 - hds adoption replace <Modal> (#23448)

* replication-promote modal

* replication component modals

* replication add secondary modal

* move update text for diff

* UI: Part 4 - hds adoption replace <Modal>  (#23451)

* k8 configure modal

* kv delete modal

* ldap modals

* pki modals

* add trash icon

* move deps

* UI: Part 5 - hds adoption replace <Modal> (#23471)

* replace confirmation modals
---------

* UI: Part 6 - hds adoption replace <Modal>  (#23484)

* search select with modal

* policy search select modal

* replace date dropdown for client dashboard

* change padding to top

* update policy example args

* lolllll test typo wow

* update dropdown tests

* shamir flow modals!

* add one more container

* update test selectors

* UI: Final hds adoption replace <Modal> cleanup PR (#23522)

* search select with modal

* policy search select modal

* replace date dropdown for client dashboard

* change padding to top

* update policy example args

* lolllll test typo wow

* update dropdown tests

* shamir flow modals!

* add one more container

* update test selectors

* remove wormhole and modal component

* fix selectors

* uninstall wormhole

* remove shamir-modal-flow class

* fix confirm modal test

* fix pki and kv test

* fix toolbar selector kv

* client and download button test

* fix-confirmation-modal-padding

* fix replication modal tests so relevant modal opens (#23540)

* more confirmation modal tests

* adds changelog
2023-10-06 22:06:36 +00:00

195 lines
7.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render, settled } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { SELECTORS } from 'vault/tests/helpers/pki/pki-issuer-details';
module('Integration | Component | page/pki-issuer-details', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'pki');
hooks.beforeEach(async function () {
this.context = { owner: this.engine };
this.store = this.owner.lookup('service:store');
this.secretMountPath = this.owner.lookup('service:secret-mount-path');
this.secretMountPath.currentPath = 'pki-test';
this.issuer = this.store.createRecord('pki/issuer', { issuerId: 'abcd-efgh' });
});
test('it renders with correct toolbar by default', async function (assert) {
await render(
hbs`
<Page::PkiIssuerDetails @issuer={{this.issuer}} />
`,
this.context
);
assert.dom(SELECTORS.rotateRoot).doesNotExist();
assert.dom(SELECTORS.crossSign).doesNotExist();
assert.dom(SELECTORS.signIntermediate).doesNotExist();
assert.dom(SELECTORS.download).hasText('Download');
assert.dom(SELECTORS.configure).doesNotExist();
assert.dom(SELECTORS.parsingAlertBanner).doesNotExist();
});
test('it renders toolbar actions depending on passed capabilities', async function (assert) {
this.set('isRotatable', true);
this.set('canRotate', true);
this.set('canCrossSign', true);
this.set('canSignIntermediate', true);
this.set('canConfigure', true);
await render(
hbs`
<Page::PkiIssuerDetails
@issuer={{this.issuer}}
@isRotatable={{this.isRotatable}}
@canRotate={{this.canRotate}}
@canCrossSign={{this.canCrossSign}}
@canSignIntermediate={{this.canSignIntermediate}}
@canConfigure={{this.canConfigure}}
/>
`,
this.context
);
assert.dom(SELECTORS.parsingAlertBanner).doesNotExist();
assert.dom(SELECTORS.rotateRoot).hasText('Rotate this root');
assert.dom(SELECTORS.crossSign).hasText('Cross-sign issuers');
assert.dom(SELECTORS.signIntermediate).hasText('Sign Intermediate');
assert.dom(SELECTORS.download).hasText('Download');
assert.dom(SELECTORS.configure).hasText('Configure');
this.set('canRotate', false);
this.set('canCrossSign', false);
this.set('canSignIntermediate', false);
this.set('canConfigure', false);
await settled();
assert.dom(SELECTORS.rotateRoot).doesNotExist();
assert.dom(SELECTORS.crossSign).doesNotExist();
assert.dom(SELECTORS.signIntermediate).doesNotExist();
assert.dom(SELECTORS.download).hasText('Download');
assert.dom(SELECTORS.configure).doesNotExist();
});
test('it renders correct details by default', async function (assert) {
await render(
hbs`
<Page::PkiIssuerDetails @issuer={{this.issuer}} />
`,
this.context
);
// Default group details:
assert.dom(SELECTORS.defaultGroup).exists('Default group of details exists');
assert.dom(SELECTORS.valueByName('Certificate')).exists('Certificate detail exists');
assert.dom(SELECTORS.copyButtonByName('Certificate')).exists('Certificate is copyable');
assert.dom(SELECTORS.valueByName('CA Chain')).exists('CA Chain detail exists');
assert.dom(SELECTORS.copyButtonByName('CA Chain')).exists('CA Chain is copyable');
assert.dom(SELECTORS.valueByName('Common name')).exists('Common name detail exists');
assert.dom(SELECTORS.valueByName('Issuer name')).exists('Issuer name detail exists');
assert.dom(SELECTORS.valueByName('Issuer ID')).exists('Issuer ID detail exists');
assert.dom(SELECTORS.copyButtonByName('Issuer ID')).exists('Issuer ID is copyable');
assert.dom(SELECTORS.valueByName('Default key ID')).exists('Default key ID detail exists');
// Issuer URLs group details:
assert.dom(SELECTORS.urlsGroup).exists('Issuer URLs group of details exists');
assert.dom(SELECTORS.valueByName('Issuing certificates')).exists('Issuing certificates detail exists');
assert
.dom(SELECTORS.valueByName('CRL distribution points'))
.exists('CRL distribution points detail exists');
assert.dom(SELECTORS.valueByName('OCSP servers')).exists('OCSP servers detail exists');
});
test('it renders parsing error banner if issuer certificate contains unsupported OIDs', async function (assert) {
this.issuer.parsedCertificate = {
common_name: 'fancy-cert-unsupported-subj-and-ext-oids',
subject_serial_number: null,
ou: null,
organization: 'Acme, Inc',
country: 'US',
locality: 'Topeka',
province: 'Kansas',
street_address: null,
parsing_errors: [new Error('certificate contains stuff we cannot parse')],
can_parse: true,
};
await render(
hbs`
<Page::PkiIssuerDetails @issuer={{this.issuer}} />
`,
this.context
);
assert.dom(SELECTORS.parsingAlertBanner).exists();
assert
.dom(SELECTORS.parsingAlertBanner)
.hasText(
"There was an error parsing certificate metadata Vault cannot display unparsed values, but this will not interfere with the certificate's functionality. However, if you wish to cross-sign this issuer it must be done manually using the CLI. Parsing error(s): certificate contains stuff we cannot parse"
);
});
test('it renders parsing error banner if can_parse=false but no parsing_errors', async function (assert) {
this.issuer.parsedCertificate = {
common_name: 'fancy-cert-unsupported-subj-and-ext-oids',
subject_serial_number: null,
ou: null,
organization: 'Acme, Inc',
country: 'US',
locality: 'Topeka',
province: 'Kansas',
street_address: null,
parsing_errors: [],
can_parse: false,
};
await render(
hbs`
<Page::PkiIssuerDetails @issuer={{this.issuer}} />
`,
this.context
);
assert.dom(SELECTORS.parsingAlertBanner).exists();
assert
.dom(SELECTORS.parsingAlertBanner)
.hasText(
"There was an error parsing certificate metadata Vault cannot display unparsed values, but this will not interfere with the certificate's functionality. However, if you wish to cross-sign this issuer it must be done manually using the CLI."
);
});
test('it renders parsing error banner if no key for parsing_errors', async function (assert) {
this.issuer.parsedCertificate = {
common_name: 'fancy-cert-unsupported-subj-and-ext-oids',
subject_serial_number: null,
ou: null,
organization: 'Acme, Inc',
country: 'US',
locality: 'Topeka',
province: 'Kansas',
street_address: null,
can_parse: false,
};
await render(
hbs`
<Page::PkiIssuerDetails @issuer={{this.issuer}} />
`,
this.context
);
assert.dom(SELECTORS.parsingAlertBanner).exists();
assert
.dom(SELECTORS.parsingAlertBanner)
.hasText(
"There was an error parsing certificate metadata Vault cannot display unparsed values, but this will not interfere with the certificate's functionality. However, if you wish to cross-sign this issuer it must be done manually using the CLI."
);
});
});