fix: align provider auth checker with config evidence · openclaw/openclaw@1db2e63
shakkernerd
·
2026-04-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ import {
|
17 | 17 | resolveEnvApiKey, |
18 | 18 | resolveModelAuthMode, |
19 | 19 | } from "./model-auth.js"; |
| 20 | +import { hasAuthForModelProvider } from "./model-provider-auth.js"; |
20 | 21 | |
21 | 22 | async function expectVertexAdcEnvApiKey(params: { |
22 | 23 | provider: string; |
@@ -525,6 +526,34 @@ describe("getApiKeyForModel", () => {
|
525 | 526 | } |
526 | 527 | }); |
527 | 528 | |
| 529 | +it("uses the same trusted workspace manifest auth evidence in provider auth checks", async () => { |
| 530 | +const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-workspace-cloud-auth-")); |
| 531 | +const credentialsPath = path.join(tempDir, "credentials.json"); |
| 532 | +await fs.writeFile(credentialsPath, "{}", "utf8"); |
| 533 | +const store = { version: 1 as const, profiles: {} }; |
| 534 | + |
| 535 | +try { |
| 536 | +await withEnvAsync({ WORKSPACE_CLOUD_CREDENTIALS: credentialsPath }, async () => { |
| 537 | +expect( |
| 538 | +hasAuthForModelProvider({ |
| 539 | +provider: "workspace-cloud", |
| 540 | +cfg: { plugins: { allow: ["workspace-cloud"] } }, |
| 541 | + store, |
| 542 | +}), |
| 543 | +).toBe(true); |
| 544 | +expect( |
| 545 | +hasAuthForModelProvider({ |
| 546 | +provider: "workspace-cloud", |
| 547 | +cfg: { plugins: {} }, |
| 548 | + store, |
| 549 | +}), |
| 550 | +).toBe(false); |
| 551 | +}); |
| 552 | +} finally { |
| 553 | +await fs.rm(tempDir, { recursive: true, force: true }); |
| 554 | +} |
| 555 | +}); |
| 556 | + |
528 | 557 | it("hasAvailableAuthForProvider('google') accepts GOOGLE_API_KEY fallback", async () => { |
529 | 558 | await withEnvAsync( |
530 | 559 | { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。