Skip to content

feat: add additional test for handlePassswordValidation #5243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/unit/node/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,22 @@ describe("isCookieValid", () => {
})
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", () => {
Expand Down