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

推荐订阅源

IT之家
IT之家
Engineering at Meta
Engineering at Meta
腾讯CDC
宝玉的分享
宝玉的分享
H
Help Net Security
I
InfoQ
博客园 - Franky
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
博客园_首页
美团技术团队
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
The Cloudflare Blog
博客园 - 司徒正美
Vercel News
Vercel News
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
月光博客
月光博客

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 gateway client broad matchers · openclaw/open...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -144,6 +144,39 @@ function getLatestWs(): MockWebSocket {

144144

return ws;

145145

}

146146147+

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

148+

if (typeof value !== "object" || value === null || Array.isArray(value)) {

149+

throw new Error(`expected ${label} to be an object`);

150+

}

151+

return value as Record<string, unknown>;

152+

}

153+154+

function expectRecordFields(

155+

value: unknown,

156+

expected: Record<string, unknown>,

157+

label: string,

158+

): Record<string, unknown> {

159+

const record = requireRecord(value, label);

160+

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

161+

expect(record[key], `${label}.${key}`).toEqual(expectedValue);

162+

}

163+

return record;

164+

}

165+166+

async function expectGatewayRequestError(

167+

promise: Promise<unknown>,

168+

expected: Record<string, unknown>,

169+

): Promise<void> {

170+

let rejected: unknown;

171+

try {

172+

await promise;

173+

} catch (error) {

174+

rejected = error;

175+

}

176+

const error = expectRecordFields(rejected, expected, "gateway request error");

177+

expectRecordFields(error.details, { method: "chat.history" }, "gateway request error details");

178+

}

179+147180

function createClientWithIdentity(

148181

deviceId: string,

149182

onClose: (code: number, reason: string) => void,

@@ -164,12 +197,8 @@ function expectSecurityConnectError(

164197

onConnectError: ReturnType<typeof vi.fn>,

165198

params?: { expectTailscaleHint?: boolean },

166199

) {

167-

expect(onConnectError).toHaveBeenCalledWith(

168-

expect.objectContaining({

169-

message: expect.stringContaining("SECURITY ERROR"),

170-

}),

171-

);

172200

const error = onConnectError.mock.calls[0]?.[0] as Error;

201+

expect(error.message).toContain("SECURITY ERROR");

173202

expect(error.message).toContain("openclaw doctor --fix");

174203

if (params?.expectTailscaleHint) {

175204

expect(error.message).toContain("Tailscale Serve/Funnel");

@@ -271,12 +300,14 @@ describe("GatewayClient security checks", () => {

271300272301

expect(onConnectError).not.toHaveBeenCalled();

273302

expect(wsInstances.length).toBe(1);

274-

expect(getLatestWs().options).not.toMatchObject({ agent: expect.any(Object) });

275-

expect((global as Record<string, unknown>)["GLOBAL_AGENT"]).toEqual(

276-

expect.objectContaining({

303+

expect(requireRecord(getLatestWs().options, "websocket options").agent).toBeUndefined();

304+

expectRecordFields(

305+

(global as Record<string, unknown>)["GLOBAL_AGENT"],

306+

{

277307

HTTP_PROXY: "http://127.0.0.1:3128",

278308

HTTPS_PROXY: "http://127.0.0.1:3128",

279-

}),

309+

},

310+

"global agent",

280311

);

281312

client.stop();

282313

});

@@ -299,7 +330,7 @@ describe("GatewayClient security checks", () => {

299330300331

expect(onConnectError).not.toHaveBeenCalled();

301332

expect(wsInstances.length).toBe(1);

302-

expect(getLatestWs().options).not.toMatchObject({ agent: expect.any(Object) });

333+

expect(requireRecord(getLatestWs().options, "websocket options").agent).toBeUndefined();

303334

} finally {

304335

client.stop();

305336

await stopProxy(handle);

@@ -420,12 +451,11 @@ describe("GatewayClient request errors", () => {

420451

}),

421452

);

422453423-

await expect(requestPromise).rejects.toMatchObject({

454+

await expectGatewayRequestError(requestPromise, {

424455

name: "GatewayClientRequestError",

425456

gatewayCode: "UNAVAILABLE",

426457

retryable: true,

427458

retryAfterMs: 250,

428-

details: { method: "chat.history" },

429459

});

430460431461

client.stop();

@@ -711,6 +741,10 @@ describe("GatewayClient connect auth payload", () => {

711741

return parseConnectRequest(ws).params?.auth ?? {};

712742

}

713743744+

function expectConnectAuthFields(ws: MockWebSocket, expected: Record<string, unknown>): void {

745+

expectRecordFields(connectFrameFrom(ws), expected, "connect auth");

746+

}

747+714748

function connectScopesFrom(ws: MockWebSocket) {

715749

return parseConnectRequest(ws).params?.scopes ?? [];

716750

}

@@ -823,9 +857,7 @@ describe("GatewayClient connect auth payload", () => {

823857

ws.emitOpen();

824858

emitConnectChallenge(ws);

825859826-

expect(connectFrameFrom(ws)).toMatchObject({

827-

token: "shared-token",

828-

});

860+

expectConnectAuthFields(ws, { token: "shared-token" });

829861

expect(connectFrameFrom(ws).deviceToken).toBeUndefined();

830862

client.stop();

831863

});

@@ -838,9 +870,7 @@ describe("GatewayClient connect auth payload", () => {

838870839871

const { ws, connect } = startClientWithEarlyChallenge({ client });

840872841-

expect(connectFrameFrom(ws)).toMatchObject({

842-

token: "shared-token",

843-

});

873+

expectConnectAuthFields(ws, { token: "shared-token" });

844874

emitHelloOk(ws, connect.id);

845875

client.stop();

846876

});

@@ -857,11 +887,10 @@ describe("GatewayClient connect auth payload", () => {

857887

ws.autoCloseOnClose = false;

858888

client.stop();

859889860-

await vi.waitFor(() =>

861-

expect(onConnectError).toHaveBeenCalledWith(

862-

expect.objectContaining({ message: "gateway client stopped" }),

863-

),

864-

);

890+

await vi.waitFor(() => {

891+

const error = onConnectError.mock.calls[0]?.[0] as Error | undefined;

892+

expect(error?.message).toBe("gateway client stopped");

893+

});

865894

expect(logDebugMock).toHaveBeenCalledWith(

866895

"gateway connect failed: Error: gateway client stopped",

867896

);

@@ -883,9 +912,7 @@ describe("GatewayClient connect auth payload", () => {

883912

ws.emitOpen();

884913

emitConnectChallenge(ws);

885914886-

expect(connectFrameFrom(ws)).toMatchObject({

887-

password: "shared-password", // pragma: allowlist secret

888-

});

915+

expectConnectAuthFields(ws, { password: "shared-password" }); // pragma: allowlist secret

889916

expect(connectFrameFrom(ws).token).toBeUndefined();

890917

expect(connectFrameFrom(ws).deviceToken).toBeUndefined();

891918

client.stop();

@@ -903,9 +930,7 @@ describe("GatewayClient connect auth payload", () => {

903930

ws.emitOpen();

904931

emitConnectChallenge(ws);

905932906-

expect(connectFrameFrom(ws)).toMatchObject({

907-

password: "shared-password", // pragma: allowlist secret

908-

});

933+

expectConnectAuthFields(ws, { password: "shared-password" }); // pragma: allowlist secret

909934

expect(connectFrameFrom(ws).bootstrapToken).toBeUndefined();

910935

expect(connectFrameFrom(ws).token).toBeUndefined();

911936

client.stop();

@@ -925,7 +950,7 @@ describe("GatewayClient connect auth payload", () => {

925950

ws.emitOpen();

926951

emitConnectChallenge(ws);

927952928-

expect(connectFrameFrom(ws)).toMatchObject({

953+

expectConnectAuthFields(ws, {

929954

token: "stored-device-token",

930955

deviceToken: "stored-device-token",

931956

});

@@ -948,7 +973,7 @@ describe("GatewayClient connect auth payload", () => {

948973

ws.emitOpen();

949974

emitConnectChallenge(ws);

950975951-

expect(connectFrameFrom(ws)).toMatchObject({

976+

expectConnectAuthFields(ws, {

952977

token: "stored-device-token",

953978

deviceToken: "stored-device-token",

954979

});

@@ -975,14 +1000,16 @@ describe("GatewayClient connect auth payload", () => {

9751000

ws.emitOpen();

9761001

emitConnectChallenge(ws);

9771002978-

expect(loadDeviceAuthTokenMock).toHaveBeenCalledWith(

979-

expect.objectContaining({

980-

deviceId: expect.any(String),

1003+

const loadTokenParams = expectRecordFields(

1004+

loadDeviceAuthTokenMock.mock.calls[0]?.[0],

1005+

{

9811006

role: "operator",

9821007

env,

983-

}),

1008+

},

1009+

"load device token params",

9841010

);

985-

expect(connectFrameFrom(ws)).toMatchObject({

1011+

expect(loadTokenParams.deviceId).toBeTypeOf("string");

1012+

expectConnectAuthFields(ws, {

9861013

token: "stored-device-token",

9871014

deviceToken: "stored-device-token",

9881015

});

@@ -1001,9 +1028,7 @@ describe("GatewayClient connect auth payload", () => {

10011028

ws.emitOpen();

10021029

emitConnectChallenge(ws);

100310301004-

expect(connectFrameFrom(ws)).toMatchObject({

1005-

bootstrapToken: "bootstrap-token",

1006-

});

1031+

expectConnectAuthFields(ws, { bootstrapToken: "bootstrap-token" });

10071032

expect(connectFrameFrom(ws).token).toBeUndefined();

10081033

expect(connectFrameFrom(ws).deviceToken).toBeUndefined();

10091034

client.stop();

@@ -1025,7 +1050,7 @@ describe("GatewayClient connect auth payload", () => {

10251050

ws.emitOpen();

10261051

emitConnectChallenge(ws);

102710521028-

expect(connectFrameFrom(ws)).toMatchObject({

1053+

expectConnectAuthFields(ws, {

10291054

token: "explicit-device-token",

10301055

deviceToken: "explicit-device-token",

10311056

});

@@ -1048,7 +1073,7 @@ describe("GatewayClient connect auth payload", () => {

10481073

ws.emitOpen();

10491074

emitConnectChallenge(ws);

105010751051-

expect(connectFrameFrom(ws)).toMatchObject({

1076+

expectConnectAuthFields(ws, {

10521077

token: "stored-device-token",

10531078

deviceToken: "stored-device-token",

10541079

});

@@ -1075,10 +1100,14 @@ describe("GatewayClient connect auth payload", () => {

10751100

connectId: firstConnect.id,

10761101

failureDetails: { code: "AUTH_TOKEN_MISMATCH", canRetryWithDeviceToken: true },

10771102

});

1078-

expect(retriedAuth).toMatchObject({

1079-

token: "shared-token",

1080-

deviceToken: "stored-device-token",

1081-

});

1103+

expectRecordFields(

1104+

retriedAuth,

1105+

{

1106+

token: "shared-token",

1107+

deviceToken: "stored-device-token",

1108+

},

1109+

"retried connect auth",

1110+

);

10821111

const ws = getLatestWs();

10831112

expect(connectScopesFrom(ws)).toEqual(["operator.read"]);

10841113

client.stop();

@@ -1097,10 +1126,14 @@ describe("GatewayClient connect auth payload", () => {

10971126

connectId: firstConnect.id,

10981127

failureDetails: { code: "AUTH_UNAUTHORIZED", recommendedNextStep: "retry_with_device_token" },

10991128

});

1100-

expect(retriedAuth).toMatchObject({

1101-

token: "shared-token",

1102-

deviceToken: "stored-device-token",

1103-

});

1129+

expectRecordFields(

1130+

retriedAuth,

1131+

{

1132+

token: "shared-token",

1133+

deviceToken: "stored-device-token",

1134+

},

1135+

"retried connect auth",

1136+

);

11041137

client.stop();

11051138

});

11061139

@@ -1145,10 +1178,12 @@ describe("GatewayClient connect auth payload", () => {

11451178

connectId: firstConnect.id,

11461179

failureDetails: { code: "AUTH_DEVICE_TOKEN_MISMATCH" },

11471180

});

1148-

expect(clearDeviceAuthTokenMock).toHaveBeenCalledWith({

1149-

deviceId: expect.any(String),

1150-

role: "operator",

1151-

});

1181+

const clearTokenParams = expectRecordFields(

1182+

clearDeviceAuthTokenMock.mock.calls[0]?.[0],

1183+

{ role: "operator" },

1184+

"clear device token params",

1185+

);

1186+

expect(clearTokenParams.deviceId).toBeTypeOf("string");

11521187

expect(onReconnectPaused).toHaveBeenCalledWith({

11531188

code: 1008,

11541189

reason: "connect failed",