Add comprehensive API endpoint tests

This commit is contained in:
2025-10-19 18:23:23 +02:00
parent 68d83e2a39
commit a057432a3e
6 changed files with 424 additions and 33 deletions

View File

@@ -1,3 +1,4 @@
"""Tests for authentication API endpoints."""
import pytest
from httpx import ASGITransport, AsyncClient
@@ -5,11 +6,22 @@ from src.server.fastapi_app import app
from src.server.services.auth_service import auth_service
@pytest.fixture(autouse=True)
def reset_auth_state():
"""Reset auth service state before each test."""
# Clear any rate limiting state and password hash
if hasattr(auth_service, '_failed'):
auth_service._failed.clear()
auth_service._hash = None
yield
# Cleanup after test
if hasattr(auth_service, '_failed'):
auth_service._failed.clear()
@pytest.mark.anyio
async def test_auth_flow_setup_login_status_logout():
# Ensure not configured at start for test isolation
auth_service._hash = None
"""Test complete authentication flow."""
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as client:
# Setup