aboutsummaryrefslogtreecommitdiff
path: root/tests/test_config.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test_config.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index d075e7d..4a5f4cb 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -39,6 +39,15 @@ def test_session_cookie_defaults(
assert config_class.SESSION_COOKIE_SAMESITE == "Lax"
+def test_source_allowlist_mode_requires_boolean_configuration(tmp_path: Path) -> None:
+ class BadSourceModeConfig(TestingConfig):
+ LOG_FILE = str(tmp_path / "mode-test.log")
+ SOURCE_ALLOWLIST_ENABLED = "yes"
+
+ with pytest.raises(ValueError, match="SOURCE_ALLOWLIST_ENABLED"):
+ create_app(BadSourceModeConfig)
+
+
def test_explicit_config_overrides_session_cookie_defaults() -> None:
class CookieOverrideConfig(TestingConfig):
SESSION_COOKIE_SECURE = True
@@ -141,6 +150,7 @@ def test_allowed_hostnames_are_normalized_at_startup(tmp_path: Path) -> None:
(["example.com", None], ValueError),
(["example.com", ""], ValueError),
(["example.com", " "], ValueError),
+ (["*.example.com"], ValueError),
],
)
def test_invalid_allowed_hostnames_fail_at_startup(
@@ -154,6 +164,23 @@ def test_invalid_allowed_hostnames_fail_at_startup(
create_app(InvalidHostnameConfig)
+def test_hostname_config_shares_admin_canonicalization(tmp_path: Path) -> None:
+ class InternationalizedHosts(TestingConfig):
+ LOG_FILE = str(tmp_path / "idn.log")
+ ALLOWED_TARGET_HOSTNAMES = {"BÜCHER.example.", "EXAMPLE.COM"}
+ IGNORED_TARGET_HOSTNAMES = {"*.BÜCHER.example.", "EXAMPLE.COM."}
+
+ app = create_app(InternationalizedHosts)
+ assert app.config["ALLOWED_TARGET_HOSTNAMES"] == {
+ "xn--bcher-kva.example",
+ "example.com",
+ }
+ assert app.config["IGNORED_TARGET_HOSTNAMES"] == {
+ "*.xn--bcher-kva.example",
+ "example.com",
+ }
+
+
def test_ignored_hostnames_are_normalized_at_startup(tmp_path: Path) -> None:
class MixedCaseConfig(TestingConfig):
LOG_FILE = str(tmp_path / "test.log")