mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-15 11:07:00 +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>
85 lines
3.6 KiB
JavaScript
85 lines
3.6 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import sinon from 'sinon';
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'vault/tests/helpers';
|
|
import { click, fillIn, render } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
|
|
module('Integration | Component | choose-pgp-key-form', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.set('onCancel', () => {});
|
|
this.set('onSubmit', () => {});
|
|
});
|
|
|
|
test('it renders correctly', async function (assert) {
|
|
await render(
|
|
hbs`<ChoosePgpKeyForm @onSubmit={{this.onSubmit}} @onCancel={{this.onCancel}} @formText="my custom form text" @buttonText="Do it" />`
|
|
);
|
|
|
|
assert.dom('[data-test-choose-pgp-key-form="begin"]').exists('PGP key selection form exists');
|
|
assert
|
|
.dom('[data-test-choose-pgp-key-description]')
|
|
.hasText('my custom form text', 'uses custom form text');
|
|
await click('[data-test-text-toggle]');
|
|
assert.dom('[data-test-use-pgp-key-button]').isDisabled('use pgp button is disabled');
|
|
await fillIn('[data-test-pgp-file-textarea]', 'base64-pgp-key');
|
|
assert.dom('[data-test-use-pgp-key-button]').isNotDisabled('use pgp button is no longer disabled');
|
|
await click('[data-test-use-pgp-key-button]');
|
|
assert
|
|
.dom('[data-test-pgp-key-confirm]')
|
|
.hasText(
|
|
'Below is the base-64 encoded PGP Key that will be used. Click the "Do it" button to proceed.',
|
|
'Incorporates button text in confirmation'
|
|
);
|
|
assert.dom('[data-test-pgp-key-copy]').hasText('base64-pgp-key', 'Shows PGP key contents');
|
|
assert.dom('[data-test-confirm-pgp-key-submit]').hasText('Do it', 'uses passed buttonText');
|
|
await click('[data-test-confirm-pgp-key-submit]');
|
|
});
|
|
test('it calls onSubmit correctly', async function (assert) {
|
|
const submitSpy = sinon.spy();
|
|
this.set('onSubmit', submitSpy);
|
|
await render(
|
|
hbs`<ChoosePgpKeyForm @onSubmit={{this.onSubmit}} @onCancel={{this.onCancel}} @buttonText="Submit" />`
|
|
);
|
|
|
|
assert.dom('[data-test-choose-pgp-key-form="begin"]').exists('PGP key selection form exists');
|
|
assert
|
|
.dom('[data-test-choose-pgp-key-description]')
|
|
.hasText('Choose a PGP Key from your computer or paste the contents of one in the form below.');
|
|
await click('[data-test-text-toggle]');
|
|
assert.dom('[data-test-use-pgp-key-button]').isDisabled('use pgp button is disabled');
|
|
await fillIn('[data-test-pgp-file-textarea]', 'base64-pgp-key');
|
|
assert.dom('[data-test-use-pgp-key-button]').isNotDisabled('use pgp button is no longer disabled');
|
|
await click('[data-test-use-pgp-key-button]');
|
|
assert
|
|
.dom('[data-test-pgp-key-confirm]')
|
|
.hasText(
|
|
'Below is the base-64 encoded PGP Key that will be used. Click the "Submit" button to proceed.',
|
|
'Confirmation text has buttonText'
|
|
);
|
|
assert.dom('[data-test-pgp-key-copy]').hasText('base64-pgp-key', 'Shows PGP key contents');
|
|
assert.dom('[data-test-confirm-pgp-key-submit]').hasText('Submit', 'uses passed buttonText');
|
|
await click('[data-test-confirm-pgp-key-submit]');
|
|
assert.ok(submitSpy.calledOnceWith('base64-pgp-key'));
|
|
});
|
|
|
|
test('it calls cancel on cancel', async function (assert) {
|
|
const cancelSpy = sinon.spy();
|
|
this.set('onCancel', cancelSpy);
|
|
await render(
|
|
hbs`<ChoosePgpKeyForm @onSubmit={{this.onSubmit}} @onCancel={{this.onCancel}} @buttonText="Submit" />`
|
|
);
|
|
|
|
await click('[data-test-text-toggle]');
|
|
await fillIn('[data-test-pgp-file-textarea]', 'base64-pgp-key');
|
|
await click('[data-test-use-pgp-key-cancel]');
|
|
assert.ok(cancelSpy.calledOnce);
|
|
});
|
|
});
|