]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
NSEC should NOT be downcased when canonicalized, nor should HIP or IPSECKEY; test all
authorBob Halley <halley@dnspython.org>
Mon, 1 Jun 2020 20:49:59 +0000 (13:49 -0700)
committerBob Halley <halley@dnspython.org>
Mon, 1 Jun 2020 20:49:59 +0000 (13:49 -0700)
dns/rdtypes/ANY/NSEC.py
tests/test_rdata.py

index 24936cbea9815c4ff5910f09fd7b0f465b2426fa..5db382bf9cc0d311f50a9d1c5cd87bf4a610b3b1 100644 (file)
@@ -88,7 +88,7 @@ class NSEC(dns.rdata.Rdata):
         return cls(rdclass, rdtype, next, windows)
 
     def _to_wire(self, file, compress=None, origin=None, canonicalize=False):
-        self.next.to_wire(file, None, origin, canonicalize)
+        self.next.to_wire(file, None, origin, False)
         for (window, bitmap) in self.windows:
             file.write(struct.pack('!BB', window, len(bitmap)))
             file.write(bitmap)
index ed2c3f3b1d0397bc83ca62ade969deba02b878df..872bdd9632ff3eab56d05b874fb7514d7df342bd 100644 (file)
@@ -139,6 +139,8 @@ class RdataTestCase(unittest.TestCase):
         #
         #   types that don't have names: HINFO
         #
+        #   NSEC3, whose downcasing was removed by RFC 6840 section 5.1
+        #
         cases = [
             ('SOA', 'NAME NAME 1 2 3 4 5'),
             ('AFSDB', '0 NAME'),
@@ -147,7 +149,6 @@ class RdataTestCase(unittest.TestCase):
             ('KX', '10 NAME'),
             ('MX', '10 NAME'),
             ('NS', 'NAME'),
-            ('NSEC', 'NAME A'),
             ('NAPTR', '0 0 a B c NAME'),
             ('PTR', 'NAME'),
             ('PX', '65535 NAME NAME'),
@@ -173,5 +174,23 @@ class RdataTestCase(unittest.TestCase):
             expected_wire = f.getvalue()
             self.assertEqual(digestable_wire, expected_wire)
 
+    def test_digestable_no_downcasing(self):
+        # Make sure that currently known types with domain names that
+        # are NOT supposed to be downcased when canonicalized are
+        # handled properly.
+        #
+        cases = [
+            ('HIP', '2 200100107B1A74DF365639CC39F1D578 Ym9ndXM= NAME name'),
+            ('IPSECKEY', '10 3 2 NAME Ym9ndXM='),
+            ('NSEC', 'NAME A'),
+        ]
+        for rdtype, text in cases:
+            origin = dns.name.from_text('example')
+            rdata = dns.rdata.from_text(dns.rdataclass.IN, rdtype, text,
+                                        origin=origin, relativize=False)
+            digestable_wire = rdata.to_digestable(origin)
+            expected_wire = rdata.to_wire(origin=origin)
+            self.assertEqual(digestable_wire, expected_wire)
+
 if __name__ == '__main__':
     unittest.main()