Skip to content

Commit cc466ee

Browse files
committed
handling for missing envs
Signed-off-by: rostalan <rlan@redhat.com>
1 parent 928aed5 commit cc466ee

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

workspaces/orchestrator/e2e-tests/tests/specs/orchestrator.tests.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ interface WorkflowInstance {
2929
serviceUrl?: string;
3030
}
3131

32-
function decodeEnvVar(name: string): string {
32+
function requireEnvVar(name: string): string {
3333
const value = process.env[name];
34-
if (!value) {
34+
if (!value?.trim()) {
3535
throw new Error(`Environment variable ${name} is not set`);
3636
}
37-
return Buffer.from(value, "base64").toString();
37+
return value;
3838
}
3939

4040
function isDataIndexHealthy(ns: string): boolean {
@@ -331,17 +331,12 @@ test.describe("Orchestrator", () => {
331331

332332
const backstageToken = await new AuthApiHelper(page).getToken();
333333

334-
const kcBaseUrl = decodeEnvVar("KEYCLOAK_AUTH_BASE_URL");
335-
const kcRealm = decodeEnvVar("KEYCLOAK_AUTH_REALM");
336-
const kcClientId = decodeEnvVar("KEYCLOAK_AUTH_CLIENTID");
337-
const kcClientSecret = decodeEnvVar("KEYCLOAK_AUTH_CLIENT_SECRET");
338-
339-
const username = process.env.GH_USER_ID;
340-
const password = process.env.GH_USER_PASS;
341-
// eslint-disable-next-line playwright/no-conditional-in-test
342-
if (!username || !password) {
343-
throw new Error("GH_USER_ID and GH_USER_PASS must be set");
344-
}
334+
const kcBaseUrl = requireEnvVar("KEYCLOAK_BASE_URL");
335+
const kcRealm = requireEnvVar("KEYCLOAK_REALM");
336+
const kcClientId = requireEnvVar("KEYCLOAK_CLIENT_ID");
337+
const kcClientSecret = requireEnvVar("KEYCLOAK_CLIENT_SECRET");
338+
const username = process.env.GH_USER_ID || "test1";
339+
const password = process.env.GH_USER_PASS || "test1@123";
345340

346341
const tokenUrl = `${kcBaseUrl}/auth/realms/${kcRealm}/protocol/openid-connect/token`;
347342

0 commit comments

Comments
 (0)