mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-17 08:02:12 -06:00
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
/**
|
|
* Test mocks that pin Browser SSRF DNS lookups to a public example address.
|
|
*/
|
|
import { vi } from "vitest";
|
|
|
|
const lookupFn = vi.hoisted(() => async (_hostname: string, options?: { all?: boolean }) => {
|
|
const result = { address: "93.184.216.34", family: 4 };
|
|
return options?.all === true ? [result] : result;
|
|
});
|
|
|
|
vi.mock("../infra/net/ssrf.js", async () => {
|
|
const actual =
|
|
await vi.importActual<typeof import("../infra/net/ssrf.js")>("../infra/net/ssrf.js");
|
|
return {
|
|
...actual,
|
|
resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) =>
|
|
actual.resolvePinnedHostnameWithPolicy(hostname, { ...params, lookupFn: lookupFn as never }),
|
|
};
|
|
});
|
|
|
|
vi.mock("../sdk-security-runtime.js", async () => {
|
|
const actual = await vi.importActual<typeof import("../sdk-security-runtime.js")>(
|
|
"../sdk-security-runtime.js",
|
|
);
|
|
return {
|
|
...actual,
|
|
resolvePinnedHostnameWithPolicy: (hostname: string, params: object = {}) =>
|
|
actual.resolvePinnedHostnameWithPolicy(hostname, { ...params, lookupFn: lookupFn as never }),
|
|
};
|
|
});
|