Skip to content

Commit d75883b

Browse files
authored
feat: add additional test for handlePasswordValidation (#5243)
1 parent 792e954 commit d75883b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/unit/node/util.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,22 @@ describe("isCookieValid", () => {
349349
})
350350
expect(isValid).toBe(false)
351351
})
352+
it("should return false and empty string as hashedPassword when passwordMethod is invalid", async () => {
353+
const p = "password1"
354+
const passwordValidation = await util.handlePasswordValidation({
355+
// @ts-expect-error although this shouldn't ever happen, it ensures the default case in this function
356+
// works as expected.
357+
passwordMethod: "INVALID",
358+
passwordFromRequestBody: p,
359+
passwordFromArgs: undefined,
360+
hashedPasswordFromArgs: undefined,
361+
})
362+
363+
const matchesHash = await util.isHashMatch(p, passwordValidation.hashedPassword)
364+
365+
expect(passwordValidation.isPasswordValid).toBe(false)
366+
expect(matchesHash).toBe(false)
367+
})
352368
})
353369

354370
describe("sanitizeString", () => {

0 commit comments

Comments
 (0)