From: phonedph1 Date: Thu, 26 Jul 2018 16:35:42 +0000 (+0000) Subject: Test that DSTPortRule captures queries X-Git-Tag: dnsdist-1.3.3~177^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8205923d5ca39b0d6c3194ae839abf962a18586;p=thirdparty%2Fpdns.git Test that DSTPortRule captures queries --- diff --git a/regression-tests.dnsdist/test_Advanced.py b/regression-tests.dnsdist/test_Advanced.py index aac6b47423..d65cca8e4b 100644 --- a/regression-tests.dnsdist/test_Advanced.py +++ b/regression-tests.dnsdist/test_Advanced.py @@ -1021,6 +1021,33 @@ class TestAdvancedNMGRule(DNSDistTest): (_, receivedResponse) = self.sendTCPQuery(query, response=None, useQueue=False) self.assertEquals(receivedResponse, expectedResponse) +class TestDSTPortRule(DNSDistTest): + + _config_params = ['_dnsDistPort', '_testServerPort'] + _config_template = """ + addAction(DSTPortRule(%d), RCodeAction(dnsdist.REFUSED)) + newServer{address="127.0.0.1:%s"} + """ + + def testDSTPortRule(self): + """ + Advanced: DSTPortRule should capture our queries + + Send queries to "dstportrule.advanced.tests.powerdns.com.", + check that we are getting a REFUSED response. + """ + + name = 'dstportrule.advanced.tests.powerdns.com.' + query = dns.message.make_query(name, 'A', 'IN') + expectedResponse = dns.message.make_response(query) + expectedResponse.set_rcode(dns.rcode.REFUSED) + + (_, receivedResponse) = self.sendUDPQuery(query, response=None, useQueue=False) + self.assertEquals(receivedResponse, expectedResponse) + + (_, receivedResponse) = self.sendTCPQuery(query, response=None, useQueue=False) + self.assertEquals(receivedResponse, expectedResponse) + class TestAdvancedLabelsCountRule(DNSDistTest): _config_template = """