]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add a test for EXTEND adding a record with mismatching TTL. 16753/head
authorMiod Vallat <miod.vallat@powerdns.com>
Wed, 21 Jan 2026 14:14:48 +0000 (15:14 +0100)
committerMiod Vallat <miod.vallat@powerdns.com>
Wed, 21 Jan 2026 14:43:16 +0000 (15:43 +0100)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
regression-tests.api/test_Zones.py

index 25db863a3e44cb2f035130132bd10260ba05bba1..bd1642257a25cfd4a2cd3384872c7a2ce830c4d9 100644 (file)
@@ -1677,6 +1677,48 @@ $NAME$  1D  IN  SOA ns1.example.org. hostmaster.example.org. (
         data2 = self.get_zone(name)
         self.assertEqual(get_rrset(data, 'a.'+name), get_rrset(data2, 'a.'+name))
 
+    def test_zone_rr_bogus_extend(self):
+        name, payload, zone = self.create_zone()
+        # add a single record with extend
+        rrset = {
+            'changetype': 'extend',
+            'name': 'txt.'+name,
+            'type': 'TXT',
+            'ttl': 3600,
+            'records': [
+                {
+                    "content": "\"hello\"",
+                    "disabled": False
+                }
+            ]
+        }
+        payload = {'rrsets': [rrset]}
+        r = self.session.patch(
+            self.url("/api/v1/servers/localhost/zones/" + name),
+            data=json.dumps(payload),
+            headers={'content-type': 'application/json'})
+        self.assert_success(r)
+        # try and add another record with a mismatching ttl
+        rrset2 = {
+            'changetype': 'extend',
+            'name': 'txt.'+name,
+            'type': 'TXT',
+            'ttl': 1234,
+            'records': [
+                {
+                    "content": "\"hello again\"",
+                    "disabled": False
+                }
+            ]
+        }
+        payload2 = {'rrsets': [rrset2]}
+        r = self.session.patch(
+            self.url("/api/v1/servers/localhost/zones/" + name),
+            data=json.dumps(payload2),
+            headers={'content-type': 'application/json'})
+        self.assertEqual(r.status_code, 422)
+        self.assert_in_json_error('uses a different TTL value than the remainder of the RRset', r.json())
+
     def test_zone_rr_update_with_prune(self):
         name, payload, zone = self.create_zone()
         # fill a bunch of records