]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Test that we do not start with an unknown selector name
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 10 Nov 2025 16:48:06 +0000 (17:48 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 10 Nov 2025 16:48:06 +0000 (17:48 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
regression-tests.dnsdist/test_Yaml.py

index 7d1e93c257143e59db386c09e3d6daabf8448357..dd84779941eba3778abaedafc08b70851cc1054f 100644 (file)
@@ -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)