MCPcopy Create free account
hub / github.com/rthalley/dnspython / testInvalidDigestLength

Method testInvalidDigestLength

tests/test_dnssec.py:1209–1230  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1207 )
1208
1209 def testInvalidDigestLength(self): # type: () -> None
1210 test_records = []
1211 for rdata in [example_ds_sha1, example_ds_sha256, example_ds_sha384]:
1212 flags, digest = rdata.to_text().rsplit(" ", 1)
1213
1214 # Make sure the construction is working
1215 dns.rdata.from_text(
1216 dns.rdataclass.IN, dns.rdatatype.DS, f"{flags} {digest}"
1217 )
1218
1219 test_records.append(
1220 f"{flags} {digest[:len(digest)//2]}"
1221 ) # too short digest
1222 test_records.append(f"{flags} {digest*2}") # too long digest
1223
1224 for record in test_records:
1225 with self.assertRaises(dns.exception.SyntaxError) as cm:
1226 dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.DS, record)
1227
1228 self.assertEqual(
1229 "digest length inconsistent with digest type", str(cm.exception)
1230 )
1231
1232 def testInvalidDigestLengthCDS0(self): # type: () -> None
1233 # Make sure the construction is working

Callers

nothing calls this directly

Calls 2

to_textMethod · 0.45
from_textMethod · 0.45

Tested by

no test coverage detected