docs: document web search fetch tests · openclaw/openclaw@caa9078
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Cloudflare Markdown web_fetch tests cover direct markdown extraction, |
| 2 | +// provider bypass, and privacy-safe token logging. |
1 | 3 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { LookupFn } from "../../infra/net/ssrf.js"; |
3 | 5 | import * as logger from "../../logger.js"; |
@@ -99,6 +101,8 @@ describe("web_fetch Cloudflare Markdown for Agents", () => {
|
99 | 101 | }); |
100 | 102 | |
101 | 103 | it("bypasses Firecrawl when runtime metadata marks Firecrawl inactive", async () => { |
| 104 | +// Runtime metadata is authoritative for the current credential snapshot; a |
| 105 | +// stale configured provider should not force provider fallback. |
102 | 106 | const fetchSpy = vi |
103 | 107 | .fn() |
104 | 108 | .mockResolvedValue( |
@@ -149,6 +153,8 @@ describe("web_fetch Cloudflare Markdown for Agents", () => {
|
149 | 153 | }); |
150 | 154 | |
151 | 155 | it("logs x-markdown-tokens when header is present", async () => { |
| 156 | +// Token diagnostics are useful, but the logged URL must be scrubbed before |
| 157 | +// query strings or private paths reach debug output. |
152 | 158 | const logSpy = vi.spyOn(logger, "logDebug").mockImplementation(() => {}); |
153 | 159 | const fetchSpy = vi |
154 | 160 | .fn() |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Shared web_search provider tests cover module-local cache isolation. |
1 | 2 | import { describe, expect, it, vi } from "vitest"; |
2 | 3 | |
3 | 4 | describe("web_search shared cache", () => { |
4 | 5 | it("keeps cache entries module-local instead of exposing them on a global symbol", async () => { |
| 6 | +// Cache state should die with the module instance; a global symbol would |
| 7 | +// leak search payloads across tests, sessions, and plugin reloads. |
5 | 8 | vi.resetModules(); |
6 | 9 | delete (globalThis as Record<PropertyKey, unknown>)[Symbol.for("openclaw.web-search.cache")]; |
7 | 10 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// web_search redirect tests cover SSRF-guarded citation URL resolution. |
1 | 2 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | |
3 | 4 | const { withStrictWebToolsEndpointMock } = vi.hoisted(() => ({ |
@@ -21,6 +22,8 @@ describe("web_search redirect resolution hardening", () => {
|
21 | 22 | }); |
22 | 23 | |
23 | 24 | it("resolves redirects via SSRF-guarded HEAD requests", async () => { |
| 25 | +// Citation redirect resolution still touches arbitrary URLs, so it must |
| 26 | +// route through the strict guarded fetch wrapper. |
24 | 27 | withStrictWebToolsEndpointMock.mockImplementation(async (_params, run) => { |
25 | 28 | return await run({ |
26 | 29 | response: new Response(null, { status: 200 }), |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// web_search signal tests cover abort propagation from the agent tool wrapper |
| 2 | +// into provider runtime execution. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { createWebSearchTool } from "./web-search.js"; |
3 | 5 | |
@@ -20,6 +22,8 @@ describe("web_search signal plumbing", () => {
|
20 | 22 | }); |
21 | 23 | |
22 | 24 | it("passes the agent abort signal into web search runtime execution", async () => { |
| 25 | +// Provider execution can be long-running; the outer agent cancellation |
| 26 | +// signal must reach the runtime path. |
23 | 27 | const controller = new AbortController(); |
24 | 28 | const tool = createWebSearchTool({ config: {} }); |
25 | 29 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。