]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Try to skip dangling CNAME tests if systemd-resolved is running. [Issue #658]
authorBob Halley <halley@dnspython.org>
Fri, 11 Jun 2021 17:26:04 +0000 (10:26 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 11 Jun 2021 17:26:04 +0000 (10:26 -0700)
tests/test_async.py
tests/test_resolver.py

index 0252f2255d2786f81e4704c641f726b31cb2ed85..cad7e20d469fd30a99475deaae604940734d8fc9 100644 (file)
@@ -49,6 +49,17 @@ except socket.gaierror:
     _network_available = False
 
 
+# Look for systemd-resolved, as it does dangling CNAME responses incorrectly.
+#
+# Currently we simply check if the nameserver is 127.0.0.53.
+_systemd_resolved_present = False
+try:
+    _resolver = dns.resolver.Resolver()
+    if _resolver.nameservers == ['127.0.0.53']:
+        _systemd_resolved_present = True
+except Exception:
+    pass
+
 # Probe for IPv4 and IPv6
 query_addresses = []
 for (af, address) in ((socket.AF_INET, '8.8.8.8'),
@@ -197,6 +208,7 @@ class AsyncTests(unittest.TestCase):
             return await dns.asyncresolver.canonical_name(name)
         self.assertEqual(self.async_run(run), cname)
 
+    @unittest.skipIf(_systemd_resolved_present, "systemd-resolved in use")
     def testCanonicalNameDangling(self):
         name = dns.name.from_text('dangling-cname.dnspython.org')
         cname = dns.name.from_text('dangling-target.dnspython.org')
index dce250bcd443a52b2d8640ab03d1d78905b147af..f264d2e9c4b52cb1e5a93766f09f535245398b83 100644 (file)
@@ -52,6 +52,18 @@ except ImportError:
     class Server(object):
         pass
 
+# Look for systemd-resolved, as it does dangling CNAME responses incorrectly.
+#
+# Currently we simply check if the nameserver is 127.0.0.53.
+_systemd_resolved_present = False
+try:
+    _resolver = dns.resolver.Resolver()
+    if _resolver.nameservers == ['127.0.0.53']:
+        _systemd_resolved_present = True
+except Exception:
+    pass
+
+
 resolv_conf = u"""
     /t/t
 # comment 1
@@ -682,6 +694,7 @@ class LiveResolverTests(unittest.TestCase):
         cname = dns.name.from_text('dmfrjf4ips8xa.cloudfront.net')
         self.assertEqual(dns.resolver.canonical_name(name), cname)
 
+    @unittest.skipIf(_systemd_resolved_present, "systemd-resolved in use")
     def testCanonicalNameDangling(self):
         name = dns.name.from_text('dangling-cname.dnspython.org')
         cname = dns.name.from_text('dangling-target.dnspython.org')