






















@@ -320,12 +320,9 @@ describe("fetchWithTimeoutGuarded", () => {
320320321321await fetchWithTimeoutGuarded("https://example.com", {}, undefined, fetch);
322322323-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
324-expect.objectContaining({
325-url: "https://example.com",
326-timeoutMs: 60_000,
327-}),
328-);
323+const call = getFirstGuardedFetchCall();
324+expect(call.url).toBe("https://example.com");
325+expect(call.timeoutMs).toBe(60_000);
329326});
330327331328it("sanitizes auditContext before passing it to the SSRF guard", async () => {
@@ -339,12 +336,9 @@ describe("fetchWithTimeoutGuarded", () => {
339336auditContext: "provider-http\r\nfal\timage\u001btest",
340337});
341338342-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
343-expect.objectContaining({
344-auditContext: "provider-http fal image test",
345-timeoutMs: 5000,
346-}),
347-);
339+const call = getFirstGuardedFetchCall();
340+expect(call.auditContext).toBe("provider-http fal image test");
341+expect(call.timeoutMs).toBe(5000);
348342});
349343350344it("passes configured explicit proxy policy through the SSRF guard", async () => {
@@ -365,14 +359,10 @@ describe("fetchWithTimeoutGuarded", () => {
365359},
366360});
367361368-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
369-expect.objectContaining({
370-dispatcherPolicy: {
371-mode: "explicit-proxy",
372-proxyUrl: "http://169.254.169.254:8080",
373-},
374-}),
375-);
362+expect(getFirstGuardedFetchCall().dispatcherPolicy).toEqual({
363+mode: "explicit-proxy",
364+proxyUrl: "http://169.254.169.254:8080",
365+});
376366});
377367378368it("forwards explicit pinDns overrides to JSON requests", async () => {
@@ -390,11 +380,7 @@ describe("fetchWithTimeoutGuarded", () => {
390380pinDns: false,
391381});
392382393-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
394-expect.objectContaining({
395-pinDns: false,
396-}),
397-);
383+expect(getFirstGuardedFetchCall().pinDns).toBe(false);
398384});
399385400386it("forwards explicit pinDns overrides to transcription requests", async () => {
@@ -412,11 +398,7 @@ describe("fetchWithTimeoutGuarded", () => {
412398pinDns: false,
413399});
414400415-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
416-expect.objectContaining({
417-pinDns: false,
418-}),
419-);
401+expect(getFirstGuardedFetchCall().pinDns).toBe(false);
420402});
421403422404it("does not set a guarded fetch mode when no HTTP proxy env is configured", async () => {
@@ -448,11 +430,7 @@ describe("fetchWithTimeoutGuarded", () => {
448430fetchFn: fetch,
449431});
450432451-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
452-expect.objectContaining({
453-mode: "trusted_env_proxy",
454-}),
455-);
433+expect(getFirstGuardedFetchCall().mode).toBe("trusted_env_proxy");
456434});
457435458436it("respects an explicit mode from the caller when HTTP proxy env is configured", async () => {
@@ -467,11 +445,7 @@ describe("fetchWithTimeoutGuarded", () => {
467445mode: "strict",
468446});
469447470-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
471-expect.objectContaining({
472-mode: "strict",
473-}),
474-);
448+expect(getFirstGuardedFetchCall().mode).toBe("strict");
475449});
476450477451it("auto-upgrades transcription requests to trusted env proxy when proxy env is configured", async () => {
@@ -489,11 +463,7 @@ describe("fetchWithTimeoutGuarded", () => {
489463fetchFn: fetch,
490464});
491465492-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
493-expect.objectContaining({
494-mode: "trusted_env_proxy",
495-}),
496-);
466+expect(getFirstGuardedFetchCall().mode).toBe("trusted_env_proxy");
497467});
498468499469it("forwards an explicit mode override through postJsonRequest even when proxy env is configured", async () => {
@@ -512,11 +482,7 @@ describe("fetchWithTimeoutGuarded", () => {
512482mode: "strict",
513483});
514484515-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
516-expect.objectContaining({
517-mode: "strict",
518-}),
519-);
485+expect(getFirstGuardedFetchCall().mode).toBe("strict");
520486});
521487522488it("forwards an explicit mode override through postTranscriptionRequest even when proxy env is configured", async () => {
@@ -535,11 +501,7 @@ describe("fetchWithTimeoutGuarded", () => {
535501mode: "strict",
536502});
537503538-expect(fetchWithSsrFGuardMock).toHaveBeenCalledWith(
539-expect.objectContaining({
540-mode: "strict",
541-}),
542-);
504+expect(getFirstGuardedFetchCall().mode).toBe("strict");
543505});
544506545507it("does not auto-upgrade when only ALL_PROXY is configured (HTTP(S) proxy gate)", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。