Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enterprise tests failing after Web REPL a11y updates #27092

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions ui/tests/acceptance/enterprise-control-groups-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -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',
Expand All @@ -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) {
Expand Down Expand Up @@ -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'));
Expand Down
10 changes: 2 additions & 8 deletions ui/tests/acceptance/enterprise-kmip-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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')) {
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/enterprise-namespaces-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading