import libnacl
import libnacl.utils
+from eqdnsmessage import AssertEqualDNSMessageMixin
+
# Python2/3 compatibility hacks
try:
from queue import Queue
pass
-class DNSDistTest(unittest.TestCase):
+class DNSDistTest(AssertEqualDNSMessageMixin, unittest.TestCase):
"""
Set up a dnsdist instance and responder threads.
Queries sent to dnsdist are relayed to the responder threads,
_healthCheckName = 'a.root-servers.net.'
_healthCheckCounter = 0
_answerUnexpected = True
+ _checkConfigExpectedOutput = None
@classmethod
def startResponders(cls):
output = subprocess.check_output(testcmd, stderr=subprocess.STDOUT, close_fds=True)
except subprocess.CalledProcessError as exc:
raise AssertionError('dnsdist --check-config failed (%d): %s' % (exc.returncode, exc.output))
- expectedOutput = ('Configuration \'%s\' OK!\n' % (confFile)).encode()
+ if cls._checkConfigExpectedOutput is not None:
+ expectedOutput = cls._checkConfigExpectedOutput
+ else:
+ expectedOutput = ('Configuration \'%s\' OK!\n' % (confFile)).encode()
if output != expectedOutput:
raise AssertionError('dnsdist --check-config failed: %s' % output)
request = dns.message.from_wire(data, ignore_trailing=True)
forceRcode = trailingDataResponse
+ wire = None
if callback:
wire = callback(request)
else:
if response:
wire = response.to_wire()
+ if not wire:
+ continue
+
sock.settimeout(2.0)
sock.sendto(wire, addr)
sock.settimeout(None)
while not self._fromResponderQueue.empty():
self._fromResponderQueue.get(False)
+ super(DNSDistTest, self).setUp()
+
@classmethod
def clearToResponderQueue(cls):
while not cls._toResponderQueue.empty():
def checkResponseNoEDNS(self, expected, received):
self.checkMessageNoEDNS(expected, received)
+