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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Engineering at Meta
Engineering at Meta
有赞技术团队
有赞技术团队
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
B
Blog
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
Microsoft Azure Blog
Microsoft Azure Blog
D
DataBreaches.Net
I
InfoQ
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
H
Help Net Security

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(qa): reject loose mock OpenAI ports · openclaw/opencl...
vincentkoc · 2026-06-17 · via Recent Commits to openclaw:main

File tree

    • npm-onboard-channel-agent

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,26 @@

11

// Mock OpenAI model config helpers for E2E fixture generation.

2+

function formatMockPortValue(value) {

3+

return value === undefined ? "<missing>" : JSON.stringify(String(value));

4+

}

5+
6+

export function parseMockOpenAiPort(value, label = "mock OpenAI port") {

7+

const text = String(value ?? "").trim();

8+

if (!/^[1-9]\d*$/u.test(text)) {

9+

throw new Error(

10+

`${label} must be a TCP port from 1 to 65535. Got: ${formatMockPortValue(value)}`,

11+

);

12+

}

13+

const port = Number(text);

14+

if (!Number.isSafeInteger(port) || port > 65535) {

15+

throw new Error(

16+

`${label} must be a TCP port from 1 to 65535. Got: ${formatMockPortValue(value)}`,

17+

);

18+

}

19+

return port;

20+

}

21+
222

export function applyMockOpenAiModelConfig(cfg, params) {

23+

const mockPort = parseMockOpenAiPort(params.mockPort);

324

const modelRef = params.modelRef ?? "openai/gpt-5.5";

425

const modelId = modelRef.split("/").at(-1) ?? "gpt-5.5";

526

const cost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };

@@ -10,7 +31,7 @@ export function applyMockOpenAiModelConfig(cfg, params) {

1031

...cfg.models?.providers,

1132

openai: {

1233

...cfg.models?.providers?.openai,

13-

baseUrl: `http://127.0.0.1:${params.mockPort}/v1`,

34+

baseUrl: `http://127.0.0.1:${mockPort}/v1`,

1435

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

1536

api: "openai-responses",

1637

agentRuntime: { id: "openclaw" },

Original file line numberDiff line numberDiff line change

@@ -8,7 +8,10 @@ import {

88

} from "../agent-turn-output.mjs";

99

import { assertOpenAiEnvAuthProfileStore } from "../auth-profile-store-assertions.mjs";

1010

import { readPositiveIntEnv } from "../env-limits.mjs";

11-

import { applyMockOpenAiModelConfig } from "../fixtures/mock-openai-config.mjs";

11+

import {

12+

applyMockOpenAiModelConfig,

13+

parseMockOpenAiPort,

14+

} from "../fixtures/mock-openai-config.mjs";

1215

import { readTextFileBounded, readTextFileTail } from "../text-file-utils.mjs";

1316
1417

const command = process.argv[2];

@@ -117,15 +120,15 @@ function assertOnboardState() {

117120

}

118121
119122

function configureMockModel() {

120-

const mockPort = Number(process.argv[3]);

123+

const mockPort = parseMockOpenAiPort(process.argv[3]);

121124

const configPath = path.join(process.env.HOME, ".openclaw", "openclaw.json");

122125

const cfg = readJson(configPath);

123126

applyMockOpenAiModelConfig(cfg, { mockPort });

124127

fs.writeFileSync(configPath, `${JSON.stringify(cfg, null, 2)}\n`);

125128

}

126129
127130

function assertMockModelConfig() {

128-

const mockPort = Number(process.argv[3]);

131+

const mockPort = parseMockOpenAiPort(process.argv[3]);

129132

const expectedModelRef = "openai/gpt-5.5";

130133

const expectedBaseUrl = `http://127.0.0.1:${mockPort}/v1`;

131134

const configPath = path.join(process.env.HOME, ".openclaw", "openclaw.json");

Original file line numberDiff line numberDiff line change

@@ -7,7 +7,10 @@ import {

77

assertOpenAiRequestLogUsed,

88

} from "../agent-turn-output.mjs";

99

import { assertOpenAiEnvAuthProfileStore } from "../auth-profile-store-assertions.mjs";

10-

import { applyMockOpenAiModelConfig } from "../fixtures/mock-openai-config.mjs";

10+

import {

11+

applyMockOpenAiModelConfig,

12+

parseMockOpenAiPort,

13+

} from "../fixtures/mock-openai-config.mjs";

1114

import { readPluginInstallRecords } from "../plugin-index-sqlite.mjs";

1215

import { readTextFileTail } from "../text-file-utils.mjs";

1316

@@ -145,7 +148,7 @@ function readStateText() {

145148

}

146149
147150

function configureMockOpenAi() {

148-

const mockPort = Number(process.argv[3]);

151+

const mockPort = parseMockOpenAiPort(process.argv[3]);

149152

const cfg = readJson(configPath());

150153

applyMockOpenAiModelConfig(cfg, { mockPort, includeImageDefaults: true });

151154

writeConfig(cfg);

Original file line numberDiff line numberDiff line change

@@ -7,7 +7,10 @@ import {

77

assertOpenAiRequestLogUsed,

88

} from "../agent-turn-output.mjs";

99

import { readBoundedResponseText as readBoundedResponseTextWithLimit } from "../bounded-response-text.mjs";

10-

import { applyMockOpenAiModelConfig } from "../fixtures/mock-openai-config.mjs";

10+

import {

11+

applyMockOpenAiModelConfig,

12+

parseMockOpenAiPort,

13+

} from "../fixtures/mock-openai-config.mjs";

1114

import { readPluginInstallRecords } from "../plugin-index-sqlite.mjs";

1215

import { readTextFileTail } from "../text-file-utils.mjs";

1316

@@ -192,7 +195,7 @@ function assertOnboard() {

192195

}

193196
194197

function configureMockModel() {

195-

const mockPort = Number(process.argv[3]);

198+

const mockPort = parseMockOpenAiPort(process.argv[3]);

196199

const cfg = readJson(configPath());

197200

applyMockOpenAiModelConfig(cfg, { mockPort });

198201

writeConfig(cfg);

Original file line numberDiff line numberDiff line change

@@ -84,6 +84,17 @@ function runOnboardAssert(home: string) {

8484

});

8585

}

8686
87+

function runMockModelAssert(home: string, command: string, port: string) {

88+

return spawnSync(process.execPath, [assertionsPath, command, port], {

89+

encoding: "utf8",

90+

env: {

91+

...process.env,

92+

HOME: home,

93+

NODE_OPTIONS: nodeOptionsWithoutExperimentalWarnings(),

94+

},

95+

});

96+

}

97+
8798

function runStatusAssert(

8899

channel: string,

89100

channelsStatus: unknown,

@@ -110,6 +121,22 @@ function runStatusAssert(

110121

}

111122
112123

describe("npm onboard channel agent assertions", () => {

124+

it("rejects loose mock OpenAI port args", () => {

125+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-onboard-assertions-"));

126+
127+

try {

128+

for (const command of ["configure-mock-model", "assert-mock-model-config"]) {

129+

const result = runMockModelAssert(tempDir, command, "1e3");

130+
131+

expect(result.status).not.toBe(0);

132+

expect(result.stderr).toContain("mock OpenAI port must be a TCP port from 1 to 65535");

133+

expect(result.stderr).toContain('"1e3"');

134+

}

135+

} finally {

136+

fs.rmSync(tempDir, { force: true, recursive: true });

137+

}

138+

});

139+
113140

it("validates OpenAI env refs from the SQLite auth profile store", () => {

114141

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-onboard-assertions-"));

115142

const agentDir = path.join(tempDir, ".openclaw", "agents", "main", "agent");

Original file line numberDiff line numberDiff line change

@@ -55,6 +55,14 @@ function writeAuthProfileStoreSqlite(agentDir: string, store: unknown) {

5555

}

5656
5757

describe("release scenario assertions", () => {

58+

it("rejects loose mock OpenAI port args", () => {

59+

const result = runAssertion(["configure-mock-openai", "1e3"]);

60+
61+

expect(result.status).not.toBe(0);

62+

expect(result.stderr).toContain("mock OpenAI port must be a TCP port from 1 to 65535");

63+

expect(result.stderr).toContain('"1e3"');

64+

});

65+
5866

it("scans large files when checking release scenario output text", () => {

5967

const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-scenarios-"));

6068

const outputPath = path.join(root, "output.log");

Original file line numberDiff line numberDiff line change

@@ -88,6 +88,21 @@ async function startTcpFixtureServer(handler: (socket: Socket) => void): Promise

8888

}

8989
9090

describe("release user journey assertions", () => {

91+

it("rejects loose mock OpenAI port args", () => {

92+

const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-user-assertions-"));

93+

const home = path.join(root, "home");

94+
95+

try {

96+

const result = runAssertion(home, ["configure-mock-model", "1e3"]);

97+
98+

expect(result.status).not.toBe(0);

99+

expect(result.stderr).toContain("mock OpenAI port must be a TCP port from 1 to 65535");

100+

expect(result.stderr).toContain('"1e3"');

101+

} finally {

102+

rmSync(root, { force: true, recursive: true });

103+

}

104+

});

105+
91106

it("scans large files when checking release user journey output text", () => {

92107

const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-user-assertions-"));

93108

const home = path.join(root, "home");