Skip to content

Commit

Permalink
fix: mail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kan-A-Pesh committed Dec 1, 2024
1 parent 37d2a2c commit bddab4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion routes/auth/send-mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ export default async function Route_Auth_Sendmail(req: Request, res: Response, n
const [username, domain] = lowercaseEmail.split("@");
const parsedEmail = `${username.replace(".", "")}@${domain}`.replace(/\+.*@/g, "@");

Logger.log("email", bodyPayload.data.email);
Logger.log("lowercaseEmail", lowercaseEmail);
Logger.log("parsedEmail", parsedEmail);

if (!isAdmin(req)) {
if (/^[a-zA-Z0-9._%-]+@edu\.devinci\.fr$/.test(parsedEmail) === false) {
if (/^[a-zA-Z0-9_-]+@edu\.devinci\.fr$/.test(parsedEmail) === false) {
return Status.send(req, next, {
status: 400,
error: "errors.auth.invalid.email"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Test authentication", () => {
});

test("should get 'too many requests' error", async () => {
const res = await post(app, "/auth/send-mail", { email: email });
const res = await post(app, "/auth/send-mail", { email: email }, { "X-ADMIN-KEY": globals.env.ADMIN_TOKEN });

expect(res.body).toStrictEqual({
masterStatus: 429,
Expand Down

0 comments on commit bddab4b

Please sign in to comment.