public
anord
read
Ledger
Why work hard when you can work easier?
Languages
Repository composition by tracked source files.
TypeScript
86%
CSS
10%
SQL
3%
Shell
1%
HTML
0%
Trace
apps/api/src/test/auth.test.ts
Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.
Author
Date
Commit
Line
Code
1
import { describe, expect, it } from "vitest";
2
import { createSessionToken, hashPassword, verifyPassword, verifySessionToken } from "../services/auth.js";
4
describe("auth helpers", () => {
5
it("hashes and verifies passwords", async () => {
6
const hash = await hashPassword("Password123!");
7
await expect(verifyPassword("Password123!", hash)).resolves.toBe(true);
8
await expect(verifyPassword("WrongPassword!", hash)).resolves.toBe(false);
9
});
11
it("creates and verifies session tokens", () => {
12
const token = createSessionToken({
13
id: "user-1",
14
email: "[email protected]",
15
displayName: "User",
16
role: "viewer",
17
groupIds: []
18
});
20
expect(verifySessionToken(token).email).toBe("[email protected]");
21
});
22
});