Skip to content

Commit

Permalink
ATO-1063: Adds fetching env var for test context
Browse files Browse the repository at this point in the history
We're now setting up the basic auth details in the ssm and
pulling them in as environment variables. This adds the values to
the test context and also throws if the values are not defined. This
should hopefully avoid a long feedback loop if these are not set correctly
  • Loading branch information
Ryan-Andrews99 committed Sep 24, 2024
1 parent 96ebf13 commit 484792b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ui-automation-tests/support/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ export class TestContext extends World {
private _otp_code: string = sms_otp_code;
private _email_code: string = email_otp_code;
private _servicename: string = servicename;
public basicAuthUsername: string;
public basicAuthPassword: string;

constructor(options: IWorldOptions) {
super(options);
this.basicAuthUsername = getEnvOrThrow("BASIC_AUTH_USERNAME");
this.basicAuthPassword = getEnvOrThrow("BASIC_AUTH_PASSWORD");
}

async goToPath(path: string) {
Expand Down Expand Up @@ -180,3 +184,10 @@ AfterAll(async function () {
});

setWorldConstructor(TestContext);

const getEnvOrThrow = (key: string): string => {
if (!process.env[key]) {
throw new Error(`Test environment variable is not defined: "${key}"`);
}
return process.env[key];
};

0 comments on commit 484792b

Please sign in to comment.