馃 distributed transcription service
thistle.dunkirk.sh
1import { expect, test } from "bun:test";
2import { hashPasswordClient } from "./client-auth";
3
4test("hashPasswordClient produces consistent output", async () => {
5 const hash1 = await hashPasswordClient("password123", "user@example.com");
6 const hash2 = await hashPasswordClient("password123", "user@example.com");
7
8 expect(hash1).toBe(hash2);
9 expect(hash1).toHaveLength(64); // 32 bytes * 2 hex chars
10});
11
12test("hashPasswordClient produces different hashes for different passwords", async () => {
13 const hash1 = await hashPasswordClient("password123", "user@example.com");
14 const hash2 = await hashPasswordClient("different", "user@example.com");
15
16 expect(hash1).not.toBe(hash2);
17});
18
19test("hashPasswordClient produces different hashes for different emails", async () => {
20 const hash1 = await hashPasswordClient("password123", "user1@example.com");
21 const hash2 = await hashPasswordClient("password123", "user2@example.com");
22
23 expect(hash1).not.toBe(hash2);
24});
25
26test("hashPasswordClient is case-insensitive for email", async () => {
27 const hash1 = await hashPasswordClient("password123", "User@Example.Com");
28 const hash2 = await hashPasswordClient("password123", "user@example.com");
29
30 expect(hash1).toBe(hash2);
31});
32
33test("hashPasswordClient produces hex-encoded output", async () => {
34 const hash = await hashPasswordClient("test", "test@test.com");
35
36 // Should only contain hex characters
37 expect(hash).toMatch(/^[0-9a-f]+$/);
38});