diff --git a/src/jcl/jabber/command.py b/src/jcl/jabber/command.py index 98f21f1..97be09a 100644 --- a/src/jcl/jabber/command.py +++ b/src/jcl/jabber/command.py @@ -274,6 +274,8 @@ class CommandManager(object): "feature-not-implemented")] except CommandError, error: return [info_query.make_error_response(error.type)] + except Exception: + return [info_query.make_error_response("service-unavailable")] def add_actions(self, command_node, actions, default_action_idx=0): actions_node = command_node.newTextChild(None, "actions", None) diff --git a/src/jcl/jabber/tests/command.py b/src/jcl/jabber/tests/command.py index 797493d..251ed5f 100644 --- a/src/jcl/jabber/tests/command.py +++ b/src/jcl/jabber/tests/command.py @@ -452,6 +452,37 @@ class CommandManager_TestCase(unittest.TestCase): + "", result_iq, True)) + def test_multi_step_command_unknown_error_in_command(self): + """ + Test if the multi steps method catch the CommandError exception + and translate it into an IQ error + """ + self.command_manager = MockCommandManager() + def execute_command1(info_query, session_context, + command_node, lang_class): + raise Exception("error") + + self.command_manager.__dict__["execute_command1_1"] = execute_command1 + info_query = Iq(stanza_type="set", + from_jid="user@test.com", + to_jid="jcl.test.com") + command_node = info_query.set_new_content(command.COMMAND_NS, + "command") + command_node.setProp("node", "command1") + result = self.command_manager.execute_multi_step_command(\ + info_query, "command1", None) + result_iq = result[0].xmlnode + self.assertTrue(jcl.tests.is_xml_equal(\ + u"" + + "" + + "" + + "", + result_iq, True)) + def test_parse_form(self): """ Check if parse_form method correctly set the session variables