diff options
| author | Bob Halley <halley@dnspython.org> | 2020-06-01 08:23:03 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2020-06-01 08:23:03 -0700 |
| commit | c19e6716a86593528ae3d4904bf1cefcfcd477b9 (patch) | |
| tree | 7c2d015ce1456031beb5fe44da280bbedffb3d3f /tests/test_rdata.py | |
| parent | 77b9cdc41ffe002c0bb49f387b4f1fdbb190ff60 (diff) | |
| download | dnspython-c19e6716a86593528ae3d4904bf1cefcfcd477b9.tar.gz | |
Fix remaining canonical form problems, and add a test. [Issue #496]
Diffstat (limited to 'tests/test_rdata.py')
| -rw-r--r-- | tests/test_rdata.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_rdata.py b/tests/test_rdata.py index b994a62..a88b977 100644 --- a/tests/test_rdata.py +++ b/tests/test_rdata.py @@ -16,11 +16,13 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +import io import unittest import dns.name import dns.rdata import dns.rdataclass +import dns.rdataset import dns.rdatatype import tests.stxt_module @@ -128,5 +130,48 @@ class RdataTestCase(unittest.TestCase): idna_codec=dns.name.IDNA_2008) self.assertEqual(str(rdata.target), 'xn--knigsgchen-b4a3dun') + def test_digestable_downcasing(self): + # Make sure all the types listed in RFC 4034 section 6.2 are + # downcased properly, except for: + # + # types we don't implement: MD, MF, MB, MG, MR, MINFO, SIG, + # NXT, A6 + # + # types that don't have names: HINFO + # + # types where the canonical form isn't relevant: RRSIG + # + cases = [ + ('SOA', 'NAME NAME 1 2 3 4 5'), + ('AFSDB', '0 NAME'), + ('CNAME', 'NAME'), + ('DNAME', 'NAME'), + ('KX', '10 NAME'), + ('MX', '10 NAME'), + ('NS', 'NAME'), + ('NSEC', 'NAME A'), + ('NAPTR', '0 0 a B c NAME'), + ('PTR', 'NAME'), + ('PX', '65535 NAME NAME'), + ('RP', 'NAME NAME'), + ('RT', '0 NAME'), + ('SRV', '0 0 0 NAME'), + ] + for rdtype, text in cases: + upper_origin = dns.name.from_text('EXAMPLE') + lower_origin = dns.name.from_text('example') + canonical_text = text.replace('NAME', 'name') + rdata = dns.rdata.from_text(dns.rdataclass.IN, rdtype, text, + origin=upper_origin, relativize=False) + canonical_rdata = dns.rdata.from_text(dns.rdataclass.IN, rdtype, + canonical_text, + origin=lower_origin, + relativize=False) + digestable_wire = rdata.to_digestable() + f = io.BytesIO() + canonical_rdata.to_wire(f) + expected_wire = f.getvalue() + self.assertEqual(digestable_wire, expected_wire) + if __name__ == '__main__': unittest.main() |
