qtype = stringFromJson(rrset, "type");
changetype = toUpper(stringFromJson(rrset, "changetype"));
- if (!iends_with(qname, dotsuffix) && !pdns_iequals(qname, zonename))
- throw ApiException("RRset "+qname+" IN "+qtype.getName()+": Name is out of zone");
-
if (changetype == "DELETE") {
// delete all matching qname/qtype RRs (and, implictly comments).
if (!di.backend->replaceRRSet(di.id, qname, qtype, vector<DNSResourceRecord>())) {
}
}
else if (changetype == "REPLACE") {
- new_records.clear();
+ // we only validate for REPLACE, as DELETE can be used to "fix" out of zone records.
+ if (!iends_with(qname, dotsuffix) && !pdns_iequals(qname, zonename))
+ throw ApiException("RRset "+qname+" IN "+qtype.getName()+": Name is out of zone");
+
+ new_records.clear();
new_comments.clear();
// new_ptrs is merged
gatherRecords(rrset, new_records, new_ptrs);
def test_zone_rr_delete_out_of_zone(self):
payload, zone = self.create_zone()
name = payload['name']
- # replace with qname mismatch
rrset = {
'changetype': 'delete',
'name': 'not-in-zone',
self.url("/servers/localhost/zones/" + name),
data=json.dumps(payload),
headers={'content-type': 'application/json'})
- self.assertEquals(r.status_code, 422)
- self.assertIn('out of zone', r.json()['error'])
+ print r.content
+ self.assertEquals(r.status_code, 200) # succeed so users can fix their wrong, old data
def test_zone_delete(self):
payload, zone = self.create_zone()