mirror of
https://github.com/danog/code-server.git
synced 2024-11-30 04:39:46 +01:00
feat: add additional test for handlePasswordValidation (#5243)
This commit is contained in:
parent
792e954937
commit
d75883bcc6
@ -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", () => {
|
||||
|
Loading…
Reference in New Issue
Block a user