This commit is contained in:
peintnermax
2024-09-12 09:11:35 +02:00
parent 38f1bad24c
commit 99aea433ea

View File

@@ -1,12 +1,39 @@
import { timestampFromDate } from "@zitadel/client";
import { stub } from "../support/mock"; import { stub } from "../support/mock";
describe("/verify", () => { describe("/verify", () => {
it("if no MFA required, redirects to loginname after successful email verification", () => { it("if no MFA required, redirects to loginname after successful email verification", () => {
stub("zitadel.user.v2.UserService", "VerifyEmail"); stub("zitadel.user.v2.UserService", "VerifyEmail");
stub("zitadel.session.v2.SessionService", "GetSession", {
data: {
session: {
id: "221394658884845598",
creationDate: new Date("2024-04-04T09:40:55.577Z"),
changeDate: new Date("2024-04-04T09:40:55.577Z"),
sequence: 859,
factors: {
user: {
id: "221394658884845598",
loginName: "john@zitadel.com",
},
otpEmail: {
// set a factor
verifiedAt: timestampFromDate(
new Date("2024-04-04T09:40:55.577Z"),
),
},
password: undefined,
webAuthN: undefined,
intent: undefined,
},
metadata: {},
},
},
});
cy.visit("/verify?userId=123&code=abc&submit=true"); cy.visit("/verify?userId=123&code=abc&submit=true");
cy.location("pathname", { timeout: 10_000 }).should("eq", "/loginname"); cy.location("pathname", { timeout: 10_000 }).should("eq", "/loginname");
}); });
it("if MFA is required, redirects to mfa/set after successful email verification", () => { it("if MFA is required and no mfa factor is found, redirects to mfa/set after successful email verification", () => {
stub("zitadel.settings.v2.SettingsService", "GetLoginSettings", { stub("zitadel.settings.v2.SettingsService", "GetLoginSettings", {
data: { data: {
settings: { settings: {
@@ -15,31 +42,27 @@ describe("/verify", () => {
}, },
}); });
stub("zitadel.user.v2.UserService", "VerifyEmail"); stub("zitadel.user.v2.UserService", "VerifyEmail");
// stub("zitadel.session.v2.SessionService", "GetSession", { stub("zitadel.session.v2.SessionService", "GetSession", {
// data: { data: {
// session: { session: {
// id: "221394658884845598", id: "221394658884845598",
// creationDate: new Date("2024-04-04T09:40:55.577Z"), creationDate: new Date("2024-04-04T09:40:55.577Z"),
// changeDate: new Date("2024-04-04T09:40:55.577Z"), changeDate: new Date("2024-04-04T09:40:55.577Z"),
// sequence: 859, sequence: 859,
// factors: { factors: {
// user: { user: {
// id: "221394658884845598", id: "221394658884845598",
// loginName: "john@zitadel.com", loginName: "john@zitadel.com",
// }, },
// otpEmail: { // set a factor otpEmail: undefined,
// verifiedAt: timestampFromDate( password: undefined,
// new Date("2024-04-04T09:40:55.577Z"), webAuthN: undefined,
// ), intent: undefined,
// }, },
// password: undefined, metadata: {},
// webAuthN: undefined, },
// intent: undefined, },
// }, });
// metadata: {},
// },
// },
// });
cy.visit("/verify?userId=123&code=abc&submit=true"); cy.visit("/verify?userId=123&code=abc&submit=true");
cy.location("pathname", { timeout: 10_000 }).should("eq", "/mfa/set"); cy.location("pathname", { timeout: 10_000 }).should("eq", "/mfa/set");
}); });