From: Miod Vallat Date: Fri, 13 Jun 2025 08:37:28 +0000 (+0200) Subject: Correctly return the previous serial number in X-PDNS-Old-Serial. X-Git-Tag: dnsdist-2.1.0-alpha0^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e697bdc197978ec6e2728a8b65fc2af8fc51d9f3;p=thirdparty%2Fpdns.git Correctly return the previous serial number in X-PDNS-Old-Serial. --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 5ec8c2c9cd..f1d0bf9063 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -2441,6 +2441,9 @@ static void patchZone(UeberBackend& backend, const ZoneName& zonename, DomainInf // edit SOA (if needed) if (!zone_disabled && !soa_edit_api_kind.empty() && !soa_edit_done) { + // return old serial in headers, before changing it + resp->headers["X-PDNS-Old-Serial"] = std::to_string(soaData.serial); + DNSResourceRecord resourceRecord; if (makeIncreasedSOARecord(soaData, soa_edit_api_kind, soa_edit_kind, resourceRecord)) { if (!domainInfo.backend->replaceRRSet(domainInfo.id, resourceRecord.qname, resourceRecord.qtype, vector(1, resourceRecord))) { @@ -2448,9 +2451,7 @@ static void patchZone(UeberBackend& backend, const ZoneName& zonename, DomainInf } } - // return old and new serials in headers - resp->headers["X-PDNS-Old-Serial"] = std::to_string(soaData.serial); - fillSOAData(resourceRecord.content, soaData); + // return new serial in headers resp->headers["X-PDNS-New-Serial"] = std::to_string(soaData.serial); } } diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index 6538c2ee67..8a4871a988 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -298,13 +298,15 @@ class AuthZones(ApiTestCase, AuthZonesHelperMixin): ] } payload = {'rrsets': [rrset]} - self.session.patch( + r = self.session.patch( self.url("/api/v1/servers/localhost/zones/" + data['id']), data=json.dumps(payload), headers={'content-type': 'application/json'}) data = self.get_zone(data['id']) soa_serial = get_first_rec(data, name, 'SOA')['content'].split(' ')[2] self.assertEqual(soa_serial[-2:], '02') + self.assertEqual(r.headers['X-PDNS-Old-Serial'][-2:], '01') + self.assertEqual(r.headers['X-PDNS-New-Serial'][-2:], '02') def test_create_zone_with_records(self): name = unique_zone_name()