summaryrefslogtreecommitdiff
path: root/tests/unittests/test_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/test_util.py')
-rw-r--r--tests/unittests/test_util.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index ecf8cf5c..865f202a 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -3026,3 +3026,18 @@ class TestVersion:
)
def test_from_str(self, str_ver, cls_ver):
assert util.Version.from_str(str_ver) == cls_ver
+
+
+@pytest.mark.allow_dns_lookup
+class TestResolvable:
+ @mock.patch.object(util, "_DNS_REDIRECT_IP", return_value=True)
+ @mock.patch.object(util.socket, "getaddrinfo")
+ def test_ips_need_not_be_resolved(self, m_getaddr, m_dns):
+ """Optimization test: dns resolution may timeout during early boot, and
+ often the urls being checked use IP addresses rather than dns names.
+ Therefore, the fast path checks if the address contains an IP and exits
+ early if the path is a valid IP.
+ """
+ assert util.is_resolvable("http://169.254.169.254/") is True
+ assert util.is_resolvable("http://[fd00:ec2::254]/") is True
+ assert not m_getaddr.called