mirror of https://git.tuxpa.in/a/code-server.git
feat: add test for hash when error (#4814)
This commit is contained in:
parent
fd643dcbc3
commit
00224fa73a
|
@ -157,12 +157,7 @@ export const generatePassword = async (length = 24): Promise<string> => {
|
|||
* Used to hash the password.
|
||||
*/
|
||||
export const hash = async (password: string): Promise<string> => {
|
||||
try {
|
||||
return await argon2.hash(password)
|
||||
} catch (error: any) {
|
||||
logger.error(error)
|
||||
return ""
|
||||
}
|
||||
return await argon2.hash(password)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -104,6 +104,10 @@ describe("hash", () => {
|
|||
const hashed = await util.hash(plainTextPassword)
|
||||
expect(hashed).not.toBe(plainTextPassword)
|
||||
})
|
||||
it("should return a hash for an empty string", async () => {
|
||||
const hashed = await util.hash("")
|
||||
expect(hashed).not.toBe("")
|
||||
})
|
||||
})
|
||||
|
||||
describe("isHashMatch", () => {
|
||||
|
|
Loading…
Reference in New Issue