Andrei Neagoie Python < 2026 >
def test_login_success(self, auth_service): auth_service.register_user("test@example.com", "ValidPass123!") token, user = auth_service.login("test@example.com", "ValidPass123!", "192.168.1.1") assert token is not None assert user.email == "test@example.com"
import jwt from jwt.exceptions import InvalidTokenError, ExpiredSignatureError class AuthenticationError(Exception): """Base exception for authentication errors""" pass andrei neagoie python
class ValidationError(AuthenticationError): """Raised when input validation fails""" pass def test_login_success(self, auth_service): auth_service
test_auth.py content: """
def test_rate_limiting(self, auth_service): auth_service.register_user("test@example.com", "ValidPass123!") ip = "192.168.1.100" # Try wrong password 5 times for _ in range(5): with pytest.raises(InvalidPasswordError): auth_service.login("test@example.com", "wrong", ip) # 6th attempt should trigger rate limit with pytest.raises(RateLimitExceededError): auth_service.login("test@example.com", "wrong", ip) user = auth_service.login("test@example.com"
