mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-23 07:31:09 +02:00
add timeout for saml and update selector (#30642)
This commit is contained in:
parent
86651479c8
commit
fdbbe1cf7e
@ -11,7 +11,7 @@
|
||||
data-test-user-menu
|
||||
as |Dropdown|
|
||||
>
|
||||
<Dropdown.Trigger data-test-user-menu-trigger>
|
||||
<Dropdown.Trigger data-test-button="user-menu-trigger">
|
||||
<Hds::Button @isIconOnly={{true}} @size="large" @icon="user" @text="User menu" />
|
||||
</Dropdown.Trigger>
|
||||
<Dropdown.Content>
|
||||
|
@ -322,7 +322,7 @@ module('Acceptance | auth login form', function (hooks) {
|
||||
|
||||
// login as user just to get token (this is the only way to generate a token in the UI right now..)
|
||||
await loginMethod(inputValues, { authType: 'userpass', toggleOptions: true });
|
||||
await click('[data-test-user-menu-trigger=""]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
const token = find('[data-test-copy-button]').getAttribute('data-test-copy-button');
|
||||
|
||||
// login with token to reproduce bug
|
||||
@ -332,7 +332,7 @@ module('Acceptance | auth login form', function (hooks) {
|
||||
.dom('[data-test-overview-card="Roles"]')
|
||||
.hasText('Roles Create new', 'database overview renders');
|
||||
// renew token
|
||||
await click('[data-test-user-menu-trigger=""]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
await click('[data-test-user-menu-item="renew token"]');
|
||||
// navigate out and back to overview tab to re-request capabilities
|
||||
await click(GENERAL.secretTab('Roles'));
|
||||
|
@ -11,6 +11,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import { login, loginMethod, logout } from 'vault/tests/helpers/auth/auth-helpers';
|
||||
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
|
||||
import { runCmd } from 'vault/tests/helpers/commands';
|
||||
import { GENERAL } from 'vault/tests/helpers/general-selectors';
|
||||
|
||||
const tokenWithPolicy = async function (name, policy) {
|
||||
return await runCmd([
|
||||
@ -51,12 +52,12 @@ module('Acceptance | cluster', function (hooks) {
|
||||
|
||||
await loginMethod({ username, password, path }, { authType: 'userpass', toggleOptions: true });
|
||||
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
assert.dom('[data-test-user-menu-item="mfa"]').exists();
|
||||
|
||||
await login();
|
||||
await settled();
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
assert.dom('[data-test-user-menu-item="mfa"]').doesNotExist();
|
||||
});
|
||||
|
||||
|
@ -12,6 +12,7 @@ import { login, loginMethod } from 'vault/tests/helpers/auth/auth-helpers';
|
||||
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
|
||||
import consoleClass from 'vault/tests/pages/components/console/ui-panel';
|
||||
import { setupMirage } from 'ember-cli-mirage/test-support';
|
||||
import { GENERAL } from 'vault/tests/helpers/general-selectors';
|
||||
|
||||
const consoleComponent = create(consoleClass);
|
||||
const USER = 'end-user';
|
||||
@ -53,7 +54,7 @@ module('Acceptance | mfa-setup', function (hooks) {
|
||||
{ username: USER, password: PASSWORD, path },
|
||||
{ authType: 'userpass', toggleOptions: true }
|
||||
);
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
await click('[data-test-user-menu-item="mfa"]');
|
||||
});
|
||||
|
||||
|
@ -9,6 +9,7 @@ import { setupApplicationTest } from 'vault/tests/helpers';
|
||||
import { login, loginMethod } from 'vault/tests/helpers/auth/auth-helpers';
|
||||
import { createPolicyCmd, deleteAuthCmd, mountAuthCmd, runCmd } from '../helpers/commands';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { GENERAL } from 'vault/tests/helpers/general-selectors';
|
||||
|
||||
const SUCCESS_MESSAGE = 'Successfully reset password';
|
||||
|
||||
@ -34,7 +35,7 @@ module('Acceptance | reset password', function (hooks) {
|
||||
await login();
|
||||
await settled();
|
||||
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
assert.dom('[data-test-user-menu-item="reset-password"]').doesNotExist();
|
||||
});
|
||||
|
||||
@ -51,7 +52,7 @@ module('Acceptance | reset password', function (hooks) {
|
||||
{ authType: 'userpass', toggleOptions: true }
|
||||
);
|
||||
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
await click('[data-test-user-menu-item="reset-password"]');
|
||||
|
||||
assert.strictEqual(currentURL(), '/vault/access/reset-password', 'links to password reset');
|
||||
|
@ -11,8 +11,13 @@ import { Response } from 'miragejs';
|
||||
import { windowStub } from 'vault/tests/helpers/oidc-window-stub';
|
||||
import { setupTotpMfaResponse } from 'vault/tests/helpers/mfa/mfa-helpers';
|
||||
import { AUTH_FORM } from 'vault/tests/helpers/auth/auth-form-selectors';
|
||||
import { MFA_SELECTORS } from 'vault/tests/helpers/mfa/mfa-selectors';
|
||||
import { GENERAL } from 'vault/tests/helpers/general-selectors';
|
||||
|
||||
import { logout } from 'vault/tests/helpers/auth/auth-helpers';
|
||||
|
||||
const DELAY_IN_MS = 500;
|
||||
|
||||
module('Acceptance | enterprise saml auth method', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
@ -40,13 +45,13 @@ module('Acceptance | enterprise saml auth method', function (hooks) {
|
||||
assert.expect(1);
|
||||
|
||||
this.server.get('/auth/token/lookup-self', (schema, req) => {
|
||||
assert.ok(true, 'request made to auth/token/lookup-self after saml callback');
|
||||
assert.true(true, 'request made to auth/token/lookup-self after saml callback');
|
||||
req.passthrough();
|
||||
});
|
||||
// select from dropdown or click auth path tab
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod));
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod), { timeout: DELAY_IN_MS });
|
||||
await fillIn(AUTH_FORM.selectMethod, 'saml');
|
||||
await click('[data-test-auth-submit]');
|
||||
await click(AUTH_FORM.login);
|
||||
});
|
||||
|
||||
test('it should login with saml from listed auth mount tab', async function (assert) {
|
||||
@ -85,7 +90,7 @@ module('Acceptance | enterprise saml auth method', function (hooks) {
|
||||
|
||||
await logout(); // clear local storage and refresh route so sys/internal/ui/mounts is reliably called
|
||||
// click auth path tab
|
||||
await waitUntil(() => find(AUTH_FORM.tabBtn('saml')));
|
||||
await waitUntil(() => find(AUTH_FORM.tabBtn('saml')), { timeout: DELAY_IN_MS });
|
||||
await click(AUTH_FORM.login);
|
||||
});
|
||||
|
||||
@ -100,9 +105,9 @@ module('Acceptance | enterprise saml auth method', function (hooks) {
|
||||
});
|
||||
|
||||
// select saml auth type
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod));
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod), { timeout: DELAY_IN_MS });
|
||||
await fillIn(AUTH_FORM.selectMethod, 'saml');
|
||||
await click('[data-test-auth-submit]');
|
||||
await click(AUTH_FORM.login);
|
||||
assert
|
||||
.dom('[data-test-message-error-description]')
|
||||
.hasText("Authentication failed: missing required 'role' parameter", 'shows API error from role fetch');
|
||||
@ -119,9 +124,9 @@ module('Acceptance | enterprise saml auth method', function (hooks) {
|
||||
});
|
||||
|
||||
// select saml auth type
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod));
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod), { timeout: DELAY_IN_MS });
|
||||
await fillIn(AUTH_FORM.selectMethod, 'saml');
|
||||
await click('[data-test-auth-submit]');
|
||||
await click(AUTH_FORM.login);
|
||||
assert
|
||||
.dom('[data-test-message-error-description]')
|
||||
.hasText('Authentication failed: something went wrong', 'shows API error from login attempt');
|
||||
@ -130,11 +135,11 @@ module('Acceptance | enterprise saml auth method', function (hooks) {
|
||||
test('it should populate saml auth method on logout', async function (assert) {
|
||||
await visit('/vault/logout');
|
||||
// select from dropdown
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod));
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod), { timeout: DELAY_IN_MS });
|
||||
await fillIn(AUTH_FORM.selectMethod, 'saml');
|
||||
await click('[data-test-auth-submit]');
|
||||
await waitUntil(() => find('[data-test-user-menu-trigger]'));
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(AUTH_FORM.login);
|
||||
await waitUntil(() => find(GENERAL.testButton('user-menu-trigger')), { timeout: DELAY_IN_MS });
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
await click('#logout');
|
||||
assert.dom(AUTH_FORM.selectMethod).hasValue('saml', 'Previous auth method selected on logout');
|
||||
});
|
||||
@ -143,10 +148,10 @@ module('Acceptance | enterprise saml auth method', function (hooks) {
|
||||
assert.expect(1);
|
||||
this.server.put('/auth/saml/token', () => setupTotpMfaResponse('saml'));
|
||||
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod));
|
||||
await waitUntil(() => find(AUTH_FORM.selectMethod), { timeout: DELAY_IN_MS });
|
||||
await fillIn(AUTH_FORM.selectMethod, 'saml');
|
||||
await click(AUTH_FORM.login);
|
||||
await waitUntil(() => find('[data-test-mfa-form]'));
|
||||
assert.dom('[data-test-mfa-form]').exists('it renders TOTP MFA form');
|
||||
await waitUntil(() => find(MFA_SELECTORS.mfaForm), { timeout: DELAY_IN_MS });
|
||||
assert.dom(MFA_SELECTORS.mfaForm).exists('it renders TOTP MFA form');
|
||||
});
|
||||
});
|
||||
|
@ -117,6 +117,7 @@ export const GENERAL = {
|
||||
cancelButton: '[data-test-cancel]',
|
||||
saveButton: '[data-test-save]',
|
||||
testButton: (label: string) => `[data-test-button="${label}"]`,
|
||||
// Code blocks
|
||||
codeBlock: (label: string) => `[data-test-code-block="${label}"]`,
|
||||
// TODO replace data-test-component="value" as a higher level selector
|
||||
codemirror: `[data-test-component="code-mirror-modifier"]`,
|
||||
|
@ -9,6 +9,7 @@ import { render, click } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import sinon from 'sinon';
|
||||
import { setRunOptions } from 'ember-a11y-testing/test-support';
|
||||
import { GENERAL } from 'vault/tests/helpers/general-selectors';
|
||||
|
||||
module('Integration | Component | sidebar-user-menu', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
@ -29,9 +30,9 @@ module('Integration | Component | sidebar-user-menu', function (hooks) {
|
||||
await render(hbs`<Sidebar::UserMenu />`);
|
||||
|
||||
assert
|
||||
.dom('[data-test-user-menu-trigger] [data-test-icon="user"]')
|
||||
.dom(`${GENERAL.testButton('user-menu-trigger')} [data-test-icon="user"]`)
|
||||
.exists('Correct icon renders for menu trigger');
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
assert.dom('[data-test-user-menu-content]').exists('User menu content renders');
|
||||
});
|
||||
|
||||
@ -40,7 +41,7 @@ module('Integration | Component | sidebar-user-menu', function (hooks) {
|
||||
sinon.stub(this.auth, 'authData').value({ displayName: 'token' });
|
||||
|
||||
await render(hbs`<Sidebar::UserMenu />`);
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
|
||||
assert.dom('.menu-label').hasText('Token', 'Auth data display name renders');
|
||||
assert.dom('li').exists({ count: 2 }, 'Correct number of menu items render');
|
||||
@ -59,7 +60,7 @@ module('Integration | Component | sidebar-user-menu', function (hooks) {
|
||||
this.auth.set('allowExpiration', true);
|
||||
|
||||
await render(hbs`<Sidebar::UserMenu />`);
|
||||
await click('[data-test-user-menu-trigger]');
|
||||
await click(GENERAL.testButton('user-menu-trigger'));
|
||||
|
||||
assert.dom('[data-test-user-menu-item="token alert"]').exists('Token expiration alert renders');
|
||||
assert.dom('[data-test-user-menu-item="mfa"]').hasText('Multi-factor authentication', 'MFA link renders');
|
||||
|
Loading…
x
Reference in New Issue
Block a user