summaryrefslogtreecommitdiff
path: root/tests/test_tsig.py
diff options
context:
space:
mode:
authorBrian Wellington <bwelling@xbill.org>2020-07-07 09:39:23 -0700
committerBrian Wellington <bwelling@xbill.org>2020-07-07 09:39:23 -0700
commitea5a8bfc00b2b0e1f43af6758e84c97c5306af5c (patch)
tree6ca906113957f818aad4d72f78a6b4f40964c0fb /tests/test_tsig.py
parente3028db2d10e7ea1d4fa48e9dc7594236a5ef1a4 (diff)
downloaddnspython-ea5a8bfc00b2b0e1f43af6758e84c97c5306af5c.tar.gz
Split TSIG sign and validate.
Diffstat (limited to 'tests/test_tsig.py')
-rw-r--r--tests/test_tsig.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/test_tsig.py b/tests/test_tsig.py
index 2722e15..59b83be 100644
--- a/tests/test_tsig.py
+++ b/tests/test_tsig.py
@@ -18,14 +18,16 @@ keyname = dns.name.from_text('keyname')
class TSIGTestCase(unittest.TestCase):
- def test_get_algorithm(self):
- n = dns.name.from_text('hmac-sha256')
- (w, alg) = dns.tsig.get_algorithm(n)
- self.assertEqual(alg, hashlib.sha256)
- (w, alg) = dns.tsig.get_algorithm('hmac-sha256')
- self.assertEqual(alg, hashlib.sha256)
- self.assertRaises(NotImplementedError,
- lambda: dns.tsig.get_algorithm('bogus'))
+ def test_get_context(self):
+ key = dns.tsig.Key('foo.com', 'abcd', 'hmac-sha256')
+ ctx = dns.tsig.get_context(key)
+ self.assertEqual(ctx.name, 'hmac-sha256')
+ key = dns.tsig.Key('foo.com', 'abcd', 'hmac-sha512')
+ ctx = dns.tsig.get_context(key)
+ self.assertEqual(ctx.name, 'hmac-sha512')
+ bogus = dns.tsig.Key('foo.com', 'abcd', 'bogus')
+ with self.assertRaises(NotImplementedError):
+ dns.tsig.get_context(bogus)
def test_sign_and_validate(self):
m = dns.message.make_query('example', 'a')