mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-15 19:17:02 +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>
86 lines
3.0 KiB
JavaScript
86 lines
3.0 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { click, fillIn, render } from '@ember/test-helpers';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { setupEngine } from 'ember-engines/test-support';
|
|
import { Response } from 'miragejs';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
import { setupRenderingTest } from 'vault/tests/helpers';
|
|
import { SELECTORS } from 'vault/tests/helpers/pki/pki-configure-create';
|
|
import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs';
|
|
|
|
/**
|
|
* this test is for the page component only. A separate test is written for the form rendered
|
|
*/
|
|
module('Integration | Component | page/pki-issuer-generate-intermediate', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupEngine(hooks, 'pki');
|
|
setupMirage(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.breadcrumbs = [{ label: 'something' }];
|
|
this.model = this.store.createRecord('pki/action', {
|
|
actionType: 'generate-csr',
|
|
});
|
|
this.secretMountPath = this.owner.lookup('service:secret-mount-path');
|
|
this.secretMountPath.currentPath = 'pki-component';
|
|
this.server.post('/sys/capabilities-self', allowAllCapabilitiesStub());
|
|
});
|
|
|
|
test('it renders correct title before and after submit', async function (assert) {
|
|
assert.expect(3);
|
|
this.server.post(`/pki-component/issuers/generate/intermediate/internal`, () => {
|
|
assert.true(true, 'Issuers endpoint called');
|
|
return {
|
|
request_id: uuidv4(),
|
|
data: {
|
|
csr: '------BEGIN CERTIFICATE------',
|
|
key_id: 'some-key-id',
|
|
},
|
|
};
|
|
});
|
|
|
|
await render(
|
|
hbs`<Page::PkiIssuerGenerateIntermediate @model={{this.model}} @breadcrumbs={{this.breadcrumbs}} />`,
|
|
{
|
|
owner: this.engine,
|
|
}
|
|
);
|
|
assert.dom('[data-test-pki-page-title]').hasText('Generate intermediate CSR');
|
|
await fillIn(SELECTORS.typeField, 'internal');
|
|
await fillIn(SELECTORS.inputByName('commonName'), 'foobar');
|
|
await click('[data-test-save]');
|
|
assert.dom('[data-test-pki-page-title]').hasText('View Generated CSR');
|
|
});
|
|
|
|
test('it does not update title if API response is an error', async function (assert) {
|
|
assert.expect(2);
|
|
this.server.post(
|
|
'/pki-component/issuers/generate/intermediate/internal',
|
|
() => new Response(403, {}, { errors: ['API returns this error'] })
|
|
);
|
|
|
|
await render(
|
|
hbs`<Page::PkiIssuerGenerateIntermediate @model={{this.model}} @breadcrumbs={{this.breadcrumbs}} />`,
|
|
{
|
|
owner: this.engine,
|
|
}
|
|
);
|
|
assert.dom('[data-test-pki-page-title]').hasText('Generate intermediate CSR');
|
|
// Fill in
|
|
await fillIn(SELECTORS.typeField, 'internal');
|
|
await fillIn(SELECTORS.inputByName('commonName'), 'foobar');
|
|
await click('[data-test-save]');
|
|
assert
|
|
.dom('[data-test-pki-page-title]')
|
|
.hasText('Generate intermediate CSR', 'title does not change if response is unsuccessful');
|
|
});
|
|
});
|