mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 14:54:33 +00:00
fix tests
This commit is contained in:
@@ -12,13 +12,40 @@ describe("register", () => {
|
|||||||
});
|
});
|
||||||
stub("zitadel.user.v2.UserService", "AddHumanUser", {
|
stub("zitadel.user.v2.UserService", "AddHumanUser", {
|
||||||
data: {
|
data: {
|
||||||
userId: "123",
|
userId: "221394658884845598",
|
||||||
email: {
|
},
|
||||||
email: "john@zitadel.com",
|
});
|
||||||
|
stub("zitadel.session.v2.SessionService", "CreateSession", {
|
||||||
|
data: {
|
||||||
|
details: {
|
||||||
|
sequence: 859,
|
||||||
|
changeDate: new Date("2024-04-04T09:40:55.577Z"),
|
||||||
|
resourceOwner: "220516472055706145",
|
||||||
},
|
},
|
||||||
profile: {
|
sessionId: "221394658884845598",
|
||||||
givenName: "John",
|
sessionToken:
|
||||||
familyName: "Doe",
|
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
||||||
|
challenges: undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
password: undefined,
|
||||||
|
webAuthN: undefined,
|
||||||
|
intent: undefined,
|
||||||
|
},
|
||||||
|
metadata: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,54 +1,89 @@
|
|||||||
import { stub } from "../support/mock";
|
import { stub } from "../support/mock";
|
||||||
|
|
||||||
describe("verify invite", () => {
|
describe("verify invite", () => {
|
||||||
// beforeEach(() => {
|
beforeEach(() => {
|
||||||
// stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||||
// data: {
|
data: {
|
||||||
// details: {
|
details: {
|
||||||
// totalResult: 1,
|
totalResult: 1,
|
||||||
// },
|
},
|
||||||
// result: [{ id: "256088834543534543" }],
|
result: [{ id: "256088834543534543" }],
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
|
|
||||||
// stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
||||||
// data: {
|
data: {
|
||||||
// authMethodTypes: [],
|
authMethodTypes: [],
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
|
|
||||||
// stub("zitadel.user.v2.UserService", "GetUserById", {
|
stub("zitadel.user.v2.UserService", "GetUserByID", {
|
||||||
// data: {
|
data: {
|
||||||
// user: {
|
user: {
|
||||||
// userId: "221394658884845598",
|
userId: "221394658884845598",
|
||||||
// state: 1,
|
state: 1,
|
||||||
// username: "john@zitadel.com",
|
username: "john@zitadel.com",
|
||||||
// loginNames: ["john@zitadel.com"],
|
loginNames: ["john@zitadel.com"],
|
||||||
// preferredLoginName: "john@zitadel.com",
|
preferredLoginName: "john@zitadel.com",
|
||||||
// human: {
|
human: {
|
||||||
// userId: "221394658884845598",
|
userId: "221394658884845598",
|
||||||
// state: 1,
|
state: 1,
|
||||||
// username: "john@zitadel.com",
|
username: "john@zitadel.com",
|
||||||
// loginNames: ["john@zitadel.com"],
|
loginNames: ["john@zitadel.com"],
|
||||||
// preferredLoginName: "john@zitadel.com",
|
preferredLoginName: "john@zitadel.com",
|
||||||
// profile: {
|
profile: {
|
||||||
// givenName: "John",
|
givenName: "John",
|
||||||
// familyName: "Doe",
|
familyName: "Doe",
|
||||||
// avatarUrl: "https://zitadel.com/avatar.jpg",
|
avatarUrl: "https://zitadel.com/avatar.jpg",
|
||||||
// },
|
},
|
||||||
// email: {
|
email: {
|
||||||
// email: "john@zitadel.com",
|
email: "john@zitadel.com",
|
||||||
// isVerified: true,
|
isVerified: false, // email is not verified yet
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
// });
|
|
||||||
|
stub("zitadel.session.v2.SessionService", "CreateSession", {
|
||||||
|
data: {
|
||||||
|
details: {
|
||||||
|
sequence: 859,
|
||||||
|
changeDate: new Date("2024-04-04T09:40:55.577Z"),
|
||||||
|
resourceOwner: "220516472055706145",
|
||||||
|
},
|
||||||
|
sessionId: "221394658884845598",
|
||||||
|
sessionToken:
|
||||||
|
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
||||||
|
challenges: undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
password: undefined,
|
||||||
|
webAuthN: undefined,
|
||||||
|
intent: undefined,
|
||||||
|
},
|
||||||
|
metadata: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it.only("shows authenticators after successful invite verification", () => {
|
it.only("shows authenticators after successful invite verification", () => {
|
||||||
stub("zitadel.user.v2.UserService", "VerifyInviteCode");
|
stub("zitadel.user.v2.UserService", "VerifyInviteCode");
|
||||||
cy.visit("/verify?userId=123&code=abc&invite=true");
|
cy.visit("/verify?userId=221394658884845598&code=abc&invite=true");
|
||||||
cy.location("pathname", { timeout: 10_000 }).should(
|
cy.location("pathname", { timeout: 10_000 }).should(
|
||||||
"eq",
|
"eq",
|
||||||
"/authenticator/set",
|
"/authenticator/set",
|
||||||
@@ -62,32 +97,32 @@ describe("verify invite", () => {
|
|||||||
});
|
});
|
||||||
// TODO: Avoid uncaught exception in application
|
// TODO: Avoid uncaught exception in application
|
||||||
cy.once("uncaught:exception", () => false);
|
cy.once("uncaught:exception", () => false);
|
||||||
cy.visit("/verify?userId=123&code=abc&invite=true");
|
cy.visit("/verify?userId=221394658884845598&code=abc&invite=true");
|
||||||
cy.contains("Could not verify invite", { timeout: 10_000 });
|
cy.contains("Could not verify invite", { timeout: 10_000 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("verify email", () => {
|
describe("verify email", () => {
|
||||||
// beforeEach(() => {
|
beforeEach(() => {
|
||||||
// stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||||
// data: {
|
data: {
|
||||||
// details: {
|
details: {
|
||||||
// totalResult: 1,
|
totalResult: 1,
|
||||||
// },
|
},
|
||||||
// result: [{ id: "256088834543534543" }],
|
result: [{ id: "256088834543534543" }],
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
|
|
||||||
// stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
||||||
// data: {
|
data: {
|
||||||
// authMethodTypes: [],
|
authMethodTypes: [],
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
it("shows password and passkey method after successful invite verification", () => {
|
it("shows password and passkey method after successful invite verification", () => {
|
||||||
stub("zitadel.user.v2.UserService", "VerifyEmail");
|
stub("zitadel.user.v2.UserService", "VerifyEmail");
|
||||||
cy.visit("/verify?userId=123&code=abc");
|
cy.visit("/verify?userId=221394658884845598&code=abc");
|
||||||
cy.location("pathname", { timeout: 10_000 }).should(
|
cy.location("pathname", { timeout: 10_000 }).should(
|
||||||
"eq",
|
"eq",
|
||||||
"/authenticator/set",
|
"/authenticator/set",
|
||||||
@@ -101,7 +136,7 @@ describe("verify email", () => {
|
|||||||
});
|
});
|
||||||
// TODO: Avoid uncaught exception in application
|
// TODO: Avoid uncaught exception in application
|
||||||
cy.once("uncaught:exception", () => false);
|
cy.once("uncaught:exception", () => false);
|
||||||
cy.visit("/verify?userId=123&code=abc&submit=true");
|
cy.visit("/verify?userId=221394658884845598&code=abc&submit=true");
|
||||||
cy.contains("Could not verify email", { timeout: 10_000 });
|
cy.contains("Could not verify email", { timeout: 10_000 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
zitadel/user/v2/user_service.proto
|
zitadel/user/v2/user_service.proto
|
||||||
|
zitadel/org/v2/org_service.proto
|
||||||
zitadel/session/v2/session_service.proto
|
zitadel/session/v2/session_service.proto
|
||||||
zitadel/settings/v2/settings_service.proto
|
zitadel/settings/v2/settings_service.proto
|
||||||
zitadel/management.proto
|
zitadel/management.proto
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export function ChooseAuthenticatorToSetup({
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{loginSettings.passkeysType === PasskeysType.ALLOWED &&
|
{loginSettings.passkeysType === PasskeysType.NOT_ALLOWED &&
|
||||||
!loginSettings.allowUsernamePassword && (
|
!loginSettings.allowUsernamePassword && (
|
||||||
<Alert type={AlertType.ALERT}>{t("noMethodsAvailable")}</Alert>
|
<Alert type={AlertType.ALERT}>{t("noMethodsAvailable")}</Alert>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import { Alert } from "@/components/alert";
|
import { Alert } from "@/components/alert";
|
||||||
import { resendVerification, sendVerification } from "@/lib/server/email";
|
import { resendVerification, sendVerification } from "@/lib/server/email";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { Button, ButtonVariants } from "./button";
|
import { Button, ButtonVariants } from "./button";
|
||||||
@@ -35,8 +34,6 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
|
|||||||
|
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
async function resendCode() {
|
async function resendCode() {
|
||||||
setError("");
|
setError("");
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
|
|||||||
if (session.factors?.user?.loginName) {
|
if (session.factors?.user?.loginName) {
|
||||||
params.set("loginName", session.factors?.user?.loginName);
|
params.set("loginName", session.factors?.user?.loginName);
|
||||||
}
|
}
|
||||||
return redirect("/authenticator/set?" + params);
|
return redirect(`/authenticator/set?${params}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +134,6 @@ export async function sendVerificationRedirectWithoutCheck(command: {
|
|||||||
if (session.factors?.user?.loginName) {
|
if (session.factors?.user?.loginName) {
|
||||||
params.set("loginName", session.factors?.user?.loginName);
|
params.set("loginName", session.factors?.user?.loginName);
|
||||||
}
|
}
|
||||||
return redirect("/authenticator/set?" + params);
|
return redirect(`/authenticator/set?${params}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,13 +54,7 @@ export async function registerUser(command: RegisterUserCommand) {
|
|||||||
checks,
|
checks,
|
||||||
undefined,
|
undefined,
|
||||||
command.authRequestId,
|
command.authRequestId,
|
||||||
).then((session) => {
|
);
|
||||||
return {
|
|
||||||
userId: human.userId,
|
|
||||||
sessionId: session.id,
|
|
||||||
factors: session.factors,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!session || !session.factors?.user) {
|
if (!session || !session.factors?.user) {
|
||||||
return { error: "Could not create session" };
|
return { error: "Could not create session" };
|
||||||
@@ -83,9 +77,9 @@ export async function registerUser(command: RegisterUserCommand) {
|
|||||||
organization: session.factors.user.organizationId,
|
organization: session.factors.user.organizationId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (command.authRequestId && session.userId) {
|
if (command.authRequestId && session.factors.user.id) {
|
||||||
params.append("authRequest", command.authRequestId);
|
params.append("authRequest", command.authRequestId);
|
||||||
params.append("sessionId", session.sessionId);
|
params.append("sessionId", session.id);
|
||||||
|
|
||||||
return redirect("/login?" + params);
|
return redirect("/login?" + params);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user