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

推荐订阅源

D
Docker
I
InfoQ
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
博客园_首页
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
B
Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
F
Fortinet All Blogs
月光博客
月光博客
GbyAI
GbyAI

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: fix strict CI gates · openclaw/openclaw@9e58cc8
steipete · 2026-05-08 · via Recent Commits to openclaw:main

@@ -1,5 +1,6 @@

11

import crypto from "node:crypto";

22

import type { IncomingMessage, ServerResponse } from "node:http";

3+

import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";

34

import { createMockIncomingRequest } from "openclaw/plugin-sdk/test-env";

45

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

56

import { createLineNodeWebhookHandler, readLineWebhookRequestBody } from "./webhook-node.js";

@@ -29,6 +30,20 @@ function createRes() {

29303031

const SECRET = "secret";

313233+

type RuntimeEnvMock = RuntimeEnv & {

34+

error: ReturnType<typeof vi.fn<(...args: unknown[]) => void>>;

35+

exit: ReturnType<typeof vi.fn<(code: number) => void>>;

36+

log: ReturnType<typeof vi.fn<(...args: unknown[]) => void>>;

37+

};

38+39+

function createRuntimeMock(): RuntimeEnvMock {

40+

return {

41+

error: vi.fn<(...args: unknown[]) => void>(),

42+

exit: vi.fn<(code: number) => void>(),

43+

log: vi.fn<(...args: unknown[]) => void>(),

44+

};

45+

}

46+3247

function createMiddlewareRes() {

3348

const res = {

3449

status: vi.fn(),

@@ -42,7 +57,7 @@ function createMiddlewareRes() {

42574358

function createPostWebhookTestHarness(rawBody: string, secret = "secret") {

4459

const bot = { handleWebhook: vi.fn(async () => {}) };

45-

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

60+

const runtime = createRuntimeMock();

4661

const handler = createLineNodeWebhookHandler({

4762

channelSecret: secret,

4863

bot,

@@ -71,11 +86,7 @@ async function invokeWebhook(params: {

7186

headers?: Record<string, string>;

7287

onEvents?: ReturnType<typeof vi.fn>;

7388

autoSign?: boolean;

74-

runtime?: {

75-

log: ReturnType<typeof vi.fn>;

76-

error: ReturnType<typeof vi.fn>;

77-

exit: ReturnType<typeof vi.fn>;

78-

};

89+

runtime?: RuntimeEnv;

7990

}) {

8091

const onEventsMock = params.onEvents ?? vi.fn(async () => {});

8192

const middleware = createLineWebhookMiddleware({

@@ -138,7 +149,7 @@ async function invokeNodePostContract(params: {

138149

throw params.failWith;

139150

}

140151

});

141-

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

152+

const runtime = createRuntimeMock();

142153

const handler = createLineNodeWebhookHandler({

143154

channelSecret: SECRET,

144155

bot: { handleWebhook: dispatched },

@@ -167,7 +178,7 @@ async function invokeMiddlewarePostContract(params: {

167178

rawBody: string;

168179

signed: boolean;

169180

}) {

170-

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

181+

const runtime = createRuntimeMock();

171182

const onEvents = vi.fn(async () => {

172183

if (params.failWith) {

173184

throw params.failWith;

@@ -182,6 +193,7 @@ async function invokeMiddlewarePostContract(params: {

182193

});

183194

return {

184195

body: res.json.mock.calls.at(-1)?.[0],

196+

contentType: undefined,

185197

dispatched,

186198

runtimeError: runtime.error,

187199

status: res.status.mock.calls.at(-1)?.[0],

@@ -288,7 +300,7 @@ describe("LINE webhook shared POST contract", () => {

288300

describe("createLineNodeWebhookHandler", () => {

289301

it("returns 200 for GET", async () => {

290302

const bot = { handleWebhook: vi.fn(async () => {}) };

291-

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

303+

const runtime = createRuntimeMock();

292304

const handler = createLineNodeWebhookHandler({

293305

channelSecret: "secret",

294306

bot,

@@ -305,7 +317,7 @@ describe("createLineNodeWebhookHandler", () => {

305317306318

it("returns 204 for HEAD", async () => {

307319

const bot = { handleWebhook: vi.fn(async () => {}) };

308-

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

320+

const runtime = createRuntimeMock();

309321

const handler = createLineNodeWebhookHandler({

310322

channelSecret: "secret",

311323

bot,

@@ -333,7 +345,7 @@ describe("createLineNodeWebhookHandler", () => {

333345334346

it("rejects unsigned POST requests before reading the body", async () => {

335347

const bot = { handleWebhook: vi.fn(async () => {}) };

336-

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

348+

const runtime = createRuntimeMock();

337349

const readBody = vi.fn(async () => JSON.stringify({ events: [{ type: "message" }] }));

338350

const handler = createLineNodeWebhookHandler({

339351

channelSecret: "secret",

@@ -353,7 +365,7 @@ describe("createLineNodeWebhookHandler", () => {

353365

it("uses strict pre-auth limits for signed POST requests", async () => {

354366

const rawBody = JSON.stringify({ events: [{ type: "message" }] });

355367

const bot = { handleWebhook: vi.fn(async () => {}) };

356-

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

368+

const runtime = createRuntimeMock();

357369

const readBody = vi.fn(async (_req: IncomingMessage, maxBytes: number, timeoutMs?: number) => {

358370

expect(maxBytes).toBe(64 * 1024);

359371

expect(timeoutMs).toBe(5_000);

@@ -414,7 +426,7 @@ describe("createLineNodeWebhookHandler", () => {

414426

),

415427

};

416428

const onRequestAuthenticated = vi.fn();

417-

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

429+

const runtime = createRuntimeMock();

418430

const handler = createLineNodeWebhookHandler({

419431

channelSecret: SECRET,

420432

bot,