]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1259] Check the class
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Mon, 3 Oct 2011 09:19:11 +0000 (11:19 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Mon, 3 Oct 2011 09:19:11 +0000 (11:19 +0200)
If it corresponds to the updater. This would be a bug, but we better
detect it sooner.

src/lib/python/isc/xfrin/diff.py
src/lib/python/isc/xfrin/tests/diff_tests.py

index 9a286e80fe63d6486901634988733574187a8153..082bdb38a4a08c3ea0a2def3a1d5bd02a2a0d96e 100644 (file)
@@ -91,6 +91,10 @@ class Diff:
         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
@@ -103,6 +107,9 @@ class Diff:
         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')
 
@@ -113,6 +120,9 @@ class Diff:
         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')
 
index 963b16d0083fd7b317eaf51ab04a47c32d28af74..dc1aca966ef4bc06208ffbdf9141c3409c747eed 100644 (file)
@@ -94,6 +94,13 @@ class DiffTest(unittest.TestCase):
         """
         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
@@ -322,6 +329,17 @@ class DiffTest(unittest.TestCase):
         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()