feat: add additional test for handlePasswordValidation (#5243)

This commit is contained in:
Joe Previte 2022-06-06 14:20:22 -04:00 committed by GitHub
parent 792e954937
commit d75883bcc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -349,6 +349,22 @@ describe("isCookieValid", () => {
}) })
expect(isValid).toBe(false) expect(isValid).toBe(false)
}) })
it("should return false and empty string as hashedPassword when passwordMethod is invalid", async () => {
const p = "password1"
const passwordValidation = await util.handlePasswordValidation({
// @ts-expect-error although this shouldn't ever happen, it ensures the default case in this function
// works as expected.
passwordMethod: "INVALID",
passwordFromRequestBody: p,
passwordFromArgs: undefined,
hashedPasswordFromArgs: undefined,
})
const matchesHash = await util.isHashMatch(p, passwordValidation.hashedPassword)
expect(passwordValidation.isPasswordValid).toBe(false)
expect(matchesHash).toBe(false)
})
}) })
describe("sanitizeString", () => { describe("sanitizeString", () => {