Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/config/src/session-cookie.branches.test.ts
T
2026-07-08 16:15:37 +02:00

24 lines
890 B
TypeScript

import { describe, expect, test } from "vitest";
import { resolveSessionCookiePolicy } from "./session-cookie.js";
describe("session cookie domain resolution for bracketed IPv6 hosts", () => {
test("keeps loopback IPv6 cookies domainless", () => {
const policy = resolveSessionCookiePolicy({
nodeEnv: "development",
routing: { appBaseDomain: "[::1]:3000", protocol: "http" },
});
expect(policy).not.toHaveProperty("domain");
expect(policy).toMatchObject({ sameSite: "lax", secure: false, httpOnly: true, path: "/" });
});
test("derives the bracket-stripped hostname for routable IPv6 base domains", () => {
const policy = resolveSessionCookiePolicy({
nodeEnv: "production",
routing: { appBaseDomain: "[2001:db8::1]:8443", protocol: "https" },
});
expect(policy).toMatchObject({ domain: "2001:db8::1", secure: true });
});
});