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:
Livio Spring
2026-03-04 13:14:52 +01:00
committed by GitHub
parent 692797eafc
commit 80aaf52aae
2 changed files with 7 additions and 7 deletions
@@ -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({
+6 -6
View File
@@ -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: [