mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-18 21:21:06 +02:00
* reuse format-duration helper * add changelog * update duration * fix 0 assuming 0s * VAULT-16593/ update tests, remove formatting assumptions * more tests * add calc function * woops, typo use % * update variable name * add back one template test * refactor to handle all duration string cases, including 3m * ok lets do that differently * comment cleanup * address comments * push to rerun checks
67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { setupEngine } from 'ember-engines/test-support';
|
|
import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-role-details';
|
|
|
|
module('Integration | Component | pki role details page', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupEngine(hooks, 'pki');
|
|
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.model = this.store.createRecord('pki/role', {
|
|
name: 'Foobar',
|
|
backend: 'pki',
|
|
noStore: false,
|
|
keyUsage: [],
|
|
extKeyUsage: ['bar', 'baz'],
|
|
ttl: 600,
|
|
});
|
|
});
|
|
|
|
test('it should render the page component', async function (assert) {
|
|
assert.expect(5);
|
|
await render(
|
|
hbs`
|
|
<Page::PkiRoleDetails @role={{this.model}} />
|
|
`,
|
|
{ owner: this.engine }
|
|
);
|
|
assert.dom(SELECTORS.issuerLabel).hasText('Issuer', 'Label is');
|
|
assert
|
|
.dom(`${SELECTORS.keyUsageValue} [data-test-icon="minus"]`)
|
|
.exists('Key usage shows dash when array is empty');
|
|
assert
|
|
.dom(SELECTORS.extKeyUsageValue)
|
|
.hasText('bar,baz', 'Key usage shows comma-joined values when array has items');
|
|
assert.dom(SELECTORS.noStoreValue).containsText('Yes', 'noStore shows opposite of what the value is');
|
|
assert.dom(SELECTORS.customTtlValue).containsText('10 minutes', 'TTL shown as duration');
|
|
});
|
|
|
|
test('it should render the notAfter date if present', async function (assert) {
|
|
assert.expect(1);
|
|
this.model = this.store.createRecord('pki/role', {
|
|
name: 'Foobar',
|
|
backend: 'pki',
|
|
noStore: false,
|
|
keyUsage: [],
|
|
extKeyUsage: ['bar', 'baz'],
|
|
notAfter: '2030-05-04T12:00:00.000Z',
|
|
});
|
|
await render(
|
|
hbs`
|
|
<Page::PkiRoleDetails @role={{this.model}} />
|
|
`,
|
|
{ owner: this.engine }
|
|
);
|
|
assert.dom(SELECTORS.customTtlValue).containsText('May', 'Formats the notAfter date instead of TTL');
|
|
});
|
|
});
|