Skip to content

Commit

Permalink
feat(email): use smtp protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Oct 24, 2024
1 parent 56a8154 commit f144fe9
Show file tree
Hide file tree
Showing 18 changed files with 339 additions and 88 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FROM base AS prod-deps
RUN corepack enable
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=bind,source=packages/email/package.json,target=packages/email/package.json \
--mount=type=cache,target=/root/.npm \
npm ci --omit=dev

Expand All @@ -14,6 +15,7 @@ RUN corepack enable
ENV CYPRESS_INSTALL_BINARY=0
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=bind,source=packages/email/package.json,target=packages/email/package.json \
--mount=type=cache,target=/root/.npm \
npm ci
COPY tsconfig.json vite.config.mjs ./
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/delete_totp/fixtures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ INSERT INTO users
(id, email, email_verified, email_verified_at, encrypted_password, created_at, updated_at,
given_name, family_name, phone_number, job, encrypted_totp_key, totp_key_verified_at, force_2fa)
VALUES
(1, '[email protected]', true, CURRENT_TIMESTAMP,
(1, '[email protected]', true, CURRENT_TIMESTAMP,
'$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP,
'Jean', 'Jean', '0123456789', 'Sbire',
'Rogal', 'Dorn', 'VII', 'Primarque',
'kuOSXGk68H2B3pYnph0uyXAHrmpbWaWyX/iX49xVaUc=.VMPBZSO+eAng7mjS.cI2kRY9rwhXchcKiiaMZIg==',
CURRENT_TIMESTAMP, true
),
(2, '[email protected]', true, CURRENT_TIMESTAMP,
(2, '[email protected]', true, CURRENT_TIMESTAMP,
'$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP,
'Jean2', 'Jean2', '0123456789', 'Sbire',
'Konrad', 'Curze', 'VIII', 'Primarque',
'kuOSXGk68H2B3pYnph0uyXAHrmpbWaWyX/iX49xVaUc=.VMPBZSO+eAng7mjS.cI2kRY9rwhXchcKiiaMZIg==',
CURRENT_TIMESTAMP, true
);
Expand Down
69 changes: 22 additions & 47 deletions cypress/e2e/delete_totp/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,58 @@
describe("delete TOTP connexion", () => {
before(() => {
cy.mailslurp().then((mailslurp) =>
mailslurp.inboxController.deleteAllInboxEmails({
inboxId: "eab4ab97-875d-4ec7-bdcc-04323948ee63",
}),
);
cy.mailslurp().then((mailslurp) =>
mailslurp.inboxController.deleteAllInboxEmails({
inboxId: "c9fabb94-9274-4ece-a3d0-54b1987c8588",
}),
);
});

it("should delete TOTP application", function () {
cy.visit("/connection-and-account");

cy.mfaLogin("[email protected]");
cy.mfaLogin("[email protected]");

cy.contains("Configurer un code à usage unique");

cy.contains("Supprimer l’application d’authentification").click();

cy.contains("L’application d’authentification a bien été supprimée.");

cy.mailslurp()
// use inbox id and a timeout of 30 seconds
.then((mailslurp) =>
mailslurp.waitForLatestEmail(
"eab4ab97-875d-4ec7-bdcc-04323948ee63",
60000,
true,
),
)
// check subject of deletion email
.then((email) => {
expect(email.subject).to.include(
"Suppression d'une application d'authentification à double facteur",
);
});
cy.maildevGetMessageBySubject(
"Suppression d'une application d'authentification à double facteur",
).then((email) => {
cy.maildevVisitMessageById(email.id);
cy.contains(
"L'application a été supprimée comme étape de connexion à deux facteurs.",
);
cy.maildevDeleteMessageById(email.id);
});
});

it("should not be ask to sign with TOTP", function () {
cy.visit("http://localhost:4000");
cy.get("button.proconnect-button").click();
cy.login("[email protected]");
cy.login("[email protected]");

cy.contains('"amr": [\n "pwd"\n ],');
});

it("should disable TOTP", function () {
cy.visit("/connection-and-account");

cy.mfaLogin("[email protected]");
cy.mfaLogin("[email protected]");

cy.contains("Validation en deux étapes");

cy.contains("Désactiver la validation en deux étapes").click();

cy.mailslurp()
// use inbox id and a timeout of 30 seconds
.then((mailslurp) =>
mailslurp.waitForLatestEmail(
"c9fabb94-9274-4ece-a3d0-54b1987c8588",
60000,
true,
),
)
// check subject of deletion email
.then((email) => {
expect(email.subject).to.include(
"Désactivation de la validation en deux étapes",
);
});
cy.maildevGetMessageBySubject(
"Désactivation de la validation en deux étapes",
).then((email) => {
cy.maildevVisitMessageById(email.id);
cy.contains(
"Votre compte ProConnect n'est plus protégé par la validation en deux étapes.",
);
cy.maildevDeleteMessageById(email.id);
});
});

it("should not be ask to sign with TOTP", function () {
cy.visit("http://localhost:4000");
cy.get("button.proconnect-button").click();
cy.login("[email protected]");
cy.login("[email protected]");

cy.contains('"amr": [\n "pwd"\n ],');
});
Expand Down
Loading

0 comments on commit f144fe9

Please sign in to comment.