@@ -115,6 +115,7 @@ impl E2eContext {
115115 proxy : Some ( proxy) ,
116116 } ;
117117 ctx. configure ( category, snapshot_name) ?;
118+ ctx. set_default_copilot_user ( ) ;
118119 Ok ( ctx)
119120 }
120121
@@ -144,6 +145,7 @@ impl E2eContext {
144145 . map_err ( |err| {
145146 std:: io:: Error :: other ( format ! ( "configure proxy without snapshot failed: {err}" ) )
146147 } ) ?;
148+ ctx. set_default_copilot_user ( ) ;
147149 Ok ( ctx)
148150 }
149151
@@ -345,11 +347,14 @@ impl E2eContext {
345347 ) ,
346348 ( "COPILOT_MCP_APPS" . into ( ) , "true" . into ( ) ) ,
347349 ( "MCP_APPS" . into ( ) , "true" . into ( ) ) ,
350+ ( "COPILOT_SDK_AUTH_TOKEN" . into ( ) , "" . into ( ) ) ,
351+ ( "GH_TOKEN" . into ( ) , DEFAULT_TEST_TOKEN . into ( ) ) ,
352+ ( "GITHUB_TOKEN" . into ( ) , DEFAULT_TEST_TOKEN . into ( ) ) ,
353+ ( "GH_ENTERPRISE_TOKEN" . into ( ) , "" . into ( ) ) ,
354+ ( "GITHUB_ENTERPRISE_TOKEN" . into ( ) , "" . into ( ) ) ,
355+ ( "COPILOT_HMAC_KEY" . into ( ) , "" . into ( ) ) ,
356+ ( "CAPI_HMAC_KEY" . into ( ) , "" . into ( ) ) ,
348357 ] ) ;
349- if std:: env:: var ( "GITHUB_ACTIONS" ) . as_deref ( ) == Ok ( "true" ) {
350- env. push ( ( "GH_TOKEN" . into ( ) , "fake-token-for-e2e-tests" . into ( ) ) ) ;
351- env. push ( ( "GITHUB_TOKEN" . into ( ) , "fake-token-for-e2e-tests" . into ( ) ) ) ;
352- }
353358 env
354359 }
355360
@@ -623,14 +628,6 @@ impl InProcessEnvGuard {
623628 return None ;
624629 }
625630 let mut pairs: Vec < ( OsString , OsString ) > = ctx. environment ( ) ;
626- // In-process, the SDK's `github_token` (lowered to `--auth-token-env
627- // COPILOT_SDK_AUTH_TOKEN` for the spawned child) is not passed to the worker,
628- // so host-side auth resolves from GH_TOKEN/GITHUB_TOKEN instead. Use the same
629- // token the replay mock registers as the authenticated Copilot user
630- // (`set_default_copilot_user` → DEFAULT_TEST_TOKEN); a placeholder token the
631- // mock doesn't know would resolve as unauthenticated (or hit real GitHub).
632- pairs. push ( ( "GH_TOKEN" . into ( ) , DEFAULT_TEST_TOKEN . into ( ) ) ) ;
633- pairs. push ( ( "GITHUB_TOKEN" . into ( ) , DEFAULT_TEST_TOKEN . into ( ) ) ) ;
634631 // Some tests opt into gated runtime APIs via per-client `options.env`, which the
635632 // in-process transport does not pass to the shared worker (see issue #1934).
636633 // These are process-global runtime gates (not per-client behavior), so applying
@@ -653,12 +650,6 @@ impl InProcessEnvGuard {
653650 // other thread races these process-wide env mutations.
654651 unsafe { std:: env:: set_var ( key, value) } ;
655652 }
656- for key in [ "COPILOT_HMAC_KEY" , "CAPI_HMAC_KEY" ] {
657- let key = OsString :: from ( key) ;
658- saved. push ( ( key. clone ( ) , std:: env:: var_os ( & key) ) ) ;
659- // SAFETY: as above.
660- unsafe { std:: env:: remove_var ( & key) } ;
661- }
662653 let previous_cwd = std:: env:: current_dir ( ) . expect ( "read in-process test cwd" ) ;
663654 std:: env:: set_current_dir ( ctx. work_dir ( ) ) . expect ( "set in-process test cwd" ) ;
664655 Some ( Self {
0 commit comments