@@ -12,6 +12,7 @@ import {
1212 bridgeCodexAppServerStartOptions ,
1313 refreshCodexAppServerAuthTokens ,
1414 resolveCodexAppServerAuthAccountCacheKey ,
15+ resolveCodexAppServerAuthProfileId ,
1516 resolveCodexAppServerHomeDir ,
1617 resolveCodexAppServerNativeHomeDir ,
1718} from "./auth-bridge.js" ;
@@ -651,6 +652,30 @@ describe("bridgeCodexAppServerStartOptions", () => {
651652 }
652653 } ) ;
653654
655+ it ( "selects an oauthRef-backed Codex profile for app-server login" , ( ) => {
656+ expect (
657+ resolveCodexAppServerAuthProfileId ( {
658+ store : {
659+ version : 1 ,
660+ profiles : {
661+ "openai-codex:default" : {
662+ type : "oauth" ,
663+ provider : "openai-codex" ,
664+ access : "" ,
665+ refresh : "" ,
666+ expires : Date . now ( ) + 60_000 ,
667+ oauthRef : {
668+ source : "openclaw-credentials" ,
669+ provider : "openai-codex" ,
670+ id : "0123456789abcdef0123456789abcdef" ,
671+ } ,
672+ } ,
673+ } ,
674+ } ,
675+ } ) ,
676+ ) . toBe ( "openai-codex:default" ) ;
677+ } ) ;
678+
654679 it ( "applies native Codex CLI OAuth when no OpenClaw auth profile exists" , async ( ) => {
655680 const root = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-codex-app-server-" ) ) ;
656681 const agentDir = path . join ( root , "agent" ) ;
0 commit comments