import { describe, expect, mock, test } from "bun:test"; const fakeEnv: Record = { INTEGRATIONS_ALLOW_LOOPBACK: "true", GITFOR_LOCAL: "true", PUBLIC_URL: "https://gitfor.dev", }; mock.module("cloudflare:workers", () => ({ env: fakeEnv, waitUntil: () => undefined })); const { isAllowedLoopback, loopbackSinksAllowed } = await import("./outbound"); describe("INTEGRATIONS_ALLOW_LOOPBACK (DEPLOY-P6)", () => { test("is ignored on a deployed forge", () => { fakeEnv.PUBLIC_URL = "https://gitfor.dev"; expect(loopbackSinksAllowed()).toBe(false); expect(isAllowedLoopback(new URL("http://localhost:9000/hook"))).toBe(false); }); test("works on a loopback forge", () => { fakeEnv.PUBLIC_URL = "http://localhost:3000"; expect(isAllowedLoopback(new URL("http://localhost:9000/hook"))).toBe(true); }); });