From 3fe7c7d6cba7913d89e9c9e7deb8d089267cc114 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Wed, 13 Apr 2016 22:30:40 +0200 Subject: [PATCH] API: honor set-ptr during zone create, too --- pdns/ws-auth.cc | 2 ++ regression-tests.api/test_Zones.py | 37 ++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 3b42c4b0e..06605ccfb 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -759,6 +759,8 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp) { di.backend->commitTransaction(); + storeChangedPTRs(B, new_ptrs); + fillZone(zonename, resp); resp->status = 201; return; diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index c34353f73..a8cfeb7f0 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -960,7 +960,40 @@ fred IN A 192.168.0.4 self.assertEquals(serverset['records'], rrset2['records']) self.assertEquals(serverset['comments'], rrset['comments']) - def test_zone_auto_ptr_ipv4(self): + def test_zone_auto_ptr_ipv4_create(self): + revzone = '4.2.192.in-addr.arpa.' + _, _, revzonedata = self.create_zone(name=revzone) + name = unique_zone_name() + rrset = { + "name": name, + "type": "A", + "ttl": 3600, + "records": [{ + "content": "192.2.4.44", + "disabled": False, + "set-ptr": True, + }], + } + name, payload, data = self.create_zone(name=name, rrsets=[rrset]) + del rrset['records'][0]['set-ptr'] + self.assertEquals(get_rrset(data, name, 'A')['records'], rrset['records']) + r = self.session.get(self.url("/api/v1/servers/localhost/zones/" + revzone)).json() + revsets = [s for s in r['rrsets'] if s['type'] == 'PTR'] + print revsets + self.assertEquals(revsets, [{ + u'name': u'44.4.2.192.in-addr.arpa.', + u'ttl': 3600, + u'type': u'PTR', + u'comments': [], + u'records': [{ + u'content': name, + u'disabled': False, + }], + }]) + # with SOA-EDIT-API DEFAULT on the revzone, the serial should now be higher. + self.assertGreater(r['serial'], revzonedata['serial']) + + def test_zone_auto_ptr_ipv4_update(self): revzone = '0.2.192.in-addr.arpa.' _, _, revzonedata = self.create_zone(name=revzone) name, payload, zone = self.create_zone() @@ -999,7 +1032,7 @@ fred IN A 192.168.0.4 # with SOA-EDIT-API DEFAULT on the revzone, the serial should now be higher. self.assertGreater(r['serial'], revzonedata['serial']) - def test_zone_auto_ptr_ipv6(self): + def test_zone_auto_ptr_ipv6_update(self): # 2001:DB8::bb:aa revzone = '8.b.d.0.1.0.0.2.ip6.arpa.' _, _, revzonedata = self.create_zone(name=revzone) -- 2.40.0