mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 11:37: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>
87 lines
3.0 KiB
JavaScript
87 lines
3.0 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, click } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
|
|
module('Integration | Component | mfa-method-form', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.model = this.store.createRecord('mfa-method');
|
|
this.model.type = 'totp';
|
|
});
|
|
|
|
test('it should render correct fields', async function (assert) {
|
|
assert.expect(6);
|
|
|
|
await render(hbs`
|
|
<Mfa::MethodForm
|
|
@model={{this.model}}
|
|
@hasActions="true"
|
|
/>
|
|
<div id="modal-wormhole"></div>
|
|
`);
|
|
assert.dom('[data-test-input="issuer"]').exists(`Issuer field input renders`);
|
|
assert.dom('[data-test-input="period"]').exists('Period field ttl renders');
|
|
assert.dom('[data-test-input="key_size"]').exists('Key size field input renders');
|
|
assert.dom('[data-test-input="qr_size"]').exists('QR size field input renders');
|
|
assert.dom('[data-test-input="algorithm"]').exists(`Algorithm field radio input renders`);
|
|
assert
|
|
.dom('[data-test-input="max_validation_attempts"]')
|
|
.exists(`Max validation attempts field input renders`);
|
|
});
|
|
|
|
test('it should create new mfa method', async function (assert) {
|
|
assert.expect(3);
|
|
|
|
this.server.post('/identity/mfa/method/totp', () => {
|
|
assert.ok(true, 'create request sent to server');
|
|
return {};
|
|
});
|
|
|
|
await render(hbs`
|
|
<Mfa::MethodForm
|
|
@hasActions="true"
|
|
@model={{this.model}}
|
|
@onSave={{fn (mut this.didSave) true}}
|
|
/>
|
|
<div id="modal-wormhole"></div>
|
|
`);
|
|
|
|
await fillIn('[data-test-input="issuer"]', 'Vault');
|
|
await click('[data-test-mfa-save]');
|
|
await fillIn('[data-test-confirmation-modal-input="Edit totp configuration?"]', 'totp');
|
|
await click('[data-test-confirm-button="Edit totp configuration?"]');
|
|
assert.true(this.didSave, 'onSave callback triggered');
|
|
assert.strictEqual(this.model.issuer, 'Vault', 'Issuer property set on model');
|
|
});
|
|
|
|
test('it should populate form fields with model data', async function (assert) {
|
|
assert.expect(3);
|
|
|
|
this.model.issuer = 'Vault';
|
|
this.model.period = '30s';
|
|
this.model.algorithm = 'SHA512';
|
|
|
|
await render(hbs`
|
|
<Mfa::MethodForm
|
|
@hasActions="true"
|
|
@model={{this.model}}
|
|
/>
|
|
<div id="modal-wormhole"></div>
|
|
`);
|
|
assert.dom('[data-test-input="issuer"]').hasValue('Vault', 'Issuer input is populated');
|
|
assert.dom('[data-test-ttl-value="Period"]').hasValue('30', 'Period input ttl is populated');
|
|
const checkedAlgorithm = this.element.querySelector('input[name=algorithm]:checked');
|
|
assert.dom(checkedAlgorithm).hasValue('SHA512', 'SHA512 radio input is selected');
|
|
});
|
|
});
|