From: Remi Gacogne Date: Mon, 10 Nov 2025 16:48:06 +0000 (+0100) Subject: dnsdist: Test that we do not start with an unknown selector name X-Git-Tag: rec-5.4.0-alpha1~91^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53d47547f68ded58263d87ec66b7b3f143640103;p=thirdparty%2Fpdns.git dnsdist: Test that we do not start with an unknown selector name Signed-off-by: Remi Gacogne --- diff --git a/regression-tests.dnsdist/test_Yaml.py b/regression-tests.dnsdist/test_Yaml.py index 7d1e93c257..dd84779941 100644 --- a/regression-tests.dnsdist/test_Yaml.py +++ b/regression-tests.dnsdist/test_Yaml.py @@ -524,3 +524,55 @@ query_rules: receivedQuery.id = query.id self.assertEqual(query, receivedQuery) self.assertEqual(response, receivedResponse) + +class TestYamlUnknownSelectorName(DNSDistTest): + + _yaml_config_template = """--- +binds: + - listen_address: "127.0.0.1:%d" + protocol: Do53 + +backends: + - address: "127.0.0.1:%d" + protocol: Do53 + +query_rules: + - name: "my-rule" + selector: + type: "And" + selectors: + - type: "ByName" + selector_name: "is-tcp" + - type: "Not" + selector: + type: "RD" + action: + type: "Pool" + pool_name: "tcp-pool" +""" + _yaml_config_params = ['_dnsDistPort', '_testServerPort'] + _config_params = [] + + def testFailToStart(self): + """ + YAML: Fails to start with unknown selector name + """ + pass + + @classmethod + def setUpClass(cls): + failed = False + try: + cls.startDNSDist() + except AssertionError as err: + failed = True + expected = "dnsdist --check-config failed (1): b'Error while parsing YAML file configs/dnsdist_TestYamlUnknownSelectorName.yml: Unable find a selector named is-tcp\\n'" + if str(err) != expected: + raise AssertionError("DNSdist should not start with an unknown selector name: %s" % (err)) + if not failed: + raise AssertionError("DNSdist should not start with an unknown selector name") + + @classmethod + def tearDownClass(cls): + if cls._dnsdist: + cls.killProcess(cls._dnsdist)