feat: Faillock-Warnung bei wiederholten Fehlversuchen
Zeigt nach dem 2. fehlgeschlagenen Login-Versuch einen Hinweis an, dass das Konto nach dem nächsten Fehlversuch gesperrt werden kann (faillock default: 3 Versuche).
This commit is contained in:
@@ -10,6 +10,7 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from moongreet.greeter import faillock_warning, FAILLOCK_MAX_ATTEMPTS
|
||||
from moongreet.ipc import create_session, post_auth_response, start_session, cancel_session
|
||||
|
||||
|
||||
@@ -177,6 +178,31 @@ class TestLoginFlow:
|
||||
assert mock.received[1] == {"type": "cancel_session"}
|
||||
|
||||
|
||||
class TestFaillockWarning:
|
||||
"""Tests for the faillock warning message logic."""
|
||||
|
||||
def test_no_warning_on_first_attempt(self) -> None:
|
||||
assert faillock_warning(1) is None
|
||||
|
||||
def test_warning_on_second_attempt(self) -> None:
|
||||
warning = faillock_warning(2)
|
||||
assert warning is not None
|
||||
assert "1" in warning # 1 Versuch übrig
|
||||
|
||||
def test_warning_on_third_attempt(self) -> None:
|
||||
warning = faillock_warning(3)
|
||||
assert warning is not None
|
||||
assert "gesperrt" in warning.lower()
|
||||
|
||||
def test_warning_beyond_max_attempts(self) -> None:
|
||||
warning = faillock_warning(4)
|
||||
assert warning is not None
|
||||
assert "gesperrt" in warning.lower()
|
||||
|
||||
def test_max_attempts_constant_is_three(self) -> None:
|
||||
assert FAILLOCK_MAX_ATTEMPTS == 3
|
||||
|
||||
|
||||
class TestLastUser:
|
||||
"""Tests for saving and loading the last logged-in user."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user