aboutsummaryrefslogtreecommitdiff
path: root/tests/test_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_config.py')
-rw-r--r--tests/test_config.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 43c29ab..fedd7ce 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -39,6 +39,39 @@ def test_session_cookie_defaults(
assert config_class.SESSION_COOKIE_SAMESITE == "Lax"
+def test_testing_config_preserves_default_request_host() -> None:
+ app = create_app(TestingConfig)
+ assert app.config["SERVER_NAME"] is None
+ assert app.config["PREFERRED_URL_SCHEME"] == "http"
+
+
+def test_digest_requires_server_name_at_app_startup() -> None:
+ class MissingServerNameConfig(TestingConfig):
+ DIGEST_EMAIL = "owner@example.com"
+ SERVER_NAME = None
+
+ with pytest.raises(RuntimeError, match="Configure SERVER_NAME"):
+ create_app(MissingServerNameConfig)
+
+
+def test_digest_rejects_blank_server_name() -> None:
+ class BlankServerNameConfig(TestingConfig):
+ DIGEST_EMAIL = "owner@example.com"
+ SERVER_NAME = " "
+
+ with pytest.raises(RuntimeError, match="Configure SERVER_NAME"):
+ create_app(BlankServerNameConfig)
+
+
+def test_server_name_optional_when_digest_disabled() -> None:
+ class NoDigestConfig(TestingConfig):
+ DIGEST_EMAIL = None
+ SERVER_NAME = None
+
+ app = create_app(NoDigestConfig)
+ assert app.config["SERVER_NAME"] is None
+
+
def test_source_allowlist_mode_requires_boolean_configuration(tmp_path: Path) -> None:
class BadSourceModeConfig(TestingConfig):
LOG_FILE = str(tmp_path / "mode-test.log")