Removes every other screen, API route, component, test and the dependencies only they used. Cookie colite_admin, Co-Lite branding, BO_USERS/BO_ROLES modules only. The user form no longer loads branches, events or country scope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { NextRequest } from "next/server";
|
|
import { middleware } from "./middleware";
|
|
import { sealSession } from "@/app/lib/sessionSeal";
|
|
|
|
// sign-session-cookies (F32): the route guard reads only a signed session cookie.
|
|
const SESSION = { token: "jwt", resetPasswordRequired: false, absoluteExpiry: 4102444800 };
|
|
|
|
function page(cookie: string): NextRequest {
|
|
return new NextRequest(new URL("/dashboard", "https://portal.test"), { headers: { cookie: "__Host-colite_admin=" + cookie } });
|
|
}
|
|
|
|
describe("middleware: signed session cookie", () => {
|
|
it("lets a signed-in visitor through", async () => {
|
|
const res = await middleware(page(await sealSession(SESSION)));
|
|
expect(res.headers.get("x-middleware-next")).toBe("1");
|
|
});
|
|
|
|
it("sends a visitor with an edited cookie to login", async () => {
|
|
const obj = JSON.parse(decodeURIComponent(await sealSession(SESSION)));
|
|
obj.token = "forged";
|
|
const res = await middleware(page(encodeURIComponent(JSON.stringify(obj))));
|
|
expect(res.headers.get("location")).toContain("/login");
|
|
});
|
|
|
|
it("sends a visitor with an unsigned cookie to login", async () => {
|
|
const res = await middleware(page(encodeURIComponent(JSON.stringify(SESSION))));
|
|
expect(res.headers.get("location")).toContain("/login");
|
|
});
|
|
});
|