@@ -13,12 +13,14 @@ import {
1313} from "../../test/helpers/openclaw-test-instance.js" ;
1414import { isProcessAlive , waitForPidFile } from "../../test/helpers/process-wait.js" ;
1515import { createDeferred } from "../../test/helpers/promise.js" ;
16- import { loadPersistedAuthProfileStore } from "../agents/auth-profiles/persisted.js" ;
16+ import { reloadSharedAuthStoreOwnership } from "../agents/auth-profiles/path-resolve.js" ;
17+ import { loadAuthProfileStoreForRuntime } from "../agents/auth-profiles/store.js" ;
1718import { resolveAgentModelPrimaryValue } from "../config/model-input.js" ;
1819import type { ModelProviderConfig } from "../config/types.models.js" ;
1920import type { OpenClawConfig } from "../config/types.openclaw.js" ;
2021import { connectGatewayClient } from "../gateway/test-helpers.e2e.js" ;
2122import { runExec } from "../process/exec.js" ;
23+ import { withEnv } from "../test-utils/env.js" ;
2224import { killPidIfAlive } from "../test-utils/process-tree.js" ;
2325import { sleep } from "../utils/sleep.js" ;
2426import { GatewayChatClient } from "./gateway-chat.js" ;
@@ -59,6 +61,7 @@ type MockModelBehavior = {
5961type MockModelRequest = {
6062 method : string ;
6163 path : string ;
64+ authorization ?: string ;
6265 body : Record < string , unknown > ;
6366} ;
6467
@@ -346,7 +349,12 @@ async function startRoutedMockModelServer(
346349 const body = await readJsonRequest ( req ) ;
347350 if ( url . pathname === "/v1/responses" || url . pathname === "/responses" ) {
348351 const modelId = typeof body . model === "string" ? body . model : "" ;
349- const request = { method : req . method , path : url . pathname , body } ;
352+ const request = {
353+ method : req . method ,
354+ path : url . pathname ,
355+ authorization : req . headers . authorization ,
356+ body,
357+ } ;
350358 const behavior = behaviors [ modelId ] ;
351359 if ( ! behavior ) {
352360 rejectedRequests . push ( request ) ;
@@ -1469,7 +1477,7 @@ describe("TUI PTY real backends", () => {
14691477 "authenticates a manifest-discovered provider and resumes the unchanged local model" ,
14701478 async ( { onTestFinished } ) => {
14711479 const pluginId = "t05-local-auth-fixture" ;
1472- const providerId = "t05-local-auth-provider " ;
1480+ const providerId = "tui-pty-mock " ;
14731481 const profileId = `${ providerId } :default` ;
14741482 const sentinel = `t05-${ randomUUID ( ) } ` ;
14751483 const expectedDigest = createHash ( "sha256" ) . update ( sentinel ) . digest ( "hex" ) ;
@@ -1587,7 +1595,13 @@ export default {
15871595 const agentDir = path . join ( fixture . stateDir , "agents" , "main" , "agent" ) ;
15881596 const sqlitePath = path . join ( agentDir , "openclaw-agent.sqlite" ) ;
15891597 expect ( await stat ( sqlitePath ) . then ( ( entry ) => entry . isFile ( ) ) ) . toBe ( true ) ;
1590- const store = loadPersistedAuthProfileStore ( agentDir ) ;
1598+ const store = withEnv ( { OPENCLAW_STATE_DIR : fixture . stateDir } , ( ) => {
1599+ reloadSharedAuthStoreOwnership ( ) ;
1600+ return loadAuthProfileStoreForRuntime ( agentDir , {
1601+ readOnly : true ,
1602+ syncExternalCli : false ,
1603+ } ) ;
1604+ } ) ;
15911605 const profile = store ?. profiles [ profileId ] ;
15921606 expect ( profile ?. type === "api_key" ) . toBe ( true ) ;
15931607 expect ( profile ?. provider === providerId ) . toBe ( true ) ;
@@ -1608,6 +1622,7 @@ export default {
16081622 onTimeout : ( ) => new Error ( "post-auth prompt did not reach the mock provider" ) ,
16091623 } ) ;
16101624 expect ( fixture . mockModel . requests ( ) [ 0 ] ?. body . model ) . toBe ( "gpt-5.5" ) ;
1625+ expect ( fixture . mockModel . requests ( ) [ 0 ] ?. authorization ) . toBe ( `Bearer ${ sentinel } ` ) ;
16111626 await fixture . run . waitForOutput ( "LOCAL_AUTH_RESPONSE" , LOCAL_OUTPUT_TIMEOUT_MS ) ;
16121627
16131628 await fixture . run . write ( "/exit\r" , { delay : false } ) ;
0 commit comments