Files
demat-facturation/server/_core/cookies.test.ts

31 lines
881 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from "vitest";
import type { Request } from "express";
import { getSessionCookieOptions } from "./cookies";
function requestFor(protocol: "http" | "https", forwardedProto?: string): Request {
return {
protocol,
headers: forwardedProto ? { "x-forwarded-proto": forwardedProto } : {},
} as Request;
}
describe("getSessionCookieOptions", () => {
it("utilise des cookies sécurisés derrière le proxy HTTPS", () => {
expect(getSessionCookieOptions(requestFor("http", "https"))).toMatchObject({
httpOnly: true,
path: "/",
secure: true,
sameSite: "none",
});
});
it("reste compatible avec lenvironnement HTTP local", () => {
expect(getSessionCookieOptions(requestFor("http"))).toMatchObject({
httpOnly: true,
path: "/",
secure: false,
sameSite: "lax",
});
});
});