Repository navigation
feat: send a custom header from env, for sites that need Authorization free - #28
Closed
Daniel Flores (dnlflores) wants to merge 2 commits into
Closed
Daniel Flores (dnlflores) wants to merge 2 commits into
Daniel Flores (dnlflores) wants to merge 2 commits into
Conversation
…n free Mirrors optionalHttpCredentialsFromEnv's AUTH_USERNAME/AUTH_PASSWORD pattern, but for a single custom header instead of HTTP Basic auth. HTTP Basic auth occupies the Authorization header, which isn't an option when the site under test needs that header for its own auth (e.g. QA Wolf's own test gym, TITAN-5366: its apps need Authorization free, so it gates everything behind a custom X-Gym-Auth header instead of Basic auth). EXTRA_HTTP_HEADER_NAME and EXTRA_HTTP_HEADER_VALUE, both required (same all-or-nothing rule as AUTH_USERNAME/PASSWORD, for the same reason: an empty header value sent preemptively can break navigation on sites that don't expect it). Applied via extraHTTPHeaders, which launch() already forwards verbatim to Playwright's native context option — no new request-interception machinery. Merges with, rather than replaces, a flow's own extraHTTPHeaders (InitializeBrowserOptions already declares that field). The flow's own header of the same name wins over the env one, consistent with explicit caller intent beating ambient config. Generic naming is deliberate: this package is public, used outside QA Wolf, so nothing gym-specific belongs in its source. The caller decides what header name and value to send. Tests: 4 new cases (neither env var set, both set, merges with a flow's own headers, flow's own header of the same name wins). All 48 tests in the repo pass; tsc clean.
Daniel Flores (dnlflores)
marked this pull request as ready for review
October 20, 2026 21:05
Release.yml publishes to npm when package.json's version is higher than what's on the registry, so this bump is what cuts the release once this PR merges to main.
Contributor
Author
|
Closing in favor of a more central fix in qawolf/platform instead. Turns out See qawolf/platform#36197 for the actual fix. No action needed on this package; reverting the version bump isn't necessary since nothing here changed functionally, but flagging in case anyone's watching releases. |
Daniel Flores (dnlflores)
deleted the
dnlflores/extra-http-header-from-env
branch
October 21, 2026 15:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview of Problem
EntryPointPageObject.initializeBrowseralready readsAUTH_USERNAME/AUTH_PASSWORDfrom the environment for HTTP Basic auth. That's not usable when the site under test needs theAuthorizationheader free for its own auth — which is exactly QA Wolf's internal test gym's situation (TITAN-5366): it moved from HTTP Basic auth to a customX-Gym-Authheader specifically so its own apps can useAuthorization.Overview of Changes
optionalExtraHttpHeaderFromEnv()mirrorsoptionalHttpCredentialsFromEnv()'s pattern: readsEXTRA_HTTP_HEADER_NAME/EXTRA_HTTP_HEADER_VALUE, both required (same all-or-nothing rule, for the same reason — an empty header sent preemptively can break navigation on sites that don't expect it)extraHTTPHeaders, whichlaunch()already forwards verbatim to Playwright's native context option — no new interception machineryextraHTTPHeaders; the flow's own header of the same name wins over the env one (explicit caller intent over ambient config)EXTRA_HTTP_HEADER_NAME=X-Gym-Auth.Testing
4 new cases: neither env var set (no-op), both set, merges with a flow's own headers, flow's own header of the same name wins. All 48 tests in the repo pass (
npx jest),npx tscclean,eslint/prettierclean.Follow-up (not in this PR)
Once published, the QA Wolf gym tooling (qawolf/platform#36197) would bump its pinned
@qawolf/pomversion and setEXTRA_HTTP_HEADER_NAME/EXTRA_HTTP_HEADER_VALUEin the seeded workspace's environment, closing the one surface that PR couldn't reach (this package is installed from npm into the seeded workspace, not part of that repo).