Skip to content

Commit 5819bfa

Browse files
committed
fix(ci): mock secureFetchWithPinnedIP in tools tests to prevent timeouts
1 parent 2eef467 commit 5819bfa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

apps/sim/tools/index.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const {
2626
mockListCustomTools,
2727
mockGetCustomToolByIdOrTitle,
2828
mockGenerateInternalToken,
29+
mockSecureFetchWithPinnedIP,
30+
mockValidateUrlWithDNS,
2931
} = vi.hoisted(() => ({
3032
mockIsHosted: { value: false },
3133
mockEnv: { NEXT_PUBLIC_APP_URL: 'http://localhost:3000' } as Record<string, string | undefined>,
@@ -40,6 +42,8 @@ const {
4042
mockListCustomTools: vi.fn(),
4143
mockGetCustomToolByIdOrTitle: vi.fn(),
4244
mockGenerateInternalToken: vi.fn(),
45+
mockSecureFetchWithPinnedIP: vi.fn(),
46+
mockValidateUrlWithDNS: vi.fn(),
4347
}))
4448

4549
// Mock feature flags
@@ -73,6 +77,11 @@ vi.mock('@/lib/auth/internal', () => ({
7377

7478
vi.mock('@/lib/billing/core/usage-log', () => ({}))
7579

80+
vi.mock('@/lib/core/security/input-validation.server', () => ({
81+
secureFetchWithPinnedIP: (...args: unknown[]) => mockSecureFetchWithPinnedIP(...args),
82+
validateUrlWithDNS: (...args: unknown[]) => mockValidateUrlWithDNS(...args),
83+
}))
84+
7685
vi.mock('@/lib/core/rate-limiter/hosted-key', () => ({
7786
getHostedKeyRateLimiter: () => mockRateLimiterFns,
7887
}))
@@ -476,6 +485,11 @@ describe('Automatic Internal Route Detection', () => {
476485
beforeEach(() => {
477486
process.env.NEXT_PUBLIC_APP_URL = 'http://localhost:3000'
478487
cleanupEnvVars = setupEnvVars({ NEXT_PUBLIC_APP_URL: 'http://localhost:3000' })
488+
489+
mockValidateUrlWithDNS.mockResolvedValue({ isValid: true, resolvedIP: '93.184.216.34' })
490+
mockSecureFetchWithPinnedIP.mockResolvedValue(
491+
new Response(JSON.stringify({}), { status: 200, headers: { 'content-type': 'application/json' } })
492+
)
479493
})
480494

481495
afterEach(() => {

0 commit comments

Comments
 (0)