mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-15 02:57:04 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
78 lines
2.8 KiB
JavaScript
78 lines
2.8 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render, fillIn } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
import { setupEngine } from 'ember-engines/test-support';
|
|
import Sinon from 'sinon';
|
|
import { SELECTORS } from 'vault/tests/helpers/pki/pki-role-generate';
|
|
import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs';
|
|
|
|
module('Integration | Component | pki-role-generate', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupMirage(hooks);
|
|
setupEngine(hooks, 'pki');
|
|
|
|
hooks.beforeEach(async function () {
|
|
this.server.post('/sys/capabilities-self', allowAllCapabilitiesStub());
|
|
this.store = this.owner.lookup('service:store');
|
|
this.secretMountPath = this.owner.lookup('service:secret-mount-path');
|
|
this.secretMountPath.currentPath = 'pki-test';
|
|
this.model = this.store.createRecord('pki/certificate/generate', {
|
|
role: 'my-role',
|
|
});
|
|
this.onSuccess = Sinon.spy();
|
|
});
|
|
|
|
test('it should render the component with the form by default', async function (assert) {
|
|
assert.expect(4);
|
|
await render(
|
|
hbs`
|
|
<div class="has-top-margin-xxl">
|
|
<PkiRoleGenerate
|
|
@model={{this.model}}
|
|
@onSuccess={{this.onSuccess}}
|
|
/>
|
|
</div>
|
|
`,
|
|
{ owner: this.engine }
|
|
);
|
|
assert.dom(SELECTORS.form).exists('shows the cert generate form');
|
|
assert.dom(SELECTORS.commonNameField).exists('shows the common name field');
|
|
assert.dom(SELECTORS.optionsToggle).exists('toggle exists');
|
|
await fillIn(SELECTORS.commonNameField, 'example.com');
|
|
assert.strictEqual(this.model.commonName, 'example.com', 'Filling in the form updates the model');
|
|
});
|
|
|
|
test('it should render the component displaying the cert', async function (assert) {
|
|
assert.expect(5);
|
|
const record = this.store.createRecord('pki/certificate/generate', {
|
|
role: 'my-role',
|
|
serialNumber: 'abcd-efgh-ijkl',
|
|
certificate: 'my-very-cool-certificate',
|
|
});
|
|
this.set('model', record);
|
|
await render(
|
|
hbs`
|
|
<div class="has-top-margin-xxl">
|
|
<PkiRoleGenerate
|
|
@model={{this.model}}
|
|
@onSuccess={{this.onSuccess}}
|
|
/>
|
|
</div>
|
|
`,
|
|
{ owner: this.engine }
|
|
);
|
|
assert.dom(SELECTORS.form).doesNotExist('Does not show the form');
|
|
assert.dom(SELECTORS.downloadButton).exists('shows the download button');
|
|
assert.dom(SELECTORS.revokeButton).exists('shows the revoke button');
|
|
assert.dom(SELECTORS.certificate).exists({ count: 1 }, 'shows certificate info row');
|
|
assert.dom(SELECTORS.serialNumber).hasText('abcd-efgh-ijkl', 'shows serial number info row');
|
|
});
|
|
});
|