@@ -63,8 +63,12 @@ vi.mock("./agent-scope-config.js", () => ({
6363 resolveDefaultAgentId : ( ) => "default" ,
6464} ) ) ;
6565
66- const { clearCurrentProviderAuthState, hasAuthForModelProvider, warmCurrentProviderAuthState } =
67- await import ( "./model-provider-auth.js" ) ;
66+ const {
67+ clearCurrentProviderAuthState,
68+ createProviderAuthChecker,
69+ hasAuthForModelProvider,
70+ warmCurrentProviderAuthState,
71+ } = await import ( "./model-provider-auth.js" ) ;
6872
6973describe ( "prepared provider auth state" , ( ) => {
7074 afterEach ( ( ) => {
@@ -147,6 +151,31 @@ describe("prepared provider auth state", () => {
147151 expect ( modelAuthMocks . hasRuntimeAvailableProviderAuth ) . toHaveBeenCalledTimes ( 2 ) ;
148152 } ) ;
149153
154+ it ( "does not prepare synthetic auth refs when plugin synthetic auth is disabled" , async ( ) => {
155+ const cfg = { } as OpenClawConfig ;
156+ modelAuthMocks . hasRuntimeAvailableProviderAuth . mockReturnValue ( false ) ;
157+
158+ const hasAuth = createProviderAuthChecker ( {
159+ cfg,
160+ allowPluginSyntheticAuth : false ,
161+ discoverExternalCliAuth : false ,
162+ } ) ;
163+
164+ await expect ( hasAuth ( "openai" ) ) . resolves . toBe ( false ) ;
165+
166+ expect ( modelAuthMocks . createRuntimeProviderAuthLookup ) . toHaveBeenCalledWith ( {
167+ cfg,
168+ workspaceDir : undefined ,
169+ env : undefined ,
170+ includePluginSyntheticAuth : false ,
171+ } ) ;
172+ const runtimeLookup =
173+ modelAuthMocks . hasRuntimeAvailableProviderAuth . mock . calls [ 0 ] ?. [ 0 ] . runtimeLookup ;
174+ expect ( runtimeLookup ) . toBe (
175+ modelAuthMocks . createRuntimeProviderAuthLookup . mock . results [ 0 ] ?. value ,
176+ ) ;
177+ } ) ;
178+
150179 it ( "hasAuthForModelProvider uses the prepared answer for equivalent runtime config clones" , async ( ) => {
151180 const cfg = { gateway : { port : 18789 } } as OpenClawConfig ;
152181 const clonedCfg = structuredClone ( cfg ) ;
0 commit comments