Skip to content

Commit 6a587b2

Browse files
authored
Merge pull request #20118 from mozilla/nshirley/func-test-improvement-1
chore(fxa): Remove requirement for CI when setting bypass token
2 parents 224c983 + 80ebc33 commit 6a587b2

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/functional-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ yarn test --project=stage --grep="errors on xss redirect_to parameter"
3636

3737
### Running against Stage or Production
3838

39-
In order to run local tests against stage or production, you'll need to set a few environment variables first. Some tests make use of the auth-client for direct calls to auth-server, so we use a bypass header for the WAF to allow the traffic. You'll need to set both `CI=1` and `CI_WAF_TOKEN="my_token"` environment variables. You can get a copy of the bypass token from 1Password.
39+
In order to run local tests against stage or production, you'll need to set a `CI_WAF_TOKEN` environment variable. We use a bypass header for the WAF to allow the traffic through and not be stopped by CAPTCHA or similar. Check 1Password for the token and make sure it's available in your environment `export CI_WAF_TOKEN=<mytoken>`.
4040

4141
### Specifying a target in tests
4242

packages/functional-tests/lib/targets/base.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ export abstract class BaseTarget {
3838
}
3939

4040
/**
41-
* Will return a `Headers` object with the WAF bypass header if we're in
42-
* CI and the token is set, otherwise undefined.
41+
* Will return a `Headers` object with the WAF bypass header if the
42+
* `CI_WAF_TOKEN` environment variable is set, otherwise it returns `undefined`.
4343
*
4444
* This can be passed to the auth-client calls that support optional headers.
4545
*/
4646
get ciHeader(): Headers | undefined {
47-
const ci = !!process.env.CI;
4847
const ciWafToken = process.env.CI_WAF_TOKEN;
49-
return ci && ciWafToken ? new Headers({ 'fxa-ci': ciWafToken }) : undefined;
48+
return ciWafToken ? new Headers({ 'fxa-ci': ciWafToken }) : undefined;
5049
}
5150

5251
constructor(

packages/functional-tests/playwright.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ const CI = !!process.env.CI;
1313
const CI_WAF_TOKEN = process.env.CI_WAF_TOKEN;
1414

1515
/**
16-
* Returns a header used for WAF bypass in CI environments.
17-
* Requires CI_WAF_TOKEN set in CircleCI and corresponding WAF condition set for target rule
16+
* Returns a header used for WAF bypass.
17+
*
18+
* Requires `CI_WAF_TOKEN` set in CircleCI, or local environment, and corresponding WAF condition set for target rule
1819
*/
1920
function getCIHeader(): Record<string, string> {
20-
return CI && CI_WAF_TOKEN ? { 'fxa-ci': CI_WAF_TOKEN } : {};
21+
return CI_WAF_TOKEN ? { 'fxa-ci': CI_WAF_TOKEN } : {};
2122
}
2223

2324
// If using the CircleCI parallelism feature, assure that the JUNIT XML report

0 commit comments

Comments
 (0)