惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Martin Fowler
Martin Fowler
博客园_首页
量子位
T
Tailwind CSS Blog
博客园 - Franky
G
Google Developers Blog
D
DataBreaches.Net
Vercel News
Vercel News
B
Blog
Recent Announcements
Recent Announcements
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
爱范儿
爱范儿
博客园 - 【当耐特】
The Cloudflare Blog
H
Help Net Security
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
C
Check Point Blog
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(providers): cover ClawRouter runtime auth paths · ope...
vincentkoc · 2026-06-17 · via Recent Commits to openclaw:main
11

import type { StreamFn } from "openclaw/plugin-sdk/agent-core";

22

import { capturePluginRegistration } from "openclaw/plugin-sdk/plugin-test-runtime";

3-

import { describe, expect, it } from "vitest";

3+

import { clearLiveCatalogCacheForTests } from "openclaw/plugin-sdk/provider-catalog-live-runtime";

4+

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

5+6+

const providerAuthRuntimeMocks = vi.hoisted(() => ({

7+

resolveApiKeyForProvider: vi.fn(),

8+

}));

9+10+

vi.mock("openclaw/plugin-sdk/provider-auth-runtime", () => providerAuthRuntimeMocks);

11+412

import plugin from "./index.js";

51314+

const LIVE_CATALOG = {

15+

providers: [

16+

{

17+

id: "openai",

18+

displayName: "OpenAI",

19+

openaiCompatible: true,

20+

nativeBaseUrl: "/v1/native/openai",

21+

routes: [

22+

{

23+

path: "/v1/responses",

24+

methods: ["POST"],

25+

requestFormat: "openai.responses",

26+

},

27+

],

28+

models: [

29+

{

30+

id: "openai/gpt-5.5-mini",

31+

upstream: "gpt-5.5-mini",

32+

capabilities: ["llm.responses"],

33+

},

34+

],

35+

},

36+

],

37+

};

38+639

describe("clawrouter provider plugin", () => {

40+

beforeEach(() => {

41+

clearLiveCatalogCacheForTests();

42+

providerAuthRuntimeMocks.resolveApiKeyForProvider.mockReset();

43+

});

44+45+

afterEach(() => {

46+

vi.unstubAllGlobals();

47+

});

48+749

it("registers managed proxy-key auth and transport routing hooks", () => {

850

const captured = capturePluginRegistration(plugin);

951

const provider = captured.providers[0];

@@ -17,13 +59,15 @@ describe("clawrouter provider plugin", () => {

1759

buildReplayPolicy: expect.any(Function),

1860

normalizeResolvedModel: expect.any(Function),

1961

sanitizeReplayHistory: expect.any(Function),

62+

wrapSimpleCompletionStreamFn: expect.any(Function),

2063

wrapStreamFn: expect.any(Function),

2164

});

2265

expect(provider?.auth[0]).toMatchObject({

2366

id: "api-key",

2467

label: "ClawRouter proxy key",

2568

kind: "api_key",

2669

});

70+

expect(provider?.wrapSimpleCompletionStreamFn).toBe(provider?.wrapStreamFn);

2771

});

28722973

it("attaches the resolved proxy key only when dispatching a request", () => {

@@ -66,6 +110,53 @@ describe("clawrouter provider plugin", () => {

66110

expect(calls[1]?.headers).toBeUndefined();

67111

});

68112113+

it("resolves managed secret refs before credential-scoped discovery", async () => {

114+

providerAuthRuntimeMocks.resolveApiKeyForProvider.mockResolvedValue({

115+

apiKey: "resolved-proxy-key",

116+

mode: "api-key",

117+

source: "models.json secretref",

118+

});

119+

const fetchMock = vi.fn(async () => Response.json(LIVE_CATALOG));

120+

vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);

121+

const provider = capturePluginRegistration(plugin).providers[0];

122+123+

const result = await provider?.catalog?.run({

124+

config: { models: {} },

125+

agentDir: "/agent",

126+

workspaceDir: "/workspace",

127+

env: {},

128+

resolveProviderAuth: () => ({

129+

apiKey: "secretref-managed",

130+

discoveryApiKey: undefined,

131+

mode: "api_key",

132+

source: "profile",

133+

profileId: "clawrouter-profile",

134+

}),

135+

resolveProviderApiKey: () => ({

136+

apiKey: "secretref-managed",

137+

discoveryApiKey: undefined,

138+

}),

139+

});

140+141+

if (!result || !("provider" in result)) {

142+

throw new Error("expected ClawRouter catalog provider result");

143+

}

144+

expect(result.provider.apiKey).toBe("secretref-managed");

145+

expect(result.provider.models.map((model) => model.id)).toEqual(["openai/gpt-5.5-mini"]);

146+

expect(providerAuthRuntimeMocks.resolveApiKeyForProvider).toHaveBeenCalledWith({

147+

provider: "clawrouter",

148+

cfg: { models: {} },

149+

agentDir: "/agent",

150+

workspaceDir: "/workspace",

151+

profileId: "clawrouter-profile",

152+

lockedProfile: true,

153+

});

154+

const fetchCall = fetchMock.mock.calls[0] as unknown as [string, RequestInit] | undefined;

155+

expect(new Headers(fetchCall?.[1]?.headers).get("Authorization")).toBe(

156+

"Bearer resolved-proxy-key",

157+

);

158+

});

159+69160

it("normalizes configured ClawRouter roots to the API base URL", () => {

70161

const provider = capturePluginRegistration(plugin).providers[0];

71162

const normalized = provider?.normalizeConfig?.({