]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - regression-tests.recursor-dnssec/test_ECS.py
Merge pull request #13509 from rgacogne/ddist-teeaction-proxyprotocol
[thirdparty/pdns.git] / regression-tests.recursor-dnssec / test_ECS.py
index b28b4b91f73109f1414cea899d5386b641bf720b..d4e5e9d72b435ad9d85a63808a0b30f9c639bb3c 100644 (file)
@@ -22,14 +22,16 @@ class ECSTest(RecursorTest):
 daemon=no
 trace=yes
 dont-query=
-ecs-add-for=0.0.0.0/0
 local-address=127.0.0.1
-packetcache-ttl=0
-packetcache-servfail-ttl=0
+packetcache-ttl=15
+packetcache-servfail-ttl=15
 max-cache-ttl=600
-threads=1
+threads=2
 loglevel=9
 disable-syslog=yes
+log-common-errors=yes
+statistics-interval=0
+ecs-add-for=0.0.0.0/0
 """
 
     def sendECSQuery(self, query, expected, expectedFirstTTL=None, scopeZeroResponse=None):
@@ -39,7 +41,7 @@ disable-syslog=yes
         self.assertRRsetInAnswer(res, expected)
         # this will break if you are not looking for the first RR, sorry!
         if expectedFirstTTL is not None:
-            self.assertEqual(res.answer[0].ttl, expectedFirstTTL)
+            self.assertTrue(res.answer[0].ttl == expectedFirstTTL or res.answer[0].ttl == expectedFirstTTL - 1)
         else:
             expectedFirstTTL = res.answer[0].ttl
         self.assertEqual(res.edns, query.edns)
@@ -117,7 +119,7 @@ disable-syslog=yes
 class testNoECS(ECSTest):
     _confdir = 'NoECS'
 
-    _config_template = """edns-subnet-whitelist=
+    _config_template = """edns-subnet-allow-list=
 forward-zones=ecs-echo.example=%s.21
     """ % (os.environ['PREFIX'])
 
@@ -142,7 +144,7 @@ forward-zones=ecs-echo.example=%s.21
 class testIncomingNoECS(ECSTest):
     _confdir = 'IncomingNoECS'
 
-    _config_template = """edns-subnet-whitelist=
+    _config_template = """edns-subnet-allow-list=
 use-incoming-edns-subnet=yes
 forward-zones=ecs-echo.example=%s.21
     """ % (os.environ['PREFIX'])
@@ -170,7 +172,7 @@ forward-zones=ecs-echo.example=%s.21
 class testECSByName(ECSTest):
     _confdir = 'ECSByName'
 
-    _config_template = """edns-subnet-whitelist=ecs-echo.example.
+    _config_template = """edns-subnet-allow-list=ecs-echo.example.
 forward-zones=ecs-echo.example=%s.21
     """ % (os.environ['PREFIX'])
 
@@ -201,7 +203,7 @@ forward-zones=ecs-echo.example=%s.21
 class testECSByNameLarger(ECSTest):
     _confdir = 'ECSByNameLarger'
 
-    _config_template = """edns-subnet-whitelist=ecs-echo.example.
+    _config_template = """edns-subnet-allow-list=ecs-echo.example.
 ecs-ipv4-bits=32
 forward-zones=ecs-echo.example=%s.21
 ecs-ipv4-cache-bits=32
@@ -235,7 +237,7 @@ ecs-ipv6-cache-bits=128
 class testECSByNameSmaller(ECSTest):
     _confdir = 'ECSByNameLarger'
 
-    _config_template = """edns-subnet-whitelist=ecs-echo.example.
+    _config_template = """edns-subnet-allow-list=ecs-echo.example.
 ecs-ipv4-bits=16
 forward-zones=ecs-echo.example=%s.21
     """ % (os.environ['PREFIX'])
@@ -262,7 +264,7 @@ forward-zones=ecs-echo.example=%s.21
 class testIncomingECSByName(ECSTest):
     _confdir = 'ECSIncomingByName'
 
-    _config_template = """edns-subnet-whitelist=ecs-echo.example.
+    _config_template = """edns-subnet-allow-list=ecs-echo.example.
 use-incoming-edns-subnet=yes
 forward-zones=ecs-echo.example=%s.21
 ecs-scope-zero-address=2001:db8::42
@@ -302,7 +304,7 @@ ecs-ipv6-cache-bits=128
 class testIncomingECSByNameLarger(ECSTest):
     _confdir = 'ECSIncomingByNameLarger'
 
-    _config_template = """edns-subnet-whitelist=ecs-echo.example.
+    _config_template = """edns-subnet-allow-list=ecs-echo.example.
 use-incoming-edns-subnet=yes
 ecs-ipv4-bits=32
 forward-zones=ecs-echo.example=%s.21
@@ -334,7 +336,7 @@ ecs-ipv6-cache-bits=128
 class testIncomingECSByNameSmaller(ECSTest):
     _confdir = 'ECSIncomingByNameSmaller'
 
-    _config_template = """edns-subnet-whitelist=ecs-echo.example.
+    _config_template = """edns-subnet-allow-list=ecs-echo.example.
 use-incoming-edns-subnet=yes
 ecs-ipv4-bits=16
 forward-zones=ecs-echo.example=%s.21
@@ -365,7 +367,7 @@ ecs-ipv6-cache-bits=128
 class testIncomingECSByNameV6(ECSTest):
     _confdir = 'ECSIncomingByNameV6'
 
-    _config_template = """edns-subnet-whitelist=ecs-echo.example.
+    _config_template = """edns-subnet-allow-list=ecs-echo.example.
 use-incoming-edns-subnet=yes
 ecs-ipv6-bits=128
 ecs-ipv4-cache-bits=32
@@ -398,7 +400,7 @@ forward-zones=ecs-echo.example=[::1]:53000
 class testECSNameMismatch(ECSTest):
     _confdir = 'ECSNameMismatch'
 
-    _config_template = """edns-subnet-whitelist=not-the-right-name.example.
+    _config_template = """edns-subnet-allow-list=not-the-right-name.example.
 forward-zones=ecs-echo.example=%s.21
     """ % (os.environ['PREFIX'])
 
@@ -423,7 +425,7 @@ forward-zones=ecs-echo.example=%s.21
 class testECSByIP(ECSTest):
     _confdir = 'ECSByIP'
 
-    _config_template = """edns-subnet-whitelist=%s.21
+    _config_template = """edns-subnet-allow-list=%s.21
 forward-zones=ecs-echo.example=%s.21
     """ % (os.environ['PREFIX'], os.environ['PREFIX'])
 
@@ -449,7 +451,7 @@ forward-zones=ecs-echo.example=%s.21
 class testIncomingECSByIP(ECSTest):
     _confdir = 'ECSIncomingByIP'
 
-    _config_template = """edns-subnet-whitelist=%s.21
+    _config_template = """edns-subnet-allow-list=%s.21
 use-incoming-edns-subnet=yes
 forward-zones=ecs-echo.example=%s.21
 ecs-scope-zero-address=::1
@@ -489,7 +491,7 @@ ecs-ipv6-cache-bits=128
 class testECSIPMismatch(ECSTest):
     _confdir = 'ECSIPMismatch'
 
-    _config_template = """edns-subnet-whitelist=192.0.2.1
+    _config_template = """edns-subnet-allow-list=192.0.2.1
 forward-zones=ecs-echo.example=%s.21
     """ % (os.environ['PREFIX'])
 
@@ -512,24 +514,34 @@ forward-zones=ecs-echo.example=%s.21
         query = dns.message.make_query(nameECS, 'TXT', 'IN', use_edns=True, options=[ecso], payload=512)
         self.sendECSQuery(query, expected)
 
+class testECSWithProxyProtocoldRecursorTest(ECSTest):
+    _confdir = 'ECSWithProxyProtocol'
+    _config_template = """
+    ecs-add-for=2001:db8::1/128
+    edns-subnet-allow-list=ecs-echo.example.
+    forward-zones=ecs-echo.example=%s.21
+    proxy-protocol-from=127.0.0.1/32
+    allow-from=2001:db8::1/128
+""" % (os.environ['PREFIX'])
+
+    def testProxyProtocolPlusECS(self):
+        qname = nameECS
+        expected = dns.rrset.from_text(qname, 0, dns.rdataclass.IN, 'TXT', '2001:db8::/56')
+
+        query = dns.message.make_query(qname, 'TXT', use_edns=True)
+        for method in ("sendUDPQueryWithProxyProtocol", "sendTCPQueryWithProxyProtocol"):
+            sender = getattr(self, method)
+            res = sender(query, True, '2001:db8::1', '2001:db8::2', 0, 65535)
+            self.assertRcodeEqual(res, dns.rcode.NOERROR)
+            self.assertRRsetInAnswer(res, expected)
+
 class testTooLargeToAddZeroScope(RecursorTest):
 
     _confdir = 'TooLargeToAddZeroScope'
-    _config_template_default = """
+    _config_template = """
 use-incoming-edns-subnet=yes
 dnssec=validate
-daemon=no
-trace=yes
-packetcache-ttl=0
-packetcache-servfail-ttl=0
-max-cache-ttl=15
-threads=1
-loglevel=9
-disable-syslog=yes
-log-common-errors=yes
 """
-    _config_template = """
-    """
     _lua_dns_script_file = """
     function preresolve(dq)
       if dq.qname == newDN('toolarge.ecs.') then