





















@@ -39,17 +39,14 @@ describe("web-guarded-fetch", () => {
39394040await withTrustedWebToolsEndpoint({ url: "https://example.com" }, async () => undefined);
414142-expect(fetchWithSsrFGuard).toHaveBeenCalledWith(
43-expect.objectContaining({
44-url: "https://example.com",
45-policy: {
46-allowRfc2544BenchmarkRange: true,
47-allowIpv6UniqueLocalRange: true,
48-hostnameAllowlist: ["example.com"],
49-},
50-mode: GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY,
51-}),
52-);
42+const call = vi.mocked(fetchWithSsrFGuard).mock.calls[0]?.[0];
43+expect(call?.url).toBe("https://example.com");
44+expect(call?.policy).toEqual({
45+allowRfc2544BenchmarkRange: true,
46+allowIpv6UniqueLocalRange: true,
47+hostnameAllowlist: ["example.com"],
48+});
49+expect(call?.mode).toBe(GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY);
5350});
54515552it("uses private-network policy only for self-hosted web tools endpoints", async () => {
@@ -61,17 +58,12 @@ describe("web-guarded-fetch", () => {
61586259await withSelfHostedWebToolsEndpoint({ url: "http://127.0.0.1:8080" }, async () => undefined);
636064-expect(fetchWithSsrFGuard).toHaveBeenCalledWith(
65-expect.objectContaining({
66-url: "http://127.0.0.1:8080",
67-policy: expect.objectContaining({
68-dangerouslyAllowPrivateNetwork: true,
69-allowRfc2544BenchmarkRange: true,
70-allowIpv6UniqueLocalRange: true,
71-}),
72-mode: GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY,
73-}),
74-);
61+const call = vi.mocked(fetchWithSsrFGuard).mock.calls[0]?.[0];
62+expect(call?.url).toBe("http://127.0.0.1:8080");
63+expect(call?.policy?.dangerouslyAllowPrivateNetwork).toBe(true);
64+expect(call?.policy?.allowRfc2544BenchmarkRange).toBe(true);
65+expect(call?.policy?.allowIpv6UniqueLocalRange).toBe(true);
66+expect(call?.mode).toBe(GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY);
7567});
76687769it("keeps strict endpoint policy unchanged", async () => {
@@ -83,12 +75,8 @@ describe("web-guarded-fetch", () => {
83758476await withStrictWebToolsEndpoint({ url: "https://example.com" }, async () => undefined);
857786-expect(fetchWithSsrFGuard).toHaveBeenCalledWith(
87-expect.objectContaining({
88-url: "https://example.com",
89-}),
90-);
9178const call = vi.mocked(fetchWithSsrFGuard).mock.calls[0]?.[0];
79+expect(call?.url).toBe("https://example.com");
9280expect(call?.policy).toBeUndefined();
9381expect(call?.mode).toBe(GUARDED_FETCH_MODE.STRICT);
9482});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。