Skip to content

Commit 79ac476

Browse files
steipeteampagent
andauthored
1 parent 3e6aec1 commit 79ac476

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎extensions/browser/src/browser/cdp.helpers.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Browser tests cover cdp.helpers plugin behavior.
22
import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";
33
import { afterEach, describe, expect, it, vi } from "vitest";
4+
import type { LookupFn } from "../infra/net/ssrf.js";
45
import {
56
assertChromeMcpCdpTransportAllowed,
67
resolveCdpReachabilityPolicy,
@@ -13,6 +14,11 @@ const PROFILE_HTTP_REACHABILITY_TIMEOUT_MS = 300;
1314
const PROFILE_WS_REACHABILITY_MIN_TIMEOUT_MS = 200;
1415
const PROFILE_WS_REACHABILITY_MAX_TIMEOUT_MS = 2000;
1516

17+
function createLookupFn(address: string): LookupFn {
18+
const family = address.includes(":") ? 6 : 4;
19+
return vi.fn(async () => [{ address, family }]) as unknown as LookupFn;
20+
}
21+
1622
const fetchWithSsrFGuardMock = vi.hoisted(() => vi.fn());
1723

1824
vi.mock("openclaw/plugin-sdk/ssrf-runtime", async (importOriginal) => {
@@ -167,7 +173,7 @@ describe("cdp helpers", () => {
167173
await expect(
168174
resolvePinnedHostnameWithPolicy("browser.example", {
169175
policy: scoped,
170-
lookupFn: async () => [{ address: "10.0.0.8", family: 4 }],
176+
lookupFn: createLookupFn("10.0.0.8"),
171177
}),
172178
).rejects.toThrow(/private\/internal\/special-use ip address/i);
173179
});
@@ -188,7 +194,7 @@ describe("cdp helpers", () => {
188194
await expect(
189195
resolvePinnedHostnameWithPolicy("browser.example", {
190196
policy: scoped,
191-
lookupFn: async () => [{ address: "10.0.0.8", family: 4 }],
197+
lookupFn: createLookupFn("10.0.0.8"),
192198
}),
193199
).resolves.toEqual(expect.objectContaining({ addresses: ["10.0.0.8"] }));
194200
});

0 commit comments

Comments
 (0)