Remove ember-cli-page-object: mount-backend-form (#28799)

* 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>
This commit is contained in:
Angel Garbarino
2024-10-30 14:15:59 -06:00
committed by GitHub
parent fedc0b127f
commit 120497d813
28 changed files with 264 additions and 266 deletions

View File

@@ -5,7 +5,7 @@
<PageHeader as |p|> <PageHeader as |p|>
<p.levelLeft> <p.levelLeft>
<h1 class="title is-3 title-with-icon" data-test-mount-form-header="true"> <h1 class="title is-3 title-with-icon" data-test-page-title>
{{#if this.showEnable}} {{#if this.showEnable}}
{{#let (find-by "type" @mountModel.type @mountTypes) as |typeInfo|}} {{#let (find-by "type" @mountModel.type @mountTypes) as |typeInfo|}}
<Icon @name={{typeInfo.glyph}} @size="24" class="has-text-grey-light" /> <Icon @name={{typeInfo.glyph}} @size="24" class="has-text-grey-light" />
@@ -59,12 +59,12 @@
@text={{if (eq @mountType "secret") "Enable engine" "Enable method"}} @text={{if (eq @mountType "secret") "Enable engine" "Enable method"}}
@icon={{if this.mountBackend.isRunning "loading"}} @icon={{if this.mountBackend.isRunning "loading"}}
type="submit" type="submit"
data-test-mount-submit="true" data-test-save
disabled={{this.mountBackend.isRunning}} disabled={{this.mountBackend.isRunning}}
/> />
</div> </div>
<div class="control"> <div class="control">
<Hds::Button @text="Back" @color="secondary" data-test-mount-back {{on "click" (fn this.setMountType "")}} /> <Hds::Button @text="Back" @color="secondary" data-test-back-button {{on "click" (fn this.setMountType "")}} />
</div> </div>
{{#if this.invalidFormAlert}} {{#if this.invalidFormAlert}}
<div class="control"> <div class="control">

View File

@@ -3,13 +3,10 @@
* SPDX-License-Identifier: BUSL-1.1 * SPDX-License-Identifier: BUSL-1.1
*/ */
import { click, currentURL, fillIn } from '@ember/test-helpers'; import { click, currentURL } from '@ember/test-helpers';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
const SELECTORS = { import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
mountType: (name) => `[data-test-mount-type="${name}"]`,
submit: '[data-test-mount-submit]',
};
const assertFields = (assert, fields, customSelectors = {}) => { const assertFields = (assert, fields, customSelectors = {}) => {
fields.forEach((param) => { fields.forEach((param) => {
@@ -22,16 +19,14 @@ const assertFields = (assert, fields, customSelectors = {}) => {
}; };
export default (test) => { export default (test) => {
test('it renders mount fields', async function (assert) { test('it renders mount fields', async function (assert) {
await click(SELECTORS.mountType(this.type)); await click(MOUNT_BACKEND_FORM.mountType(this.type));
await click(GENERAL.toggleGroup('Method Options')); await click(GENERAL.toggleGroup('Method Options'));
assertFields(assert, this.mountFields, this.customSelectors); assertFields(assert, this.mountFields, this.customSelectors);
}); });
test('it renders tune fields', async function (assert) { test('it renders tune fields', async function (assert) {
// enable auth method to check tune fields // enable auth method to check tune fields
await click(SELECTORS.mountType(this.type)); await mountBackend(this.type, this.path);
await fillIn(GENERAL.inputByAttr('path'), this.path);
await click(SELECTORS.submit);
assert.strictEqual( assert.strictEqual(
currentURL(), currentURL(),
`/vault/settings/auth/configure/${this.path}/configuration`, `/vault/settings/auth/configure/${this.path}/configuration`,

View File

@@ -22,6 +22,7 @@ import rolesPage from 'vault/tests/pages/secrets/backend/kmip/roles';
import credentialsPage from 'vault/tests/pages/secrets/backend/kmip/credentials'; import credentialsPage from 'vault/tests/pages/secrets/backend/kmip/credentials';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend'; import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { allEngines } from 'vault/helpers/mountable-secret-engines'; import { allEngines } from 'vault/helpers/mountable-secret-engines';
import { mountEngineCmd, runCmd } from 'vault/tests/helpers/commands'; import { mountEngineCmd, runCmd } from 'vault/tests/helpers/commands';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
@@ -29,18 +30,9 @@ import { v4 as uuidv4 } from 'uuid';
// port has a lower limit of 1024 // port has a lower limit of 1024
const getRandomPort = () => Math.floor(Math.random() * 5000 + 1024); const getRandomPort = () => Math.floor(Math.random() * 5000 + 1024);
const mount = async (backend) => {
const res = await runCmd(`write sys/mounts/${backend} type=kmip`);
await settled();
if (res.includes('Error')) {
throw new Error(`Error mounting secrets engine: ${res}`);
}
return backend;
};
const mountWithConfig = async (backend) => { const mountWithConfig = async (backend) => {
const addr = `127.0.0.1:${getRandomPort()}`; const addr = `127.0.0.1:${getRandomPort()}`;
await mount(backend); await runCmd(mountEngineCmd('kmip', backend), false);
const res = await runCmd(`write ${backend}/config listen_addrs=${addr}`); const res = await runCmd(`write ${backend}/config listen_addrs=${addr}`);
if (res.includes('Error')) { if (res.includes('Error')) {
throw new Error(`Error configuring KMIP: ${res}`); throw new Error(`Error configuring KMIP: ${res}`);
@@ -105,8 +97,8 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) {
const engine = allEngines().find((e) => e.type === 'kmip'); const engine = allEngines().find((e) => e.type === 'kmip');
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType(engine.type); await mountBackend(engine.type, `${engine.type}-${uuidv4()}`);
await mountSecrets.path(this.backend).submit();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
`vault.cluster.secrets.backend.${engine.engineRoute}`, `vault.cluster.secrets.backend.${engine.engineRoute}`,
@@ -116,7 +108,8 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) {
}); });
test('it can configure a KMIP secrets engine', async function (assert) { test('it can configure a KMIP secrets engine', async function (assert) {
const backend = await mount(this.backend); await runCmd(mountEngineCmd('kmip', this.backend));
const backend = this.backend;
await scopesPage.visit({ backend }); await scopesPage.visit({ backend });
await settled(); await settled();
await scopesPage.configurationLink(); await scopesPage.configurationLink();

View File

@@ -10,6 +10,7 @@ import authPage from 'vault/tests/pages/auth';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend'; import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support';
import { allEngines } from 'vault/helpers/mountable-secret-engines'; import { allEngines } from 'vault/helpers/mountable-secret-engines';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { runCmd } from '../helpers/commands'; import { runCmd } from '../helpers/commands';
module('Acceptance | Enterprise | keymgmt', function (hooks) { module('Acceptance | Enterprise | keymgmt', function (hooks) {
@@ -27,9 +28,7 @@ module('Acceptance | Enterprise | keymgmt', function (hooks) {
// delete any previous mount with same name // delete any previous mount with same name
await runCmd([`delete sys/mounts/${engine.type}`]); await runCmd([`delete sys/mounts/${engine.type}`]);
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType(engine.type); await mountBackend(engine.type, engine.type);
await mountSecrets.path(engine.type);
await mountSecrets.submit();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),

View File

@@ -5,7 +5,7 @@
import { module, test } from 'qunit'; import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit'; import { setupApplicationTest } from 'ember-qunit';
import { currentURL, click, settled, currentRouteName } from '@ember/test-helpers'; import { currentURL, click, settled, currentRouteName, visit } from '@ember/test-helpers';
import { create } from 'ember-cli-page-object'; import { create } from 'ember-cli-page-object';
import { selectChoose } from 'ember-power-select/test-support'; import { selectChoose } from 'ember-power-select/test-support';
import { typeInSearch, clickTrigger } from 'ember-power-select/test-support/helpers'; import { typeInSearch, clickTrigger } from 'ember-power-select/test-support/helpers';
@@ -19,16 +19,11 @@ import alphabetsPage from 'vault/tests/pages/secrets/backend/transform/alphabets
import searchSelect from 'vault/tests/pages/components/search-select'; import searchSelect from 'vault/tests/pages/components/search-select';
import { runCmd } from '../helpers/commands'; import { runCmd } from '../helpers/commands';
import { allEngines } from 'vault/helpers/mountable-secret-engines'; import { allEngines } from 'vault/helpers/mountable-secret-engines';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { v4 as uuidv4 } from 'uuid';
const searchSelectComponent = create(searchSelect); const searchSelectComponent = create(searchSelect);
const mount = async () => {
const path = `transform-${Date.now()}`;
await mountSecrets.enable('transform', path);
await settled();
return path;
};
const newTransformation = async (backend, name, submit = false) => { const newTransformation = async (backend, name, submit = false) => {
const transformationName = name || 'foo'; const transformationName = name || 'foo';
await transformationsPage.visitCreate({ backend }); await transformationsPage.visitCreate({ backend });
@@ -75,9 +70,7 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
// delete any previous mount with same name // delete any previous mount with same name
await runCmd([`delete sys/mounts/${engine.type}`]); await runCmd([`delete sys/mounts/${engine.type}`]);
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType(engine.type); await mountBackend(engine.type, engine.type);
await mountSecrets.path(engine.type);
await mountSecrets.submit();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
@@ -108,7 +101,9 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
}); });
test('it can create a transformation and add itself to the role attached', async function (assert) { test('it can create a transformation and add itself to the role attached', async function (assert) {
const backend = await mount(); await visit('/vault/settings/mount-secret-backend');
const backend = `transform-${uuidv4()}`;
await mountBackend('transform', backend);
const transformationName = 'foo'; const transformationName = 'foo';
const roleName = 'foo-role'; const roleName = 'foo-role';
await settled(); await settled();
@@ -158,7 +153,9 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
test('it can create a role and add itself to the transformation attached', async function (assert) { test('it can create a role and add itself to the transformation attached', async function (assert) {
const roleName = 'my-role'; const roleName = 'my-role';
const backend = await mount(); await visit('/vault/settings/mount-secret-backend');
const backend = `transform-${uuidv4()}`;
await mountBackend('transform', backend);
// create transformation without role // create transformation without role
await newTransformation(backend, 'a-transformation', true); await newTransformation(backend, 'a-transformation', true);
await click(`[data-test-secret-breadcrumb="${backend}"] a`); await click(`[data-test-secret-breadcrumb="${backend}"] a`);
@@ -197,7 +194,9 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
test('it adds a role to a transformation when added to a role', async function (assert) { test('it adds a role to a transformation when added to a role', async function (assert) {
const roleName = 'role-test'; const roleName = 'role-test';
const backend = await mount(); await visit('/vault/settings/mount-secret-backend');
const backend = `transform-${uuidv4()}`;
await mountBackend('transform', backend);
const transformation = await newTransformation(backend, 'b-transformation', true); const transformation = await newTransformation(backend, 'b-transformation', true);
await newRole(backend, roleName); await newRole(backend, roleName);
await transformationsPage.visitShow({ backend, id: transformation }); await transformationsPage.visitShow({ backend, id: transformation });
@@ -207,7 +206,9 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
test('it shows a message if an update fails after save', async function (assert) { test('it shows a message if an update fails after save', async function (assert) {
const roleName = 'role-remove'; const roleName = 'role-remove';
const backend = await mount(); await visit('/vault/settings/mount-secret-backend');
const backend = `transform-${uuidv4()}`;
await mountBackend('transform', backend);
// Create transformation // Create transformation
const transformation = await newTransformation(backend, 'c-transformation', true); const transformation = await newTransformation(backend, 'c-transformation', true);
// create role // create role
@@ -244,7 +245,9 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
test('it allows creation and edit of a template', async function (assert) { test('it allows creation and edit of a template', async function (assert) {
const templateName = 'my-template'; const templateName = 'my-template';
const backend = await mount(); await visit('/vault/settings/mount-secret-backend');
const backend = `transform-${uuidv4()}`;
await mountBackend('transform', backend);
await click('[data-test-secret-list-tab="Templates"]'); await click('[data-test-secret-list-tab="Templates"]');
assert.strictEqual( assert.strictEqual(
@@ -286,7 +289,9 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
test('it allows creation and edit of an alphabet', async function (assert) { test('it allows creation and edit of an alphabet', async function (assert) {
const alphabetName = 'vowels-only'; const alphabetName = 'vowels-only';
const backend = await mount(); await visit('/vault/settings/mount-secret-backend');
const backend = `transform-${uuidv4()}`;
await mountBackend('transform', backend);
await click('[data-test-secret-list-tab="Alphabets"]'); await click('[data-test-secret-list-tab="Alphabets"]');
assert.strictEqual( assert.strictEqual(

View File

@@ -11,6 +11,7 @@ import { v4 as uuidv4 } from 'uuid';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend'; import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import backendsPage from 'vault/tests/pages/secrets/backends'; import backendsPage from 'vault/tests/pages/secrets/backends';
import authPage from 'vault/tests/pages/auth'; import authPage from 'vault/tests/pages/auth';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
module('Acceptance | alicloud/enable', function (hooks) { module('Acceptance | alicloud/enable', function (hooks) {
setupApplicationTest(hooks); setupApplicationTest(hooks);
@@ -24,10 +25,7 @@ module('Acceptance | alicloud/enable', function (hooks) {
const enginePath = `alicloud-${this.uid}`; const enginePath = `alicloud-${this.uid}`;
await mountSecrets.visit(); await mountSecrets.visit();
await settled(); await settled();
await mountSecrets.selectType('alicloud'); await mountBackend('alicloud', enginePath);
await settled();
await mountSecrets.path(enginePath).submit();
await settled();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),

View File

@@ -16,6 +16,7 @@ import { runCmd } from 'vault/tests/helpers/commands';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { overrideResponse } from 'vault/tests/helpers/stubs'; import { overrideResponse } from 'vault/tests/helpers/stubs';
import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors'; import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { import {
createConfig, createConfig,
expectedConfigKeys, expectedConfigKeys,
@@ -46,9 +47,7 @@ module('Acceptance | aws | configuration', function (hooks) {
const path = `aws-${this.uid}`; const path = `aws-${this.uid}`;
// in this test go through the full mount process. Bypass this step in later tests. // in this test go through the full mount process. Bypass this step in later tests.
await visit('/vault/settings/mount-secret-backend'); await visit('/vault/settings/mount-secret-backend');
await click(SES.mountType('aws')); await mountBackend('aws', path);
await fillIn(GENERAL.inputByAttr('path'), path);
await click(SES.mountSubmit);
await click(SES.configTab); await click(SES.configTab);
assert.dom(GENERAL.emptyStateTitle).hasText('AWS not configured'); assert.dom(GENERAL.emptyStateTitle).hasText('AWS not configured');
assert.dom(GENERAL.emptyStateActions).hasText('Configure AWS'); assert.dom(GENERAL.emptyStateActions).hasText('Configure AWS');

View File

@@ -11,6 +11,7 @@ import { v4 as uuidv4 } from 'uuid';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend'; import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import backendsPage from 'vault/tests/pages/secrets/backends'; import backendsPage from 'vault/tests/pages/secrets/backends';
import authPage from 'vault/tests/pages/auth'; import authPage from 'vault/tests/pages/auth';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
module('Acceptance | gcpkms/enable', function (hooks) { module('Acceptance | gcpkms/enable', function (hooks) {
setupApplicationTest(hooks); setupApplicationTest(hooks);
@@ -25,9 +26,8 @@ module('Acceptance | gcpkms/enable', function (hooks) {
const enginePath = `gcpkms-${this.uid}`; const enginePath = `gcpkms-${this.uid}`;
await mountSecrets.visit(); await mountSecrets.visit();
await settled(); await settled();
await mountSecrets.selectType('gcpkms'); await mountBackend('gcpkms', enginePath);
await mountSecrets.path(enginePath).submit();
await settled();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
'vault.cluster.secrets.backends', 'vault.cluster.secrets.backends',

View File

@@ -19,6 +19,7 @@ import { writeSecret, writeVersionedSecret } from 'vault/tests/helpers/kv/kv-run
import { runCmd } from 'vault/tests/helpers/commands'; import { runCmd } from 'vault/tests/helpers/commands';
import { PAGE } from 'vault/tests/helpers/kv/kv-selectors'; import { PAGE } from 'vault/tests/helpers/kv/kv-selectors';
import codemirror from 'vault/tests/helpers/codemirror'; import codemirror from 'vault/tests/helpers/codemirror';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { SECRET_ENGINE_SELECTORS as SS } from 'vault/tests/helpers/secret-engine/secret-engine-selectors'; import { SECRET_ENGINE_SELECTORS as SS } from 'vault/tests/helpers/secret-engine/secret-engine-selectors';
@@ -49,15 +50,14 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) {
const enginePath = `kv-secret-${this.uid}`; const enginePath = `kv-secret-${this.uid}`;
const maxVersion = '101'; const maxVersion = '101';
await mountSecrets.visit(); await mountSecrets.visit();
await click('[data-test-mount-type="kv"]'); await click(MOUNT_BACKEND_FORM.mountType('kv'));
await fillIn(GENERAL.inputByAttr('path'), enginePath);
await fillIn('[data-test-input="path"]', enginePath);
await fillIn('[data-test-input="maxVersions"]', maxVersion); await fillIn('[data-test-input="maxVersions"]', maxVersion);
await click('[data-test-input="casRequired"]'); await click('[data-test-input="casRequired"]');
await click('[data-test-toggle-label="Automate secret deletion"]'); await click('[data-test-toggle-label="Automate secret deletion"]');
await fillIn('[data-test-select="ttl-unit"]', 's'); await fillIn('[data-test-select="ttl-unit"]', 's');
await fillIn('[data-test-ttl-value="Automate secret deletion"]', '1'); await fillIn('[data-test-ttl-value="Automate secret deletion"]', '1');
await click('[data-test-mount-submit="true"]'); await click(GENERAL.saveButton);
await click(PAGE.secretTab('Configuration')); await click(PAGE.secretTab('Configuration'));
@@ -138,8 +138,11 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) {
this.backend = `kv-v1-${this.uid}`; this.backend = `kv-v1-${this.uid}`;
// mount version 1 engine // mount version 1 engine
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType('kv'); await click(MOUNT_BACKEND_FORM.mountType('kv'));
await mountSecrets.path(this.backend).toggleOptions().version(1).submit(); await fillIn(GENERAL.inputByAttr('path'), this.backend);
await click(GENERAL.toggleGroup('Method Options'));
await mountSecrets.version(1);
await click(GENERAL.saveButton);
}); });
hooks.afterEach(async function () { hooks.afterEach(async function () {
await runCmd([`delete sys/mounts/${this.backend}`]); await runCmd([`delete sys/mounts/${this.backend}`]);

View File

@@ -10,10 +10,11 @@ import { v4 as uuidv4 } from 'uuid';
import ldapMirageScenario from 'vault/mirage/scenarios/ldap'; import ldapMirageScenario from 'vault/mirage/scenarios/ldap';
import ldapHandlers from 'vault/mirage/handlers/ldap'; import ldapHandlers from 'vault/mirage/handlers/ldap';
import authPage from 'vault/tests/pages/auth'; import authPage from 'vault/tests/pages/auth';
import { click, fillIn, visit } from '@ember/test-helpers'; import { click, visit } from '@ember/test-helpers';
import { selectChoose } from 'ember-power-select/test-support'; import { selectChoose } from 'ember-power-select/test-support';
import { isURL, visitURL } from 'vault/tests/helpers/ldap/ldap-helpers'; import { isURL, visitURL } from 'vault/tests/helpers/ldap/ldap-helpers';
import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands'; import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
module('Acceptance | ldap | overview', function (hooks) { module('Acceptance | ldap | overview', function (hooks) {
setupApplicationTest(hooks); setupApplicationTest(hooks);
@@ -35,9 +36,7 @@ module('Acceptance | ldap | overview', function (hooks) {
const backend = 'ldap-test-mount'; const backend = 'ldap-test-mount';
await visit('/vault/secrets'); await visit('/vault/secrets');
await click('[data-test-enable-engine]'); await click('[data-test-enable-engine]');
await click('[data-test-mount-type="ldap"]'); await mountBackend('ldap', backend);
await fillIn('[data-test-input="path"]', backend);
await click('[data-test-mount-submit]');
assert.true(isURL('overview', backend), 'Transitions to ldap overview route on mount success'); assert.true(isURL('overview', backend), 'Transitions to ldap overview route on mount success');
assert.dom('[data-test-header-title]').hasText(backend); assert.dom('[data-test-header-title]').hasText(backend);
// cleanup mounted engine // cleanup mounted engine

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: BUSL-1.1 * SPDX-License-Identifier: BUSL-1.1
*/ */
import { click, fillIn, currentURL, visit, waitFor } from '@ember/test-helpers'; import { click, currentURL, visit, waitFor } from '@ember/test-helpers';
import { module, test } from 'qunit'; import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit'; import { setupApplicationTest } from 'ember-qunit';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
@@ -14,6 +14,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support';
import { runCmd } from 'vault/tests/helpers/commands'; import { runCmd } from 'vault/tests/helpers/commands';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors'; import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { configUrl } from 'vault/tests/helpers/secret-engine/secret-engine-helpers'; import { configUrl } from 'vault/tests/helpers/secret-engine/secret-engine-helpers';
import { overrideResponse } from 'vault/tests/helpers/stubs'; import { overrideResponse } from 'vault/tests/helpers/stubs';
@@ -31,9 +32,7 @@ module('Acceptance | ssh | configuration', function (hooks) {
const sshPath = `ssh-${this.uid}`; const sshPath = `ssh-${this.uid}`;
// in this test go through the full mount process. Bypass this step in later tests. // in this test go through the full mount process. Bypass this step in later tests.
await visit('/vault/settings/mount-secret-backend'); await visit('/vault/settings/mount-secret-backend');
await click(SES.mountType('ssh')); await mountBackend('ssh', sshPath);
await fillIn(GENERAL.inputByAttr('path'), sshPath);
await click(SES.mountSubmit);
await click(SES.configTab); await click(SES.configTab);
assert.dom(GENERAL.emptyStateTitle).hasText('SSH not configured'); assert.dom(GENERAL.emptyStateTitle).hasText('SSH not configured');
assert.dom(GENERAL.emptyStateActions).hasText('Configure SSH'); assert.dom(GENERAL.emptyStateActions).hasText('Configure SSH');

View File

@@ -106,6 +106,7 @@ module('Acceptance | ssh | roles', function (hooks) {
}, },
}, },
]; ];
test('it creates roles, generates keys and deletes roles', async function (assert) { test('it creates roles, generates keys and deletes roles', async function (assert) {
assert.expect(28); assert.expect(28);
const sshPath = `ssh-${this.uid}`; const sshPath = `ssh-${this.uid}`;
@@ -150,8 +151,7 @@ module('Acceptance | ssh | roles', function (hooks) {
await settled(); // eslint-disable-line await settled(); // eslint-disable-line
role.assertAfterGenerate(assert, sshPath); role.assertAfterGenerate(assert, sshPath);
// click the "Back" button await click(GENERAL.backButton);
await click(SES.backButton);
assert.dom('[data-test-secret-generate-form]').exists(`${role.type}: back takes you back to the form`); assert.dom('[data-test-secret-generate-form]').exists(`${role.type}: back takes you back to the form`);
await click(GENERAL.cancelButton); await click(GENERAL.cancelButton);
@@ -175,13 +175,22 @@ module('Acceptance | ssh | roles', function (hooks) {
await runCmd(`delete sys/mounts/${sshPath}`); await runCmd(`delete sys/mounts/${sshPath}`);
}); });
module('Acceptance | ssh | otp role', function () { module('Acceptance | ssh | otp role', function () {
const createOTPRole = async (name) => {
await fillIn(GENERAL.inputByAttr('name'), name);
await fillIn(GENERAL.inputByAttr('keyType'), name);
await click(GENERAL.toggleGroup('Options'));
await fillIn(GENERAL.inputByAttr('keyType'), 'otp');
await fillIn(GENERAL.inputByAttr('defaultUser'), 'admin');
await fillIn(GENERAL.inputByAttr('cidrList'), '0.0.0.0/0');
await click(SES.ssh.createRole);
};
test('it deletes a role from list view', async function (assert) { test('it deletes a role from list view', async function (assert) {
assert.expect(2); assert.expect(2);
const path = `ssh-${this.uid}`; const path = `ssh-${this.uid}`;
await enablePage.enable('ssh', path); await enablePage.enable('ssh', path);
await settled(); await settled();
await editPage.visitRoot({ backend: path }); await editPage.visitRoot({ backend: path });
await editPage.createOTPRole('role'); await createOTPRole('role');
await settled(); await settled();
await showPage.visit({ backend: path, id: 'role' }); await showPage.visit({ backend: path, id: 'role' });
await settled(); await settled();
@@ -203,7 +212,7 @@ module('Acceptance | ssh | roles', function (hooks) {
await enablePage.enable('ssh', path); await enablePage.enable('ssh', path);
await settled(); await settled();
await editPage.visitRoot({ backend: path }); await editPage.visitRoot({ backend: path });
await editPage.createOTPRole('role'); await createOTPRole('role');
await settled(); await settled();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
@@ -222,11 +231,11 @@ module('Acceptance | ssh | roles', function (hooks) {
'navs to the credentials page' 'navs to the credentials page'
); );
await generatePage.generateOTP(); await fillIn(GENERAL.inputByAttr('username'), 'admin');
await settled(); await fillIn(GENERAL.inputByAttr('ip'), '192.168.1.1');
await click(GENERAL.saveButton);
assert.ok(generatePage.warningIsPresent, 'shows warning'); assert.ok(generatePage.warningIsPresent, 'shows warning');
await generatePage.back(); await click(GENERAL.backButton);
await settled();
assert.ok(generatePage.userIsPresent, 'clears generate, shows user input'); assert.ok(generatePage.userIsPresent, 'clears generate, shows user input');
assert.ok(generatePage.ipIsPresent, 'clears generate, shows ip input'); assert.ok(generatePage.ipIsPresent, 'clears generate, shows ip input');
// cleanup // cleanup

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: BUSL-1.1 * SPDX-License-Identifier: BUSL-1.1
*/ */
import { currentURL, find, visit, settled, click } from '@ember/test-helpers'; import { currentURL, visit, click, fillIn } from '@ember/test-helpers';
import { module, test } from 'qunit'; import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit'; import { setupApplicationTest } from 'ember-qunit';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
@@ -13,6 +13,7 @@ import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import authPage from 'vault/tests/pages/auth'; import authPage from 'vault/tests/pages/auth';
import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands'; import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
const { searchSelect } = GENERAL; const { searchSelect } = GENERAL;
@@ -31,22 +32,24 @@ module('Acceptance | secret engine mount settings', function (hooks) {
// mount unsupported backend // mount unsupported backend
await visit('/vault/settings/mount-secret-backend'); await visit('/vault/settings/mount-secret-backend');
assert.strictEqual(currentURL(), '/vault/settings/mount-secret-backend'); assert.strictEqual(
currentURL(),
await mountSecrets.selectType(type); '/vault/settings/mount-secret-backend',
await mountSecrets 'navigates to the mount secret backend page'
.path(path)
.toggleOptions()
.enableDefaultTtl()
.defaultTTLUnit('s')
.defaultTTLVal(100)
.submit();
await settled();
assert.ok(
find('[data-test-flash-message]').textContent.trim(),
`Successfully mounted '${type}' at '${path}'!`
); );
await settled(); await click(MOUNT_BACKEND_FORM.mountType(type));
await fillIn(GENERAL.inputByAttr('path'), path);
await click(GENERAL.toggleGroup('Method Options'));
await mountSecrets.enableDefaultTtl().defaultTTLUnit('s').defaultTTLVal(100);
await click(GENERAL.saveButton);
assert
.dom(`${GENERAL.flashMessage}.is-success`)
.includesText(
`Success Successfully mounted the ${type} secrets engine at ${path}`,
'flash message is shown after mounting'
);
assert.strictEqual(currentURL(), `/vault/secrets`, 'redirects to secrets page'); assert.strictEqual(currentURL(), `/vault/secrets`, 'redirects to secrets page');
// cleanup // cleanup
await runCmd(deleteEngineCmd(path)); await runCmd(deleteEngineCmd(path));

View File

@@ -3,14 +3,14 @@
* SPDX-License-Identifier: BUSL-1.1 * SPDX-License-Identifier: BUSL-1.1
*/ */
import { click, currentRouteName, fillIn, visit } from '@ember/test-helpers'; import { click, currentRouteName, visit } from '@ember/test-helpers';
import { module, test } from 'qunit'; import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit'; import { setupApplicationTest } from 'ember-qunit';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { login } from 'vault/tests/helpers/auth/auth-helpers'; import { login } from 'vault/tests/helpers/auth/auth-helpers';
import { deleteAuthCmd, runCmd } from 'vault/tests/helpers/commands'; import { deleteAuthCmd, runCmd } from 'vault/tests/helpers/commands';
import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Acceptance | settings/auth/enable', function (hooks) { module('Acceptance | settings/auth/enable', function (hooks) {
setupApplicationTest(hooks); setupApplicationTest(hooks);
@@ -26,9 +26,7 @@ module('Acceptance | settings/auth/enable', function (hooks) {
const type = 'approle'; const type = 'approle';
await visit('/vault/settings/auth/enable'); await visit('/vault/settings/auth/enable');
assert.strictEqual(currentRouteName(), 'vault.cluster.settings.auth.enable'); assert.strictEqual(currentRouteName(), 'vault.cluster.settings.auth.enable');
await click(SES.mountType(type)); await mountBackend(type, path);
await fillIn(GENERAL.inputByAttr('path'), path);
await click(SES.mountSubmit);
assert assert
.dom(GENERAL.latestFlashContent) .dom(GENERAL.latestFlashContent)
.hasText(`Successfully mounted the ${type} auth method at ${path}.`); .hasText(`Successfully mounted the ${type} auth method at ${path}.`);
@@ -49,9 +47,7 @@ module('Acceptance | settings/auth/enable', function (hooks) {
const path = `approle-config-${this.uid}`; const path = `approle-config-${this.uid}`;
const type = 'approle'; const type = 'approle';
await visit('/vault/settings/auth/enable'); await visit('/vault/settings/auth/enable');
await click(SES.mountType(type)); await mountBackend(type, path);
await fillIn(GENERAL.inputByAttr('path'), path);
await click(SES.mountSubmit);
// the config details is updated to query mount details from sys/internal/ui/mounts // the config details is updated to query mount details from sys/internal/ui/mounts
// but we still want these forms to continue using sys/auth which returns 0 for default ttl values // but we still want these forms to continue using sys/auth which returns 0 for default ttl values
// check tune form (right after enabling) // check tune form (right after enabling)

View File

@@ -30,6 +30,8 @@ import { mountableEngines } from 'vault/helpers/mountable-secret-engines'; // al
import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends'; import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors'; import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { SELECTORS as OIDC } from 'vault/tests/helpers/oidc-config'; import { SELECTORS as OIDC } from 'vault/tests/helpers/oidc-config';
import { adminOidcCreateRead, adminOidcCreate } from 'vault/tests/helpers/secret-engine/policy-generator'; import { adminOidcCreateRead, adminOidcCreate } from 'vault/tests/helpers/secret-engine/policy-generator';
import { WIF_ENGINES } from 'vault/helpers/mountable-secret-engines'; import { WIF_ENGINES } from 'vault/helpers/mountable-secret-engines';
@@ -59,17 +61,17 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
await page.visit(); await page.visit();
assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend'); assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend');
await page.selectType('kv'); await click(MOUNT_BACKEND_FORM.mountType('kv'));
await fillIn(GENERAL.inputByAttr('path'), path);
await click(GENERAL.toggleGroup('Method Options'));
await page await page
.path(path)
.toggleOptions()
.enableDefaultTtl() .enableDefaultTtl()
.defaultTTLUnit('h') .defaultTTLUnit('h')
.defaultTTLVal(defaultTTLHours) .defaultTTLVal(defaultTTLHours)
.enableMaxTtl() .enableMaxTtl()
.maxTTLUnit('h') .maxTTLUnit('h')
.maxTTLVal(maxTTLHours) .maxTTLVal(maxTTLHours);
.submit(); await click(GENERAL.saveButton);
await configPage.visit({ backend: path }); await configPage.visit({ backend: path });
assert.strictEqual(configPage.defaultTTL, `${this.calcDays(defaultTTLHours)}`, 'shows the proper TTL'); assert.strictEqual(configPage.defaultTTL, `${this.calcDays(defaultTTLHours)}`, 'shows the proper TTL');
assert.strictEqual(configPage.maxTTL, `${this.calcDays(maxTTLHours)}`, 'shows the proper max TTL'); assert.strictEqual(configPage.maxTTL, `${this.calcDays(maxTTLHours)}`, 'shows the proper max TTL');
@@ -82,16 +84,16 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
await page.visit(); await page.visit();
assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend'); assert.strictEqual(
await page.selectType('kv'); currentRouteName(),
await page 'vault.cluster.settings.mount-secret-backend',
.path(path) 'navigates to mount page'
.toggleOptions() );
.enableDefaultTtl() await click(MOUNT_BACKEND_FORM.mountType('kv'));
.enableMaxTtl() await fillIn(GENERAL.inputByAttr('path'), path);
.maxTTLUnit('h') await click(GENERAL.toggleGroup('Method Options'));
.maxTTLVal(maxTTLHours) await page.enableDefaultTtl().enableMaxTtl().maxTTLUnit('h').maxTTLVal(maxTTLHours);
.submit(); await click(GENERAL.saveButton);
await configPage.visit({ backend: path }); await configPage.visit({ backend: path });
assert.strictEqual(configPage.defaultTTL, '1 month 1 day', 'shows system default TTL'); assert.strictEqual(configPage.defaultTTL, '1 month 1 day', 'shows system default TTL');
assert.strictEqual(configPage.maxTTL, `${this.calcDays(maxTTLHours)}`, 'shows the proper max TTL'); assert.strictEqual(configPage.maxTTL, `${this.calcDays(maxTTLHours)}`, 'shows the proper max TTL');
@@ -100,7 +102,7 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
test('it sets the max ttl after pki chosen, resets after', async function (assert) { test('it sets the max ttl after pki chosen, resets after', async function (assert) {
await page.visit(); await page.visit();
assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend'); assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend');
await page.selectType('pki'); await click(MOUNT_BACKEND_FORM.mountType('pki'));
assert.dom('[data-test-input="maxLeaseTtl"]').exists(); assert.dom('[data-test-input="maxLeaseTtl"]').exists();
assert assert
.dom('[data-test-input="maxLeaseTtl"] [data-test-ttl-toggle]') .dom('[data-test-input="maxLeaseTtl"] [data-test-ttl-toggle]')
@@ -109,8 +111,8 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
assert.dom('[data-test-input="maxLeaseTtl"] [data-test-select="ttl-unit"]').hasValue('d'); assert.dom('[data-test-input="maxLeaseTtl"] [data-test-select="ttl-unit"]').hasValue('d');
// Go back and choose a different type // Go back and choose a different type
await page.back(); await click(GENERAL.backButton);
await page.selectType('database'); await click(MOUNT_BACKEND_FORM.mountType('database'));
assert.dom('[data-test-input="maxLeaseTtl"]').exists('3650'); assert.dom('[data-test-input="maxLeaseTtl"]').exists('3650');
assert assert
.dom('[data-test-input="maxLeaseTtl"] [data-test-ttl-toggle]') .dom('[data-test-input="maxLeaseTtl"] [data-test-ttl-toggle]')
@@ -131,13 +133,12 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
await page.visit(); await page.visit();
assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend'); assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend');
await page.selectType('kv'); await mountBackend('kv', path);
await page.path(path).submit();
await page.secretList(); await page.secretList();
await settled(); await settled();
await page.enableEngine(); await page.enableEngine();
await page.selectType('kv'); await mountBackend('kv', path);
await page.path(path).submit();
assert.dom('[data-test-message-error-description]').containsText(`path is already in use at ${path}`); assert.dom('[data-test-message-error-description]').containsText(`path is already in use at ${path}`);
assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend'); assert.strictEqual(currentRouteName(), 'vault.cluster.settings.mount-secret-backend');
@@ -185,9 +186,11 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
await authPage.login(userToken); await authPage.login(userToken);
// create the engine // create the engine
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType('kv'); await click(MOUNT_BACKEND_FORM.mountType('kv'));
await mountSecrets.path(enginePath).setMaxVersion(101).submit(); await fillIn(GENERAL.inputByAttr('path'), enginePath);
await settled(); await mountSecrets.setMaxVersion(101);
await click(GENERAL.saveButton);
assert assert
.dom('[data-test-flash-message]') .dom('[data-test-flash-message]')
.containsText( .containsText(
@@ -213,8 +216,8 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
`delete sys/mounts/${engine.type}`, `delete sys/mounts/${engine.type}`,
]); ]);
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType(engine.type); await mountBackend(engine.type, engine.type);
await mountSecrets.path(engine.type).submit();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
`vault.cluster.secrets.backend.${engine.engineRoute}`, `vault.cluster.secrets.backend.${engine.engineRoute}`,
@@ -240,12 +243,13 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
`delete sys/mounts/${engine.type}`, `delete sys/mounts/${engine.type}`,
]); ]);
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType(engine.type); await click(MOUNT_BACKEND_FORM.mountType(engine.type));
await mountSecrets.path(engine.type); await fillIn(GENERAL.inputByAttr('path'), engine.type);
if (engine.type === 'kv') { if (engine.type === 'kv') {
await mountSecrets.toggleOptions().version(1); await click(GENERAL.toggleGroup('Method Options'));
await mountSecrets.version(1);
} }
await mountSecrets.submit(); await click(GENERAL.saveButton);
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
@@ -269,8 +273,7 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
`delete sys/mounts/${engine.type}`, `delete sys/mounts/${engine.type}`,
]); ]);
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType(engine.type); await mountBackend(engine.type, engine.type);
await mountSecrets.path(engine.type).submit();
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
@@ -288,9 +291,7 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
`delete sys/mounts/${v2}`, `delete sys/mounts/${v2}`,
]); ]);
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType('kv'); await mountBackend('kv', v2);
await mountSecrets.path(v2).submit();
assert.strictEqual(currentURL(), `/vault/secrets/${v2}/kv/list`, `${v2} navigates to list url`); assert.strictEqual(currentURL(), `/vault/secrets/${v2}/kv/list`, `${v2} navigates to list url`);
assert.strictEqual( assert.strictEqual(
currentRouteName(), currentRouteName(),
@@ -304,8 +305,11 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
`delete sys/mounts/${v1}`, `delete sys/mounts/${v1}`,
]); ]);
await mountSecrets.visit(); await mountSecrets.visit();
await mountSecrets.selectType('kv'); await click(MOUNT_BACKEND_FORM.mountType('kv'));
await mountSecrets.path(v1).toggleOptions().version(1).submit(); await fillIn(GENERAL.inputByAttr('path'), v1);
await click(GENERAL.toggleGroup('Method Options'));
await mountSecrets.version(1);
await click(GENERAL.saveButton);
assert.strictEqual(currentURL(), `/vault/secrets/${v1}/list`, `${v1} navigates to list url`); assert.strictEqual(currentURL(), `/vault/secrets/${v1}/list`, `${v1} navigates to list url`);
assert.strictEqual( assert.strictEqual(
@@ -322,7 +326,7 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
for (const engine of WIF_ENGINES) { for (const engine of WIF_ENGINES) {
await page.visit(); await page.visit();
await page.selectType(engine); await click(MOUNT_BACKEND_FORM.mountType(engine));
await click(GENERAL.toggleGroup('Method Options')); await click(GENERAL.toggleGroup('Method Options'));
assert assert
.dom('[data-test-search-select-with-modal]') .dom('[data-test-search-select-with-modal]')
@@ -336,8 +340,8 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
.hasText('some-key', 'some-key was selected and displays in the search select'); .hasText('some-key', 'some-key was selected and displays in the search select');
} }
// Go back and choose a non-wif engine type // Go back and choose a non-wif engine type
await page.back(); await click(GENERAL.backButton);
await page.selectType('ssh'); await click(MOUNT_BACKEND_FORM.mountType('ssh'));
assert assert
.dom('[data-test-search-select-with-modal]') .dom('[data-test-search-select-with-modal]')
.doesNotExist('for type ssh, the modal field does not render.'); .doesNotExist('for type ssh, the modal field does not render.');
@@ -357,8 +361,8 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
await logout.visit(); await logout.visit();
await authPage.login(secretsAdminToken); await authPage.login(secretsAdminToken);
await page.visit(); await page.visit();
await page.selectType(engine); await click(MOUNT_BACKEND_FORM.mountType(engine));
await page.path(path); await fillIn(GENERAL.inputByAttr('path'), path);
await click(GENERAL.toggleGroup('Method Options')); await click(GENERAL.toggleGroup('Method Options'));
await clickTrigger('#key'); await clickTrigger('#key');
// create new key // create new key
@@ -371,7 +375,7 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
assert.dom('#search-select-modal').doesNotExist('modal disappears onSave'); assert.dom('#search-select-modal').doesNotExist('modal disappears onSave');
assert.dom(GENERAL.searchSelect.selectedOption()).hasText(newKey, `${newKey} is now selected`); assert.dom(GENERAL.searchSelect.selectedOption()).hasText(newKey, `${newKey} is now selected`);
await page.submit(); await click(GENERAL.saveButton);
await visit(`/vault/secrets/${path}/configuration`); await visit(`/vault/secrets/${path}/configuration`);
await click(SES.configurationToggle); await click(SES.configurationToggle);
assert assert
@@ -397,12 +401,12 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
await logout.visit(); await logout.visit();
await authPage.login(secretsNoOidcAdminToken); await authPage.login(secretsNoOidcAdminToken);
await page.visit(); await page.visit();
await page.selectType(engine); await click(MOUNT_BACKEND_FORM.mountType(engine));
await page.path(path); await fillIn(GENERAL.inputByAttr('path'), path);
await click(GENERAL.toggleGroup('Method Options')); await click(GENERAL.toggleGroup('Method Options'));
// type-in fallback component to create new key // type-in fallback component to create new key
await typeIn(GENERAL.inputSearch('key'), 'general-key'); await typeIn(GENERAL.inputSearch('key'), 'general-key');
await page.submit(); await click(GENERAL.saveButton);
assert assert
.dom(GENERAL.latestFlashContent) .dom(GENERAL.latestFlashContent)
.hasText(`Successfully mounted the aws secrets engine at ${path}.`); .hasText(`Successfully mounted the aws secrets engine at ${path}.`);

View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { fillIn, click } from '@ember/test-helpers';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
export const mountBackend = async (type, path) => {
await click(MOUNT_BACKEND_FORM.mountType(type));
if (path) {
await fillIn(GENERAL.inputByAttr('path'), path);
await click(GENERAL.saveButton);
} else {
// save with default path
await click(GENERAL.saveButton);
}
};

View File

@@ -0,0 +1,10 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
/** Ideally we wouldn't have one selector for one file.
However, given the coupled nature of mounting both secret engines and auth methods in one form, and the organization of our helpers, I've opted to keep this as is. This selector spans multiple test, is component scoped and it's used by both secret engines and auth methods. */
export const MOUNT_BACKEND_FORM = {
mountType: (name: string) => `[data-test-mount-type="${name}"]`,
};

View File

@@ -94,6 +94,7 @@ export const GENERAL = {
navLink: (label: string) => `[data-test-sidebar-nav-link="${label}"]`, navLink: (label: string) => `[data-test-sidebar-nav-link="${label}"]`,
cancelButton: '[data-test-cancel]', cancelButton: '[data-test-cancel]',
saveButton: '[data-test-save]', saveButton: '[data-test-save]',
backButton: '[data-test-back-button]',
codemirror: `[data-test-component="code-mirror-modifier"]`, codemirror: `[data-test-component="code-mirror-modifier"]`,
codemirrorTextarea: `[data-test-component="code-mirror-modifier"] textarea`, codemirrorTextarea: `[data-test-component="code-mirror-modifier"] textarea`,
}; };

View File

@@ -4,7 +4,6 @@
*/ */
export const SECRET_ENGINE_SELECTORS = { export const SECRET_ENGINE_SELECTORS = {
backButton: '[data-test-back-button]',
configTab: '[data-test-configuration-tab]', configTab: '[data-test-configuration-tab]',
configure: '[data-test-secret-backend-configure]', configure: '[data-test-secret-backend-configure]',
configureTitle: (type: string) => `[data-test-backend-configure-title="${type}"]`, configureTitle: (type: string) => `[data-test-backend-configure-title="${type}"]`,
@@ -15,8 +14,6 @@ export const SECRET_ENGINE_SELECTORS = {
title: '[data-test-backend-error-title]', title: '[data-test-backend-error-title]',
}, },
generateLink: '[data-test-backend-credentials]', generateLink: '[data-test-backend-credentials]',
mountType: (name: string) => `[data-test-mount-type="${name}"]`,
mountSubmit: '[data-test-mount-submit]',
secretHeader: '[data-test-secret-header]', secretHeader: '[data-test-secret-header]',
secretLink: (name: string) => (name ? `[data-test-secret-link="${name}"]` : '[data-test-secret-link]'), secretLink: (name: string) => (name ? `[data-test-secret-link="${name}"]` : '[data-test-secret-link]'),
secretLinkMenu: (name: string) => `[data-test-secret-link="${name}"] [data-test-popup-menu-trigger]`, secretLinkMenu: (name: string) => `[data-test-secret-link="${name}"] [data-test-popup-menu-trigger]`,

View File

@@ -198,7 +198,7 @@ module('Integration | Component | auth | page ', function (hooks) {
'To finish signing in, you will need to complete an additional MFA step. Please wait... Back to login', 'To finish signing in, you will need to complete an additional MFA step. Please wait... Back to login',
'renders okta number challenge on submit' 'renders okta number challenge on submit'
); );
await click('[data-test-back-button]'); await click(GENERAL.backButton);
assert.dom(AUTH_FORM.form).exists('renders auth form on return to login'); assert.dom(AUTH_FORM.form).exists('renders auth form on return to login');
assert.dom(GENERAL.selectByAttr('auth-method')).hasValue('okta', 'preserves method type on back'); assert.dom(GENERAL.selectByAttr('auth-method')).hasValue('okta', 'preserves method type on back');
}); });

View File

@@ -6,19 +6,18 @@
import { later, _cancelTimers as cancelTimers } from '@ember/runloop'; import { later, _cancelTimers as cancelTimers } from '@ember/runloop';
import { module, test } from 'qunit'; import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit'; import { setupRenderingTest } from 'ember-qunit';
import { render, settled, click, typeIn } from '@ember/test-helpers'; import { render, settled, click, typeIn, fillIn } from '@ember/test-helpers';
import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support';
import { allowAllCapabilitiesStub, noopStub } from 'vault/tests/helpers/stubs'; import { allowAllCapabilitiesStub, noopStub } from 'vault/tests/helpers/stubs';
import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
import { methods } from 'vault/helpers/mountable-auth-methods';
import { mountableEngines } from 'vault/helpers/mountable-secret-engines';
import hbs from 'htmlbars-inline-precompile'; import hbs from 'htmlbars-inline-precompile';
import { create } from 'ember-cli-page-object';
import mountBackendForm from '../../pages/components/mount-backend-form';
import sinon from 'sinon'; import sinon from 'sinon';
const component = create(mountBackendForm);
module('Integration | Component | mount backend form', function (hooks) { module('Integration | Component | mount backend form', function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
setupMirage(hooks); setupMirage(hooks);
@@ -45,51 +44,56 @@ module('Integration | Component | mount backend form', function (hooks) {
}); });
test('it renders default state', async function (assert) { test('it renders default state', async function (assert) {
assert.expect(15);
await render( await render(
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
assert.strictEqual( assert
component.header, .dom(GENERAL.title)
'Enable an Authentication Method', .hasText('Enable an Authentication Method', 'renders auth header in default state');
'renders auth header in default state'
); for (const method of methods()) {
assert.ok(component.types.length > 0, 'renders type picker'); assert
.dom(MOUNT_BACKEND_FORM.mountType(method.type))
.hasText(method.displayName, `renders type:${method.displayName} picker`);
}
}); });
test('it changes path when type is changed', async function (assert) { test('it changes path when type is changed', async function (assert) {
await render( await render(
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.selectType('aws');
assert.strictEqual(component.pathValue, 'aws', 'sets the value of the type'); await click(MOUNT_BACKEND_FORM.mountType('aws'));
await component.back(); assert.dom(GENERAL.inputByAttr('path')).hasValue('aws', 'sets the value of the type');
await component.selectType('approle'); await click(GENERAL.backButton);
assert.strictEqual(component.pathValue, 'approle', 'updates the value of the type'); await click(MOUNT_BACKEND_FORM.mountType('approle'));
assert.dom(GENERAL.inputByAttr('path')).hasValue('approle', 'updates the value of the type');
}); });
test('it keeps path value if the user has changed it', async function (assert) { test('it keeps path value if the user has changed it', async function (assert) {
await render( await render(
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.selectType('approle'); await click(MOUNT_BACKEND_FORM.mountType('approle'));
assert.strictEqual(this.model.type, 'approle', 'Updates type on model'); assert.strictEqual(this.model.type, 'approle', 'Updates type on model');
assert.strictEqual(component.pathValue, 'approle', 'defaults to approle (first in the list)'); assert.dom(GENERAL.inputByAttr('path')).hasValue('approle', 'defaults to approle (first in the list)');
await component.path('newpath'); await fillIn(GENERAL.inputByAttr('path'), 'newpath');
assert.strictEqual(this.model.path, 'newpath', 'Updates path on model'); assert.strictEqual(this.model.path, 'newpath', 'Updates path on model');
await component.back(); await click(GENERAL.backButton);
assert.strictEqual(this.model.type, '', 'Clears type on back'); assert.strictEqual(this.model.type, '', 'Clears type on back');
assert.strictEqual(this.model.path, 'newpath', 'Path is still newPath'); assert.strictEqual(this.model.path, 'newpath', 'Path is still newPath');
await component.selectType('aws'); await click(MOUNT_BACKEND_FORM.mountType('aws'));
assert.strictEqual(this.model.type, 'aws', 'Updates type on model'); assert.strictEqual(this.model.type, 'aws', 'Updates type on model');
assert.strictEqual(component.pathValue, 'newpath', 'keeps custom path value'); assert.dom(GENERAL.inputByAttr('path')).hasValue('newpath', 'keeps custom path value');
}); });
test('it does not show a selected token type when first mounting an auth method', async function (assert) { test('it does not show a selected token type when first mounting an auth method', async function (assert) {
await render( await render(
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.selectType('github'); await click(MOUNT_BACKEND_FORM.mountType('github'));
await component.toggleOptions(); await click(GENERAL.toggleGroup('Method Options'));
assert assert
.dom('[data-test-input="config.tokenType"]') .dom('[data-test-input="config.tokenType"]')
.hasValue('', 'token type does not have a default value.'); .hasValue('', 'token type does not have a default value.');
@@ -113,7 +117,7 @@ module('Integration | Component | mount backend form', function (hooks) {
await render( await render(
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.mount('approle', 'foo'); await mountBackend('approle', 'foo');
later(() => cancelTimers(), 50); later(() => cancelTimers(), 50);
await settled(); await settled();
@@ -131,40 +135,45 @@ module('Integration | Component | mount backend form', function (hooks) {
this.model.set('config', this.store.createRecord('mount-config')); this.model.set('config', this.store.createRecord('mount-config'));
}); });
test('it renders secret specific headers', async function (assert) { test('it renders secret engine specific headers', async function (assert) {
assert.expect(17);
await render( await render(
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
assert.strictEqual(component.header, 'Enable a Secrets Engine', 'renders secrets header'); assert.dom(GENERAL.title).hasText('Enable a Secrets Engine', 'renders secrets header');
assert.ok(component.types.length > 0, 'renders type picker'); for (const method of mountableEngines()) {
assert
.dom(MOUNT_BACKEND_FORM.mountType(method.type))
.hasText(method.displayName, `renders type:${method.displayName} picker`);
}
}); });
test('it changes path when type is changed', async function (assert) { test('it changes path when type is changed', async function (assert) {
await render( await render(
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.selectType('azure'); await click(MOUNT_BACKEND_FORM.mountType('azure'));
assert.strictEqual(component.pathValue, 'azure', 'sets the value of the type'); assert.dom(GENERAL.inputByAttr('path')).hasValue('azure', 'sets the value of the type');
await component.back(); await click(GENERAL.backButton);
await component.selectType('nomad'); await click(MOUNT_BACKEND_FORM.mountType('nomad'));
assert.strictEqual(component.pathValue, 'nomad', 'updates the value of the type'); assert.dom(GENERAL.inputByAttr('path')).hasValue('nomad', 'updates the value of the type');
}); });
test('it keeps path value if the user has changed it', async function (assert) { test('it keeps path value if the user has changed it', async function (assert) {
await render( await render(
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.selectType('kv'); await click(MOUNT_BACKEND_FORM.mountType('kv'));
assert.strictEqual(this.model.type, 'kv', 'Updates type on model'); assert.strictEqual(this.model.type, 'kv', 'Updates type on model');
assert.strictEqual(component.pathValue, 'kv', 'path matches mount type'); assert.dom(GENERAL.inputByAttr('path')).hasValue('kv', 'path matches mount type');
await component.path('newpath'); await fillIn(GENERAL.inputByAttr('path'), 'newpath');
assert.strictEqual(this.model.path, 'newpath', 'Updates path on model'); assert.strictEqual(this.model.path, 'newpath', 'Updates path on model');
await component.back(); await click(GENERAL.backButton);
assert.strictEqual(this.model.type, '', 'Clears type on back'); assert.strictEqual(this.model.type, '', 'Clears type on back');
assert.strictEqual(this.model.path, 'newpath', 'path is still newpath'); assert.strictEqual(this.model.path, 'newpath', 'path is still newpath');
await component.selectType('ssh'); await click(MOUNT_BACKEND_FORM.mountType('ssh'));
assert.strictEqual(this.model.type, 'ssh', 'Updates type on model'); assert.strictEqual(this.model.type, 'ssh', 'Updates type on model');
assert.strictEqual(component.pathValue, 'newpath', 'path stays the same'); assert.dom(GENERAL.inputByAttr('path')).hasValue('newpath', 'path stays the same');
}); });
test('it calls mount success', async function (assert) { test('it calls mount success', async function (assert) {
@@ -181,7 +190,7 @@ module('Integration | Component | mount backend form', function (hooks) {
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.mount('ssh', 'foo'); await mountBackend('ssh', 'foo');
later(() => cancelTimers(), 50); later(() => cancelTimers(), 50);
await settled(); await settled();
@@ -197,15 +206,15 @@ module('Integration | Component | mount backend form', function (hooks) {
await render( await render(
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.selectType('ldap'); await click(MOUNT_BACKEND_FORM.mountType('ldap'));
await click(GENERAL.toggleGroup('Method Options')); await click(GENERAL.toggleGroup('Method Options'));
assert assert
.dom(GENERAL.fieldByAttr('identityTokenKey')) .dom(GENERAL.fieldByAttr('identityTokenKey'))
.doesNotExist(`Identity token key field hidden when type=${this.model.type}`); .doesNotExist(`Identity token key field hidden when type=${this.model.type}`);
await component.back(); await click(GENERAL.backButton);
await component.selectType('aws'); await click(MOUNT_BACKEND_FORM.mountType('aws'));
await click(GENERAL.toggleGroup('Method Options')); await click(GENERAL.toggleGroup('Method Options'));
assert assert
.dom(GENERAL.fieldByAttr('identityTokenKey')) .dom(GENERAL.fieldByAttr('identityTokenKey'))
@@ -216,7 +225,7 @@ module('Integration | Component | mount backend form', function (hooks) {
await render( await render(
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />` hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
); );
await component.selectType('aws'); await click(MOUNT_BACKEND_FORM.mountType('aws'));
assert.strictEqual( assert.strictEqual(
this.model.config.identityTokenKey, this.model.config.identityTokenKey,
undefined, undefined,

View File

@@ -11,6 +11,7 @@ import sinon from 'sinon';
import { allEngines, mountableEngines } from 'vault/helpers/mountable-secret-engines'; import { allEngines, mountableEngines } from 'vault/helpers/mountable-secret-engines';
import { allMethods, methods } from 'vault/helpers/mountable-auth-methods'; import { allMethods, methods } from 'vault/helpers/mountable-auth-methods';
import { setRunOptions } from 'ember-a11y-testing/test-support'; import { setRunOptions } from 'ember-a11y-testing/test-support';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
const secretTypes = mountableEngines().map((engine) => engine.type); const secretTypes = mountableEngines().map((engine) => engine.type);
const allSecretTypes = allEngines().map((engine) => engine.type); const allSecretTypes = allEngines().map((engine) => engine.type);
@@ -25,26 +26,28 @@ module('Integration | Component | mount-backend/type-form', function (hooks) {
}); });
test('it calls secrets setMountType when type is selected', async function (assert) { test('it calls secrets setMountType when type is selected', async function (assert) {
assert.expect(secretTypes.length + 1, 'renders all mountable engines plus calls a spy');
const spy = sinon.spy(); const spy = sinon.spy();
this.set('setType', spy); this.set('setType', spy);
await render(hbs`<MountBackend::TypeForm @mountType="secret" @setMountType={{this.setType}} />`); await render(hbs`<MountBackend::TypeForm @mountType="secret" @setMountType={{this.setType}} />`);
assert for (const type of secretTypes) {
.dom('[data-test-mount-type]') assert.dom(MOUNT_BACKEND_FORM.mountType(type)).exists(`Renders ${type} mountable secret engine`);
.exists({ count: secretTypes.length }, 'Renders all mountable engines'); }
await click(`[data-test-mount-type="ssh"]`); await click(MOUNT_BACKEND_FORM.mountType('ssh'));
assert.ok(spy.calledOnceWith('ssh')); assert.ok(spy.calledOnceWith('ssh'));
}); });
test('it calls auth setMountType when type is selected', async function (assert) { test('it calls auth setMountType when type is selected', async function (assert) {
assert.expect(authTypes.length + 1, 'renders all mountable auth methods plus calls a spy');
const spy = sinon.spy(); const spy = sinon.spy();
this.set('setType', spy); this.set('setType', spy);
await render(hbs`<MountBackend::TypeForm @setMountType={{this.setType}} />`); await render(hbs`<MountBackend::TypeForm @setMountType={{this.setType}} />`);
assert for (const type of authTypes) {
.dom('[data-test-mount-type]') assert.dom(MOUNT_BACKEND_FORM.mountType(type)).exists(`Renders ${type} mountable auth engine`);
.exists({ count: authTypes.length }, 'Renders all mountable auth methods'); }
await click(`[data-test-mount-type="okta"]`); await click(MOUNT_BACKEND_FORM.mountType('okta'));
assert.ok(spy.calledOnceWith('okta')); assert.ok(spy.calledOnceWith('okta'));
}); });
@@ -55,6 +58,7 @@ module('Integration | Component | mount-backend/type-form', function (hooks) {
}); });
test('it renders correct items for enterprise secrets', async function (assert) { test('it renders correct items for enterprise secrets', async function (assert) {
assert.expect(allSecretTypes.length, 'renders all enterprise secret engines');
setRunOptions({ setRunOptions({
rules: { rules: {
// TODO: Fix disabled enterprise options with enterprise badge // TODO: Fix disabled enterprise options with enterprise badge
@@ -62,14 +66,17 @@ module('Integration | Component | mount-backend/type-form', function (hooks) {
}, },
}); });
await render(hbs`<MountBackend::TypeForm @mountType="secret" @setMountType={{this.setType}} />`); await render(hbs`<MountBackend::TypeForm @mountType="secret" @setMountType={{this.setType}} />`);
assert for (const type of allSecretTypes) {
.dom('[data-test-mount-type]') assert.dom(MOUNT_BACKEND_FORM.mountType(type)).exists(`Renders ${type} secret engine`);
.exists({ count: allSecretTypes.length }, 'Renders all secret engines'); }
}); });
test('it renders correct items for enterprise auth methods', async function (assert) { test('it renders correct items for enterprise auth methods', async function (assert) {
assert.expect(allAuthTypes.length, 'renders all enterprise auth engines');
await render(hbs`<MountBackend::TypeForm @mountType="auth" @setMountType={{this.setType}} />`); await render(hbs`<MountBackend::TypeForm @mountType="auth" @setMountType={{this.setType}} />`);
assert.dom('[data-test-mount-type]').exists({ count: allAuthTypes.length }, 'Renders all auth methods'); for (const type of allAuthTypes) {
assert.dom(MOUNT_BACKEND_FORM.mountType(type)).exists(`Renders ${type} auth engine`);
}
}); });
}); });
}); });

View File

@@ -8,6 +8,7 @@ import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers'; import { render, click } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars'; import { hbs } from 'ember-cli-htmlbars';
import sinon from 'sinon'; import sinon from 'sinon';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | auth | okta-number-challenge', function (hooks) { module('Integration | Component | auth | okta-number-challenge', function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@@ -71,7 +72,7 @@ module('Integration | Component | auth | okta-number-challenge', function (hooks
'Correct description renders' 'Correct description renders'
); );
assert.dom('[data-test-message-error]').hasText(`Error ${this.hasError}`); assert.dom('[data-test-message-error]').hasText(`Error ${this.hasError}`);
await click('[data-test-back-button]'); await click(GENERAL.backButton);
assert.true(this.onCancel.calledOnce, 'onCancel is called'); assert.true(this.onCancel.calledOnce, 'onCancel is called');
}); });
}); });

View File

@@ -1,33 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { clickable, collection, fillable, text, value, attribute } from 'ember-cli-page-object';
import fields from './form-field';
export default {
...fields,
header: text('[data-test-mount-form-header]'),
submit: clickable('[data-test-mount-submit]'),
back: clickable('[data-test-mount-back]'),
path: fillable('[data-test-input="path"]'),
toggleOptions: clickable('[data-test-toggle-group="Method Options"]'),
pathValue: value('[data-test-input="path"]'),
types: collection('[data-test-mount-type]', {
select: clickable(),
id: attribute('id'),
}),
type: fillable('[name="mount-type"]'),
async selectType(type) {
return this.types.filterBy('id', type)[0].select();
},
async mount(type, path) {
await this.selectType(type);
if (path) {
await this.path(path).submit();
} else {
await this.submit();
}
},
};

View File

@@ -10,15 +10,6 @@ export default create({
...Base, ...Base,
visitEdit: visitable('/vault/secrets/:backend/edit/:id'), visitEdit: visitable('/vault/secrets/:backend/edit/:id'),
visitEditRoot: visitable('/vault/secrets/:backend/edit'), visitEditRoot: visitable('/vault/secrets/:backend/edit'),
keyType: fillable('[data-test-input="keyType"]'),
defaultUser: fillable('[data-test-input="defaultUser"]'),
toggleMore: clickable('[data-test-toggle-group="Options"]'),
name: fillable('[data-test-input="name"]'), name: fillable('[data-test-input="name"]'),
CIDR: fillable('[data-test-input="cidrList"]'),
save: clickable('[data-test-role-ssh-create]'), save: clickable('[data-test-role-ssh-create]'),
async createOTPRole(name) {
await this.name(name);
await this.toggleMore().keyType('otp').defaultUser('admin').CIDR('0.0.0.0/0').save();
},
}); });

View File

@@ -4,7 +4,7 @@
*/ */
import { Base } from '../credentials'; import { Base } from '../credentials';
import { clickable, value, create, fillable, isPresent } from 'ember-cli-page-object'; import { value, create, fillable, isPresent } from 'ember-cli-page-object';
export default create({ export default create({
...Base, ...Base,
@@ -14,9 +14,5 @@ export default create({
ip: fillable('[data-test-input="ip"]'), ip: fillable('[data-test-input="ip"]'),
warningIsPresent: isPresent('[data-test-warning]'), warningIsPresent: isPresent('[data-test-warning]'),
commonNameValue: value('[data-test-input="commonName"]'), commonNameValue: value('[data-test-input="commonName"]'),
submit: clickable('[data-test-save]'), generateOTP: async function () {},
back: clickable('[data-test-back-button]'),
generateOTP: async function () {
await this.user('admin').ip('192.168.1.1').submit();
},
}); });

View File

@@ -4,15 +4,14 @@
*/ */
import { create, visitable } from 'ember-cli-page-object'; import { create, visitable } from 'ember-cli-page-object';
import backendForm from '../../components/mount-backend-form';
import flashMessages from '../../components/flash-message'; import flashMessages from '../../components/flash-message';
import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
export default create({ export default create({
visit: visitable('/vault/settings/auth/enable'), visit: visitable('/vault/settings/auth/enable'),
...backendForm,
flash: flashMessages, flash: flashMessages,
enable: async function (type, path) { enable: async function (type, path) {
await this.visit(); await this.visit();
await this.mount(type, path); await mountBackend(type, path);
}, },
}); });

View File

@@ -5,11 +5,10 @@
import { create, visitable, fillable, clickable } from 'ember-cli-page-object'; import { create, visitable, fillable, clickable } from 'ember-cli-page-object';
import { settled } from '@ember/test-helpers'; import { settled } from '@ember/test-helpers';
import mountForm from 'vault/tests/pages/components/mount-backend-form'; import { mountBackend } from 'vault/tests/helpers/components/mount-backend-form-helpers';
export default create({ export default create({
visit: visitable('/vault/settings/mount-secret-backend'), visit: visitable('/vault/settings/mount-secret-backend'),
...mountForm,
version: fillable('[data-test-input="version"]'), version: fillable('[data-test-input="version"]'),
setMaxVersion: fillable('[data-test-input="maxVersions"]'), setMaxVersion: fillable('[data-test-input="maxVersions"]'),
enableMaxTtl: clickable('[data-test-toggle-input="Max Lease TTL"]'), enableMaxTtl: clickable('[data-test-toggle-input="Max Lease TTL"]'),
@@ -23,7 +22,7 @@ export default create({
enable: async function (type, path) { enable: async function (type, path) {
await this.visit(); await this.visit();
await settled(); await settled();
await this.mount(type, path); await mountBackend(type, path);
await settled(); await settled();
}, },
}); });