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

推荐订阅源

Engineering at Meta
Engineering at Meta
J
Java Code Geeks
I
InfoQ
腾讯CDC
Vercel News
Vercel News
IT之家
IT之家
V
Visual Studio Blog
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 叶小钗
有赞技术团队
有赞技术团队
月光博客
月光博客
Martin Fowler
Martin Fowler
量子位
L
LangChain Blog
B
Blog
Last Week in AI
Last Week in AI
博客园 - 司徒正美
Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans

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
test: clear onboard auth broad matchers · openclaw/opencl...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -81,6 +81,30 @@ vi.mock("../secrets/provider-env-vars.js", () => ({

8181

getProviderEnvVars: vi.fn((provider: string) => providerEnvVarsById[provider] ?? []),

8282

}));

838384+

function requireRecord(value: unknown, label: string): Record<string, unknown> {

85+

expect(typeof value, label).toBe("object");

86+

expect(value, label).not.toBeNull();

87+

return value as Record<string, unknown>;

88+

}

89+90+

function expectFields(value: unknown, expected: Record<string, unknown>, label = "record") {

91+

const record = requireRecord(value, label);

92+

for (const [key, expectedValue] of Object.entries(expected)) {

93+

expect(record[key], key).toEqual(expectedValue);

94+

}

95+

return record;

96+

}

97+98+

async function expectMissingFile(readPromise: Promise<unknown>) {

99+

try {

100+

await readPromise;

101+

} catch (error) {

102+

expectFields(error, { code: "ENOENT" }, "read error");

103+

return;

104+

}

105+

throw new Error("Expected file read to fail with ENOENT");

106+

}

107+84108

describe("writeOAuthCredentials", () => {

85109

const lifecycle = createAuthTestLifecycle([

86110

"OPENCLAW_STATE_DIR",

@@ -112,15 +136,13 @@ describe("writeOAuthCredentials", () => {

112136

const parsed = await readAuthProfilesForAgent<{

113137

profiles?: Record<string, OAuthCredentials & { type?: string }>;

114138

}>(defaultAgentDir);

115-

expect(parsed.profiles?.["openai-codex:default"]).toMatchObject({

139+

expectFields(parsed.profiles?.["openai-codex:default"], {

116140

refresh: "refresh-token",

117141

access: "access-token",

118142

type: "oauth",

119143

});

120144121-

await expect(

122-

fs.readFile(path.join(env.agentDir, "auth-profiles.json"), "utf8"),

123-

).rejects.toMatchObject({ code: "ENOENT" });

145+

await expectMissingFile(fs.readFile(path.join(env.agentDir, "auth-profiles.json"), "utf8"));

124146

});

125147126148

it("writes OAuth credentials to all sibling agent dirs when syncSiblingAgents=true", async () => {

@@ -152,7 +174,7 @@ describe("writeOAuthCredentials", () => {

152174

const parsed = JSON.parse(raw) as {

153175

profiles?: Record<string, OAuthCredentials & { type?: string }>;

154176

};

155-

expect(parsed.profiles?.["openai-codex:default"]).toMatchObject({

177+

expectFields(parsed.profiles?.["openai-codex:default"], {

156178

refresh: "refresh-sync",

157179

access: "access-sync",

158180

type: "oauth",

@@ -184,14 +206,12 @@ describe("writeOAuthCredentials", () => {

184206

const kidParsed = JSON.parse(kidRaw) as {

185207

profiles?: Record<string, OAuthCredentials & { type?: string }>;

186208

};

187-

expect(kidParsed.profiles?.["openai-codex:default"]).toMatchObject({

209+

expectFields(kidParsed.profiles?.["openai-codex:default"], {

188210

access: "access-kid",

189211

type: "oauth",

190212

});

191213192-

await expect(fs.readFile(authProfilePathFor(mainAgentDir), "utf8")).rejects.toMatchObject({

193-

code: "ENOENT",

194-

});

214+

await expectMissingFile(fs.readFile(authProfilePathFor(mainAgentDir), "utf8"));

195215

});

196216197217

it("syncs siblings from explicit agentDir outside OPENCLAW_STATE_DIR", async () => {

@@ -223,7 +243,7 @@ describe("writeOAuthCredentials", () => {

223243

const parsed = JSON.parse(raw) as {

224244

profiles?: Record<string, OAuthCredentials & { type?: string }>;

225245

};

226-

expect(parsed.profiles?.["openai-codex:default"]).toMatchObject({

246+

expectFields(parsed.profiles?.["openai-codex:default"], {

227247

refresh: "refresh-ext",

228248

access: "access-ext",

229249

type: "oauth",

@@ -232,9 +252,7 @@ describe("writeOAuthCredentials", () => {

232252233253

// Global state dir should NOT have credentials written

234254

const globalMain = path.join(tempStateDir, "agents", "main", "agent");

235-

await expect(fs.readFile(authProfilePathFor(globalMain), "utf8")).rejects.toMatchObject({

236-

code: "ENOENT",

237-

});

255+

await expectMissingFile(fs.readFile(authProfilePathFor(globalMain), "utf8"));

238256

});

239257

});

240258

@@ -280,11 +298,11 @@ describe("upsertApiKeyProfile secret refs", () => {

280298

});

281299

upsertApiKeyProfile({ provider: "openai", input: "sk-openai-env", agentDir: env.agentDir });

282300283-

expect(await readProfile(env.agentDir, "moonshot:default")).toMatchObject({

301+

expectFields(await readProfile(env.agentDir, "moonshot:default"), {

284302

key: "sk-moonshot-env",

285303

});

286304

expect((await readProfile(env.agentDir, "moonshot:default"))?.keyRef).toBeUndefined();

287-

expect(await readProfile(env.agentDir, "openai:default")).toMatchObject({

305+

expectFields(await readProfile(env.agentDir, "openai:default"), {

288306

key: "sk-openai-env",

289307

});

290308

expect((await readProfile(env.agentDir, "openai:default"))?.keyRef).toBeUndefined();

@@ -315,18 +333,18 @@ describe("upsertApiKeyProfile secret refs", () => {

315333

profileId: "moonshot:plain",

316334

});

317335318-

expect(await readProfile(env.agentDir, "moonshot:default")).toMatchObject({

336+

expectFields(await readProfile(env.agentDir, "moonshot:default"), {

319337

keyRef: { source: "env", provider: "default", id: "MOONSHOT_API_KEY" },

320338

});

321339

expect((await readProfile(env.agentDir, "moonshot:default"))?.key).toBeUndefined();

322-

expect(await readProfile(env.agentDir, "openai:default")).toMatchObject({

340+

expectFields(await readProfile(env.agentDir, "openai:default"), {

323341

keyRef: { source: "env", provider: "default", id: "OPENAI_API_KEY" },

324342

});

325343

expect((await readProfile(env.agentDir, "openai:default"))?.key).toBeUndefined();

326-

expect(await readProfile(env.agentDir, "moonshot:inline")).toMatchObject({

344+

expectFields(await readProfile(env.agentDir, "moonshot:inline"), {

327345

keyRef: { source: "env", provider: "default", id: "MOONSHOT_API_KEY" },

328346

});

329-

expect(await readProfile(env.agentDir, "moonshot:plain")).toMatchObject({

347+

expectFields(await readProfile(env.agentDir, "moonshot:plain"), {

330348

key: "sk-moonshot-plaintext",

331349

});

332350

expect((await readProfile(env.agentDir, "moonshot:plain"))?.keyRef).toBeUndefined();

@@ -364,21 +382,21 @@ describe("upsertApiKeyProfile secret refs", () => {

364382

});

365383

}

366384367-

expect(await readProfile(env.agentDir, "cloudflare-ai-gateway:default")).toMatchObject({

385+

expectFields(await readProfile(env.agentDir, "cloudflare-ai-gateway:default"), {

368386

keyRef: { source: "env", provider: "default", id: "CLOUDFLARE_AI_GATEWAY_API_KEY" },

369387

metadata: { accountId: "account-1", gatewayId: "gateway-1" },

370388

});

371389

expect((await readProfile(env.agentDir, "cloudflare-ai-gateway:default"))?.key).toBeUndefined();

372-

expect(await readProfile(env.agentDir, "volcengine:default")).toMatchObject({

390+

expectFields(await readProfile(env.agentDir, "volcengine:default"), {

373391

keyRef: { source: "env", provider: "default", id: "VOLCANO_ENGINE_API_KEY" },

374392

});

375-

expect(await readProfile(env.agentDir, "byteplus:default")).toMatchObject({

393+

expectFields(await readProfile(env.agentDir, "byteplus:default"), {

376394

keyRef: { source: "env", provider: "default", id: "BYTEPLUS_API_KEY" },

377395

});

378-

expect(await readProfile(env.agentDir, "opencode:default")).toMatchObject({

396+

expectFields(await readProfile(env.agentDir, "opencode:default"), {

379397

keyRef: { source: "env", provider: "default", id: "OPENCODE_API_KEY" },

380398

});

381-

expect(await readProfile(env.agentDir, "opencode-go:default")).toMatchObject({

399+

expectFields(await readProfile(env.agentDir, "opencode-go:default"), {

382400

keyRef: { source: "env", provider: "default", id: "OPENCODE_API_KEY" },

383401

});

384402

});

@@ -405,15 +423,13 @@ describe("upsertApiKeyProfile", () => {

405423

const parsed = await readAuthProfilesForAgent<{

406424

profiles?: Record<string, { type?: string; provider?: string; key?: string }>;

407425

}>(defaultAgentDir);

408-

expect(parsed.profiles?.["minimax:default"]).toMatchObject({

426+

expectFields(parsed.profiles?.["minimax:default"], {

409427

type: "api_key",

410428

provider: "minimax",

411429

key: "sk-minimax-test",

412430

});

413431414-

await expect(

415-

fs.readFile(path.join(env.agentDir, "auth-profiles.json"), "utf8"),

416-

).rejects.toMatchObject({ code: "ENOENT" });

432+

await expectMissingFile(fs.readFile(path.join(env.agentDir, "auth-profiles.json"), "utf8"));

417433

});

418434

});

419435