summaryrefslogtreecommitdiff
path: root/tests/test_edns.py
diff options
context:
space:
mode:
authorBrian Wellington <bwelling@xbill.org>2020-06-17 11:50:25 -0700
committerBrian Wellington <bwelling@xbill.org>2020-06-17 11:50:25 -0700
commit0bbca68e277f6dbcf0d7d6df1bdf28f4f2124f85 (patch)
treea49b33cf2a3cce1cc00ae0efee69cafd18b74d70 /tests/test_edns.py
parentf028afbd0d8b26ed7a647e1c695cba4067ef638f (diff)
downloaddnspython-0bbca68e277f6dbcf0d7d6df1bdf28f4f2124f85.tar.gz
Improve EDNS option test coverage.
Diffstat (limited to 'tests/test_edns.py')
-rw-r--r--tests/test_edns.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/test_edns.py b/tests/test_edns.py
index 9383947..f4d6075 100644
--- a/tests/test_edns.py
+++ b/tests/test_edns.py
@@ -29,6 +29,7 @@ class OptionTestCase(unittest.TestCase):
opt.to_wire(io)
data = io.getvalue()
self.assertEqual(data, b'data')
+ self.assertEqual(dns.edns.option_from_wire(3, data, 0, len(data)), opt)
def testECSOption_prefix_length(self):
opt = dns.edns.ECSOption('1.2.255.33', 20)
@@ -37,14 +38,6 @@ class OptionTestCase(unittest.TestCase):
data = io.getvalue()
self.assertEqual(data, b'\x00\x01\x14\x00\x01\x02\xf0')
- def testECSOption_from_wire(self):
- opt = dns.edns.option_from_wire(8, b'\x00\x01\x14\x00\x01\x02\xf0',
- 0, 7)
- self.assertEqual(opt.otype, dns.edns.ECS)
- self.assertEqual(opt.address, '1.2.240.0')
- self.assertEqual(opt.srclen, 20)
- self.assertEqual(opt.scopelen, 0)
-
def testECSOption(self):
opt = dns.edns.ECSOption('1.2.3.4', 24)
io = BytesIO()
@@ -59,6 +52,12 @@ class OptionTestCase(unittest.TestCase):
data = io.getvalue()
self.assertEqual(data, b'\x00\x01\x19\x00\x01\x02\x03\x80')
+ opt2 = dns.edns.option_from_wire(dns.edns.ECS, data, 0, len(data))
+ self.assertEqual(opt2.otype, dns.edns.ECS)
+ self.assertEqual(opt2.address, '1.2.3.128')
+ self.assertEqual(opt2.srclen, 25)
+ self.assertEqual(opt2.scopelen, 0)
+
def testECSOption_v6(self):
opt = dns.edns.ECSOption('2001:4b98::1')
io = BytesIO()
@@ -66,6 +65,12 @@ class OptionTestCase(unittest.TestCase):
data = io.getvalue()
self.assertEqual(data, b'\x00\x02\x38\x00\x20\x01\x4b\x98\x00\x00\x00')
+ opt2 = dns.edns.option_from_wire(dns.edns.ECS, data, 0, len(data))
+ self.assertEqual(opt2.otype, dns.edns.ECS)
+ self.assertEqual(opt2.address, '2001:4b98::')
+ self.assertEqual(opt2.srclen, 56)
+ self.assertEqual(opt2.scopelen, 0)
+
def testECSOption_from_text_valid(self):
ecs1 = dns.edns.ECSOption.from_text('1.2.3.4/24/0')
self.assertEqual(ecs1, dns.edns.ECSOption('1.2.3.4', 24, 0))