]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1790] Add more testcases for missing keys
authorMukund Sivaraman <muks@isc.org>
Thu, 10 May 2012 04:00:50 +0000 (09:30 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 14 May 2012 17:11:08 +0000 (22:41 +0530)
Strictly, this is not necessary as the spec file schema would check for
it.

src/bin/xfrin/tests/xfrin_test.py
src/bin/xfrin/xfrin.py.in

index 2a471d2bd445874b6f9bdaf072de0aa8222bdd11..b4fcefb049d8bd7faeee90996316ca717aba424b 100644 (file)
@@ -2931,7 +2931,7 @@ class TestXfrinProcess(unittest.TestCase):
         self.assertTrue(self._send_cc_session.recv_called)
         self.assertTrue(self._send_cc_session.recv_called_correctly)
 
-    def test_inmem_not_memory(self):
+    def test_inmem_datasource_type_not_memory(self):
         """
         Inmem configuration where the datasource type is not memory. In
         this case, loadzone should not be sent to b10-auth.
@@ -2945,7 +2945,21 @@ class TestXfrinProcess(unittest.TestCase):
         self.assertFalse(self._send_cc_session.recv_called)
         self.assertFalse(self._send_cc_session.recv_called_correctly)
 
-    def test_inmem_not_sqlite3(self):
+    def test_inmem_datasource_type_is_missing(self):
+        """
+        Inmem configuration where the datasource type is missing. In
+        this case, loadzone should not be sent to b10-auth.
+        """
+        self._module_cc.config = [{'zones': [{'origin': 'example.org', 'filetype': 'sqlite3',
+                                              'file': 'data/inmem-xfrin.sqlite3'}],
+                                   'class': 'IN'}]
+        self.__do_test([XFRIN_OK], [RRType.IXFR()], RRType.IXFR())
+        self.assertFalse(self._send_cc_session.send_called)
+        self.assertFalse(self._send_cc_session.send_called_correctly)
+        self.assertFalse(self._send_cc_session.recv_called)
+        self.assertFalse(self._send_cc_session.recv_called_correctly)
+
+    def test_inmem_backend_type_not_sqlite3(self):
         """
         Inmem configuration where the datasource backing file is not of
         type sqlite3. In this case, loadzone should not be sent to
@@ -2960,7 +2974,21 @@ class TestXfrinProcess(unittest.TestCase):
         self.assertFalse(self._send_cc_session.recv_called)
         self.assertFalse(self._send_cc_session.recv_called_correctly)
 
-    def test_inmem_not_of_same_class(self):
+    def test_inmem_backend_type_is_missing(self):
+        """
+        Inmem configuration where the datasource backing file type is
+        not set. In this case, loadzone should not be sent to b10-auth.
+        """
+        self._module_cc.config = [{'zones': [{'origin': 'example.org',
+                                              'file': 'data/inmem-xfrin.sqlite3'}],
+                                   'type': 'memory', 'class': 'IN'}]
+        self.__do_test([XFRIN_OK], [RRType.IXFR()], RRType.IXFR())
+        self.assertFalse(self._send_cc_session.send_called)
+        self.assertFalse(self._send_cc_session.send_called_correctly)
+        self.assertFalse(self._send_cc_session.recv_called)
+        self.assertFalse(self._send_cc_session.recv_called_correctly)
+
+    def test_inmem_class_is_different(self):
         """
         Inmem configuration where the datasource class does not match
         the received class. In this case, loadzone should not be sent to
@@ -2975,7 +3003,22 @@ class TestXfrinProcess(unittest.TestCase):
         self.assertFalse(self._send_cc_session.recv_called)
         self.assertFalse(self._send_cc_session.recv_called_correctly)
 
-    def test_inmem_not_present(self):
+    def test_inmem_class_is_missing(self):
+        """
+        Inmem configuration where the datasource class is missing. In
+        this case, we assume the IN class and loadzone may be sent to
+        b10-auth if everything else matches.
+        """
+        self._module_cc.config = [{'zones': [{'origin': 'example.org', 'filetype': 'sqlite3',
+                                              'file': 'data/inmem-xfrin.sqlite3'}],
+                                   'type': 'memory'}]
+        self.__do_test([XFRIN_OK], [RRType.IXFR()], RRType.IXFR())
+        self.assertTrue(self._send_cc_session.send_called)
+        self.assertTrue(self._send_cc_session.send_called_correctly)
+        self.assertTrue(self._send_cc_session.recv_called)
+        self.assertTrue(self._send_cc_session.recv_called_correctly)
+
+    def test_inmem_name_doesnt_match(self):
         """
         Inmem configuration where the origin does not match the received
         name. In this case, loadzone should not be sent to b10-auth.
@@ -2989,6 +3032,20 @@ class TestXfrinProcess(unittest.TestCase):
         self.assertFalse(self._send_cc_session.recv_called)
         self.assertFalse(self._send_cc_session.recv_called_correctly)
 
+    def test_inmem_name_is_missing(self):
+        """
+        Inmem configuration where the origin is missing. In this case,
+        loadzone should not be sent to b10-auth.
+        """
+        self._module_cc.config = [{'zones': [{'filetype': 'sqlite3',
+                                              'file': 'data/inmem-xfrin.sqlite3'}],
+                                   'type': 'memory', 'class': 'IN'}]
+        self.__do_test([XFRIN_OK], [RRType.IXFR()], RRType.IXFR())
+        self.assertFalse(self._send_cc_session.send_called)
+        self.assertFalse(self._send_cc_session.send_called_correctly)
+        self.assertFalse(self._send_cc_session.recv_called)
+        self.assertFalse(self._send_cc_session.recv_called_correctly)
+
 class TestFormatting(unittest.TestCase):
     # If the formatting functions are moved to a more general library
     # (ticket #1379), these tests should be moved with them.
index fd2d58766d8d4f92f4bf4a3d79fa78d115766c93..114bac4dac404ec5058139a08fdcefc1147856b7 100755 (executable)
@@ -1256,6 +1256,8 @@ def _do_auth_loadzone(server, zone_name, zone_class):
     if is_default:
         return
     for d in datasources:
+        if "type" not in d:
+            continue
         try:
             if "class" in d:
                 dclass = RRClass(d["class"])
@@ -1267,6 +1269,10 @@ def _do_auth_loadzone(server, zone_name, zone_class):
 
         if d["type"].lower() == "memory" and dclass == zone_class:
             for zone in d["zones"]:
+                if "filetype" not in zone:
+                    continue
+                if "origin" not in zone:
+                    continue
                 if "filetype" not in zone:
                     continue
                 try: