fix(e2e): Update vault addresses to work in AWS (#3206)
This commit is contained in:
1 parent
e345946c7d
commit
28b185bec8
2 files changed
+30
-2
No files matched your search
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { test } from '../../global-setup.js';
|
||||
import { isAwsController } from '../../helpers/general.js';
|
||||
import { expect } from '@playwright/test';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
@@ -26,6 +27,7 @@ test.beforeEach(async () => {
|
||||
execSync(`vault auth disable userpass`);
|
||||
});
|
||||
|
||||
/* eslint-disable playwright/no-conditional-in-test */
|
||||
test(
|
||||
'Set up OIDC auth method',
|
||||
{ tag: ['@ce', '@ent', '@aws', '@docker'] },
|
||||
@@ -36,18 +38,29 @@ test(
|
||||
adminAuthMethodId,
|
||||
adminLoginName,
|
||||
adminPassword,
|
||||
vaultAddr,
|
||||
vaultAddrUnified,
|
||||
}) => {
|
||||
await page.goto('/');
|
||||
let orgName;
|
||||
let policyName;
|
||||
try {
|
||||
await page.goto('/');
|
||||
|
||||
const userName = 'end-user';
|
||||
const password = 'password123';
|
||||
const email = 'vault@hashicorp.com';
|
||||
|
||||
const isAws = await isAwsController(controllerAddr);
|
||||
let vaultAddress;
|
||||
if (isAws) {
|
||||
vaultAddress = vaultAddr;
|
||||
} else {
|
||||
vaultAddress = vaultAddrUnified;
|
||||
}
|
||||
|
||||
const { issuer, clientId, clientSecret, authPolicyName } =
|
||||
await vaultCli.setupVaultOidc(
|
||||
vaultAddrUnified,
|
||||
vaultAddress,
|
||||
userName,
|
||||
password,
|
||||
email,
|
||||
|
||||
@@ -19,3 +19,18 @@ export async function checkEnv(envs) {
|
||||
throw new Error('Missing Environment Variables -- ' + missing);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a controller address is an AWS controller by examining the hostname for 'amazonaws.com'
|
||||
* @param {*} controllerAddr
|
||||
* @returns
|
||||
*/
|
||||
export async function isAwsController(controllerAddr) {
|
||||
try {
|
||||
const { hostname } = new URL(controllerAddr);
|
||||
return hostname === 'amazonaws.com' || hostname.endsWith('.amazonaws.com');
|
||||
} catch {
|
||||
// If the URL is invalid, treat it as non-AWS.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user