aboutsummaryrefslogtreecommitdiff
path: root/tests/test_config.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test_config.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index dd02c01..933f437 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -232,3 +232,25 @@ def test_development_rejects_placeholder_even_with_debug(tmp_path: Path) -> None
with pytest.raises(RuntimeError, match="SECRET_KEY"):
create_app(LocalDevelopment)
+
+
+def test_resource_limits_have_safe_defaults() -> None:
+ assert DefaultConfig.MAX_CONTENT_LENGTH == 64 * 1024
+ assert DefaultConfig.MAX_WEBMENTION_URL_BYTES == 8192
+ assert DefaultConfig.RECEIVED_RETENTION_DAYS == 30
+ assert DefaultConfig.RECEIVED_RETENTION_SCHEDULE == "0 3 * * *"
+
+
+@pytest.mark.parametrize(
+ "key", ["MAX_CONTENT_LENGTH", "MAX_WEBMENTION_URL_BYTES", "RECEIVED_RETENTION_DAYS"]
+)
+@pytest.mark.parametrize("value", [None, "100", 0, -1, True, 1.5])
+def test_invalid_resource_limits_fail_at_startup(
+ tmp_path: Path, key: str, value: object
+) -> None:
+ class InvalidResourceLimit(TestingConfig):
+ LOG_FILE = str(tmp_path / "invalid-resource.log")
+
+ setattr(InvalidResourceLimit, key, value)
+ with pytest.raises(ValueError, match=key):
+ create_app(InvalidResourceLimit)