test: establish monitoring configuration contract

This commit is contained in:
2026-08-04 11:01:09 +08:00
parent 63bf68e73f
commit 44bf6e003e
8 changed files with 127 additions and 14 deletions
+38
View File
@@ -0,0 +1,38 @@
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)