diff --git a/ui/tests/acceptance/auth-list-test.js b/ui/tests/acceptance/auth-list-test.js index ea311a3c04..491800463b 100644 --- a/ui/tests/acceptance/auth-list-test.js +++ b/ui/tests/acceptance/auth-list-test.js @@ -13,7 +13,7 @@ import authPage from 'vault/tests/pages/auth'; import enablePage from 'vault/tests/pages/settings/auth/enable'; import { allSupportedAuthBackends, supportedAuthBackends } from 'vault/helpers/supported-auth-backends'; import { supportedManagedAuthBackends } from 'vault/helpers/supported-managed-auth-backends'; -import { deleteAuthCmd, mountAuthCmd, runCmd } from 'vault/tests/helpers/commands'; +import { deleteAuthCmd, mountAuthCmd, runCmd, createNS } from 'vault/tests/helpers/commands'; const SELECTORS = { backendLink: (path) => `[data-test-auth-backend-link="${path}"]`, @@ -152,7 +152,8 @@ module('Acceptance | auth backend list', function (hooks) { test('enterprise: token config within namespace', async function (assert) { const ns = 'ns-wxyz'; - await runCmd(`write sys/namespaces/${ns} -f`); + await runCmd(createNS(ns), false); + await settled(); await authPage.loginNs(ns); // go directly to token configure route await visit('/vault/settings/auth/configure/token/options'); diff --git a/ui/tests/acceptance/cluster-test.js b/ui/tests/acceptance/cluster-test.js index 0beec908d3..036397c622 100644 --- a/ui/tests/acceptance/cluster-test.js +++ b/ui/tests/acceptance/cluster-test.js @@ -3,7 +3,6 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import { create } from 'ember-cli-page-object'; import { settled, click, visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; @@ -12,17 +11,13 @@ import { v4 as uuidv4 } from 'uuid'; import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; import enablePage from 'vault/tests/pages/settings/auth/enable'; -import consoleClass from 'vault/tests/pages/components/console/ui-panel'; - -const consoleComponent = create(consoleClass); +import { runCmd } from 'vault/tests/helpers/commands'; const tokenWithPolicy = async function (name, policy) { - await consoleComponent.runCommands([ + return await runCmd([ `write sys/policies/acl/${name} policy=${btoa(policy)}`, `write -field=client_token auth/token/create policies=${name}`, ]); - - return consoleComponent.lastLogOutput; }; module('Acceptance | cluster', function (hooks) { @@ -53,7 +48,7 @@ module('Acceptance | cluster', function (hooks) { const path = `cluster-userpass-${uuidv4()}`; await enablePage.enable('userpass', path); - await consoleComponent.runCommands([`write auth/${path}/users/end-user password="${password}"`]); + await runCmd([`write auth/${path}/users/end-user password="${password}"`]); await logout.visit(); await settled(); @@ -89,11 +84,11 @@ module('Acceptance | cluster', function (hooks) { capabilities = ["read"] }, `; - await consoleComponent.runCommands([ + const noDefaultPolicyUser = await runCmd([ `write sys/policies/acl/login-only policy=${btoa(login_only)}`, `write -field=client_token auth/token/create no_default_policy=true policies="login-only"`, ]); - const noDefaultPolicyUser = consoleComponent.lastLogOutput; + assert.dom('[data-test-resultant-acl-banner]').doesNotExist('Resultant ACL banner does not show as root'); await logout.visit(); assert.dom('[data-test-resultant-acl-banner]').doesNotExist('Does not show on login page'); diff --git a/ui/tests/acceptance/enterprise-control-groups-test.js b/ui/tests/acceptance/enterprise-control-groups-test.js index c80e53894f..04e7575d4f 100644 --- a/ui/tests/acceptance/enterprise-control-groups-test.js +++ b/ui/tests/acceptance/enterprise-control-groups-test.js @@ -16,6 +16,7 @@ import controlGroupSuccess from 'vault/tests/pages/components/control-group-succ import { writeSecret } from 'vault/tests/helpers/kv/kv-run-commands'; import authPage from 'vault/tests/pages/auth'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { runCmd } from 'vault/tests/helpers/commands'; const consoleComponent = create(consoleClass); const authFormComponent = create(authForm); @@ -83,7 +84,7 @@ module('Acceptance | Enterprise | control groups', function (hooks) { await visit('/vault/secrets'); await consoleComponent.toggle(); await settled(); - await consoleComponent.runCommands([ + await runCmd([ //enable kv-v1 mount and write a secret 'write sys/mounts/kv type=kv', 'write kv/foo bar=baz', @@ -101,13 +102,13 @@ module('Acceptance | Enterprise | control groups', function (hooks) { await settled(); const userpassAccessor = consoleComponent.lastTextOutput; - await consoleComponent.runCommands([ + await runCmd([ // lookup entity id for our authorizer `write -field=id identity/lookup/entity name=${ADMIN_USER}`, ]); await settled(); const authorizerEntityId = consoleComponent.lastTextOutput; - await consoleComponent.runCommands([ + await runCmd([ // create alias for authorizor and add them to the managers group `write identity/alias mount_accessor=${userpassAccessor} entity_id=${authorizerEntityId} name=${ADMIN_USER}`, `write identity/group name=managers member_entity_ids=${authorizerEntityId} policies=authorizer`, @@ -123,10 +124,7 @@ module('Acceptance | Enterprise | control groups', function (hooks) { }; test('for v2 secrets it redirects you if you try to navigate to a Control Group restricted path', async function (assert) { - await consoleComponent.runCommands([ - 'write sys/mounts/kv-v2-mount type=kv-v2', - 'delete kv-v2-mount/metadata/foo', - ]); + await runCmd(['write sys/mounts/kv-v2-mount type=kv-v2', 'delete kv-v2-mount/metadata/foo']); await writeSecret('kv-v2-mount', 'foo', 'bar', 'baz'); await settled(); await setupControlGroup(this); @@ -222,7 +220,7 @@ module('Acceptance | Enterprise | control groups', function (hooks) { await settled(); await consoleComponent.toggle(); await settled(); - await consoleComponent.runCommands('read kv/foo'); + await runCmd('read kv/foo'); await settled(); const output = consoleComponent.lastLogOutput; assert.ok(output.includes('A Control Group was encountered at kv/foo')); diff --git a/ui/tests/acceptance/enterprise-kmip-test.js b/ui/tests/acceptance/enterprise-kmip-test.js index ac8ea2033e..383d95971c 100644 --- a/ui/tests/acceptance/enterprise-kmip-test.js +++ b/ui/tests/acceptance/enterprise-kmip-test.js @@ -6,9 +6,7 @@ import { currentURL, currentRouteName, settled, fillIn, waitUntil, find } from '@ember/test-helpers'; import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; -import { create } from 'ember-cli-page-object'; -import consoleClass from 'vault/tests/pages/components/console/ui-panel'; import authPage from 'vault/tests/pages/auth'; import scopesPage from 'vault/tests/pages/secrets/backend/kmip/scopes'; import rolesPage from 'vault/tests/pages/secrets/backend/kmip/roles'; @@ -16,8 +14,7 @@ import credentialsPage from 'vault/tests/pages/secrets/backend/kmip/credentials' import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend'; import { allEngines } from 'vault/helpers/mountable-secret-engines'; import { setRunOptions } from 'ember-a11y-testing/test-support'; - -const uiConsole = create(consoleClass); +import { runCmd } from 'vault/tests/helpers/commands'; const getRandomPort = () => { let a = Math.floor(100000 + Math.random() * 900000); @@ -33,9 +30,8 @@ const mount = async (shouldConfig = true) => { const commands = shouldConfig ? [`write sys/mounts/${path} type=kmip`, `write ${path}/config listen_addrs=${addr}`] : [`write sys/mounts/${path} type=kmip`]; - await uiConsole.runCommands(commands); + const res = await runCmd(commands); await settled(); - const res = uiConsole.lastLogOutput; if (res.includes('Error')) { throw new Error(`Error mounting secrets engine: ${res}`); } @@ -47,9 +43,8 @@ const createScope = async () => { await settled(); const scope = `scope-${Date.now()}`; await settled(); - await uiConsole.runCommands([`write ${path}/scope/${scope} -force`]); + const res = await runCmd([`write ${path}/scope/${scope} -force`]); await settled(); - const res = uiConsole.lastLogOutput; if (res.includes('Error')) { throw new Error(`Error creating scope: ${res}`); } @@ -60,9 +55,8 @@ const createRole = async () => { const { path, scope } = await createScope(); await settled(); const role = `role-${Date.now()}`; - await uiConsole.runCommands([`write ${path}/scope/${scope}/role/${role} operation_all=true`]); + const res = await runCmd([`write ${path}/scope/${scope}/role/${role} operation_all=true`]); await settled(); - const res = uiConsole.lastLogOutput; if (res.includes('Error')) { throw new Error(`Error creating role: ${res}`); } @@ -72,10 +66,10 @@ const createRole = async () => { const generateCreds = async () => { const { path, scope, role } = await createRole(); await settled(); - await uiConsole.runCommands([ + const serial = await runCmd([ `write ${path}/scope/${scope}/role/${role}/credential/generate format=pem -field=serial_number`, ]); - const serial = uiConsole.lastLogOutput; + await settled(); if (serial.includes('Error')) { throw new Error(`Credential generation failed with error: ${serial}`); } @@ -94,7 +88,7 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) { const engine = allEngines().find((e) => e.type === 'kmip'); assert.expect(1); - await uiConsole.runCommands([ + await runCmd([ // delete any previous mount with same name `delete sys/mounts/${engine.type}`, ]); @@ -106,7 +100,7 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) { `vault.cluster.secrets.backend.${engine.engineRoute}`, `Transitions to ${engine.displayName} route on mount success` ); - await uiConsole.runCommands([ + await runCmd([ // cleanup after `delete sys/mounts/${engine.type}`, ]); @@ -221,9 +215,8 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) { await settled(); const scope = `scope-for-can-create-role`; await settled(); - await uiConsole.runCommands([`write ${path}/scope/${scope} -force`]); + const res = await runCmd([`write ${path}/scope/${scope} -force`]); await settled(); - const res = uiConsole.lastLogOutput; if (res.includes('Error')) { throw new Error(`Error creating scope: ${res}`); } diff --git a/ui/tests/acceptance/enterprise-namespaces-test.js b/ui/tests/acceptance/enterprise-namespaces-test.js index a9543a55cc..386bb6ef5f 100644 --- a/ui/tests/acceptance/enterprise-namespaces-test.js +++ b/ui/tests/acceptance/enterprise-namespaces-test.js @@ -6,15 +6,10 @@ import { click, settled, visit, fillIn, currentURL } from '@ember/test-helpers'; import { module, test, skip } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; -import { create } from 'ember-cli-page-object'; -import consoleClass from 'vault/tests/pages/components/console/ui-panel'; +import { runCmd, createNS } from 'vault/tests/helpers/commands'; import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; -const shell = create(consoleClass); - -const createNS = (name) => shell.runCommands(`write sys/namespaces/${name} -force`); - module('Acceptance | Enterprise | namespaces', function (hooks) { setupApplicationTest(hooks); @@ -24,9 +19,8 @@ module('Acceptance | Enterprise | namespaces', function (hooks) { test('it clears namespaces when you log out', async function (assert) { const ns = 'foo'; - await createNS(ns); - await shell.runCommands(`write -field=client_token auth/token/create policies=default`); - const token = shell.lastLogOutput; + await runCmd(createNS(ns), false); + const token = await runCmd(`write -field=client_token auth/token/create policies=default`); await logout.visit(); await authPage.login(token); await click('[data-test-namespace-toggle]'); @@ -45,7 +39,7 @@ module('Acceptance | Enterprise | namespaces', function (hooks) { const nses = ['beep', 'boop', 'bop']; for (const [i, ns] of nses.entries()) { - await createNS(ns); + await runCmd(createNS(ns), false); await settled(); // the namespace path will include all of the namespaces up to this point const targetNamespace = nses.slice(0, i + 1).join('/'); diff --git a/ui/tests/acceptance/enterprise-oidc-namespace-test.js b/ui/tests/acceptance/enterprise-oidc-namespace-test.js index 1ce25f562e..7caf49afef 100644 --- a/ui/tests/acceptance/enterprise-oidc-namespace-test.js +++ b/ui/tests/acceptance/enterprise-oidc-namespace-test.js @@ -6,17 +6,11 @@ import { currentURL, click } from '@ember/test-helpers'; import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; -import { create } from 'ember-cli-page-object'; +import { runCmd, createNS } from 'vault/tests/helpers/commands'; import { setupMirage } from 'ember-cli-mirage/test-support'; import parseURL from 'core/utils/parse-url'; -import consoleClass from 'vault/tests/pages/components/console/ui-panel'; import authPage from 'vault/tests/pages/auth'; -const shell = create(consoleClass); - -const createNS = async (name) => { - await shell.runCommands(`write sys/namespaces/${name} -force`); -}; const SELECTORS = { authTab: (path) => `[data-test-auth-method="${path}"] a`, }; @@ -33,7 +27,7 @@ module('Acceptance | Enterprise | oidc auth namespace test', function (hooks) { this.server.post(`/auth/:path/config`, () => {}); this.enableOidc = (path, role = '') => { - return shell.runCommands([ + return runCmd([ `write sys/auth/${path} type=oidc`, `write auth/${path}/config default_role="${role}" oidc_discovery_url="https://example.com"`, // show method as tab @@ -41,7 +35,7 @@ module('Acceptance | Enterprise | oidc auth namespace test', function (hooks) { ]); }; - this.disableOidc = (path) => shell.runCommands([`delete /sys/auth/${path}`]); + this.disableOidc = (path) => runCmd([`delete /sys/auth/${path}`]); }); test('oidc: request is made to auth_url when a namespace is inputted', async function (assert) { @@ -61,7 +55,7 @@ module('Acceptance | Enterprise | oidc auth namespace test', function (hooks) { // enable oidc in root namespace, without default role await this.enableOidc(this.rootOidc); // create child namespace to enable oidc - await createNS(this.namespace); + await runCmd(createNS(this.namespace), false); // enable oidc in child namespace with default role await authPage.loginNs(this.namespace); await this.enableOidc(this.nsOidc, `${this.nsOidc}-role`); @@ -83,6 +77,6 @@ module('Acceptance | Enterprise | oidc auth namespace test', function (hooks) { await authPage.login(); await this.disableOidc(this.rootOidc); await this.disableOidc(this.nsOidc); - await shell.runCommands([`delete /sys/auth/${this.namespace}`]); + await runCmd([`delete /sys/auth/${this.namespace}`]); }); }); diff --git a/ui/tests/integration/components/auth-form-test.js b/ui/tests/integration/components/auth-form-test.js index ed329bc042..1f589229c6 100644 --- a/ui/tests/integration/components/auth-form-test.js +++ b/ui/tests/integration/components/auth-form-test.js @@ -43,6 +43,7 @@ module('Integration | Component | auth form', function (hooks) { hooks.beforeEach(function () { this.owner.register('service:router', routerService); this.router = this.owner.lookup('service:router'); + this.onSuccess = sinon.spy(); }); const CSP_ERR_TEXT = `Error This is a standby Vault node but can't communicate with the active node via request forwarding. Sign in at the active node to use the Vault UI.`; @@ -232,7 +233,9 @@ module('Integration | Component | auth form', function (hooks) { const wrappedToken = '54321'; this.set('wrappedToken', wrappedToken); this.set('cluster', EmberObject.create({})); - await render(hbs``); + await render( + hbs`` + ); later(() => cancelTimers(), 50); await settled(); assert.strictEqual(