All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 50s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 lines
643 B
TypeScript
14 lines
643 B
TypeScript
import "../setup.ts";
|
|
import { assert, assertFalse } from "@std/assert";
|
|
import { isAuthPayload, isPasswordResetPayload } from "../../model/auth.ts";
|
|
|
|
Deno.test("isAuthPayload refuses purpose-scoped tokens", () => {
|
|
const base = { userId: "u", username: "n", role: "user", exp: 1 };
|
|
assert(isAuthPayload(base));
|
|
assertFalse(isAuthPayload({ ...base, purpose: "media" }));
|
|
assertFalse(isAuthPayload({ ...base, role: "root" }));
|
|
assertFalse(isAuthPayload({ ...base, exp: "1" }));
|
|
assert(isPasswordResetPayload({ purpose: "password-reset", userId: "u" }));
|
|
assertFalse(isPasswordResetPayload({ purpose: "media", userId: "u" }));
|
|
});
|