From: Otto Moerbeek Date: Tue, 11 May 2021 11:52:28 +0000 (+0200) Subject: Add corresponding regress test X-Git-Tag: rec-4.4.4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10390%2Fhead;p=thirdparty%2Fpdns.git Add corresponding regress test --- diff --git a/regression-tests.recursor-dnssec/test_ECS.py b/regression-tests.recursor-dnssec/test_ECS.py index 57b8a09d99..efa799f14f 100644 --- a/regression-tests.recursor-dnssec/test_ECS.py +++ b/regression-tests.recursor-dnssec/test_ECS.py @@ -520,6 +520,77 @@ class testECSWithProxyProtocoldRecursorTest(ECSTest): self.assertRcodeEqual(res, dns.rcode.NOERROR) self.assertRRsetInAnswer(res, expected) +class testTooLargeToAddZeroScope(RecursorTest): + + _confdir = 'TooLargeToAddZeroScope' + _config_template_default = """ +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 + dq:addRecord(pdns.TXT, '%s', pdns.place.ANSWER) + return true + end + return false + end + """ % ('A'*447) + + _roothints = None + + @classmethod + def setUpClass(cls): + + # we don't need all the auth stuff + cls.setUpSockets() + cls.startResponders() + + confdir = os.path.join('configs', cls._confdir) + cls.createConfigDir(confdir) + + cls.generateRecursorConfig(confdir) + cls.startRecursor(confdir, cls._recursorPort) + + @classmethod + def tearDownClass(cls): + cls.tearDownRecursor() + + @classmethod + def generateRecursorConfig(cls, confdir): + super(testTooLargeToAddZeroScope, cls).generateRecursorConfig(confdir) + + def testTooLarge(self): + qname = 'toolarge.ecs.' + ecso = clientsubnetoption.ClientSubnetOption('192.0.2.1', 24) + query = dns.message.make_query(qname, 'TXT', 'IN', use_edns=True, options=[ecso], payload=512) + + # should not have an ECS Option since the packet is too large already + res = self.sendUDPQuery(query, timeout=5.0) + self.assertRcodeEqual(res, dns.rcode.NOERROR) + self.assertEqual(len(res.answer), 1) + self.assertEqual(res.edns, 0) + self.assertEqual(len(res.options), 0) + + res = self.sendTCPQuery(query, timeout=5.0) + self.assertRcodeEqual(res, dns.rcode.NOERROR) + self.assertEqual(len(res.answer), 1) + self.assertEqual(res.edns, 0) + self.assertEqual(len(res.options), 1) + self.assertEqual(res.options[0].otype, 8) + self.assertEqual(res.options[0].scope, 0) + class UDPECSResponder(DatagramProtocol): @staticmethod def ipToStr(option):