aboutsummaryrefslogtreecommitdiff
path: root/tests/test_config.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-15 20:42:20 +0100
committerDennis Fink2026-11-15 20:42:20 +0100
commit509d93b2976e353d29441a7a7b7e78ca466dc4fd (patch)
tree753e637aefabd4293f808addbf9c310eaf0aa552 /tests/test_config.py
parentc74feda222745ab7cca8993df83d9ea5f9d07e5b (diff)
downloadwebmentions-ssg-509d93b2976e353d29441a7a7b7e78ca466dc4fd.tar.gz
webmentions-ssg-509d93b2976e353d29441a7a7b7e78ca466dc4fd.zip
refactor(core)!: standardize application terminology
Rename configuration keys, task helpers, forms, network utilities, and view endpoints to make their responsibilities and domains more explicit. Align source-management routes and templates with the new terminology and rename the target-matching module and related task abstractions consistently. BREAKING CHANGE: configuration keys have been renamed and sent-source routes move from `/sent` to `/sources`, with corresponding blueprint endpoint changes.
Diffstat (limited to '')
-rw-r--r--tests/test_config.py54
1 files changed, 27 insertions, 27 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 4a59236..a4c5e9b 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -19,7 +19,7 @@ from webmentions_ssg.config import (
ProductionConfig,
TestingConfig,
)
-from webmentions_ssg.forms import AllowedHostname
+from webmentions_ssg.forms import AllowedTargetHostname
@pytest.mark.parametrize(
@@ -66,7 +66,7 @@ def test_missing_development_configuration_is_optional(tmp_path: Path) -> None:
LOG_FILE = str(tmp_path / "development.log")
app = create_app(LocalDevelopmentConfig)
- assert app.config["ALLOWED_HOSTNAMES"] == set()
+ assert app.config["ALLOWED_TARGET_HOSTNAMES"] == set()
def test_development_creates_local_directory_on_first_start(
@@ -98,27 +98,27 @@ def test_testing_creates_local_log_directory_on_first_start(
def test_endpoint_limits_are_inherited_from_defaults() -> None:
for config in (DefaultConfig, DevelopmentConfig, ProductionConfig, TestingConfig):
assert config.MAX_REDIRECTS == 20
- assert config.MAX_SOURCE_BYTES == 1_000_000
- assert config.MAX_TARGET_BYTES == 1_000_000
- assert config.REQUEST_TIMEOUT == 5.0
- assert config.REQUEST_TOTAL_TIMEOUT == 30.0
+ assert config.MAX_RECEIVED_SOURCE_BYTES == 1_000_000
+ assert config.MAX_DISCOVERY_TARGET_BYTES == 1_000_000
+ assert config.REQUEST_TIMEOUT_SECONDS == 5.0
+ assert config.REQUEST_TOTAL_TIMEOUT_SECONDS == 30.0
- assert set() == DefaultConfig.ALLOWED_HOSTNAMES
- assert DefaultConfig.IGNORED_HOSTNAMES == ()
+ assert set() == DefaultConfig.ALLOWED_TARGET_HOSTNAMES
+ assert DefaultConfig.IGNORED_TARGET_HOSTNAMES == ()
def test_allowed_hostnames_are_normalized_at_startup(tmp_path: Path) -> None:
class MixedCaseConfig(TestingConfig):
LOG_FILE = str(tmp_path / "test.log")
- ALLOWED_HOSTNAMES = [" DennisFink.Me ", "EXAMPLE.COM", "dennisfink.me"]
+ ALLOWED_TARGET_HOSTNAMES = [" DennisFink.Me ", "EXAMPLE.COM", "dennisfink.me"]
app = create_app(MixedCaseConfig)
- assert app.config["ALLOWED_HOSTNAMES"] == {"dennisfink.me", "example.com"}
- assert isinstance(app.config["ALLOWED_HOSTNAMES"], set)
+ assert app.config["ALLOWED_TARGET_HOSTNAMES"] == {"dennisfink.me", "example.com"}
+ assert isinstance(app.config["ALLOWED_TARGET_HOSTNAMES"], set)
# The form validator must compare complete hostnames, never substrings.
target = Field()
- validator = AllowedHostname(message="Hostname not allowed")
+ validator = AllowedTargetHostname(message="Hostname not allowed")
form = BaseForm({})
with app.app_context():
for url in ("https://dennisfink.me/post", "https://EXAMPLE.com/post"):
@@ -148,19 +148,19 @@ def test_invalid_allowed_hostnames_fail_at_startup(
) -> None:
class InvalidHostnameConfig(TestingConfig):
LOG_FILE = str(tmp_path / "test.log")
- ALLOWED_HOSTNAMES = hostnames
+ ALLOWED_TARGET_HOSTNAMES = hostnames
- with pytest.raises(expected_exception, match="ALLOWED_HOSTNAMES"):
+ with pytest.raises(expected_exception, match="ALLOWED_TARGET_HOSTNAMES"):
create_app(InvalidHostnameConfig)
def test_ignored_hostnames_are_normalized_at_startup(tmp_path: Path) -> None:
class MixedCaseConfig(TestingConfig):
LOG_FILE = str(tmp_path / "test.log")
- IGNORED_HOSTNAMES = [" Example.COM. ", "*.EXAMPLE.com.", "example.com"]
+ IGNORED_TARGET_HOSTNAMES = [" Example.COM. ", "*.EXAMPLE.com.", "example.com"]
app = create_app(MixedCaseConfig)
- assert app.config["IGNORED_HOSTNAMES"] == {"*.example.com", "example.com"}
+ assert app.config["IGNORED_TARGET_HOSTNAMES"] == {"*.example.com", "example.com"}
@pytest.mark.parametrize(
@@ -181,9 +181,9 @@ def test_invalid_ignored_hostnames_fail_at_startup(
) -> None:
class InvalidHostnameConfig(TestingConfig):
LOG_FILE = str(tmp_path / "test.log")
- IGNORED_HOSTNAMES = hostnames
+ IGNORED_TARGET_HOSTNAMES = hostnames
- with pytest.raises(expected_exception, match="IGNORED_HOSTNAMES"):
+ with pytest.raises(expected_exception, match="IGNORED_TARGET_HOSTNAMES"):
create_app(InvalidHostnameConfig)
@@ -197,7 +197,7 @@ def test_production_requires_nonempty_allowed_hostnames(tmp_path: Path) -> None:
class EmptyHostnamesConfig(ProductionConfig):
CONFIG_FILE = str(config_path)
- with pytest.raises(RuntimeError, match="ALLOWED_HOSTNAMES"):
+ with pytest.raises(RuntimeError, match="ALLOWED_TARGET_HOSTNAMES"):
create_app(EmptyHostnamesConfig)
@@ -221,7 +221,7 @@ def test_production_rejects_ephemeral_or_discarding_huey_queue(
class ProductionWithQueue(ProductionConfig):
CONFIG_FILE = str(config_path)
SECRET_KEY = "a-long-secret-string-for-a-production-test"
- ALLOWED_HOSTNAMES = {"example.com"}
+ ALLOWED_TARGET_HOSTNAMES = {"example.com"}
RATELIMIT_STORAGE_URI = "redis://localhost:6379/1"
LOG_FILE = str(tmp_path / "production.log")
@@ -242,7 +242,7 @@ def test_production_prefers_explicit_huey_url_over_legacy_option(
class ProductionWithExplicitQueue(ProductionConfig):
CONFIG_FILE = str(config_path)
SECRET_KEY = "a-long-secret-string-for-a-production-test"
- ALLOWED_HOSTNAMES = {"example.com"}
+ ALLOWED_TARGET_HOSTNAMES = {"example.com"}
RATELIMIT_STORAGE_URI = "redis://localhost:6379/1"
LOG_FILE = str(tmp_path / "production.log")
HUEY = {"url": "memory://"}
@@ -256,15 +256,15 @@ def test_environment_allowed_hostnames_override_config_file(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
config_path = tmp_path / "development.cfg"
- config_path.write_text('ALLOWED_HOSTNAMES = ["first.example"]\n')
- monkeypatch.setenv("WEBMENTIONS_SSG_ALLOWED_HOSTNAMES", '["SECOND.EXAMPLE"]')
+ config_path.write_text('ALLOWED_TARGET_HOSTNAMES = ["first.example"]\n')
+ monkeypatch.setenv("WEBMENTIONS_SSG_ALLOWED_TARGET_HOSTNAMES", '["SECOND.EXAMPLE"]')
class LocalDevelopmentConfig(DevelopmentConfig):
CONFIG_FILE = str(config_path)
LOG_FILE = str(tmp_path / "development.log")
app = create_app(LocalDevelopmentConfig)
- assert app.config["ALLOWED_HOSTNAMES"] == {"second.example"}
+ assert app.config["ALLOWED_TARGET_HOSTNAMES"] == {"second.example"}
@pytest.mark.parametrize(
@@ -288,7 +288,7 @@ def test_production_refuses_missing_weak_or_example_secret_key(
class SecretKeyConfig(ProductionConfig):
CONFIG_FILE = str(config_file)
LOG_FILE = str(tmp_path / "production.log")
- ALLOWED_HOSTNAMES = {"example.com"}
+ ALLOWED_TARGET_HOSTNAMES = {"example.com"}
RATELIMIT_STORAGE_URI = "redis://localhost:6379"
SECRET_KEY = secret
@@ -308,7 +308,7 @@ def test_production_uses_persistent_configured_secret(
class ConfiguredProduction(ProductionConfig):
CONFIG_FILE = str(config_file)
LOG_FILE = str(tmp_path / "production.log")
- ALLOWED_HOSTNAMES = {"example.com"}
+ ALLOWED_TARGET_HOSTNAMES = {"example.com"}
RATELIMIT_STORAGE_URI = "redis://localhost:6379"
HUEY_URL = f"sqlite:///{tmp_path / 'huey.db'}"
@@ -330,7 +330,7 @@ def test_production_accepts_environment_secret_override(
class EnvConfiguredProduction(ProductionConfig):
CONFIG_FILE = str(config_file)
LOG_FILE = str(tmp_path / "production.log")
- ALLOWED_HOSTNAMES = {"example.com"}
+ ALLOWED_TARGET_HOSTNAMES = {"example.com"}
RATELIMIT_STORAGE_URI = "redis://localhost:6379"
HUEY_URL = f"sqlite:///{tmp_path / 'huey.db'}"