From 5819bfa564a26c1dd863fae69ea80a33f9fd151e Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 9 Apr 2026 14:22:19 -0700 Subject: [PATCH] fix(ci): mock secureFetchWithPinnedIP in tools tests to prevent timeouts --- apps/sim/tools/index.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/sim/tools/index.test.ts b/apps/sim/tools/index.test.ts index e3ecf97fae..aa0f983a2d 100644 --- a/apps/sim/tools/index.test.ts +++ b/apps/sim/tools/index.test.ts @@ -26,6 +26,8 @@ const { mockListCustomTools, mockGetCustomToolByIdOrTitle, mockGenerateInternalToken, + mockSecureFetchWithPinnedIP, + mockValidateUrlWithDNS, } = vi.hoisted(() => ({ mockIsHosted: { value: false }, mockEnv: { NEXT_PUBLIC_APP_URL: 'http://localhost:3000' } as Record, @@ -40,6 +42,8 @@ const { mockListCustomTools: vi.fn(), mockGetCustomToolByIdOrTitle: vi.fn(), mockGenerateInternalToken: vi.fn(), + mockSecureFetchWithPinnedIP: vi.fn(), + mockValidateUrlWithDNS: vi.fn(), })) // Mock feature flags @@ -73,6 +77,11 @@ vi.mock('@/lib/auth/internal', () => ({ vi.mock('@/lib/billing/core/usage-log', () => ({})) +vi.mock('@/lib/core/security/input-validation.server', () => ({ + secureFetchWithPinnedIP: (...args: unknown[]) => mockSecureFetchWithPinnedIP(...args), + validateUrlWithDNS: (...args: unknown[]) => mockValidateUrlWithDNS(...args), +})) + vi.mock('@/lib/core/rate-limiter/hosted-key', () => ({ getHostedKeyRateLimiter: () => mockRateLimiterFns, })) @@ -476,6 +485,11 @@ describe('Automatic Internal Route Detection', () => { beforeEach(() => { process.env.NEXT_PUBLIC_APP_URL = 'http://localhost:3000' cleanupEnvVars = setupEnvVars({ NEXT_PUBLIC_APP_URL: 'http://localhost:3000' }) + + mockValidateUrlWithDNS.mockResolvedValue({ isValid: true, resolvedIP: '93.184.216.34' }) + mockSecureFetchWithPinnedIP.mockResolvedValue( + new Response(JSON.stringify({}), { status: 200, headers: { 'content-type': 'application/json' } }) + ) }) afterEach(() => {