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", {
|
||||
data: {
|
||||
userId: "123",
|
||||
email: {
|
||||
email: "john@zitadel.com",
|
||||
userId: "221394658884845598",
|
||||
},
|
||||
profile: {
|
||||
givenName: "John",
|
||||
familyName: "Doe",
|
||||
});
|
||||
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: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,54 +1,89 @@
|
||||
import { stub } from "../support/mock";
|
||||
|
||||
describe("verify invite", () => {
|
||||
// beforeEach(() => {
|
||||
// stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||
// data: {
|
||||
// details: {
|
||||
// totalResult: 1,
|
||||
// },
|
||||
// result: [{ id: "256088834543534543" }],
|
||||
// },
|
||||
// });
|
||||
beforeEach(() => {
|
||||
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||
data: {
|
||||
details: {
|
||||
totalResult: 1,
|
||||
},
|
||||
result: [{ id: "256088834543534543" }],
|
||||
},
|
||||
});
|
||||
|
||||
// stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
||||
// data: {
|
||||
// authMethodTypes: [],
|
||||
// },
|
||||
// });
|
||||
stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
||||
data: {
|
||||
authMethodTypes: [],
|
||||
},
|
||||
});
|
||||
|
||||
// stub("zitadel.user.v2.UserService", "GetUserById", {
|
||||
// data: {
|
||||
// user: {
|
||||
// userId: "221394658884845598",
|
||||
// state: 1,
|
||||
// username: "john@zitadel.com",
|
||||
// loginNames: ["john@zitadel.com"],
|
||||
// preferredLoginName: "john@zitadel.com",
|
||||
// human: {
|
||||
// userId: "221394658884845598",
|
||||
// state: 1,
|
||||
// username: "john@zitadel.com",
|
||||
// loginNames: ["john@zitadel.com"],
|
||||
// preferredLoginName: "john@zitadel.com",
|
||||
// profile: {
|
||||
// givenName: "John",
|
||||
// familyName: "Doe",
|
||||
// avatarUrl: "https://zitadel.com/avatar.jpg",
|
||||
// },
|
||||
// email: {
|
||||
// email: "john@zitadel.com",
|
||||
// isVerified: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
stub("zitadel.user.v2.UserService", "GetUserByID", {
|
||||
data: {
|
||||
user: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
human: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
profile: {
|
||||
givenName: "John",
|
||||
familyName: "Doe",
|
||||
avatarUrl: "https://zitadel.com/avatar.jpg",
|
||||
},
|
||||
email: {
|
||||
email: "john@zitadel.com",
|
||||
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", () => {
|
||||
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(
|
||||
"eq",
|
||||
"/authenticator/set",
|
||||
@@ -62,32 +97,32 @@ describe("verify invite", () => {
|
||||
});
|
||||
// TODO: Avoid uncaught exception in application
|
||||
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 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("verify email", () => {
|
||||
// beforeEach(() => {
|
||||
// stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||
// data: {
|
||||
// details: {
|
||||
// totalResult: 1,
|
||||
// },
|
||||
// result: [{ id: "256088834543534543" }],
|
||||
// },
|
||||
// });
|
||||
beforeEach(() => {
|
||||
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||
data: {
|
||||
details: {
|
||||
totalResult: 1,
|
||||
},
|
||||
result: [{ id: "256088834543534543" }],
|
||||
},
|
||||
});
|
||||
|
||||
// stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
||||
// data: {
|
||||
// authMethodTypes: [],
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
||||
data: {
|
||||
authMethodTypes: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("shows password and passkey method after successful invite verification", () => {
|
||||
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(
|
||||
"eq",
|
||||
"/authenticator/set",
|
||||
@@ -101,7 +136,7 @@ describe("verify email", () => {
|
||||
});
|
||||
// TODO: Avoid uncaught exception in application
|
||||
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 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
zitadel/user/v2/user_service.proto
|
||||
zitadel/org/v2/org_service.proto
|
||||
zitadel/session/v2/session_service.proto
|
||||
zitadel/settings/v2/settings_service.proto
|
||||
zitadel/management.proto
|
||||
|
||||
@@ -25,7 +25,7 @@ export function ChooseAuthenticatorToSetup({
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
{loginSettings.passkeysType === PasskeysType.ALLOWED &&
|
||||
{loginSettings.passkeysType === PasskeysType.NOT_ALLOWED &&
|
||||
!loginSettings.allowUsernamePassword && (
|
||||
<Alert type={AlertType.ALERT}>{t("noMethodsAvailable")}</Alert>
|
||||
)}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { Alert } from "@/components/alert";
|
||||
import { resendVerification, sendVerification } from "@/lib/server/email";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { Button, ButtonVariants } from "./button";
|
||||
@@ -35,8 +34,6 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
|
||||
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
async function resendCode() {
|
||||
setError("");
|
||||
setLoading(true);
|
||||
|
||||
@@ -74,7 +74,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
|
||||
if (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) {
|
||||
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,
|
||||
undefined,
|
||||
command.authRequestId,
|
||||
).then((session) => {
|
||||
return {
|
||||
userId: human.userId,
|
||||
sessionId: session.id,
|
||||
factors: session.factors,
|
||||
};
|
||||
});
|
||||
);
|
||||
|
||||
if (!session || !session.factors?.user) {
|
||||
return { error: "Could not create session" };
|
||||
@@ -83,9 +77,9 @@ export async function registerUser(command: RegisterUserCommand) {
|
||||
organization: session.factors.user.organizationId,
|
||||
});
|
||||
|
||||
if (command.authRequestId && session.userId) {
|
||||
if (command.authRequestId && session.factors.user.id) {
|
||||
params.append("authRequest", command.authRequestId);
|
||||
params.append("sessionId", session.sessionId);
|
||||
params.append("sessionId", session.id);
|
||||
|
||||
return redirect("/login?" + params);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user