(self, alg, length)
| 255 | self.assertRaises(ex, bad) |
| 256 | |
| 257 | def _test_truncated_algorithm(self, alg, length): |
| 258 | key = dns.tsig.Key("foo", b"abcdefg", algorithm=alg) |
| 259 | q = dns.message.make_query("example", "a") |
| 260 | q.use_tsig(key) |
| 261 | q2 = dns.message.from_wire(q.to_wire(), keyring=key) |
| 262 | |
| 263 | self.assertTrue(q2.had_tsig) |
| 264 | self.assertEqual(q2.tsig[0].algorithm, q.tsig[0].algorithm) |
| 265 | self.assertEqual(len(q2.tsig[0].mac), length // 8) |
| 266 | |
| 267 | def test_hmac_sha256_128(self): |
| 268 | self._test_truncated_algorithm(dns.tsig.HMAC_SHA256_128, 128) |
no test coverage detected