diff options
| author | Brian Wellington <bwelling@xbill.org> | 2020-08-10 14:27:44 -0700 |
|---|---|---|
| committer | Brian Wellington <bwelling@xbill.org> | 2020-08-10 14:27:44 -0700 |
| commit | 0cdfab7c1ea9470faf015493a6274f0637789dc8 (patch) | |
| tree | 614714f8d46b8f43243c6576bc4a2ce46783a0bb /tests | |
| parent | b4e690c4b0a846b67701eeb7107c88765caab9ad (diff) | |
| download | dnspython-0cdfab7c1ea9470faf015493a6274f0637789dc8.tar.gz | |
Adds support for reading TSIG text format.
Implements from_text for the TSIG record type, and clean up some other
things.
Fixes the text format to emit fields in the right order; fudge and
time_signed were reversed. This also matches BIND's output format now.
Add get_uint48() to the tokenizer, so that from_text() can use it. Add
get_uint48() to the wire parser, and use it in from_wire, for
consistency.
Change dns.tsig.sign() to use rdata.replace() rather than constructing a
new TSIG record manually; this couldn't be done before, because
replace() uses text format for validation.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_tokenizer.py | 3 | ||||
| -rw-r--r-- | tests/test_tsig.py | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py index 8340f46..e4797a5 100644 --- a/tests/test_tokenizer.py +++ b/tests/test_tokenizer.py @@ -207,6 +207,9 @@ class TokenizerTestCase(unittest.TestCase): tok = dns.tokenizer.Tokenizer('q1234') tok.get_int() with self.assertRaises(dns.exception.SyntaxError): + tok = dns.tokenizer.Tokenizer('281474976710656') + tok.get_uint48() + with self.assertRaises(dns.exception.SyntaxError): tok = dns.tokenizer.Tokenizer('4294967296') tok.get_uint32() with self.assertRaises(dns.exception.SyntaxError): diff --git a/tests/test_tsig.py b/tests/test_tsig.py index 6e3993b..b8a38b4 100644 --- a/tests/test_tsig.py +++ b/tests/test_tsig.py @@ -245,3 +245,22 @@ class TSIGTestCase(unittest.TestCase): def test_hmac_sha512_256(self): self._test_truncated_algorithm(dns.tsig.HMAC_SHA512_256, 256) + + def text_format(self): + key = dns.tsig.Key('foo', b'abcdefg', algorithm=alg) + q = dns.message.make_query('example', 'a') + q.use_tsig(key) + _ = q.to_wire() + + text = q.tsig[0].to_text() + tsig2 = dns.rdata.from_text('ANY', 'TSIG', text) + self.assertEqual(tsig2, q.tsig[0]) + + q = dns.message.make_query('example', 'a') + q.use_tsig(key, other_data='abc') + q.use_tsig(key) + _ = q.to_wire() + + text = q.tsig[0].to_text() + tsig2 = dns.rdata.from_text('ANY', 'TSIG', text) + self.assertEqual(tsig2, q.tsig[0]) |
