]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Test that DSTPortRule captures queries
authorphonedph1 <phoned@gmail.com>
Thu, 26 Jul 2018 16:35:42 +0000 (16:35 +0000)
committerphonedph1 <phoned@gmail.com>
Thu, 26 Jul 2018 16:35:42 +0000 (16:35 +0000)
regression-tests.dnsdist/test_Advanced.py

index aac6b474236d9cf4c0280185a0c1f1e3dfafcbfc..d65cca8e4b63f1ba39b11ec64d7093ed5f93e71d 100644 (file)
@@ -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 = """