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>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""
|
|
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):
|
|
"""
|
|
Reset configuration before each test.
|
|
|
|
This prevents config from one test affecting another test.
|
|
"""
|
|
# Clear all GONDULF_ environment variables
|
|
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:")
|