diff options
| author | Brian Wellington <bwelling@xbill.org> | 2022-07-15 09:01:17 -0700 |
|---|---|---|
| committer | Brian Wellington <bwelling@xbill.org> | 2022-07-15 09:01:17 -0700 |
| commit | 8a10f7b9b28950a60ae452f019268ca9a4306f5a (patch) | |
| tree | 71cc30b2babc8b050cdea0fd2f0a928bc568590a /tests | |
| parent | 759421d3e9add44fb5aecf3bac2939ef6bc85b59 (diff) | |
| download | dnspython-8a10f7b9b28950a60ae452f019268ca9a4306f5a.tar.gz | |
Fix dns.rdatatype special cases.
Prior to this change, there was logic in dns.rdatatype.from_text() and
to_text() to deal with types not handled by the RdataType enum;
specifically, the NSAP-PTR type (the enum value has a different name,
because of the hyphen) and user-registered types.
This was fine when internal code called these methods, but most callers
of from_text() were converted to dns.rdatatype.RdataType.make(), which
supports both integer and text input, and it doesn't handle the special
cases.
This change adds more hooks into the enum wrapper and moves the special
case handling for RdataType into them.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_rdata.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_rdata.py b/tests/test_rdata.py index a1c066a..7302369 100644 --- a/tests/test_rdata.py +++ b/tests/test_rdata.py @@ -61,6 +61,9 @@ class RdataTestCase(unittest.TestCase): self.assertEqual(rdata.strings, (b"hello", b"world")) self.assertEqual(dns.rdatatype.to_text(TTXT), "TTXT") self.assertEqual(dns.rdatatype.from_text("TTXT"), TTXT) + self.assertEqual(dns.rdatatype.RdataType.make("TTXT"), TTXT) + self.assertEqual(dns.rdatatype.from_text("ttxt"), TTXT) + self.assertEqual(dns.rdatatype.RdataType.make("ttxt"), TTXT) def test_module_reregistration(self): def bad(): @@ -937,6 +940,14 @@ class UtilTestCase(unittest.TestCase): with self.assertRaises(dns.ttl.BadTTL): dns.rdataset.from_text("in", "a", "10.0.0.1", "10.0.0.2") + def test_nsap_ptr_type(self): + # The NSAP-PTR type is special because it contains a dash, which means + # that its enum value is not the same as its string value. + self.assertEqual(dns.rdatatype.from_text("NSAP-PTR"), dns.rdatatype.NSAP_PTR) + self.assertEqual( + dns.rdatatype.RdataType.make("NSAP-PTR"), dns.rdatatype.NSAP_PTR + ) + Rdata = dns.rdata.Rdata |
