Skip to content

Commit 7fcf82b

Browse files
Rust e2e: align in-process host auth token with the mock's registered user
In-process, the SDK github_token (lowered to --auth-token-env COPILOT_SDK_AUTH_TOKEN for the spawned child) is not passed to the worker, so host-side auth resolves from GH_TOKEN/GITHUB_TOKEN. The InProcessEnvGuard set these to a placeholder the replay mock never registered, so auth resolved as unauthenticated (client::should_get_ authenticated_status / should_list_models_when_authenticated) or hit real GitHub. Use DEFAULT_TEST_TOKEN — the token set_default_copilot_user registers as the authenticated Copilot user — so in-process auth matches the mock. Fixes the two client auth tests and callback_token_is_applied_as_authorization_header in-process. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2786c9f commit 7fcf82b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

rust/tests/e2e/support.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,14 @@ impl InProcessEnvGuard {
608608
return None;
609609
}
610610
let mut pairs: Vec<(OsString, OsString)> = ctx.environment();
611-
pairs.push(("GH_TOKEN".into(), "fake-token-for-e2e-tests".into()));
612-
pairs.push(("GITHUB_TOKEN".into(), "fake-token-for-e2e-tests".into()));
611+
// In-process, the SDK's `github_token` (lowered to `--auth-token-env
612+
// COPILOT_SDK_AUTH_TOKEN` for the spawned child) is not passed to the worker,
613+
// so host-side auth resolves from GH_TOKEN/GITHUB_TOKEN instead. Use the same
614+
// token the replay mock registers as the authenticated Copilot user
615+
// (`set_default_copilot_user` → DEFAULT_TEST_TOKEN); a placeholder token the
616+
// mock doesn't know would resolve as unauthenticated (or hit real GitHub).
617+
pairs.push(("GH_TOKEN".into(), DEFAULT_TEST_TOKEN.into()));
618+
pairs.push(("GITHUB_TOKEN".into(), DEFAULT_TEST_TOKEN.into()));
613619

614620
let mut saved: Vec<(OsString, Option<OsString>)> = Vec::new();
615621
for (key, value) in &pairs {

0 commit comments

Comments
 (0)