forked from PalisadoesFoundation/talawa-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d298c1
commit f45df1c
Showing
4 changed files
with
41 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ describe("encryptionModule", () => { | |
const originalKey = process.env.ENCRYPTION_KEY; | ||
process.env.ENCRYPTION_KEY = "invalid_key"; | ||
expect(() => encryptEmail("[email protected]")).toThrow( | ||
"Encryption key must be a 256-bit hexadecimal string (64 characters).", | ||
"Encryption key must be a valid 256-bit hexadecimal string (64 characters).", | ||
); | ||
process.env.ENCRYPTION_KEY = originalKey; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { hashEmail } from "../../src/utilities/hashEmail"; | ||
import { setHashPepper } from "../../setup"; | ||
|
||
describe("hashingModule", () => { | ||
describe("hashingEmail", () => { | ||
|
@@ -29,21 +30,29 @@ describe("hashingModule", () => { | |
expect(() => hashEmail(undefined as unknown as string)).toThrow(); | ||
}); | ||
|
||
it("should produce different hashes with different HASH_PEPPER values", () => { | ||
it("should produce different hashes with different HASH_PEPPER values", async () => { | ||
const email = "[email protected]"; | ||
const originalPepper = process.env.HASH_PEPPER; | ||
if (!originalPepper) { | ||
throw new Error("HASH_PEPPER environment variable is required"); | ||
} | ||
try { | ||
process.env.HASH_PEPPER = "pepper1"; | ||
const hash1 = hashEmail(email); | ||
process.env.HASH_PEPPER = "pepper2"; | ||
const hash2 = hashEmail(email); | ||
expect(hash1).not.toEqual(hash2); | ||
} finally { | ||
process.env.HASH_PEPPER = originalPepper; | ||
} | ||
}); | ||
const pepper1 = await setHashPepper(); | ||
const pepper2 = await setHashPepper(); | ||
if(pepper1 != undefined && pepper2 != undefined) | ||
{ | ||
|
||
process.env.HASH_PEPPER = pepper1; | ||
const hash1 = hashEmail(email); | ||
process.env.HASH_PEPPER = "pepper2"; | ||
const hash2 = hashEmail(email); | ||
expect(hash1).not.toEqual(hash2); | ||
} | ||
} | ||
finally { | ||
process.env.HASH_PEPPER = originalPepper; | ||
} | ||
} | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters