]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add a Dynamic block rcode rate test using YAML
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 10 Jul 2025 08:35:29 +0000 (10:35 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 10 Jul 2025 13:34:55 +0000 (15:34 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
regression-tests.dnsdist/test_DynBlocksServFail.py

index fa142c8fbd502ccb63558ad7d4032e9bd6752d0d..ec3bb830e412f4172daa04c268b79861d2ee4358 100644 (file)
@@ -112,3 +112,40 @@ class TestDynBlockGroupServFails(DynBlocksTest):
         """
         name = 'servfailrate.group.dynblocks.tests.powerdns.com.'
         self.doTestRCodeRate(name, dns.rcode.SERVFAIL)
+
+class TestDynBlockGroupServFailsYAML(DynBlocksTest):
+
+    _yaml_config_template = """---
+dynamic_rules:
+  - name: "Block client generating too many ServFails"
+    mask_ipv4: 24
+    mask_ipv6: 128
+    exclude_ranges:
+      - "192.0.2.1/32"
+      - "192.0.2.2/32"
+    include_ranges:
+      - "127.0.0.0/24"
+    exclude_domains:
+      - "unused."
+    rules:
+      - type: "rcode-rate"
+        rate: %d
+        seconds: %d
+        action_duration: %d
+        comment: "Exceeded query rate"
+        action: "Drop"
+        rcode: "2"
+
+backends:
+  - address: "127.0.0.1:%d"
+    protocol: Do53
+"""
+    _config_params = []
+    _yaml_config_params = ['_dynBlockQPS', '_dynBlockPeriod', '_dynBlockDuration', '_testServerPort']
+
+    def testDynBlocksServFailRate(self):
+        """
+        Dyn Blocks (group / YAML): Server Failure Rate
+        """
+        name = 'servfailrate.group.dynblocks.tests.powerdns.com.'
+        self.doTestRCodeRate(name, dns.rcode.SERVFAIL)