]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth-py tests: py3 9712/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 17 Nov 2020 09:57:45 +0000 (10:57 +0100)
committerKevin P. Fleming <kevin@km6g.us>
Tue, 17 Nov 2020 11:03:08 +0000 (06:03 -0500)
regression-tests.auth-py/clientsubnetoption.py
regression-tests.auth-py/requirements.txt
regression-tests.auth-py/test_IXFR.py

index c4f78f25d28b1a6bfb08965e3a4a735119365992..5da748ab0b0901758a0a5bb4349f75955599d229 100644 (file)
@@ -35,6 +35,7 @@ Requirements:
 from __future__ import print_function
 from __future__ import division
 
+import math
 import socket
 import struct
 import dns
@@ -125,7 +126,7 @@ class ClientSubnetOption(dns.edns.Option):
         """" Determines whether this instance is using the draft option code """
         return self.option == DRAFT_OPTION_CODE
 
-    def to_wire(self, file):
+    def to_wire(self, file=None):
         """Create EDNS packet as defined in draft-vandergaast-edns-client-subnet-01."""
 
         ip = self.calculate_ip()
@@ -142,7 +143,10 @@ class ClientSubnetOption(dns.edns.Option):
 
         format = "!HBB%ds" % (mask_bits // 8)
         data = struct.pack(format, self.family, self.mask, self.scope, test)
-        file.write(data)
+        if file:
+            file.write(data)
+        else:
+            return data
 
     def from_wire(cls, otype, wire, current, olen):
         """Read EDNS packet as defined in draft-vandergaast-edns-client-subnet-01.
@@ -173,6 +177,23 @@ class ClientSubnetOption(dns.edns.Option):
 
     from_wire = classmethod(from_wire)
 
+    # needed in 2.0.0..
+    @classmethod
+    def from_wire_parser(cls, otype, parser):
+        family, src, scope = parser.get_struct('!HBB')
+        addrlen = int(math.ceil(src / 8.0))
+        prefix = parser.get_bytes(addrlen)
+        if family == 1:
+            pad = 4 - addrlen
+            addr = dns.ipv4.inet_ntoa(prefix + b'\x00' * pad)
+        elif family == 2:
+            pad = 16 - addrlen
+            addr = dns.ipv6.inet_ntoa(prefix + b'\x00' * pad)
+        else:
+            raise ValueError('unsupported family')
+
+        return cls(addr, src, scope, otype)
+
     def __repr__(self):
         if self.family == FAMILY_IPV4:
             ip = socket.inet_ntop(socket.AF_INET, struct.pack('!L', self.ip))
@@ -189,6 +210,9 @@ class ClientSubnetOption(dns.edns.Option):
             self.scope
         )
 
+    def to_text(self):
+        return self.__repr__()
+
     def __eq__(self, other):
         """Rich comparison method for equality.
 
index 27efa323412b0f6077c563c21ec05452789b469c..6f6ac0bab0797f0d533f05db4e7c1f69a143abe3 100644 (file)
@@ -2,4 +2,4 @@ dnspython>=1.11
 nose>=1.3.7
 Twisted>0.15.0
 requests>=2.18.4
-git+https://github.com/PowerDNS/xfrserver.git@0.2
+git+https://github.com/PowerDNS/xfrserver.git@0.3
index 0970d92321ec1d9346339636364aca550d9bff90..fa8c8508223232c0324de2e45eda991d199e6e17 100644 (file)
@@ -239,6 +239,6 @@ newrecord.example.        8484    A       192.0.2.42
         ret = subprocess.check_output([os.environ['PDNSUTIL'],
                            '--config-dir=configs/auth',
                            'list-zone', 'example'], stderr=subprocess.STDOUT)
-        rets = ret.split('\n')
+        rets = ret.split(b'\n')
 
-        self.assertEqual(1, sum('SOA' in l for l in ret.split('\n')))
\ No newline at end of file
+        self.assertEqual(1, sum(b'SOA' in l for l in ret.split(b'\n')))
\ No newline at end of file