Skip to content

Commit

Permalink
add failing test that PowerDNS#7900 should fix
Browse files Browse the repository at this point in the history
  • Loading branch information
melissavoegeli committed Jun 19, 2019
1 parent 67dedcb commit 1cb771c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions regression-tests.dnsdist/test_DOH.py
Expand Up @@ -5,7 +5,8 @@
from dnsdisttests import DNSDistTest

import pycurl

import re
from StringIO import StringIO
#from hyper import HTTP20Connection
#from hyper.ssl_compat import SSLContext, PROTOCOL_TLSv1_2

Expand Down Expand Up @@ -33,12 +34,14 @@ def openDOHConnection(cls, port, caFile, timeout=2.0):
def sendDOHQuery(cls, port, servername, baseurl, query, response=None, timeout=2.0, caFile=None, useQueue=True, rawQuery=False, customHeaders=[]):
url = cls.getDOHGetURL(baseurl, query, rawQuery)
conn = cls.openDOHConnection(port, caFile=caFile, timeout=timeout)
response_headers = StringIO()
#conn.setopt(pycurl.VERBOSE, True)
conn.setopt(pycurl.URL, url)
conn.setopt(pycurl.RESOLVE, ["%s:%d:127.0.0.1" % (servername, port)])
conn.setopt(pycurl.SSL_VERIFYPEER, 1)
conn.setopt(pycurl.SSL_VERIFYHOST, 2)
conn.setopt(pycurl.HTTPHEADER, customHeaders)
conn.setopt(pycurl.HEADERFUNCTION, response_headers.write)
if caFile:
conn.setopt(pycurl.CAINFO, caFile)

Expand All @@ -47,6 +50,7 @@ def sendDOHQuery(cls, port, servername, baseurl, query, response=None, timeout=2

receivedQuery = None
message = None
cls._response_headers = ''
data = conn.perform_rb()
rcode = conn.getinfo(pycurl.RESPONSE_CODE)
if rcode == 200:
Expand All @@ -55,6 +59,7 @@ def sendDOHQuery(cls, port, servername, baseurl, query, response=None, timeout=2
if useQueue and not cls._fromResponderQueue.empty():
receivedQuery = cls._fromResponderQueue.get(True, timeout)

cls._response_headers = response_headers.getvalue()
return (receivedQuery, message)

@classmethod
Expand Down Expand Up @@ -128,7 +133,7 @@ class TestDOH(DNSDistDOHTest):
_serverName = 'tls.tests.dnsdist.org'
_caCert = 'ca.pem'
_dohServerPort = 8443
_serverName = 'tls.tests.dnsdist.org'
_customResponseHeaders = 'Access-Control-Allow-Origin: *'
_dohBaseURL = ("https://%s:%d/" % (_serverName, _dohServerPort))
_config_template = """
newServer{address="127.0.0.1:%s"}
Expand Down Expand Up @@ -165,6 +170,7 @@ def testDOHSimple(self):
self.assertTrue(receivedResponse)
receivedQuery.id = expectedQuery.id
self.assertEquals(expectedQuery, receivedQuery)
self.assertTrue(re.match(self._customResponseHeaders, self._response_headers))
self.checkQueryEDNSWithoutECS(expectedQuery, receivedQuery)
self.assertEquals(response, receivedResponse)

Expand Down

0 comments on commit 1cb771c

Please sign in to comment.