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

推荐订阅源

N
Netflix TechBlog - Medium
IT之家
IT之家
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
小众软件
小众软件
博客园 - 叶小钗
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理

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: report gateway health auth diagnostics (#89337) · op...
RomneyDa · 2026-06-03 · via Recent Commits to openclaw:main
11

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

22

import type { OpenClawConfig } from "../config/config.js";

3+

import {

4+

GATEWAY_HEALTH_CREDENTIALS_REQUIRED_MESSAGE,

5+

GATEWAY_HEALTH_CREDENTIALS_REQUIRED_TITLE,

6+

} from "./gateway-health-auth-diagnostic.js";

3748

const callGateway = vi.hoisted(() => vi.fn());

9+

const isGatewayCredentialsRequiredError = vi.hoisted(() => vi.fn(() => false));

10+

const probeGatewayStatus = vi.hoisted(() => vi.fn());

511

const note = vi.hoisted(() => vi.fn());

12+

const TEST_GATEWAY_URL = "ws://127.0.0.1:18789";

13+

const TEST_AUTH_CLOSE_ERROR = "gateway closed (1008):";

14+

const TEST_TLS_FINGERPRINT = "sha256:test-doctor-gateway-fingerprint";

615716

vi.mock("../gateway/call.js", () => ({

817

buildGatewayConnectionDetails: vi.fn(() => ({

9-

message: "Gateway target: ws://127.0.0.1:18789",

18+

message: `Gateway target: ${TEST_GATEWAY_URL}`,

19+

url: TEST_GATEWAY_URL,

20+

})),

21+

buildGatewayProbeConnectionDetails: vi.fn(() => ({

22+

preauthHandshakeTimeoutMs: 4321,

23+

tlsFingerprint: TEST_TLS_FINGERPRINT,

24+

url: TEST_GATEWAY_URL,

1025

})),

1126

callGateway,

27+

isGatewayCredentialsRequiredError,

28+

}));

29+30+

vi.mock("../cli/daemon-cli/probe.js", () => ({

31+

probeGatewayStatus,

1232

}));

13331434

vi.mock("../../packages/terminal-core/src/note.js", () => ({

@@ -26,6 +46,9 @@ describe("checkGatewayHealth", () => {

26462747

beforeEach(() => {

2848

callGateway.mockReset();

49+

isGatewayCredentialsRequiredError.mockReset();

50+

isGatewayCredentialsRequiredError.mockReturnValue(false);

51+

probeGatewayStatus.mockReset();

2952

note.mockReset();

3053

});

3154

@@ -35,7 +58,7 @@ describe("checkGatewayHealth", () => {

35583659

await expect(

3760

checkGatewayHealth({ runtime: runtime as never, cfg, timeoutMs: 3000 }),

38-

).resolves.toEqual({ healthOk: true, status: { ok: true } });

61+

).resolves.toEqual({ authenticated: true, healthOk: true, status: { ok: true } });

39624063

expect(callGateway).toHaveBeenNthCalledWith(1, {

4164

method: "status",

@@ -58,7 +81,11 @@ describe("checkGatewayHealth", () => {

58815982

await expect(

6083

checkGatewayHealth({ runtime: runtime as never, cfg, timeoutMs: 3000 }),

61-

).resolves.toEqual({ healthOk: true, status: { runtimeVersion: "2026.4.23" } });

84+

).resolves.toEqual({

85+

authenticated: true,

86+

healthOk: true,

87+

status: { runtimeVersion: "2026.4.23" },

88+

});

62896390

const mismatchNotes = note.mock.calls

6491

.filter(([, title]) => title === "OpenClaw version mismatch")

@@ -78,13 +105,43 @@ describe("checkGatewayHealth", () => {

7810579106

await expect(

80107

checkGatewayHealth({ runtime: runtime as never, cfg, timeoutMs: 3000 }),

81-

).resolves.toEqual({ healthOk: false });

108+

).resolves.toEqual({ authenticated: false, healthOk: false, status: undefined });

8210983110

expect(callGateway).toHaveBeenCalledTimes(1);

84111

expect(runtime.error).toHaveBeenCalledWith(

85112

expect.stringContaining("gateway timeout after 3000ms"),

86113

);

87114

});

115+116+

it("reports credentials-required when status RPC auth blocks a reachable gateway", async () => {

117+

callGateway.mockRejectedValueOnce(new Error());

118+

isGatewayCredentialsRequiredError.mockReturnValueOnce(true);

119+

probeGatewayStatus.mockResolvedValueOnce({

120+

ok: false,

121+

kind: "connect",

122+

error: TEST_AUTH_CLOSE_ERROR,

123+

});

124+

const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };

125+126+

await expect(

127+

checkGatewayHealth({ runtime: runtime as never, cfg, timeoutMs: 3000 }),

128+

).resolves.toEqual({ authenticated: false, healthOk: true });

129+130+

expect(probeGatewayStatus).toHaveBeenCalledWith({

131+

url: TEST_GATEWAY_URL,

132+

timeoutMs: 3000,

133+

tlsFingerprint: TEST_TLS_FINGERPRINT,

134+

preauthHandshakeTimeoutMs: 4321,

135+

config: cfg,

136+

json: true,

137+

});

138+

expect(runtime.error).not.toHaveBeenCalled();

139+

expect(note).toHaveBeenCalledWith(

140+

GATEWAY_HEALTH_CREDENTIALS_REQUIRED_MESSAGE,

141+

GATEWAY_HEALTH_CREDENTIALS_REQUIRED_TITLE,

142+

);

143+

expect(callGateway).toHaveBeenCalledTimes(1);

144+

});

88145

});

8914690147

describe("probeGatewayMemoryStatus", () => {

@@ -116,7 +173,7 @@ describe("probeGatewayMemoryStatus", () => {

116173

// A transport timeout must NOT be treated as a skipped probe. It is a real

117174

// diagnostic signal and the renderer should warn for key-optional providers.

118175

callGateway.mockRejectedValue(

119-

new Error("gateway timeout after 8000ms\nGateway target: ws://127.0.0.1:18789"),

176+

new Error(`gateway timeout after 8000ms\nGateway target: ${TEST_GATEWAY_URL}`),

120177

);

121178122179

const result = await probeGatewayMemoryStatus({ cfg });