Files
rf4-spotter/apps/api/tests/test_config.py
T
ik 870d9cc7f9
CI / backend-and-migrations (push) Canceled after 0s
CI / astro-build (push) Canceled after 0s
CI / compose-e2e (push) Canceled after 0s
feat: harden production data and backups
2026-09-06 14:08:07 +07:00

39 lines
1.2 KiB
Python

import pytest
from pydantic import ValidationError
from app.config import Settings
def production_settings(**changes) -> Settings:
values = {
"deployment_environment": "production",
"admin_token": "a" * 32,
"rate_limit_secret": "r" * 32,
"s3_access_key": "access-key-1234",
"s3_secret_key": "s" * 32,
"s3_public_endpoint_url": "https://files.rf4spotter.ru",
"cors_origins": ["https://rf4spotter.ru"],
"seed_demo_data": False,
}
return Settings(**(values | changes))
def test_production_settings_accept_real_domains_and_secrets() -> None:
settings = production_settings()
assert settings.cors_origins == ["https://rf4spotter.ru"]
@pytest.mark.parametrize(("field", "value"), [
("admin_token", "change-me-in-production"),
("rate_limit_secret", "short"),
("s3_access_key", "rf4-local"),
("s3_secret_key", "rf4-local-secret"),
("cors_origins", ["http://rf4spotter.ru"]),
("s3_public_endpoint_url", "http://files.rf4spotter.ru"),
("seed_demo_data", True),
])
def test_production_settings_reject_insecure_values(field: str, value: object) -> None:
with pytest.raises(ValidationError):
production_settings(**{field: value})