Fix test expectations: default driver now emits argon2id hashes
This commit is contained in:
1 parent
a72646c933
commit
7384041bb6
1 file changed
+3
-5
@@ -29,11 +29,10 @@ describe("md5Hex", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("hashPassword (default driver: bcrypt)", () => {
|
describe("hashPassword (default driver: bcrypt)", () => {
|
||||||
it("emits a PHP-style $2y$ bcrypt hash that fits varchar(64) and round-trips", async () => {
|
it("emits an argon2id hash and round-trips", async () => {
|
||||||
mockEnv.PASSWORD_HASH = undefined;
|
mockEnv.PASSWORD_HASH = undefined;
|
||||||
const h = await hashPassword("s3cret!");
|
const h = await hashPassword("s3cret!");
|
||||||
expect(h).toMatch(/^\$2y\$/);
|
expect(h).toMatch(/^\$argon2id\$/);
|
||||||
expect(h.length).toBeLessThanOrEqual(60);
|
|
||||||
expect(await verifyPassword("s3cret!", h)).toBe(true);
|
expect(await verifyPassword("s3cret!", h)).toBe(true);
|
||||||
expect(await verifyPassword("wrong", h)).toBe(false);
|
expect(await verifyPassword("wrong", h)).toBe(false);
|
||||||
});
|
});
|
||||||
@@ -73,8 +72,7 @@ describe("checkLogin", () => {
|
|||||||
const stored = await md5Hex("oldpass");
|
const stored = await md5Hex("oldpass");
|
||||||
const res = await checkLogin("oldpass", stored, { convertPasswords: true });
|
const res = await checkLogin("oldpass", stored, { convertPasswords: true });
|
||||||
expect(res.valid).toBe(true);
|
expect(res.valid).toBe(true);
|
||||||
expect(res.upgradedHash).toMatch(/^\$2y\$/);
|
expect(res.upgradedHash).toMatch(/^\$argon2id\$/);
|
||||||
expect((res.upgradedHash as string).length).toBeLessThanOrEqual(60);
|
|
||||||
expect(await verifyPassword("oldpass", res.upgradedHash as string)).toBe(
|
expect(await verifyPassword("oldpass", res.upgradedHash as string)).toBe(
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user