|
| 1 | +import { describe, expect, test } from "vitest"; |
| 2 | +import { getUinHash } from "../../../src/api/functions/uin.js"; |
| 3 | + |
| 4 | +describe("UIN hashing test", async () => { |
| 5 | + test("Hashes are the same as previously run", async () => { |
| 6 | + const pepper = "2c8feda7-17af-4cd1-b783-0097f61a99f9" |
| 7 | + const uin = "123456789"; |
| 8 | + const expectedHash = "$argon2id$v=19$m=65536,t=3,p=4$YWNtdWl1Y3Vpbg$nTyHsSnzvhe9+UIVEb/ol+k8dU1qTSEFoui6Hq8KbBY" |
| 9 | + const hashed = await getUinHash({ |
| 10 | + pepper, uin |
| 11 | + }); |
| 12 | + expect(hashed).toStrictEqual(expectedHash); |
| 13 | + }) |
| 14 | + test("Hashes are the same from run to run", async () => { |
| 15 | + const pepper = "c84b88f6-81cb-4748-b4a7-212431e10bbe" |
| 16 | + const uin = "123456789"; |
| 17 | + const hashed1 = await getUinHash({ |
| 18 | + pepper, uin |
| 19 | + }); |
| 20 | + const hashed2 = await getUinHash({ |
| 21 | + pepper, uin |
| 22 | + }); |
| 23 | + expect(hashed1).toStrictEqual(hashed2); |
| 24 | + }) |
| 25 | + test("Hashes are different from run to run", async () => { |
| 26 | + const pepper = "c84b88f6-81cb-4748-b4a7-212431e10bbe" |
| 27 | + const uin = "123456789"; |
| 28 | + const hashed1 = await getUinHash({ |
| 29 | + pepper, uin |
| 30 | + }); |
| 31 | + const hashed2 = await getUinHash({ |
| 32 | + pepper, uin: "987654321" |
| 33 | + }); |
| 34 | + expect(hashed1).not.toStrictEqual(hashed2); |
| 35 | + }) |
| 36 | +}) |
0 commit comments