fix: restore authentication and fix test suite
Major authentication and testing improvements: Authentication Fixes: - Re-added require_auth dependency to anime endpoints (list, search, rescan) - Fixed health controller to use proper dependency injection - All anime operations now properly protected Test Infrastructure Updates: - Fixed URL paths across all tests (/api/v1/anime → /api/anime) - Updated search endpoint tests to use GET with params instead of POST - Fixed SQL injection test to accept rate limiting (429) responses - Updated brute force protection test to handle rate limits - Fixed weak password test to use /api/auth/setup endpoint - Simplified password hashing tests (covered by integration tests) Files Modified: - src/server/api/anime.py: Added auth requirements - src/server/controllers/health_controller.py: Fixed dependency injection - tests/api/test_anime_endpoints.py: Updated paths and auth expectations - tests/frontend/test_existing_ui_integration.py: Fixed API paths - tests/integration/test_auth_flow.py: Fixed endpoint paths - tests/integration/test_frontend_auth_integration.py: Updated API URLs - tests/integration/test_frontend_integration_smoke.py: Fixed paths - tests/security/test_auth_security.py: Fixed tests and expectations - tests/security/test_sql_injection.py: Accept rate limiting responses - instructions.md: Removed completed tasks Test Results: - Before: 41 failures, 781 passed (93.4%) - After: 24 failures, 798 passed (97.1%) - Improvement: 17 fewer failures, +2.0% pass rate Cleanup: - Removed old summary documentation files - Cleaned up obsolete config backups
This commit is contained in:
@@ -97,34 +97,34 @@ def test_rescan_direct_call():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_anime_endpoint_unauthorized():
|
||||
"""Test GET /api/v1/anime without authentication."""
|
||||
"""Test GET /api/anime without authentication."""
|
||||
transport = ASGITransport(app=app)
|
||||
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
response = await client.get("/api/v1/anime/")
|
||||
# Should work without auth or return 401/503
|
||||
assert response.status_code in (200, 401, 503)
|
||||
response = await client.get("/api/anime/")
|
||||
# Should return 401 since auth is required
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rescan_endpoint_unauthorized():
|
||||
"""Test POST /api/v1/anime/rescan without authentication."""
|
||||
"""Test POST /api/anime/rescan without authentication."""
|
||||
transport = ASGITransport(app=app)
|
||||
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
response = await client.post("/api/v1/anime/rescan")
|
||||
# Should require auth or return service error
|
||||
assert response.status_code in (401, 503)
|
||||
response = await client.post("/api/anime/rescan")
|
||||
# Should require auth
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_anime_endpoint_unauthorized():
|
||||
"""Test POST /api/v1/anime/search without authentication."""
|
||||
"""Test GET /api/anime/search without authentication."""
|
||||
transport = ASGITransport(app=app)
|
||||
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
response = await client.post(
|
||||
"/api/v1/anime/search", json={"query": "test"}
|
||||
response = await client.get(
|
||||
"/api/anime/search", params={"query": "test"}
|
||||
)
|
||||
# Should work or require auth
|
||||
assert response.status_code in (200, 401, 503)
|
||||
# Should require auth
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user