if (previous.qname == rec.qname) {
if (previous.qtype == rec.qtype) {
if (onlyOneEntryTypes.count(rec.qtype.getCode()) != 0) {
- rejectRecord(rec, " has more than one record");
+ rejectRecord(rec, ": only one such record allowed");
}
if (previous.content == rec.content) {
- throw CheckException("Duplicate record in RRset " + rec.qname.toString() + " IN " + rec.qtype.toString() + " with content \"" + rec.content + "\"");
+ rejectRecord(rec, std::string{": duplicate record with content \""} + rec.content + "\"");
}
}
- else if (QType::exclusiveEntryTypes.count(rec.qtype.getCode()) != 0 || QType::exclusiveEntryTypes.count(previous.qtype.getCode()) != 0) {
- rejectRecord(rec, ": Conflicts with another RRset");
+ else {
+ if (QType::exclusiveEntryTypes.count(rec.qtype.getCode()) != 0
+ || QType::exclusiveEntryTypes.count(previous.qtype.getCode()) != 0) {
+ rejectRecord(rec, std::string{": conflicts with existing "} + previous.qtype.toString() + " RRset of the same name");
+ }
}
}
if (rec.qname == zone.operator const DNSName&()) {
if (nonApexTypes.count(rec.qtype.getCode()) != 0) {
- rejectRecord(rec, " is not allowed at apex");
+ rejectRecord(rec, ": is not allowed at apex");
}
}
else if (atApexTypes.count(rec.qtype.getCode()) != 0) {
- rejectRecord(rec, " is only allowed at apex");
+ rejectRecord(rec, ": is only allowed at apex");
}
// Check if the DNSNames that should be hostnames, are hostnames
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
- self.assertIn('Conflicts with another RRset', r.json()['error'])
+ self.assertIn('conflicts with existing NS RRset', r.json()['error'])
def test_export_zone_json(self):
name, payload, zone = self.create_zone(nameservers=['ns1.foo.com.', 'ns2.foo.com.'], soa_edit_api='')
data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
- self.assertIn('Duplicate record in RRset', r.json()['error'])
+ self.assertIn('duplicate record with content', r.json()['error'])
def test_zone_rr_update_duplicate_rrset(self):
name, payload, zone = self.create_zone()
r = self.session.patch(self.url("/api/v1/servers/localhost/zones/" + name), data=json.dumps(payload),
headers={'content-type': 'application/json'})
self.assertEqual(r.status_code, 422)
- self.assertIn('IN ' + qtype + ' has more than one record', r.json()['error'])
+ self.assertIn('IN ' + qtype + ': only one such record', r.json()['error'])
def test_rrset_zone_apex(self):
name, payload, zone = self.create_zone()
("out of zone", [{'name': 'not-in-zone.', 'type': 'NS', 'ttl': 3600, 'records': [{"content": "ns1.example.org."}]}]),
("contains unsupported characters", [{'name': 'test:.$NAME$', 'type': 'NS', 'ttl': 3600, 'records': [{"content": "ns1.example.org."}]}]),
("unknown type", [{'name': '$NAME$', 'type': 'INVALID', 'ttl': 3600, 'records': [{"content": "192.0.2.1"}]}]),
- ("Conflicts with another RRset", [{'name': '$NAME$', 'type': 'CNAME', 'ttl': 3600, 'records': [{"content": "example.org."}]}]),
+ ("conflicts with existing NS RRset", [{'name': '$NAME$', 'type': 'CNAME', 'ttl': 3600, 'records': [{"content": "example.org."}]}]),
])
def test_zone_replace_rrsets_invalid(self, expected_error, invalid_rrsets):
"""Test validation of RRsets before replacing them"""