mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-14 18:47:01 +02:00
* adds development workflow to mirage config * adds mirage handler and factory for mfa workflow * adds mfa handling to auth service and cluster adapter * moves auth success logic from form to controller * adds mfa form component * shows delayed auth message for all methods * adds new code delay to mfa form * adds error views * fixes merge conflict * adds integration tests for mfa-form component * fixes auth tests * updates mfa response handling to align with backend * updates mfa-form to handle multiple methods and constraints * adds noDefault arg to Select component * updates mirage mfa handler to align with backend and adds generator for various mfa scenarios * adds tests * flaky test fix attempt * reverts test fix attempt * adds changelog entry * updates comments for todo items * removes faker from mfa mirage factory and handler * adds number to word helper * fixes tests
39 lines
1.6 KiB
JavaScript
39 lines
1.6 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { click } from '@ember/test-helpers';
|
|
import { TOTP_NOT_CONFIGURED } from 'vault/services/auth';
|
|
import { TOTP_NA_MSG, MFA_ERROR_MSG } from 'vault/components/mfa-error';
|
|
const UNAUTH = 'MFA authorization failed';
|
|
|
|
module('Integration | Component | mfa-error', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('it renders', async function (assert) {
|
|
const auth = this.owner.lookup('service:auth');
|
|
auth.set('mfaErrors', [TOTP_NOT_CONFIGURED]);
|
|
|
|
this.onClose = () => assert.ok(true, 'onClose event is triggered');
|
|
|
|
await render(hbs`<MfaError @onClose={{this.onClose}}/>`);
|
|
|
|
assert.dom('[data-test-empty-state-title]').hasText('TOTP not set up', 'Title renders for TOTP error');
|
|
assert
|
|
.dom('[data-test-empty-state-subText]')
|
|
.hasText(TOTP_NOT_CONFIGURED, 'Error message renders for TOTP error');
|
|
assert.dom('[data-test-empty-state-message]').hasText(TOTP_NA_MSG, 'Description renders for TOTP error');
|
|
|
|
auth.set('mfaErrors', [UNAUTH]);
|
|
await render(hbs`<MfaError @onClose={{this.onClose}}/>`);
|
|
|
|
assert.dom('[data-test-empty-state-title]').hasText('Unauthorized', 'Title renders for mfa error');
|
|
assert.dom('[data-test-empty-state-subText]').hasText(UNAUTH, 'Error message renders for mfa error');
|
|
assert.dom('[data-test-empty-state-message]').hasText(MFA_ERROR_MSG, 'Description renders for mfa error');
|
|
|
|
await click('[data-test-go-back]');
|
|
|
|
assert.equal(auth.mfaErrors, null, 'mfaErrors unset in auth service');
|
|
});
|
|
});
|