|
1 | 1 | // Exercises startup provider discovery scoping without loading real plugin manifests. |
| 2 | +import { mkdtemp, writeFile } from "node:fs/promises"; |
| 3 | +import os from "node:os"; |
| 4 | +import path from "node:path"; |
2 | 5 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 6 | import type { PluginMetadataSnapshotOwnerMaps } from "../plugins/plugin-metadata-snapshot.js"; |
4 | 7 | import type { ProviderPlugin } from "../plugins/types.js"; |
@@ -205,6 +208,38 @@ describe("resolveImplicitProviders startup discovery scope", () => { |
205 | 208 | expect(mocks.runProviderCatalog).not.toHaveBeenCalled(); |
206 | 209 | }); |
207 | 210 |
|
| 211 | + it("fills missing static catalog apiKey from Google Vertex ADC auth evidence", async () => { |
| 212 | + const tempDir = await mkdtemp(path.join(os.tmpdir(), "openclaw-google-vertex-adc-")); |
| 213 | + const credentialsPath = path.join(tempDir, "application_default_credentials.json"); |
| 214 | + await writeFile(credentialsPath, JSON.stringify({ type: "authorized_user" })); |
| 215 | + mocks.resolveRuntimePluginDiscoveryProviders.mockResolvedValue([ |
| 216 | + createStaticOnlyProvider("google"), |
| 217 | + ]); |
| 218 | + mocks.runProviderStaticCatalog.mockResolvedValue({ |
| 219 | + providers: { |
| 220 | + "google-vertex": { |
| 221 | + baseUrl: "https://aiplatform.googleapis.com", |
| 222 | + api: "google-vertex" as const, |
| 223 | + models: [createTextModel("gemini-3.1-pro-preview", "Gemini 3.1 Pro Preview")], |
| 224 | + }, |
| 225 | + }, |
| 226 | + }); |
| 227 | + |
| 228 | + const providers = await resolveImplicitProviders({ |
| 229 | + agentDir: "/tmp/openclaw-agent", |
| 230 | + config: {}, |
| 231 | + env: { |
| 232 | + GOOGLE_APPLICATION_CREDENTIALS: credentialsPath, |
| 233 | + GOOGLE_CLOUD_PROJECT: "vertex-project", |
| 234 | + GOOGLE_CLOUD_LOCATION: "global", |
| 235 | + } as NodeJS.ProcessEnv, |
| 236 | + explicitProviders: {}, |
| 237 | + providerDiscoveryEntriesOnly: true, |
| 238 | + }); |
| 239 | + |
| 240 | + expect(providers?.["google-vertex"]?.apiKey).toBe("gcp-vertex-credentials"); |
| 241 | + }); |
| 242 | + |
208 | 243 | it("falls back to static provider catalogs when runtime discovery has no rows", async () => { |
209 | 244 | mocks.resolveRuntimePluginDiscoveryProviders.mockResolvedValue([ |
210 | 245 | createProviderWithStaticCatalog("minimax"), |
|
0 commit comments