Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+66
-3
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { resolveApiSessionCookiePolicy, resolveSessionCookiePolicy } from "./session-cookie.js";
|
||||
import { resolveApiSessionCookiePolicy, resolveHostOnlyCookiePolicy, resolveSessionCookiePolicy, resolveWebSessionCookiePolicy } from "./session-cookie.js";
|
||||
|
||||
const productionRouting = {
|
||||
appBaseDomain: "example.com",
|
||||
@@ -72,7 +72,7 @@ describe("session cookie policy", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("resolves API session cookies with the API name and shared production hardening", () => {
|
||||
test("resolves API session cookies with the API name and host-only production hardening", () => {
|
||||
const policy = resolveApiSessionCookiePolicy({
|
||||
nodeEnv: "production",
|
||||
routing: productionRouting,
|
||||
@@ -82,13 +82,13 @@ describe("session cookie policy", () => {
|
||||
expect(policy).toEqual({
|
||||
name: "hivegrid_api_session",
|
||||
maxAge: 900,
|
||||
domain: "example.com",
|
||||
sameSite: "lax",
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
path: "/",
|
||||
});
|
||||
expect(policy.name).not.toBe("hivegrid_session");
|
||||
expect(policy).not.toHaveProperty("domain");
|
||||
expect(JSON.stringify(policy)).not.toContain("secret");
|
||||
});
|
||||
|
||||
@@ -109,4 +109,67 @@ describe("session cookie policy", () => {
|
||||
path: "/",
|
||||
});
|
||||
});
|
||||
|
||||
test("uses distinct secure and local names for arbitrary host-only auth cookies", () => {
|
||||
expect(
|
||||
resolveHostOnlyCookiePolicy({
|
||||
nodeEnv: "test",
|
||||
routing: productionRouting,
|
||||
secureName: "__Host-hivegrid_auth_marker",
|
||||
localName: "hivegrid_auth_marker",
|
||||
maxAge: 60,
|
||||
})
|
||||
).toEqual({
|
||||
name: "__Host-hivegrid_auth_marker",
|
||||
maxAge: 60,
|
||||
sameSite: "lax",
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
path: "/",
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveHostOnlyCookiePolicy({
|
||||
nodeEnv: "development",
|
||||
routing: { appBaseDomain: "localhost:3000", protocol: "http" },
|
||||
secureName: "__Host-hivegrid_auth_marker",
|
||||
localName: "hivegrid_auth_marker",
|
||||
})
|
||||
).toMatchObject({ name: "hivegrid_auth_marker", secure: false, path: "/" });
|
||||
});
|
||||
|
||||
test.each(["app", "admin"] as const)("uses a distinct host-prefixed production cookie for the %s surface", (surface) => {
|
||||
const policy = resolveWebSessionCookiePolicy({
|
||||
nodeEnv: "production",
|
||||
routing: productionRouting,
|
||||
surface,
|
||||
maxAge: 900,
|
||||
});
|
||||
|
||||
expect(policy).toEqual({
|
||||
name: `__Host-hivegrid_${surface}_session`,
|
||||
maxAge: 900,
|
||||
sameSite: surface === "admin" ? "strict" : "lax",
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
path: "/",
|
||||
});
|
||||
expect(policy).not.toHaveProperty("domain");
|
||||
});
|
||||
|
||||
test.each(["app", "admin"] as const)("uses a localhost-compatible host-only cookie for the %s surface", (surface) => {
|
||||
const policy = resolveWebSessionCookiePolicy({
|
||||
nodeEnv: "development",
|
||||
routing: { appBaseDomain: "localhost:3000", protocol: "http" },
|
||||
surface,
|
||||
});
|
||||
|
||||
expect(policy).toMatchObject({
|
||||
name: `hivegrid_${surface}_session`,
|
||||
sameSite: surface === "admin" ? "strict" : "lax",
|
||||
secure: false,
|
||||
path: "/",
|
||||
});
|
||||
expect(policy).not.toHaveProperty("domain");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user