






















@@ -959,6 +959,60 @@ describe("getApiKeyForModel", () => {
959959});
960960});
961961962+it("resolveEnvApiKey('google-vertex') accepts Unicode explicit ADC credential paths", async () => {
963+const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-google-adc-unicode-"));
964+const explicitDir = path.join(homeDir, "認証情報");
965+const fallbackDir = path.join(homeDir, ".config", "gcloud");
966+const explicitCredentialsPath = path.join(explicitDir, "adc.json");
967+await fs.mkdir(explicitDir, { recursive: true });
968+await fs.mkdir(fallbackDir, { recursive: true });
969+await fs.writeFile(explicitCredentialsPath, "{}", "utf8");
970+await fs.writeFile(
971+path.join(fallbackDir, "application_default_credentials.json"),
972+"{}",
973+"utf8",
974+);
975+976+try {
977+const resolved = resolveEnvApiKey("google-vertex", {
978+GOOGLE_APPLICATION_CREDENTIALS: explicitCredentialsPath,
979+GOOGLE_CLOUD_LOCATION: "us-central1",
980+GOOGLE_CLOUD_PROJECT: "vertex-project",
981+HOME: homeDir,
982+} as NodeJS.ProcessEnv);
983+984+expect(resolved?.apiKey).toBe("gcp-vertex-credentials");
985+expect(resolved?.source).toBe("gcloud adc");
986+} finally {
987+await fs.rm(homeDir, { recursive: true, force: true });
988+}
989+});
990+991+it("resolveEnvApiKey('google-vertex') accepts Unicode ADC fallback home paths", async () => {
992+const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-google-adc-home-"));
993+const homeDir = path.join(tempDir, "認証情報-home");
994+const fallbackDir = path.join(homeDir, ".config", "gcloud");
995+await fs.mkdir(fallbackDir, { recursive: true });
996+await fs.writeFile(
997+path.join(fallbackDir, "application_default_credentials.json"),
998+"{}",
999+"utf8",
1000+);
1001+1002+try {
1003+const resolved = resolveEnvApiKey("google-vertex", {
1004+GOOGLE_CLOUD_LOCATION: "us-central1",
1005+GOOGLE_CLOUD_PROJECT: "vertex-project",
1006+HOME: homeDir,
1007+} as NodeJS.ProcessEnv);
1008+1009+expect(resolved?.apiKey).toBe("gcp-vertex-credentials");
1010+expect(resolved?.source).toBe("gcloud adc");
1011+} finally {
1012+await fs.rm(tempDir, { recursive: true, force: true });
1013+}
1014+});
1015+9621016it("resolveEnvApiKey('google-vertex') keeps ADC fallback when manifest env candidates are empty", async () => {
9631017const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-google-adc-candidates-"));
9641018const credentialsPath = path.join(tempDir, "adc.json");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。