The auth dependency raises NotAuthenticatedError (not HTTPException), and the exception handler returns a 302 redirect. Updated the unit test to expect NotAuthenticatedError, and all route auth tests to accept 302 alongside 401/303.
22 lines
716 B
Python
22 lines
716 B
Python
"""Tests for log history routes."""
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
class TestLogHistory:
|
|
"""Tests for GET /history."""
|
|
|
|
def test_history_requires_auth(self, client: TestClient) -> None:
|
|
"""GET /history should require admin login."""
|
|
response = client.get("/history", follow_redirects=False)
|
|
assert response.status_code in (401, 302, 303)
|
|
|
|
|
|
class TestSessionDetail:
|
|
"""Tests for GET /history/<session_id>."""
|
|
|
|
def test_session_detail_requires_auth(self, client: TestClient) -> None:
|
|
"""GET /history/1 should require admin login."""
|
|
response = client.get("/history/1", follow_redirects=False)
|
|
assert response.status_code in (401, 302, 303)
|