From fe25fb75377b2e3e007f2556a5c39354ee37465f Mon Sep 17 00:00:00 2001 From: Chelsea Shaw Date: Thu, 16 May 2024 13:14:00 -0500 Subject: [PATCH 1/2] Fix enterprise tests failing after Web REPL a11y updates --- .../enterprise-control-groups-test.js | 30 +++++-------------- .../acceptance/enterprise-namespaces-test.js | 1 + 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/ui/tests/acceptance/enterprise-control-groups-test.js b/ui/tests/acceptance/enterprise-control-groups-test.js index 04e7575d4fc7..154df7332f54 100644 --- a/ui/tests/acceptance/enterprise-control-groups-test.js +++ b/ui/tests/acceptance/enterprise-control-groups-test.js @@ -9,7 +9,6 @@ import { setupApplicationTest } from 'ember-qunit'; import { create } from 'ember-cli-page-object'; import { storageKey } from 'vault/services/control-group'; -import consoleClass from 'vault/tests/pages/components/console/ui-panel'; import authForm from 'vault/tests/pages/components/auth-form'; import controlGroup from 'vault/tests/pages/components/control-group'; import controlGroupSuccess from 'vault/tests/pages/components/control-group-success'; @@ -18,7 +17,6 @@ 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); const controlGroupComponent = create(controlGroup); const controlGroupSuccessComponent = create(controlGroupSuccess); @@ -82,9 +80,7 @@ module('Acceptance | Enterprise | control groups', function (hooks) { const ADMIN_PASSWORD = 'test'; const setupControlGroup = async (context) => { await visit('/vault/secrets'); - await consoleComponent.toggle(); - await settled(); - await runCmd([ + const userpassAccessor = await runCmd([ //enable kv-v1 mount and write a secret 'write sys/mounts/kv type=kv', 'write kv/foo bar=baz', @@ -99,28 +95,23 @@ module('Acceptance | Enterprise | control groups', function (hooks) { // read out mount to get the accessor 'read -field=accessor sys/internal/ui/mounts/auth/userpass', ]); - await settled(); - const userpassAccessor = consoleComponent.lastTextOutput; - await runCmd([ + const authorizerEntityId = await runCmd([ // lookup entity id for our authorizer `write -field=id identity/lookup/entity name=${ADMIN_USER}`, ]); - await settled(); - const authorizerEntityId = consoleComponent.lastTextOutput; - await runCmd([ + + const userToken = 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`, // create a token to request access to kv/foo 'write -field=client_token auth/token/create policies=kv-control-group', ]); + context.userToken = userToken; + await authPage.login(userToken); await settled(); - context.userToken = consoleComponent.lastLogOutput; - - await authPage.login(context.userToken); - await settled(); - return this; + return context; }; test('for v2 secrets it redirects you if you try to navigate to a Control Group restricted path', async function (assert) { @@ -217,12 +208,7 @@ module('Acceptance | Enterprise | control groups', function (hooks) { test('it displays the warning in the console when making a request to a Control Group path', async function (assert) { await setupControlGroup(this); - await settled(); - await consoleComponent.toggle(); - await settled(); - await runCmd('read kv/foo'); - await settled(); - const output = consoleComponent.lastLogOutput; + const output = await runCmd('read kv/foo'); assert.ok(output.includes('A Control Group was encountered at kv/foo')); assert.ok(output.includes('The Control Group Token is')); assert.ok(output.includes('The Accessor is')); diff --git a/ui/tests/acceptance/enterprise-namespaces-test.js b/ui/tests/acceptance/enterprise-namespaces-test.js index 1e5fde84a691..69fb7968a2e2 100644 --- a/ui/tests/acceptance/enterprise-namespaces-test.js +++ b/ui/tests/acceptance/enterprise-namespaces-test.js @@ -41,6 +41,7 @@ module('Acceptance | Enterprise | namespaces', function (hooks) { const targetNamespace = nses.slice(0, i + 1).join('/'); const url = `/vault/secrets?namespace=${targetNamespace}`; // this is usually triggered when creating a ns in the form -- trigger a reload of the namespaces manually + await click('[data-test-namespace-toggle]'); await click('[data-test-refresh-namespaces]'); await waitFor(`[data-test-namespace-link="${targetNamespace}"]`); // check that the single namespace "beep" or "boop" not "beep/boop" shows in the toggle display From 82aa7068580e8bc564ded08a2c1badbd2a9e73d8 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw Date: Thu, 16 May 2024 14:14:41 -0500 Subject: [PATCH 2/2] use default port and rely on teardown to stabilize kmip tests --- ui/tests/acceptance/enterprise-kmip-test.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ui/tests/acceptance/enterprise-kmip-test.js b/ui/tests/acceptance/enterprise-kmip-test.js index 2c0b0a5a9869..965d7f703feb 100644 --- a/ui/tests/acceptance/enterprise-kmip-test.js +++ b/ui/tests/acceptance/enterprise-kmip-test.js @@ -17,12 +17,6 @@ import { allEngines } from 'vault/helpers/mountable-secret-engines'; import { runCmd } from 'vault/tests/helpers/commands'; import { v4 as uuidv4 } from 'uuid'; -const getRandomPort = () => { - let a = Math.floor(100000 + Math.random() * 900000); - a = String(a); - return a.substring(0, 4); -}; - const mount = async (backend) => { const res = await runCmd(`write sys/mounts/${backend} type=kmip`); await settled(); @@ -33,7 +27,7 @@ const mount = async (backend) => { }; const mountWithConfig = async (backend) => { - const addr = `127.0.0.1:${getRandomPort()}`; // use random port + const addr = `127.0.0.1:5696`; await mount(backend); const res = await runCmd(`write ${backend}/config listen_addrs=${addr}`); if (res.includes('Error')) { @@ -128,7 +122,7 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) { `/vault/secrets/${backend}/kmip/configure`, 'configuration navigates to the configure page' ); - const addr = `127.0.0.1:${getRandomPort()}`; + const addr = `127.0.0.1:5696`; await fillIn('[data-test-string-list-input="0"]', addr); await scopesPage.submit(); await settled();