From 6d9cfbabafd373aaca7b9f9ed607f9aa4b39f3b9 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 13 Nov 2026 17:00:10 +0100 Subject: refactor(core): extract hostname resolution helper Move DNS resolution and address parsing into a dedicated helper so public address validation resolves hostnames through a single, testable path. --- tests/test_net.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/test_net.py b/tests/test_net.py index 928a0d5..05ae5a4 100644 --- a/tests/test_net.py +++ b/tests/test_net.py @@ -191,6 +191,16 @@ def test_ip_literal_does_not_use_dns() -> None: dns_resolve.assert_not_called() +def test_public_addresses_resolves_hostname_once() -> None: + with patch("webmentions_ssg.net.dns.resolver.resolve_name") as resolve: + resolve.return_value.addresses.return_value = ["93.184.216.34", "8.8.8.8"] + assert public_addresses("example.com", lifetime=1.5) == ( + "93.184.216.34", + "8.8.8.8", + ) + resolve.assert_called_once_with("example.com", lifetime=1.5) + + @pytest.mark.parametrize( "address", [ -- cgit v1.3.1