From: Pieter Lexis Date: Thu, 20 Jun 2019 12:04:23 +0000 (+0200) Subject: auth: add edited_serial to Zone object X-Git-Tag: dnsdist-1.4.0-rc1~100^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1258fecde7a3c8b801c1aaf677628f73a9d3229e;p=pdns auth: add edited_serial to Zone object This gives API consumers the ability to see the edited SOA serial. The API code used the same functions as the DNSSECKeeper, so this serial will match the one send to clients in response to queries. Closes #7961 --- diff --git a/docs/http-api/swagger/authoritative-api-swagger.yaml b/docs/http-api/swagger/authoritative-api-swagger.yaml index fa0fe9528..11d7861b1 100644 --- a/docs/http-api/swagger/authoritative-api-swagger.yaml +++ b/docs/http-api/swagger/authoritative-api-swagger.yaml @@ -919,6 +919,9 @@ definitions: notified_serial: type: integer description: 'The SOA serial notifications have been sent out for' + edited_serial: + type: integer + description: 'The SOA serial as seen in query responses. Calculated using the SOA-EDIT metadata, default-soa-edit and default-soa-edit-signed settings' masters: type: array items: diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 61d9cb538..25f980e85 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -336,6 +336,7 @@ static Json::object getZoneInfo(const DomainInfo& di, DNSSECKeeper *dk) { { "account", di.account }, { "masters", masters }, { "serial", (double)di.serial }, + { "edited_serial", (double)calculateEditSOA(di.serial, *dk, di.zone) }, { "notified_serial", (double)di.notified_serial }, { "last_check", (double)di.last_check } }; diff --git a/regression-tests.api/runtests.py b/regression-tests.api/runtests.py index 56d5e3e7b..f9f4dba17 100755 --- a/regression-tests.api/runtests.py +++ b/regression-tests.api/runtests.py @@ -38,6 +38,7 @@ gsqlite3-dnssec=on gsqlite3-database="""+SQLITE_DB+""" module-dir=../regression-tests/modules bind-config=bindbackend.conf +default-soa-edit=INCEPTION-INCREMENT """ BINDBACKEND_CONF_TPL = """ diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index 514cea8e0..03fd58646 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -59,7 +59,7 @@ class Zones(ApiTestCase): print(example_com) required_fields = ['id', 'url', 'name', 'kind'] if is_auth(): - required_fields = required_fields + ['masters', 'last_check', 'notified_serial', 'serial', 'account'] + required_fields = required_fields + ['masters', 'last_check', 'notified_serial', 'edited_serial', 'serial', 'account'] self.assertNotEquals(example_com['serial'], 0) elif is_recursor(): required_fields = required_fields + ['recursion_desired', 'servers'] @@ -99,7 +99,7 @@ class AuthZones(ApiTestCase, AuthZonesHelperMixin): def test_create_zone(self): # soa_edit_api has a default, override with empty for this test name, payload, data = self.create_zone(serial=22, soa_edit_api='') - for k in ('id', 'url', 'name', 'masters', 'kind', 'last_check', 'notified_serial', 'serial', 'soa_edit_api', 'soa_edit', 'account'): + for k in ('id', 'url', 'name', 'masters', 'kind', 'last_check', 'notified_serial', 'serial', 'edited_serial', 'soa_edit_api', 'soa_edit', 'account'): self.assertIn(k, data) if k in payload: self.assertEquals(data[k], payload[k]) @@ -113,6 +113,7 @@ class AuthZones(ApiTestCase, AuthZonesHelperMixin): # Because we had confusion about dots, check that the DB is without dots. dbrecs = get_db_records(name, 'SOA') self.assertEqual(dbrecs[0]['content'], expected_soa.replace('. ', ' ')) + self.assertNotEquals(data['serial'], data['edited_serial']) def test_create_zone_with_soa_edit_api(self): # soa_edit_api wins over serial