if rr.get_rdata_count() != 1:
raise ValueError('The rrset must contain exactly 1 Rdata, but ' +
'it holds ' + str(rr.get_rdata_count()))
+ if rr.get_class() != self.__updater.get_class():
+ raise ValueError("The rrset's class " + str(rr.get_class()) +
+ " does not match updater's " +
+ str(self.__updater.get_class()))
self.__buffer.append((operation, rr))
if len(self.__buffer) >= DIFF_APPLY_TRESHOLD:
# Time to auto-apply, so the data don't accumulate too much
The rr is of isc.dns.RRset type and it must contain only one RR.
If this is not the case or if the diff was already commited, this
raises the ValueError exception.
+
+ The rr class must match the one of the datasource client. If
+ it does not, ValueError is raised.
"""
self.__data_common(rr, 'add')
The rr is of isc.dns.RRset type and it must contain only one RR.
If this is not the case or if the diff was already commited, this
raises the ValueError exception.
+
+ The rr class must match the one of the datasource client. If
+ it does not, ValueError is raised.
"""
self.__data_common(rr, 'remove')
"""
self.__data_operations.append(('remove', rrset))
+ def get_class(self):
+ """
+ This one is part of pretending to be a zone updater. It returns
+ the IN class.
+ """
+ return self.__rrclass
+
def get_updater(self, zone_name, replace):
"""
This one pretends this is the data source client and serves
diff.compact()
check()
+ def test_wrong_class(self):
+ """
+ Test a wrong class of rrset is rejected.
+ """
+ diff = Diff(self, Name('example.org.'))
+ rrset = RRset(Name('a.example.org.'), RRClass.CH(), RRType.NS(),
+ self.__ttl)
+ rrset.add_rdata(Rdata(RRType.NS(), RRClass.CH(), 'ns.example.org.'))
+ self.assertRaises(ValueError, diff.add_data, rrset)
+ self.assertRaises(ValueError, diff.remove_data, rrset)
+
if __name__ == "__main__":
isc.log.init("bind10")
unittest.main()