Files
PingWatch/backend/tests/test_settings_validation.py
T

39 lines
1.1 KiB
Python

import pytest
from pydantic import ValidationError
from app.config import Settings
from app.services.settings_validation import validate_runtime_settings
def test_production_rejects_legacy_jwt_secret():
settings = Settings(
environment="production",
secret_key="change-me-to-a-long-random-string",
)
with pytest.raises(ValueError, match="SECRET_KEY"):
validate_runtime_settings(settings)
def test_probe_packet_count_must_be_positive():
with pytest.raises(ValidationError):
Settings(probe_packets_per_round=0)
def test_production_rejects_tls_disabled_casdoor():
settings = Settings(
environment="production",
secret_key="a-safe-production-secret",
casdoor_endpoint="http://casdoor.internal",
)
with pytest.raises(ValueError, match="CASDOOR"):
validate_runtime_settings(settings)
def test_enabled_wecom_delivery_requires_all_credentials():
settings = Settings(wecom_notification_enabled=True, WECOM_CORP_ID="corp")
with pytest.raises(ValueError, match="WECOM"):
validate_runtime_settings(settings)