11// Google tests cover index plugin behavior.
2+ import { mkdtemp , writeFile } from "node:fs/promises" ;
3+ import os from "node:os" ;
4+ import path from "node:path" ;
25import type { Context , Model } from "openclaw/plugin-sdk/llm" ;
36import type {
47 ProviderReplaySessionEntry ,
@@ -14,6 +17,7 @@ import type { RealtimeVoiceProviderPlugin } from "openclaw/plugin-sdk/realtime-v
1417import { describe , expect , it , vi } from "vitest" ;
1518import { registerGoogleGeminiCliProvider } from "./gemini-cli-provider.js" ;
1619import googlePlugin from "./index.js" ;
20+ import googleProviderDiscovery from "./provider-discovery.js" ;
1721import { registerGoogleProvider } from "./provider-registration.js" ;
1822
1923const googleProviderPlugin = {
@@ -163,6 +167,59 @@ describe("google provider plugin hooks", () => {
163167 ) . toBe ( "native" ) ;
164168 } ) ;
165169
170+ it ( "resolves Google Vertex ADC auth evidence to the config marker" , async ( ) => {
171+ const tempDir = await mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-google-vertex-config-key-" ) ) ;
172+ const credentialsPath = path . join ( tempDir , "application_default_credentials.json" ) ;
173+ await writeFile (
174+ credentialsPath ,
175+ JSON . stringify ( {
176+ type : "authorized_user" ,
177+ client_id : "client-id" ,
178+ client_secret : "client-secret" ,
179+ refresh_token : "refresh-token" ,
180+ } ) ,
181+ "utf8" ,
182+ ) ;
183+ const { providers } = await registerProviderPlugin ( {
184+ plugin : googleProviderPlugin ,
185+ id : "google" ,
186+ name : "Google Provider" ,
187+ } ) ;
188+ const provider = requireRegisteredProvider ( providers , "google-vertex" ) ;
189+
190+ expect (
191+ provider . resolveConfigApiKey ?.( {
192+ provider : "google-vertex" ,
193+ env : {
194+ GOOGLE_APPLICATION_CREDENTIALS : credentialsPath ,
195+ GOOGLE_CLOUD_PROJECT : "vertex-project" ,
196+ GOOGLE_CLOUD_LOCATION : "global" ,
197+ } ,
198+ } ) ,
199+ ) . toBe ( "gcp-vertex-credentials" ) ;
200+ expect (
201+ provider . resolveConfigApiKey ?.( {
202+ provider : "google-vertex" ,
203+ env : {
204+ GOOGLE_APPLICATION_CREDENTIALS : credentialsPath ,
205+ GOOGLE_CLOUD_PROJECT : "" ,
206+ GCLOUD_PROJECT : "vertex-project" ,
207+ GOOGLE_CLOUD_LOCATION : "global" ,
208+ } ,
209+ } ) ,
210+ ) . toBe ( "gcp-vertex-credentials" ) ;
211+ expect (
212+ googleProviderDiscovery . resolveConfigApiKey ?.( {
213+ provider : "google-vertex" ,
214+ env : {
215+ GOOGLE_APPLICATION_CREDENTIALS : credentialsPath ,
216+ GOOGLE_CLOUD_PROJECT : "vertex-project" ,
217+ GOOGLE_CLOUD_LOCATION : "global" ,
218+ } ,
219+ } ) ,
220+ ) . toBe ( "gcp-vertex-credentials" ) ;
221+ } ) ;
222+
166223 it ( "owns Gemini tool schema normalization for direct and CLI providers" , async ( ) => {
167224 const { providers } = await registerProviderPlugin ( {
168225 plugin : googleProviderPlugin ,
0 commit comments