mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +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
|
||||
mockGetLoginSettings.mockResolvedValue({ passwordCheckLifetime: { seconds: BigInt(86400) } });
|
||||
mockGetLoginSettings.mockResolvedValue({ passwordCheckLifetime: { seconds: BigInt(86400) }, allowLocalAuthentication: true });
|
||||
|
||||
// 4. Create session success
|
||||
mockCreateSessionAndUpdateCookie.mockResolvedValue({
|
||||
|
||||
@@ -330,7 +330,7 @@ describe("sendPassword", () => {
|
||||
test("should return generic error when user not found and ignoreUnknownUsernames is true", async () => {
|
||||
mockGetSessionCookieByLoginName.mockResolvedValue(null);
|
||||
mockSearchUsers.mockResolvedValue({ result: [] });
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true });
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true, allowLocalAuthentication: true });
|
||||
|
||||
const result = await sendPassword({
|
||||
loginName: "[email protected]",
|
||||
@@ -343,7 +343,7 @@ describe("sendPassword", () => {
|
||||
test("should return specific error when user not found and ignoreUnknownUsernames is false", async () => {
|
||||
mockGetSessionCookieByLoginName.mockResolvedValue(null);
|
||||
mockSearchUsers.mockResolvedValue({ result: [] });
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false });
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false, allowLocalAuthentication: true });
|
||||
|
||||
const result = await sendPassword({
|
||||
loginName: "[email protected]",
|
||||
@@ -358,7 +358,7 @@ describe("sendPassword", () => {
|
||||
mockSearchUsers.mockResolvedValue({
|
||||
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
||||
});
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true });
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true, allowLocalAuthentication: true });
|
||||
mockCreateSessionAndUpdateCookie.mockRejectedValue({ failedAttempts: 1 });
|
||||
|
||||
const result = await sendPassword({
|
||||
@@ -374,7 +374,7 @@ describe("sendPassword", () => {
|
||||
mockSearchUsers.mockResolvedValue({
|
||||
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)
|
||||
mockCreateSessionAndUpdateCookie.mockRejectedValue(new Error("Some internal error"));
|
||||
|
||||
@@ -391,7 +391,7 @@ describe("sendPassword", () => {
|
||||
mockSearchUsers.mockResolvedValue({
|
||||
result: [{ userId: "user123", type: { case: "human", value: {} }, state: 1 }],
|
||||
});
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false });
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: false, allowLocalAuthentication: true });
|
||||
mockCreateSessionAndUpdateCookie.mockRejectedValue({ failedAttempts: 1 });
|
||||
mockGetLockoutSettings.mockResolvedValue({ maxPasswordAttempts: BigInt(5) });
|
||||
|
||||
@@ -415,7 +415,7 @@ describe("sendPassword", () => {
|
||||
const terminatedError = { message: "session already terminated" };
|
||||
mockSetSessionAndUpdateCookie.mockRejectedValue(terminatedError);
|
||||
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true });
|
||||
mockGetLoginSettings.mockResolvedValue({ ignoreUnknownUsernames: true, allowLocalAuthentication: true });
|
||||
|
||||
mockSearchUsers.mockResolvedValue({
|
||||
result: [
|
||||
|
||||
Reference in New Issue
Block a user