mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-19 11:45:12 +00:00
test: fix login unit tests (#11761)
# Which Problems Are Solved The login unit tests broke due to a recent merge. # How the Problems Are Solved This PR fixes the broken tests. # Additional Changes None # Additional Context - requires backport to v4.x
This commit is contained in:
@@ -113,7 +113,7 @@ describe("sendPassword", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 3. Login settings
|
// 3. Login settings
|
||||||
mockGetLoginSettings.mockResolvedValue({ passwordCheckLifetime: { seconds: BigInt(86400) } });
|
mockGetLoginSettings.mockResolvedValue({ passwordCheckLifetime: { seconds: BigInt(86400) }, allowLocalAuthentication: true });
|
||||||
|
|
||||||
// 4. Create session success
|
// 4. Create session success
|
||||||
mockCreateSessionAndUpdateCookie.mockResolvedValue({
|
mockCreateSessionAndUpdateCookie.mockResolvedValue({
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ describe("sendPassword", () => {
|
|||||||
test("should return generic error when user not found and ignoreUnknownUsernames is true", async () => {
|
test("should return generic error when user not found and ignoreUnknownUsernames is true", async () => {
|
||||||
mockGetSessionCookieByLoginName.mockResolvedValue(null);
|
mockGetSessionCookieByLoginName.mockResolvedValue(null);
|
||||||
mockSearchUsers.mockResolvedValue({ result: [] });
|
mockSearchUsers.mockResolvedValue({ result: [] });
|
||||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true });
|
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true, allowLocalAuthentication: true });
|
||||||
|
|
||||||
const result = await sendPassword({
|
const result = await sendPassword({
|
||||||
loginName: "[email protected]",
|
loginName: "[email protected]",
|
||||||
@@ -343,7 +343,7 @@ describe("sendPassword", () => {
|
|||||||
test("should return specific error when user not found and ignoreUnknownUsernames is false", async () => {
|
test("should return specific error when user not found and ignoreUnknownUsernames is false", async () => {
|
||||||
mockGetSessionCookieByLoginName.mockResolvedValue(null);
|
mockGetSessionCookieByLoginName.mockResolvedValue(null);
|
||||||
mockSearchUsers.mockResolvedValue({ result: [] });
|
mockSearchUsers.mockResolvedValue({ result: [] });
|
||||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false });
|
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false, allowLocalAuthentication: true });
|
||||||
|
|
||||||
const result = await sendPassword({
|
const result = await sendPassword({
|
||||||
loginName: "[email protected]",
|
loginName: "[email protected]",
|
||||||
@@ -358,7 +358,7 @@ describe("sendPassword", () => {
|
|||||||
mockSearchUsers.mockResolvedValue({
|
mockSearchUsers.mockResolvedValue({
|
||||||
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
||||||
});
|
});
|
||||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true });
|
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true, allowLocalAuthentication: true });
|
||||||
mockCreateSessionAndUpdateCookie.mockRejectedValue({ failedAttempts: 1 });
|
mockCreateSessionAndUpdateCookie.mockRejectedValue({ failedAttempts: 1 });
|
||||||
|
|
||||||
const result = await sendPassword({
|
const result = await sendPassword({
|
||||||
@@ -374,7 +374,7 @@ describe("sendPassword", () => {
|
|||||||
mockSearchUsers.mockResolvedValue({
|
mockSearchUsers.mockResolvedValue({
|
||||||
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
||||||
});
|
});
|
||||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true });
|
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true, allowLocalAuthentication: true });
|
||||||
// Simulate an error that is NOT a failed attempt error (e.g. database error)
|
// Simulate an error that is NOT a failed attempt error (e.g. database error)
|
||||||
mockCreateSessionAndUpdateCookie.mockRejectedValue(new Error("Some internal error"));
|
mockCreateSessionAndUpdateCookie.mockRejectedValue(new Error("Some internal error"));
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ describe("sendPassword", () => {
|
|||||||
mockSearchUsers.mockResolvedValue({
|
mockSearchUsers.mockResolvedValue({
|
||||||
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
||||||
});
|
});
|
||||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false });
|
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false, allowLocalAuthentication: true });
|
||||||
mockCreateSessionAndUpdateCookie.mockRejectedValue({ failedAttempts: 1 });
|
mockCreateSessionAndUpdateCookie.mockRejectedValue({ failedAttempts: 1 });
|
||||||
mockGetLockoutSettings.mockResolvedValue({ maxPasswordAttempts: BigInt(5) });
|
mockGetLockoutSettings.mockResolvedValue({ maxPasswordAttempts: BigInt(5) });
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ describe("sendPassword", () => {
|
|||||||
const terminatedError = { message: "session already terminated" };
|
const terminatedError = { message: "session already terminated" };
|
||||||
mockSetSessionAndUpdateCookie.mockRejectedValue(terminatedError);
|
mockSetSessionAndUpdateCookie.mockRejectedValue(terminatedError);
|
||||||
|
|
||||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true });
|
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true, allowLocalAuthentication: true });
|
||||||
|
|
||||||
mockSearchUsers.mockResolvedValue({
|
mockSearchUsers.mockResolvedValue({
|
||||||
result: [
|
result: [
|
||||||
|
|||||||
Reference in New Issue
Block a user