|
45 | 45 | from dns.rdtypes.ANY.GPOS import GPOS |
46 | 46 | from dns.rdtypes.ANY.LOC import LOC |
47 | 47 | from dns.rdtypes.ANY.OPT import OPT |
| 48 | +from dns.rdtypes.IN.WKS import WKS |
48 | 49 | from tests.util import here |
49 | 50 |
|
50 | 51 |
|
@@ -511,6 +512,22 @@ def test_misc_bad_WKS_text(self): |
511 | 512 | except dns.exception.SyntaxError as e: |
512 | 513 | self.assertIsInstance(e.__cause__, NotImplementedError) |
513 | 514 |
|
| 515 | + def test_wks_bounds(self): |
| 516 | + rd = dns.rdata.from_text("IN", "WKS", "10.0.0.1 udp 0") |
| 517 | + self.assertEqual(rd.bitmap, b"\x80") |
| 518 | + rd = dns.rdata.from_text("IN", "WKS", "10.0.0.1 udp 65535") |
| 519 | + self.assertEqual(len(rd.bitmap), 8192) |
| 520 | + self.assertEqual(rd.bitmap[-1], 1) |
| 521 | + with self.assertRaises(dns.exception.SyntaxError): |
| 522 | + rd = dns.rdata.from_text("IN", "WKS", "10.0.0.1 udp -1") |
| 523 | + with self.assertRaises(dns.exception.SyntaxError): |
| 524 | + rd = dns.rdata.from_text("IN", "WKS", "10.0.0.1 udp 65536") |
| 525 | + # test direct invocation of the constructor too |
| 526 | + rd = WKS(dns.rdataclass.IN, dns.rdatatype.WKS, "10.0.0.1", 1, bytes()) |
| 527 | + rd = WKS(dns.rdataclass.IN, dns.rdatatype.WKS, "10.0.0.1", 1, bytes(8192)) |
| 528 | + with self.assertRaises(ValueError): |
| 529 | + WKS(dns.rdataclass.IN, dns.rdatatype.WKS, "10.0.0.1", 1, bytes(8193)) |
| 530 | + |
514 | 531 | def test_GPOS_float_converters(self): |
515 | 532 | rd = dns.rdata.from_text("in", "gpos", "49 0 0") |
516 | 533 | self.assertEqual(rd.float_latitude, 49.0) |
|
0 commit comments