diff --git a/apps/backend/src/oauth/ssrf-protection.test.ts b/apps/backend/src/oauth/ssrf-protection.test.ts index 330fb7f25..68b001db3 100644 --- a/apps/backend/src/oauth/ssrf-protection.test.ts +++ b/apps/backend/src/oauth/ssrf-protection.test.ts @@ -1,19 +1,14 @@ import { StatusError } from "@hexclave/shared/dist/utils/errors"; -import { describe, expect, it } from "vitest"; +import { describe, expect, it, vi } from "vitest"; import dns from "node:dns"; import { assertSafeOAuthResolvedAddress, assertSafeOAuthUrlWithoutDns, isBlockedOAuthIpAddress, safeOAuthDnsLookup } from "./ssrf-protection"; async function withProductionNodeEnv(callback: () => Promise): Promise { - const previousNodeEnv = process.env.NODE_ENV; - process.env.NODE_ENV = "production"; + vi.stubEnv("NODE_ENV", "production"); try { return await callback(); } finally { - if (previousNodeEnv === undefined) { - delete process.env.NODE_ENV; - } else { - process.env.NODE_ENV = previousNodeEnv; - } + vi.unstubAllEnvs(); } }