summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-07-07 17:29:35 -0700
committerGitHub <noreply@github.com>2020-07-07 17:29:35 -0700
commite4ccb0e27ff163a2967530f0356bb4e8c0b5d14a (patch)
tree3c561a81a3cdacd2e0ae435ba3a7e5bd61323990 /tests
parentda76c54eaa2e6d0e8c15267f37eadd92df86868f (diff)
parentea5a8bfc00b2b0e1f43af6758e84c97c5306af5c (diff)
downloaddnspython-e4ccb0e27ff163a2967530f0356bb4e8c0b5d14a.tar.gz
Merge pull request #531 from bwelling/tsig2
Split TSIG sign and validate.
Diffstat (limited to 'tests')
-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 f5c62cc..4b8a395 100644
--- a/tests/test_tsig.py
+++ b/tests/test_tsig.py
@@ -19,14 +19,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')