From: Jelte Jansen Date: Wed, 23 May 2012 07:31:55 +0000 (+0200) Subject: [1455] handling part and response building X-Git-Tag: trac2351_base~226^2~67^2~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=005a08df4279a119671c58698faf6e86fbc9fded;p=thirdparty%2Fkea.git [1455] handling part and response building --- diff --git a/src/lib/python/isc/ddns/libddns_messages.mes b/src/lib/python/isc/ddns/libddns_messages.mes index 4c48c4cf9a..6f00d68056 100644 --- a/src/lib/python/isc/ddns/libddns_messages.mes +++ b/src/lib/python/isc/ddns/libddns_messages.mes @@ -39,3 +39,11 @@ possible, you may want to check the implementation or configuration of those clients to suppress the requests. As specified in Section 3.1 of RFC2136, the receiving server will return a response with an RCODE of NOTAUTH. + +% LIBDDNS_UPDATE_PREREQUISITE_FAILED prerequisite failed in update update client %1 for zone %2: result code %3 +The handling of the prerequisite section (RFC2136 Section 3.2) found +that one of the prerequisites was not satisfied. The result code +should give more information on what prerequisite type failed. +If the result code is FORMERR, the prerequisite section was not well-formed. +An error response with the given result code is sent back to the client. + diff --git a/src/lib/python/isc/ddns/session.py b/src/lib/python/isc/ddns/session.py index 084eb878d6..0814aeb71e 100644 --- a/src/lib/python/isc/ddns/session.py +++ b/src/lib/python/isc/ddns/session.py @@ -123,9 +123,14 @@ class UpdateSession: try: datasrc_client, zname, zclass = self.__get_update_zone() # conceptual code that would follow - prereq_result = self.__check_prerequisites(datasrc_client, zname, zclass) - if prereq_result != UPDATE_SUCCESS: - return prereq_result, zname, zclass + prereq_result = self.__check_prerequisites(datasrc_client, + zname, zclass) + if prereq_result != Rcode.NOERROR(): + logger.info(LIBDDNS_UPDATE_PREREQUISITE_FAILED, + ClientFormatter(self.__client_addr), + zname, prereq_result) + self.__make_response(prereq_result) + return UPDATE_ERROR, zname, zclass # self.__check_update_acl() # self.__do_update() # self.__make_response(Rcode.NOERROR()) @@ -247,7 +252,7 @@ class UpdateSession: def __check_prerequisite_name_not_in_use(self, datasrc_client, rrset): '''Check whether the name of the given RRset is not in use (i.e. does not exist at all, or is an empty nonterminal. - RFC2136 Section 2.4.5 + RFC2136 Section 2.4.5. ''' return not self.__check_prerequisite_name_in_use(datasrc_client, rrset) diff --git a/src/lib/python/isc/ddns/tests/session_tests.py b/src/lib/python/isc/ddns/tests/session_tests.py index 750239cea5..8ef0211478 100644 --- a/src/lib/python/isc/ddns/tests/session_tests.py +++ b/src/lib/python/isc/ddns/tests/session_tests.py @@ -477,12 +477,24 @@ class SessionTest(unittest.TestCase): returns the Rcode specified in 'expected'.''' msg_data, msg = create_update_msg([TEST_ZONE_RECORD], prerequisites) - session = UpdateSession(msg, msg_data, TEST_CLIENT4, None) + zconfig = ZoneConfig([], TEST_RRCLASS, self.__datasrc_client) + session = UpdateSession(msg, msg_data, TEST_CLIENT4, zconfig) # compare the to_text output of the rcodes (nicer error messages) + # This call itself should also be done by handle(), + # but just for better failures, it is first called on itw own self.assertEqual(expected.to_text(), session._UpdateSession__check_prerequisites(self.__datasrc_client, TEST_ZONE_NAME, TEST_RRCLASS).to_text()) + # Now see if handle finds the same result + (result, _, _) = session.handle() + self.assertEqual(expected, + session._UpdateSession__message.get_rcode()) + # And that the result looks right + if expected == Rcode.NOERROR(): + self.assertEqual(UPDATE_SUCCESS, result) + else: + self.assertEqual(UPDATE_ERROR, result) def test_check_prerequisites(self): # This test checks if the actual prerequisite-type-specific