feat: implement setup redirect middleware and fix test suite
- Created SetupRedirectMiddleware to redirect unconfigured apps to /setup - Enhanced /api/auth/setup endpoint to save anime_directory to config - Updated SetupRequest model to accept optional anime_directory parameter - Modified setup.html to send anime_directory in setup API call - Added @pytest.mark.requires_clean_auth marker for tests needing unconfigured state - Modified conftest.py to conditionally setup auth based on test marker - Fixed all test failures (846/846 tests now passing) - Updated instructions.md to mark setup tasks as complete This implementation ensures users are guided through initial setup before accessing the application, while maintaining test isolation and preventing auth state leakage between tests.
This commit is contained in:
@@ -287,6 +287,7 @@ class TestTokenValidation:
|
||||
assert data["authenticated"] is True
|
||||
|
||||
|
||||
@pytest.mark.requires_clean_auth
|
||||
class TestProtectedEndpoints:
|
||||
"""Test that all protected endpoints enforce authentication."""
|
||||
|
||||
@@ -348,12 +349,14 @@ class TestProtectedEndpoints:
|
||||
|
||||
async def test_config_endpoints_require_auth(self, client):
|
||||
"""Test that config endpoints require authentication."""
|
||||
# Without token
|
||||
# Setup auth first so middleware doesn't redirect
|
||||
token = await self.get_valid_token(client)
|
||||
|
||||
# Without token - should require auth
|
||||
response = await client.get("/api/config")
|
||||
assert response.status_code == 401
|
||||
|
||||
# With token
|
||||
token = await self.get_valid_token(client)
|
||||
# With token - should work
|
||||
response = await client.get(
|
||||
"/api/config",
|
||||
headers={"Authorization": f"Bearer {token}"}
|
||||
|
||||
@@ -18,6 +18,7 @@ async def client():
|
||||
yield ac
|
||||
|
||||
|
||||
@pytest.mark.requires_clean_auth
|
||||
class TestFrontendAuthIntegration:
|
||||
"""Test authentication integration matching frontend expectations."""
|
||||
|
||||
@@ -177,6 +178,7 @@ class TestFrontendAuthIntegration:
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.requires_clean_auth
|
||||
class TestTokenAuthenticationFlow:
|
||||
"""Test JWT token-based authentication workflow."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user