From: Remi Gacogne Date: Fri, 6 Jul 2018 14:06:13 +0000 (+0200) Subject: dnsdist: Make sure that DynBlock tests do not pass when they shouldn't X-Git-Tag: dnsdist-1.3.1~9^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e44df0f1f5611bf5a32673b88c285145851fabea;p=pdns dnsdist: Make sure that DynBlock tests do not pass when they shouldn't --- diff --git a/regression-tests.dnsdist/dnsdisttests.py b/regression-tests.dnsdist/dnsdisttests.py index 1d3ad6e7a..51cf6ac02 100644 --- a/regression-tests.dnsdist/dnsdisttests.py +++ b/regression-tests.dnsdist/dnsdisttests.py @@ -52,7 +52,7 @@ class DNSDistTest(unittest.TestCase): _consoleKey = None _healthCheckName = 'a.root-servers.net.' _healthCheckCounter = 0 - _healthCheckAnswerUnexpected = False + _answerUnexpected = True @classmethod def startResponders(cls): @@ -159,9 +159,12 @@ class DNSDistTest(unittest.TestCase): response.id = request.id toQueue.put(request, True, cls._queueTimeout) - if not response and (healthCheck or cls._healthCheckAnswerUnexpected): - # unexpected query, or health check - response = dns.message.make_response(request) + if not response: + if healthCheck: + response = dns.message.make_response(request) + elif cls._answerUnexpected: + response = dns.message.make_response(request) + response.set_rcode(dns.rcode.SERVFAIL) return response diff --git a/regression-tests.dnsdist/test_DynBlocks.py b/regression-tests.dnsdist/test_DynBlocks.py index caa32d35d..5cd01e46a 100644 --- a/regression-tests.dnsdist/test_DynBlocks.py +++ b/regression-tests.dnsdist/test_DynBlocks.py @@ -34,7 +34,7 @@ class DynBlocksTest(DNSDistTest): self.assertGreaterEqual(values['blocks'], minBlocks) self.assertLessEqual(values['blocks'], maxBlocks) - def doTestQRate(self, name, testViaAPI=False): + def doTestQRate(self, name, testViaAPI=True): query = dns.message.make_query(name, 'A', 'IN') response = dns.message.make_response(query) rrset = dns.rrset.from_text(name, @@ -459,7 +459,7 @@ class TestDynBlockQPS(DynBlocksTest): Dyn Blocks: QRate """ name = 'qrate.dynblocks.tests.powerdns.com.' - self.doTestQRate(name, testViaAPI=True) + self.doTestQRate(name) class TestDynBlockGroupQPS(DynBlocksTest): @@ -483,7 +483,7 @@ class TestDynBlockGroupQPS(DynBlocksTest): Dyn Blocks (Group): QRate """ name = 'qrate.group.dynblocks.tests.powerdns.com.' - self.doTestQRate(name, testViaAPI=True) + self.doTestQRate(name) class TestDynBlockQPSRefused(DynBlocksTest): diff --git a/regression-tests.dnsdist/test_HealthChecks.py b/regression-tests.dnsdist/test_HealthChecks.py index 7acbbf552..8e25488c0 100644 --- a/regression-tests.dnsdist/test_HealthChecks.py +++ b/regression-tests.dnsdist/test_HealthChecks.py @@ -133,7 +133,7 @@ class TestHealthCheckCustomNameNoAnswer(HealthCheckTest): # because it uses a different health check configuration _testServerPort = 5384 - _healthCheckAnswerUnexpected = False + _answerUnexpected = False _config_template = """ setKey("%s") controlSocket("127.0.0.1:%d") @@ -153,7 +153,7 @@ class TestHealthCheckCustomFunction(HealthCheckTest): # this test suite uses a different responder port # because it uses a different health check configuration _testServerPort = 5385 - _healthCheckAnswerUnexpected = False + _answerUnexpected = False _healthCheckName = 'powerdns.com.' _config_template = """ diff --git a/regression-tests.dnsdist/test_TCPLimits.py b/regression-tests.dnsdist/test_TCPLimits.py index 41ccbb9b4..e67a152d3 100644 --- a/regression-tests.dnsdist/test_TCPLimits.py +++ b/regression-tests.dnsdist/test_TCPLimits.py @@ -9,7 +9,7 @@ class TestTCPLimits(DNSDistTest): # this test suite uses a different responder port # because it uses a different health check configuration _testServerPort = 5395 - _healthCheckAnswerUnexpected = True + _answerUnexpected = True _tcpIdleTimeout = 2 _maxTCPQueriesPerConn = 5