feat: complete MVP foundation auth and dashboard
This commit is contained in:
26
tests/proxy-auth.test.ts
Normal file
26
tests/proxy-auth.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { shouldRedirectDashboardRequest } from "../lib/proxy-auth";
|
||||
|
||||
test("shouldRedirectDashboardRequest protects dashboard paths without a valid mock cookie", () => {
|
||||
assert.equal(
|
||||
shouldRedirectDashboardRequest("/dashboard", undefined),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldRedirectDashboardRequest("/dashboard/leads", "wrong"),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("shouldRedirectDashboardRequest allows valid mock sessions and non-dashboard paths", () => {
|
||||
assert.equal(
|
||||
shouldRedirectDashboardRequest(
|
||||
"/dashboard",
|
||||
"mock-admin",
|
||||
),
|
||||
false,
|
||||
);
|
||||
assert.equal(shouldRedirectDashboardRequest("/audit/example", undefined), false);
|
||||
});
|
||||
Reference in New Issue
Block a user