Files
vault/ui/tests/pages/auth.js
Chelsea Shaw cb217388d4 UI: handle reduced disclosure endpoints (#24262)
* Create app-footer component with tests

* glimmerize vault route + controller

* Add dev mode badge to new footer

* Fix version on dashboard

* update app-footer tests

* update version title component

* Handle case for chroot namespace fail on health check

* cleanup

* fix ent tests

* add missing headers

* extra version fetch on login success, clear version on logout and seal

* Add coverage for clearing version on seal

* rename isOSS to isCommunity

* remove is-version helper

* test version in footer on unseal flow

* fix enterprise test

* VAULT-21399 test coverage

* VAULT-21400 test coverage
2023-12-04 14:28:16 -06:00

70 lines
2.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { create, visitable, fillable, clickable } from 'ember-cli-page-object';
import { click, settled } from '@ember/test-helpers';
import VAULT_KEYS from 'vault/tests/helpers/vault-keys';
const { rootToken } = VAULT_KEYS;
export default create({
visit: visitable('/vault/auth'),
logout: visitable('/vault/logout'),
submit: clickable('[data-test-auth-submit]'),
tokenInput: fillable('[data-test-token]'),
usernameInput: fillable('[data-test-username]'),
passwordInput: fillable('[data-test-password]'),
namespaceInput: fillable('[data-test-auth-form-ns-input]'),
optionsToggle: clickable('[data-test-auth-form-options-toggle]'),
mountPath: fillable('[data-test-auth-form-mount-path]'),
login: async function (token = rootToken) {
// make sure we're always logged out and logged back in
await this.logout();
await settled();
// clear session storage to ensure we have a clean state
window.localStorage.clear();
await this.visit({ with: 'token' });
await settled();
return this.tokenInput(token).submit();
},
loginUsername: async function (username, password, path) {
// make sure we're always logged out and logged back in
await this.logout();
await settled();
// clear local storage to ensure we have a clean state
window.localStorage.clear();
await this.visit({ with: 'userpass' });
await settled();
if (path) {
await this.optionsToggle();
await this.mountPath(path);
}
await this.usernameInput(username);
return this.passwordInput(password).submit();
},
loginNs: async function (ns, token = rootToken) {
// make sure we're always logged out and logged back in
await this.logout();
await settled();
// clear session storage to ensure we have a clean state
window.localStorage.clear();
await this.visit({ with: 'token' });
await settled();
await this.namespaceInput(ns);
await settled();
await this.tokenInput(token).submit();
return;
},
clickLogout: async function (clearNamespace = false) {
await click('[data-test-user-menu-trigger]');
await click('[data-test-user-menu-content] a#logout');
if (clearNamespace) {
await this.namespaceInput('');
}
return;
},
});