mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	 120497d813
			
		
	
	120497d813
	
	
	
		
			
			* first round, there shall be more * fix secret test * more clean up * maybe last round of clean up? * this is going to take a while * all the things or more of them at least * this is the song that never ends... * ... it goes on and on my friend. * clean up clean up everybody lets clean up * rename mount helper to mountBackend * clean up 🧹 * address pr comments --------- Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
		
			
				
	
	
		
			79 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /**
 | |
|  * Copyright (c) HashiCorp, Inc.
 | |
|  * SPDX-License-Identifier: BUSL-1.1
 | |
|  */
 | |
| 
 | |
| import { module, test } from 'qunit';
 | |
| import { setupRenderingTest } from 'ember-qunit';
 | |
| import { render, click } from '@ember/test-helpers';
 | |
| import { hbs } from 'ember-cli-htmlbars';
 | |
| import sinon from 'sinon';
 | |
| import { GENERAL } from 'vault/tests/helpers/general-selectors';
 | |
| 
 | |
| module('Integration | Component | auth | okta-number-challenge', function (hooks) {
 | |
|   setupRenderingTest(hooks);
 | |
| 
 | |
|   hooks.beforeEach(function () {
 | |
|     this.oktaNumberChallengeAnswer = null;
 | |
|     this.hasError = false;
 | |
|     this.onCancel = sinon.spy();
 | |
|     this.renderComponent = async () => {
 | |
|       return render(hbs`
 | |
|   <OktaNumberChallenge
 | |
|     @correctAnswer={{this.oktaNumberChallengeAnswer}}
 | |
|     @hasError={{this.hasError}}
 | |
|     @onReturnToLogin={{this.onCancel}}
 | |
|   />
 | |
|   `);
 | |
|     };
 | |
|   });
 | |
| 
 | |
|   test('it should render correct descriptions', async function (assert) {
 | |
|     await this.renderComponent();
 | |
|     assert
 | |
|       .dom('[data-test-okta-number-challenge-description]')
 | |
|       .includesText(
 | |
|         'To finish signing in, you will need to complete an additional MFA step.',
 | |
|         'Correct description renders'
 | |
|       );
 | |
|     assert.dom('[data-test-loading]').includesText('Please wait...', 'Correct loading description renders');
 | |
|   });
 | |
| 
 | |
|   test('it should show correct number for okta number challenge', async function (assert) {
 | |
|     this.oktaNumberChallengeAnswer = 1;
 | |
|     await this.renderComponent();
 | |
|     assert
 | |
|       .dom('[data-test-okta-number-challenge-description]')
 | |
|       .includesText(
 | |
|         'To finish signing in, you will need to complete an additional MFA step.',
 | |
|         'Correct description renders'
 | |
|       );
 | |
|     assert
 | |
|       .dom('[data-test-verification-type]')
 | |
|       .includesText('Okta verification', 'Correct verification type renders');
 | |
| 
 | |
|     assert
 | |
|       .dom('[data-test-description]')
 | |
|       .includesText(
 | |
|         'Select the following number to complete verification:',
 | |
|         'Correct verification description renders'
 | |
|       );
 | |
|     assert.dom('[data-test-answer]').includesText('1', 'Correct okta number challenge answer renders');
 | |
|   });
 | |
| 
 | |
|   test('it should show error screen', async function (assert) {
 | |
|     this.hasError = 'Authentication failed: multi-factor authentication denied';
 | |
|     await this.renderComponent();
 | |
| 
 | |
|     assert
 | |
|       .dom('[data-test-okta-number-challenge-description]')
 | |
|       .hasTextContaining(
 | |
|         'To finish signing in, you will need to complete an additional MFA step.',
 | |
|         'Correct description renders'
 | |
|       );
 | |
|     assert.dom('[data-test-message-error]').hasText(`Error ${this.hasError}`);
 | |
|     await click(GENERAL.backButton);
 | |
|     assert.true(this.onCancel.calledOnce, 'onCancel is called');
 | |
|   });
 | |
| });
 |