feat(security): merge Phase 4b security hardening

Complete security hardening implementation including HTTPS enforcement,
security headers, rate limiting, and comprehensive security test suite.

Key features:
- HTTPS enforcement with HSTS support
- Security headers (CSP, X-Frame-Options, X-Content-Type-Options)
- Rate limiting for all critical endpoints
- Enhanced email template security
- 87% test coverage with security-specific tests

Architect approval: 9.5/10

Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 18:28:50 -07:00
parent 115e733604
commit d3c3e8dc6b
23 changed files with 3762 additions and 7 deletions

View File

@@ -2,9 +2,25 @@
Pytest configuration and shared fixtures.
"""
import os
import pytest
@pytest.fixture(scope="session", autouse=True)
def setup_test_config():
"""
Setup test configuration before any tests run.
This ensures required environment variables are set for test execution.
"""
# Set required configuration
os.environ.setdefault("GONDULF_SECRET_KEY", "test-secret-key-for-testing-only-32chars")
os.environ.setdefault("GONDULF_BASE_URL", "http://localhost:8000")
os.environ.setdefault("GONDULF_DEBUG", "true")
os.environ.setdefault("GONDULF_DATABASE_URL", "sqlite:///:memory:")
@pytest.fixture(autouse=True)
def reset_config_before_test(monkeypatch):
"""
@@ -13,8 +29,12 @@ def reset_config_before_test(monkeypatch):
This prevents config from one test affecting another test.
"""
# Clear all GONDULF_ environment variables
import os
gondulf_vars = [key for key in os.environ.keys() if key.startswith("GONDULF_")]
for var in gondulf_vars:
monkeypatch.delenv(var, raising=False)
# Re-set required test configuration
monkeypatch.setenv("GONDULF_SECRET_KEY", "test-secret-key-for-testing-only-32chars")
monkeypatch.setenv("GONDULF_BASE_URL", "http://localhost:8000")
monkeypatch.setenv("GONDULF_DEBUG", "true")
monkeypatch.setenv("GONDULF_DATABASE_URL", "sqlite:///:memory:")