Browse Source

[1512] distinguished successful update and error with a response.

JINMEI Tatuya 13 years ago
parent
commit
b6453630ee

+ 5 - 3
src/lib/python/isc/ddns/session.py

@@ -17,8 +17,9 @@ import isc.dns
 import isc.ddns.zone_config
 import isc.ddns.zone_config
 
 
 # Result codes for UpdateSession.handle()
 # Result codes for UpdateSession.handle()
-UPDATE_DONE = 0        # handled completely, and the response is ready
-UPDATE_DROP = 1        # critical error happened, no response should be sent
+UPDATE_SUCCESS = 0     # update request granted and succeeded
+UPDATE_ERROR = 1       # some error happened with a corresponding response
+UPDATE_DROP = 2        # critical error happened, no response should be sent
 
 
 # Convenient aliases of update-specific section names
 # Convenient aliases of update-specific section names
 SECTION_ZONE = isc.dns.Message.SECTION_QUESTION
 SECTION_ZONE = isc.dns.Message.SECTION_QUESTION
@@ -64,9 +65,10 @@ class UpdateSession:
             # self.__check_update_acl()
             # self.__check_update_acl()
             # self.__do_update()
             # self.__do_update()
             # self.__make_response(Rcode.NOERROR())
             # self.__make_response(Rcode.NOERROR())
+            return UPDATE_SUCCESS
         except ZoneError as e:
         except ZoneError as e:
             self.__make_response(e.rcode)
             self.__make_response(e.rcode)
-        return UPDATE_DONE
+        return UPDATE_ERROR
 
 
     def __get_update_zone(self):
     def __get_update_zone(self):
         '''Parse the zone section and find the zone to be updated.
         '''Parse the zone section and find the zone to be updated.

+ 6 - 5
src/lib/python/isc/ddns/tests/session_tests.py

@@ -68,14 +68,14 @@ class SessionTest(unittest.TestCase):
         # Zone section is empty
         # Zone section is empty
         msg_data, msg = create_update_msg(zones=[])
         msg_data, msg = create_update_msg(zones=[])
         session = UpdateSession(msg, msg_data, None, None)
         session = UpdateSession(msg, msg_data, None, None)
-        self.assertEqual(UPDATE_DONE, session.handle())
+        self.assertEqual(UPDATE_ERROR, session.handle())
         self.check_response(session.get_message(), Rcode.FORMERR())
         self.check_response(session.get_message(), Rcode.FORMERR())
 
 
         # Zone section contains multiple records
         # Zone section contains multiple records
         msg_data, msg = create_update_msg(zones=[TEST_ZONE_RECORD,
         msg_data, msg = create_update_msg(zones=[TEST_ZONE_RECORD,
                                                  TEST_ZONE_RECORD])
                                                  TEST_ZONE_RECORD])
         session = UpdateSession(msg, msg_data, None, None)
         session = UpdateSession(msg, msg_data, None, None)
-        self.assertEqual(UPDATE_DONE, session.handle())
+        self.assertEqual(UPDATE_ERROR, session.handle())
         self.check_response(session.get_message(), Rcode.FORMERR())
         self.check_response(session.get_message(), Rcode.FORMERR())
 
 
         # Zone section's type is not SOA
         # Zone section's type is not SOA
@@ -83,7 +83,7 @@ class SessionTest(unittest.TestCase):
                                                           TEST_RRCLASS,
                                                           TEST_RRCLASS,
                                                           RRType.A())])
                                                           RRType.A())])
         session = UpdateSession(msg, msg_data, None, None)
         session = UpdateSession(msg, msg_data, None, None)
-        self.assertEqual(UPDATE_DONE, session.handle())
+        self.assertEqual(UPDATE_ERROR, session.handle())
         self.check_response(session.get_message(), Rcode.FORMERR())
         self.check_response(session.get_message(), Rcode.FORMERR())
 
 
     def test_update_secondary(self):
     def test_update_secondary(self):
@@ -96,11 +96,12 @@ class SessionTest(unittest.TestCase):
                                                           RRType.SOA())])
                                                           RRType.SOA())])
         session = UpdateSession(msg, msg_data, None,
         session = UpdateSession(msg, msg_data, None,
                                 ZoneConfig([(sec_zone, TEST_RRCLASS)]))
                                 ZoneConfig([(sec_zone, TEST_RRCLASS)]))
-        self.assertEqual(UPDATE_DONE, session.handle())
+        self.assertEqual(UPDATE_ERROR, session.handle())
         self.check_response(session.get_message(), Rcode.REFUSED())
         self.check_response(session.get_message(), Rcode.REFUSED())
 
 
     def test_handle(self):
     def test_handle(self):
-        self.assertEqual(UPDATE_DONE, self.__session.handle())
+        self.assertEqual(UPDATE_SUCCESS, self.__session.handle())
+        self.assertNotEqual(UPDATE_ERROR, self.__session.handle())
         self.assertNotEqual(UPDATE_DROP, self.__session.handle())
         self.assertNotEqual(UPDATE_DROP, self.__session.handle())
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":