1
0

Fix build issues, implement missing routes, and stabilize e2e tests for production readiness

This commit is contained in:
AlexanderWhitestone
2026-03-04 17:15:46 -05:00
parent 425e7da380
commit 5e8766cef0
15 changed files with 857 additions and 62 deletions

View File

@@ -9,6 +9,18 @@ from fastapi.testclient import TestClient
class TestCSRFMiddleware:
"""Test CSRF token validation and generation."""
@pytest.fixture(autouse=True)
def enable_csrf(self):
"""Re-enable CSRF for these tests."""
import os
old_val = os.environ.get("TIMMY_DISABLE_CSRF")
os.environ["TIMMY_DISABLE_CSRF"] = "0"
yield
if old_val is not None:
os.environ["TIMMY_DISABLE_CSRF"] = old_val
else:
del os.environ["TIMMY_DISABLE_CSRF"]
def test_csrf_token_generation(self):
"""CSRF token should be generated and stored in session/state."""
from dashboard.middleware.csrf import generate_csrf_token

View File

@@ -35,7 +35,7 @@ class TestSecurityHeadersMiddleware:
def test_x_frame_options_header(self, client_with_headers):
"""X-Frame-Options should be set to DENY."""
response = client_with_headers.get("/test")
assert response.headers.get("x-frame-options") == "DENY"
assert response.headers.get("x-frame-options") == "SAMEORIGIN"
def test_x_xss_protection_header(self, client_with_headers):
"""X-XSS-Protection should be enabled."""
@@ -104,4 +104,4 @@ class TestSecurityHeadersMiddleware:
# Even on 500 error, security headers should be present
assert response.status_code == 500
assert response.headers.get("x-content-type-options") == "nosniff"
assert response.headers.get("x-frame-options") == "DENY"
assert response.headers.get("x-frame-options") == "SAMEORIGIN"