Implement admin ad-hoc command filtering
darcs-hash:20070905192007-86b55-e09501f370e284e62181f199af1a5a1d7138dde1.gz
This commit is contained in:
@@ -61,7 +61,7 @@ class CommandManager(object):
|
|||||||
self.__logger = logging.getLogger("jcl.jabber.command.CommandManager")
|
self.__logger = logging.getLogger("jcl.jabber.command.CommandManager")
|
||||||
self.component = component
|
self.component = component
|
||||||
self.account_manager = account_manager
|
self.account_manager = account_manager
|
||||||
self.commands = []
|
self.commands = {}
|
||||||
self.command_re = re.compile("([^#]*#)?(.*)")
|
self.command_re = re.compile("([^#]*#)?(.*)")
|
||||||
self.sessions = {}
|
self.sessions = {}
|
||||||
|
|
||||||
@@ -83,15 +83,18 @@ class CommandManager(object):
|
|||||||
command_desc = short_command_name
|
command_desc = short_command_name
|
||||||
return command_desc
|
return command_desc
|
||||||
|
|
||||||
def list_commands(self, disco_items, lang_class):
|
def list_commands(self, jid, disco_items, lang_class):
|
||||||
"""Return DiscoItem for each supported commands"""
|
"""Return DiscoItem for each supported commands"""
|
||||||
for command_name in self.commands:
|
for command_name in self.commands.keys():
|
||||||
command_desc = self.get_command_desc(command_name,
|
must_be_admin = self.commands[command_name]
|
||||||
lang_class)
|
if not must_be_admin or \
|
||||||
DiscoItem(disco_items,
|
(must_be_admin and unicode(jid) in self.component.get_admins()):
|
||||||
self.component.jid,
|
command_desc = self.get_command_desc(command_name,
|
||||||
command_name,
|
lang_class)
|
||||||
command_desc)
|
DiscoItem(disco_items,
|
||||||
|
self.component.jid,
|
||||||
|
command_name,
|
||||||
|
command_desc)
|
||||||
return disco_items
|
return disco_items
|
||||||
|
|
||||||
def get_command_info(self, disco_info, command_name, lang_class):
|
def get_command_info(self, disco_info, command_name, lang_class):
|
||||||
@@ -105,14 +108,21 @@ class CommandManager(object):
|
|||||||
|
|
||||||
def apply_command_action(self, info_query, command_name, action):
|
def apply_command_action(self, info_query, command_name, action):
|
||||||
"""Apply action on command"""
|
"""Apply action on command"""
|
||||||
short_command_name = self.get_short_command_name(command_name)
|
must_be_admin = self.commands[command_name]
|
||||||
action_command_method = "apply_" + action + "_command"
|
if not must_be_admin or \
|
||||||
if hasattr(self, action_command_method):
|
(must_be_admin and
|
||||||
return getattr(self, action_command_method)(info_query,
|
unicode(info_query.get_from()) in self.component.get_admins()):
|
||||||
short_command_name)
|
short_command_name = self.get_short_command_name(command_name)
|
||||||
|
action_command_method = "apply_" + action + "_command"
|
||||||
|
if hasattr(self, action_command_method):
|
||||||
|
return getattr(self, action_command_method)(info_query,
|
||||||
|
short_command_name)
|
||||||
|
else:
|
||||||
|
return [info_query.make_error_response(\
|
||||||
|
"feature-not-implemented")]
|
||||||
else:
|
else:
|
||||||
return [info_query.make_error_response(\
|
return [info_query.make_error_response(\
|
||||||
"feature-not-implemented")]
|
"forbidden")]
|
||||||
|
|
||||||
def apply_execute_command(self, info_query, short_command_name):
|
def apply_execute_command(self, info_query, short_command_name):
|
||||||
return self.execute_multi_step_command(\
|
return self.execute_multi_step_command(\
|
||||||
@@ -243,31 +253,30 @@ class JCLCommandManager(CommandManager):
|
|||||||
"""
|
"""
|
||||||
CommandManager.__init__(self, component, account_manager)
|
CommandManager.__init__(self, component, account_manager)
|
||||||
self.__logger = logging.getLogger("jcl.jabber.command.JCLCommandManager")
|
self.__logger = logging.getLogger("jcl.jabber.command.JCLCommandManager")
|
||||||
self.commands.extend(["list",
|
self.commands["http://jabber.org/protocol/admin#add-user"] = True
|
||||||
"http://jabber.org/protocol/admin#add-user",
|
self.commands["http://jabber.org/protocol/admin#delete-user"] = True
|
||||||
"http://jabber.org/protocol/admin#delete-user",
|
self.commands["http://jabber.org/protocol/admin#disable-user"] = True
|
||||||
"http://jabber.org/protocol/admin#disable-user",
|
self.commands["http://jabber.org/protocol/admin#reenable-user"] = True
|
||||||
"http://jabber.org/protocol/admin#reenable-user",
|
self.commands["http://jabber.org/protocol/admin#end-user-session"] = True
|
||||||
"http://jabber.org/protocol/admin#end-user-session",
|
self.commands["http://jabber.org/protocol/admin#get-user-password"] = True
|
||||||
"http://jabber.org/protocol/admin#get-user-password",
|
self.commands["http://jabber.org/protocol/admin#change-user-password"] = True
|
||||||
"http://jabber.org/protocol/admin#change-user-password",
|
self.commands["http://jabber.org/protocol/admin#get-user-roster"] = True
|
||||||
"http://jabber.org/protocol/admin#get-user-roster",
|
self.commands["http://jabber.org/protocol/admin#get-user-lastlogin"] = True
|
||||||
"http://jabber.org/protocol/admin#get-user-lastlogin",
|
self.commands["http://jabber.org/protocol/admin#get-registered-users-num"] = True
|
||||||
"http://jabber.org/protocol/admin#get-registered-users-num",
|
self.commands["http://jabber.org/protocol/admin#get-disabled-users-num"] = True
|
||||||
"http://jabber.org/protocol/admin#get-disabled-users-num",
|
self.commands["http://jabber.org/protocol/admin#get-online-users-num"] = True
|
||||||
"http://jabber.org/protocol/admin#get-online-users-num",
|
self.commands["http://jabber.org/protocol/admin#get-registered-users-list"] = True
|
||||||
"http://jabber.org/protocol/admin#get-registered-users-list",
|
self.commands["http://jabber.org/protocol/admin#get-disabled-users-list"] = True
|
||||||
"http://jabber.org/protocol/admin#get-disabled-users-list",
|
self.commands["http://jabber.org/protocol/admin#get-online-users-list"] = True
|
||||||
"http://jabber.org/protocol/admin#get-online-users-lists",
|
self.commands["http://jabber.org/protocol/admin#announce"] = True
|
||||||
"http://jabber.org/protocol/admin#announce",
|
self.commands["http://jabber.org/protocol/admin#set-motd"] = True
|
||||||
"http://jabber.org/protocol/admin#set-motd",
|
self.commands["http://jabber.org/protocol/admin#edit-motd"] = True
|
||||||
"http://jabber.org/protocol/admin#edit-motd",
|
self.commands["http://jabber.org/protocol/admin#delete-motd"] = True
|
||||||
"http://jabber.org/protocol/admin#delete-motd",
|
self.commands["http://jabber.org/protocol/admin#set-welcome"] = True
|
||||||
"http://jabber.org/protocol/admin#set-welcome",
|
self.commands["http://jabber.org/protocol/admin#delete-welcome"] = True
|
||||||
"http://jabber.org/protocol/admin#delete-welcome",
|
self.commands["http://jabber.org/protocol/admin#edit-admin"] = True
|
||||||
"http://jabber.org/protocol/admin#edit-admin",
|
self.commands["http://jabber.org/protocol/admin#restart"] = True
|
||||||
"http://jabber.org/protocol/admin#restart",
|
self.commands["http://jabber.org/protocol/admin#shutdown"] = True
|
||||||
"http://jabber.org/protocol/admin#shutdown"])
|
|
||||||
|
|
||||||
def get_name_and_jid(self, mixed_name_and_jid):
|
def get_name_and_jid(self, mixed_name_and_jid):
|
||||||
return mixed_name_and_jid.split("/", 1)[:2]
|
return mixed_name_and_jid.split("/", 1)[:2]
|
||||||
@@ -405,23 +414,6 @@ class JCLCommandManager(CommandManager):
|
|||||||
lang_class, format_as_xml),
|
lang_class, format_as_xml),
|
||||||
[])
|
[])
|
||||||
|
|
||||||
def execute_list_1(self, info_query, session_context,
|
|
||||||
command_node, lang_class):
|
|
||||||
"""Execute command 'list'. List accounts"""
|
|
||||||
self.__logger.debug("Executing 'list' command")
|
|
||||||
result_form = Form(xmlnode_or_type="result",
|
|
||||||
title="Registered account") # TODO : add to Lang
|
|
||||||
result_form.reported_fields.append(FieldNoType(name="name",
|
|
||||||
label="Account name")) # TODO: add to Lang
|
|
||||||
bare_from_jid = unicode(info_query.get_from().bare())
|
|
||||||
for _account in account.get_accounts(bare_from_jid):
|
|
||||||
fields = [FieldNoType(name="name",
|
|
||||||
value=_account.name)]
|
|
||||||
result_form.add_item(fields)
|
|
||||||
result_form.as_xml(command_node)
|
|
||||||
command_node.setProp("status", STATUS_COMPLETED)
|
|
||||||
return (result_form, [])
|
|
||||||
|
|
||||||
def execute_add_user_1(self, info_query, session_context,
|
def execute_add_user_1(self, info_query, session_context,
|
||||||
command_node, lang_class):
|
command_node, lang_class):
|
||||||
self.__logger.debug("Executing command 'add-user' step 1")
|
self.__logger.debug("Executing command 'add-user' step 1")
|
||||||
@@ -942,6 +934,7 @@ class CommandDiscoGetItemsHandler(DiscoHandler):
|
|||||||
"""
|
"""
|
||||||
if not disco_obj:
|
if not disco_obj:
|
||||||
disco_obj = DiscoItems()
|
disco_obj = DiscoItems()
|
||||||
return [command_manager.list_commands(disco_items=disco_obj,
|
return [command_manager.list_commands(jid=info_query.get_from(),
|
||||||
|
disco_items=disco_obj,
|
||||||
lang_class=lang_class)]
|
lang_class=lang_class)]
|
||||||
|
|
||||||
|
|||||||
@@ -597,7 +597,7 @@ class JCLComponent(Component, object):
|
|||||||
return map(string.strip,
|
return map(string.strip,
|
||||||
admins_str.split(','))
|
admins_str.split(','))
|
||||||
else:
|
else:
|
||||||
return None
|
return []
|
||||||
|
|
||||||
def set_admins(self, admins):
|
def set_admins(self, admins):
|
||||||
self.set_config_parameter("component", "admins", ",".join(admins))
|
self.set_config_parameter("component", "admins", ",".join(admins))
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
|
from pyxmpp.jid import JID
|
||||||
from pyxmpp.presence import Presence
|
from pyxmpp.presence import Presence
|
||||||
from pyxmpp.jabber.dataforms import Form
|
from pyxmpp.jabber.dataforms import Form
|
||||||
from pyxmpp.iq import Iq
|
from pyxmpp.iq import Iq
|
||||||
from pyxmpp.message import Message
|
from pyxmpp.message import Message
|
||||||
|
from pyxmpp.jabber.disco import DiscoItems
|
||||||
|
|
||||||
import jcl.tests
|
import jcl.tests
|
||||||
from jcl.lang import Lang
|
from jcl.lang import Lang
|
||||||
@@ -50,6 +52,12 @@ class FieldNoType_TestCase(unittest.TestCase):
|
|||||||
field.complete_xml_element(fake_iq.xmlnode, None)
|
field.complete_xml_element(fake_iq.xmlnode, None)
|
||||||
self.assertFalse(fake_iq.xmlnode.hasProp("type"))
|
self.assertFalse(fake_iq.xmlnode.hasProp("type"))
|
||||||
|
|
||||||
|
class MockComponent(object):
|
||||||
|
jid = JID("jcl.test.com")
|
||||||
|
|
||||||
|
def get_admins(self):
|
||||||
|
return ["admin@test.com"]
|
||||||
|
|
||||||
class CommandManager_TestCase(unittest.TestCase):
|
class CommandManager_TestCase(unittest.TestCase):
|
||||||
def test_get_short_command_name_form_long_name(self):
|
def test_get_short_command_name_form_long_name(self):
|
||||||
command_name = command.command_manager.get_short_command_name("http://jabber.org/protocol/admin#test-command")
|
command_name = command.command_manager.get_short_command_name("http://jabber.org/protocol/admin#test-command")
|
||||||
@@ -59,6 +67,105 @@ class CommandManager_TestCase(unittest.TestCase):
|
|||||||
command_name = command.command_manager.get_short_command_name("test-command")
|
command_name = command.command_manager.get_short_command_name("test-command")
|
||||||
self.assertEquals(command_name, "test_command")
|
self.assertEquals(command_name, "test_command")
|
||||||
|
|
||||||
|
def test_list_commands(self):
|
||||||
|
command.command_manager.commands["command1"] = True
|
||||||
|
command.command_manager.commands["command2"] = False
|
||||||
|
command.command_manager.component = MockComponent()
|
||||||
|
disco_items = command.command_manager.list_commands(jid="user@test.com",
|
||||||
|
disco_items=DiscoItems(),
|
||||||
|
lang_class=Lang.en)
|
||||||
|
items = disco_items.get_items()
|
||||||
|
self.assertEquals(len(items), 1)
|
||||||
|
self.assertEquals(items[0].get_node(), "command2")
|
||||||
|
self.assertEquals(items[0].get_name(), "command2")
|
||||||
|
|
||||||
|
def test_list_commands_as_admin(self):
|
||||||
|
command.command_manager.commands = {}
|
||||||
|
command.command_manager.commands["command1"] = True
|
||||||
|
command.command_manager.commands["command2"] = False
|
||||||
|
command.command_manager.component = MockComponent()
|
||||||
|
disco_items = command.command_manager.list_commands(jid="admin@test.com",
|
||||||
|
disco_items=DiscoItems(),
|
||||||
|
lang_class=Lang.en)
|
||||||
|
items = disco_items.get_items()
|
||||||
|
self.assertEquals(len(items), 2)
|
||||||
|
self.assertEquals(items[0].get_node(), "command1")
|
||||||
|
self.assertEquals(items[0].get_name(), "command1")
|
||||||
|
self.assertEquals(items[1].get_node(), "command2")
|
||||||
|
self.assertEquals(items[1].get_name(), "command2")
|
||||||
|
|
||||||
|
def test_apply_admin_command_action_as_admin(self):
|
||||||
|
command.command_manager.commands["command1"] = True
|
||||||
|
command.command_manager.apply_execute_command = \
|
||||||
|
lambda iq, command_name: []
|
||||||
|
command.command_manager.component = MockComponent()
|
||||||
|
info_query = Iq(stanza_type="set",
|
||||||
|
from_jid="admin@test.com",
|
||||||
|
to_jid="jcl.test.com")
|
||||||
|
result = command.command_manager.apply_command_action(info_query,
|
||||||
|
"command1",
|
||||||
|
"execute")
|
||||||
|
self.assertEquals(result, [])
|
||||||
|
|
||||||
|
def test_apply_admin_command_action_as_user(self):
|
||||||
|
command.command_manager.commands["command1"] = True
|
||||||
|
command.command_manager.apply_execute_command = \
|
||||||
|
lambda iq, command_name: []
|
||||||
|
command.command_manager.component = MockComponent()
|
||||||
|
info_query = Iq(stanza_type="set",
|
||||||
|
from_jid="user@test.com",
|
||||||
|
to_jid="jcl.test.com")
|
||||||
|
result = command.command_manager.apply_command_action(info_query,
|
||||||
|
"command1",
|
||||||
|
"execute")
|
||||||
|
self.assertEquals(len(result), 1)
|
||||||
|
self.assertEquals(result[0].get_type(), "error")
|
||||||
|
self.assertEquals(result[0].xmlnode.children.name, "error")
|
||||||
|
self.assertEquals(result[0].xmlnode.children.prop("type"), "auth")
|
||||||
|
self.assertEquals(result[0].xmlnode.children.children.name, "forbidden")
|
||||||
|
|
||||||
|
def test_apply_non_admin_command_action_as_admin(self):
|
||||||
|
command.command_manager.commands["command1"] = False
|
||||||
|
command.command_manager.apply_execute_command = \
|
||||||
|
lambda iq, command_name: []
|
||||||
|
command.command_manager.component = MockComponent()
|
||||||
|
info_query = Iq(stanza_type="set",
|
||||||
|
from_jid="admin@test.com",
|
||||||
|
to_jid="jcl.test.com")
|
||||||
|
result = command.command_manager.apply_command_action(info_query,
|
||||||
|
"command1",
|
||||||
|
"execute")
|
||||||
|
self.assertEquals(result, [])
|
||||||
|
|
||||||
|
def test_apply_non_admin_command_action_as_user(self):
|
||||||
|
command.command_manager.commands["command1"] = False
|
||||||
|
command.command_manager.apply_execute_command = \
|
||||||
|
lambda iq, command_name: []
|
||||||
|
command.command_manager.component = MockComponent()
|
||||||
|
info_query = Iq(stanza_type="set",
|
||||||
|
from_jid="user@test.com",
|
||||||
|
to_jid="jcl.test.com")
|
||||||
|
result = command.command_manager.apply_command_action(info_query,
|
||||||
|
"command1",
|
||||||
|
"execute")
|
||||||
|
self.assertEquals(result, [])
|
||||||
|
|
||||||
|
def test_apply_command_non_existing_action(self):
|
||||||
|
command.command_manager.commands["command1"] = False
|
||||||
|
command.command_manager.component = MockComponent()
|
||||||
|
info_query = Iq(stanza_type="set",
|
||||||
|
from_jid="user@test.com",
|
||||||
|
to_jid="jcl.test.com")
|
||||||
|
result = command.command_manager.apply_command_action(info_query,
|
||||||
|
"command1",
|
||||||
|
"noexecute")
|
||||||
|
self.assertEquals(len(result), 1)
|
||||||
|
self.assertEquals(result[0].get_type(), "error")
|
||||||
|
self.assertEquals(result[0].xmlnode.children.name, "error")
|
||||||
|
self.assertEquals(result[0].xmlnode.children.prop("type"), "cancel")
|
||||||
|
self.assertEquals(result[0].xmlnode.children.children.name,
|
||||||
|
"feature-not-implemented")
|
||||||
|
|
||||||
class JCLCommandManager_TestCase(JCLTestCase):
|
class JCLCommandManager_TestCase(JCLTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
JCLTestCase.setUp(self, tables=[Account, ExampleAccount,
|
JCLTestCase.setUp(self, tables=[Account, ExampleAccount,
|
||||||
@@ -73,6 +180,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
"5347",
|
"5347",
|
||||||
self.config,
|
self.config,
|
||||||
self.config_file)
|
self.config_file)
|
||||||
|
self.comp.set_admins(["admin@test.com"])
|
||||||
self.command_manager = JCLCommandManager(self.comp,
|
self.command_manager = JCLCommandManager(self.comp,
|
||||||
self.comp.account_manager)
|
self.comp.account_manager)
|
||||||
|
|
||||||
@@ -98,7 +206,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
def test_add_form_select_user_jids(self):
|
def test_add_form_select_user_jids(self):
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
self.command_manager.add_form_select_user_jids(command_node, Lang.en)
|
self.command_manager.add_form_select_user_jids(command_node, Lang.en)
|
||||||
@@ -113,7 +221,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
def test_add_form_select_user_jid(self):
|
def test_add_form_select_user_jid(self):
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
self.command_manager.add_form_select_user_jid(command_node, Lang.en)
|
self.command_manager.add_form_select_user_jid(command_node, Lang.en)
|
||||||
@@ -153,7 +261,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account32@jcl.test.com")
|
jid="account32@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
session_context = {}
|
session_context = {}
|
||||||
@@ -221,7 +329,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account32@jcl.test.com")
|
jid="account32@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
session_context = {}
|
session_context = {}
|
||||||
@@ -284,7 +392,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account32@jcl.test.com")
|
jid="account32@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
session_context = {}
|
session_context = {}
|
||||||
@@ -318,7 +426,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -353,7 +461,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -388,7 +496,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -446,15 +554,13 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertTrue(isinstance(iq_result, Iq))
|
self.assertTrue(isinstance(iq_result, Iq))
|
||||||
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
||||||
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
||||||
self.assertEquals(iq_result.get_to(), "user1@test.com")
|
self.assertEquals(iq_result.get_to(), "admin@test.com")
|
||||||
|
|
||||||
presence_component = stanza_sent[1]
|
presence_component = stanza_sent[1]
|
||||||
self.assertTrue(isinstance(presence_component, Presence))
|
self.assertTrue(isinstance(presence_component, Presence))
|
||||||
self.assertEquals(presence_component.get_from(), "jcl.test.com")
|
self.assertEquals(presence_component.get_from(), "jcl.test.com")
|
||||||
self.assertEquals(presence_component.get_to(), "user2@test.com")
|
self.assertEquals(presence_component.get_to(), "user2@test.com")
|
||||||
self.assertEquals(presence_component.get_node().prop("type"),
|
self.assertEquals(presence_component.get_node().prop("type"),
|
||||||
"subscribe")
|
"subscribe")
|
||||||
|
|
||||||
message = stanza_sent[2]
|
message = stanza_sent[2]
|
||||||
self.assertTrue(isinstance(message, Message))
|
self.assertTrue(isinstance(message, Message))
|
||||||
self.assertEquals(message.get_from(), "jcl.test.com")
|
self.assertEquals(message.get_from(), "jcl.test.com")
|
||||||
@@ -463,7 +569,6 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
_account.get_new_message_subject(Lang.en))
|
_account.get_new_message_subject(Lang.en))
|
||||||
self.assertEquals(message.get_body(),
|
self.assertEquals(message.get_body(),
|
||||||
_account.get_new_message_body(Lang.en))
|
_account.get_new_message_body(Lang.en))
|
||||||
|
|
||||||
presence_account = stanza_sent[3]
|
presence_account = stanza_sent[3]
|
||||||
self.assertTrue(isinstance(presence_account, Presence))
|
self.assertTrue(isinstance(presence_account, Presence))
|
||||||
self.assertEquals(presence_account.get_from(), "account1@jcl.test.com")
|
self.assertEquals(presence_account.get_from(), "account1@jcl.test.com")
|
||||||
@@ -475,7 +580,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -510,7 +615,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -545,7 +650,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# First step again
|
# First step again
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -605,7 +710,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -640,7 +745,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#add-user")
|
||||||
@@ -658,7 +763,6 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertEquals(xml_command.prop("sessionid"), session_id)
|
self.assertEquals(xml_command.prop("sessionid"), session_id)
|
||||||
self.assertEquals(xml_command.children, None)
|
self.assertEquals(xml_command.children, None)
|
||||||
|
|
||||||
|
|
||||||
def test_execute_delete_user(self):
|
def test_execute_delete_user(self):
|
||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
@@ -686,7 +790,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account32@jcl.test.com")
|
jid="account32@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#delete-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#delete-user")
|
||||||
@@ -703,7 +807,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#delete-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#delete-user")
|
||||||
@@ -731,7 +835,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#delete-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#delete-user")
|
||||||
@@ -777,7 +881,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertTrue(isinstance(iq_result, Iq))
|
self.assertTrue(isinstance(iq_result, Iq))
|
||||||
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
||||||
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
||||||
self.assertEquals(iq_result.get_to(), "user1@test.com")
|
self.assertEquals(iq_result.get_to(), "admin@test.com")
|
||||||
presence_component = stanza_sent[1]
|
presence_component = stanza_sent[1]
|
||||||
self.assertTrue(isinstance(presence_component, Presence))
|
self.assertTrue(isinstance(presence_component, Presence))
|
||||||
self.assertEquals(presence_component.get_from(), "account11@jcl.test.com")
|
self.assertEquals(presence_component.get_from(), "account11@jcl.test.com")
|
||||||
@@ -836,7 +940,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account32.enabled = False
|
account32.enabled = False
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#disable-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#disable-user")
|
||||||
@@ -853,7 +957,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#disable-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#disable-user")
|
||||||
@@ -885,7 +989,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#disable-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#disable-user")
|
||||||
@@ -944,7 +1048,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account32.enabled = True
|
account32.enabled = True
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#reenable-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#reenable-user")
|
||||||
@@ -961,7 +1065,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#reenable-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#reenable-user")
|
||||||
@@ -993,7 +1097,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#reenable-user")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#reenable-user")
|
||||||
@@ -1048,7 +1152,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account32@jcl.test.com")
|
jid="account32@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#end-user-session")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#end-user-session")
|
||||||
@@ -1065,7 +1169,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#end-user-session")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#end-user-session")
|
||||||
@@ -1097,7 +1201,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#end-user-session")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#end-user-session")
|
||||||
@@ -1126,7 +1230,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertTrue(isinstance(iq_result, Iq))
|
self.assertTrue(isinstance(iq_result, Iq))
|
||||||
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
||||||
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
||||||
self.assertEquals(iq_result.get_to(), "user1@test.com")
|
self.assertEquals(iq_result.get_to(), "admin@test.com")
|
||||||
presence_component = stanza_sent[1]
|
presence_component = stanza_sent[1]
|
||||||
self.assertTrue(isinstance(presence_component, Presence))
|
self.assertTrue(isinstance(presence_component, Presence))
|
||||||
self.assertEquals(presence_component.get_from(), "account11@jcl.test.com")
|
self.assertEquals(presence_component.get_from(), "account11@jcl.test.com")
|
||||||
@@ -1161,7 +1265,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-password")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-password")
|
||||||
@@ -1178,7 +1282,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-password")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-password")
|
||||||
@@ -1206,7 +1310,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-password")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-password")
|
||||||
@@ -1233,7 +1337,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertTrue(isinstance(iq_result, Iq))
|
self.assertTrue(isinstance(iq_result, Iq))
|
||||||
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
self.assertEquals(iq_result.get_node().prop("type"), "result")
|
||||||
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
self.assertEquals(iq_result.get_from(), "jcl.test.com")
|
||||||
self.assertEquals(iq_result.get_to(), "user1@test.com")
|
self.assertEquals(iq_result.get_to(), "admin@test.com")
|
||||||
fields = iq_result.xpath_eval("c:command/data:x/data:field",
|
fields = iq_result.xpath_eval("c:command/data:x/data:field",
|
||||||
{"c": "http://jabber.org/protocol/commands",
|
{"c": "http://jabber.org/protocol/commands",
|
||||||
"data": "jabber:x:data"})
|
"data": "jabber:x:data"})
|
||||||
@@ -1273,7 +1377,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#change-user-password")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#change-user-password")
|
||||||
@@ -1290,7 +1394,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#change-user-password")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#change-user-password")
|
||||||
@@ -1322,7 +1426,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#change-user-password")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#change-user-password")
|
||||||
@@ -1388,7 +1492,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account=account22)
|
account=account22)
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-roster")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-roster")
|
||||||
@@ -1405,7 +1509,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-roster")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-roster")
|
||||||
@@ -1472,7 +1576,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-lastlogin")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-lastlogin")
|
||||||
@@ -1489,7 +1593,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-lastlogin")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-lastlogin")
|
||||||
@@ -1517,7 +1621,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Third step
|
# Third step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-lastlogin")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-user-lastlogin")
|
||||||
@@ -1574,7 +1678,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-registered-users-num")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-registered-users-num")
|
||||||
@@ -1618,7 +1722,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.enabled = False
|
account22.enabled = False
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-disabled-users-num")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-disabled-users-num")
|
||||||
@@ -1663,7 +1767,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = "chat"
|
account22.status = "chat"
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-online-users-num")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-online-users-num")
|
||||||
@@ -1705,7 +1809,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-registered-users-list")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-registered-users-list")
|
||||||
@@ -1755,7 +1859,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
jid="account2" + str(i) + "@jcl.test.com")
|
jid="account2" + str(i) + "@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node", "http://jabber.org/protocol/admin#get-registered-users-list")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-registered-users-list")
|
||||||
@@ -1794,7 +1898,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -1871,7 +1975,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.enabled = False
|
account22.enabled = False
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -1925,7 +2029,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
_account.enabled = False
|
_account.enabled = False
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -1966,7 +2070,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2042,7 +2146,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = "xa"
|
account22.status = "xa"
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2096,7 +2200,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
_account.status = "away"
|
_account.status = "away"
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2137,7 +2241,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2213,7 +2317,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = "xa"
|
account22.status = "xa"
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2239,7 +2343,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2297,7 +2401,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = account.OFFLINE
|
account22.status = account.OFFLINE
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2325,7 +2429,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2361,9 +2465,6 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
def test_execute_edit_motd(self):
|
def test_execute_edit_motd(self):
|
||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
config_file = tempfile.mktemp(".conf", "jcltest", jcl.tests.DB_DIR)
|
|
||||||
self.comp.config_file = config_file
|
|
||||||
self.comp.config = ConfigParser()
|
|
||||||
self.comp.set_motd("test motd")
|
self.comp.set_motd("test motd")
|
||||||
model.db_connect()
|
model.db_connect()
|
||||||
user1 = User(jid="test1@test.com")
|
user1 = User(jid="test1@test.com")
|
||||||
@@ -2386,7 +2487,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = account.OFFLINE
|
account22.status = account.OFFLINE
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2414,7 +2515,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2450,14 +2551,10 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertTrue(self.comp.config.has_option("component", "motd"))
|
self.assertTrue(self.comp.config.has_option("component", "motd"))
|
||||||
self.assertEquals(self.comp.config.get("component", "motd"),
|
self.assertEquals(self.comp.config.get("component", "motd"),
|
||||||
"Message Of The Day")
|
"Message Of The Day")
|
||||||
os.unlink(config_file)
|
|
||||||
|
|
||||||
def test_execute_delete_motd(self):
|
def test_execute_delete_motd(self):
|
||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
config_file = tempfile.mktemp(".conf", "jcltest", jcl.tests.DB_DIR)
|
|
||||||
self.comp.config_file = config_file
|
|
||||||
self.comp.config = ConfigParser()
|
|
||||||
self.comp.set_motd("test motd")
|
self.comp.set_motd("test motd")
|
||||||
model.db_connect()
|
model.db_connect()
|
||||||
user1 = User(jid="test1@test.com")
|
user1 = User(jid="test1@test.com")
|
||||||
@@ -2480,7 +2577,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = account.OFFLINE
|
account22.status = account.OFFLINE
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2498,14 +2595,10 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.__check_actions(result[0])
|
self.__check_actions(result[0])
|
||||||
self.comp.config.read(self.comp.config_file)
|
self.comp.config.read(self.comp.config_file)
|
||||||
self.assertFalse(self.comp.config.has_option("component", "motd"))
|
self.assertFalse(self.comp.config.has_option("component", "motd"))
|
||||||
os.unlink(config_file)
|
|
||||||
|
|
||||||
def test_execute_set_welcome(self):
|
def test_execute_set_welcome(self):
|
||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
config_file = tempfile.mktemp(".conf", "jcltest", jcl.tests.DB_DIR)
|
|
||||||
self.comp.config_file = config_file
|
|
||||||
self.comp.config = ConfigParser()
|
|
||||||
self.comp.set_welcome_message("Welcome Message")
|
self.comp.set_welcome_message("Welcome Message")
|
||||||
model.db_connect()
|
model.db_connect()
|
||||||
user1 = User(jid="test1@test.com")
|
user1 = User(jid="test1@test.com")
|
||||||
@@ -2528,7 +2621,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = account.OFFLINE
|
account22.status = account.OFFLINE
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2556,7 +2649,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2587,14 +2680,10 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertTrue(self.comp.config.has_option("component", "welcome_message"))
|
self.assertTrue(self.comp.config.has_option("component", "welcome_message"))
|
||||||
self.assertEquals(self.comp.config.get("component", "welcome_message"),
|
self.assertEquals(self.comp.config.get("component", "welcome_message"),
|
||||||
"New Welcome Message")
|
"New Welcome Message")
|
||||||
os.unlink(config_file)
|
|
||||||
|
|
||||||
def test_execute_delete_welcome(self):
|
def test_execute_delete_welcome(self):
|
||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
config_file = tempfile.mktemp(".conf", "jcltest", jcl.tests.DB_DIR)
|
|
||||||
self.comp.config_file = config_file
|
|
||||||
self.comp.config = ConfigParser()
|
|
||||||
self.comp.set_motd("test motd")
|
self.comp.set_motd("test motd")
|
||||||
model.db_connect()
|
model.db_connect()
|
||||||
user1 = User(jid="test1@test.com")
|
user1 = User(jid="test1@test.com")
|
||||||
@@ -2617,7 +2706,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = account.OFFLINE
|
account22.status = account.OFFLINE
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2636,14 +2725,10 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.comp.config.read(self.comp.config_file)
|
self.comp.config.read(self.comp.config_file)
|
||||||
self.assertFalse(self.comp.config.has_option("component",
|
self.assertFalse(self.comp.config.has_option("component",
|
||||||
"welcome_message"))
|
"welcome_message"))
|
||||||
os.unlink(config_file)
|
|
||||||
|
|
||||||
def test_execute_edit_admin(self):
|
def test_execute_edit_admin(self):
|
||||||
self.comp.account_manager.account_classes = (ExampleAccount,
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
Example2Account)
|
Example2Account)
|
||||||
config_file = tempfile.mktemp(".conf", "jcltest", jcl.tests.DB_DIR)
|
|
||||||
self.comp.config_file = config_file
|
|
||||||
self.comp.config = ConfigParser()
|
|
||||||
self.comp.set_admins(["admin1@test.com", "admin2@test.com"])
|
self.comp.set_admins(["admin1@test.com", "admin2@test.com"])
|
||||||
model.db_connect()
|
model.db_connect()
|
||||||
user1 = User(jid="test1@test.com")
|
user1 = User(jid="test1@test.com")
|
||||||
@@ -2666,7 +2751,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
account22.status = account.OFFLINE
|
account22.status = account.OFFLINE
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin1@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2696,7 +2781,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
# Second step
|
# Second step
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin1@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
command_node.setProp("node",
|
command_node.setProp("node",
|
||||||
@@ -2727,12 +2812,11 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertTrue(self.comp.config.has_option("component", "admins"))
|
self.assertTrue(self.comp.config.has_option("component", "admins"))
|
||||||
self.assertEquals(self.comp.config.get("component", "admins"),
|
self.assertEquals(self.comp.config.get("component", "admins"),
|
||||||
"admin3@test.com,admin4@test.com")
|
"admin3@test.com,admin4@test.com")
|
||||||
os.unlink(config_file)
|
|
||||||
|
|
||||||
# def test_execute_restart(self):
|
# def test_execute_restart(self):
|
||||||
# #TODO : implement command
|
# #TODO : implement command
|
||||||
# info_query = Iq(stanza_type="set",
|
# info_query = Iq(stanza_type="set",
|
||||||
# from_jid="user1@test.com",
|
# from_jid="admin@test.com",
|
||||||
# to_jid="jcl.test.com")
|
# to_jid="jcl.test.com")
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
# result = self.command_manager.execute_add_user(info_query)
|
||||||
# self.assertNotEquals(result, None)
|
# self.assertNotEquals(result, None)
|
||||||
@@ -2741,7 +2825,7 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
# def test_execute_shutdown(self):
|
# def test_execute_shutdown(self):
|
||||||
# #TODO : implement command
|
# #TODO : implement command
|
||||||
# info_query = Iq(stanza_type="set",
|
# info_query = Iq(stanza_type="set",
|
||||||
# from_jid="user1@test.com",
|
# from_jid="admin@test.com",
|
||||||
# to_jid="jcl.test.com")
|
# to_jid="jcl.test.com")
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
# result = self.command_manager.execute_add_user(info_query)
|
||||||
# self.assertNotEquals(result, None)
|
# self.assertNotEquals(result, None)
|
||||||
|
|||||||
@@ -535,7 +535,8 @@ class JCLComponent_TestCase(JCLTestCase):
|
|||||||
info_query = Iq(stanza_type="get",
|
info_query = Iq(stanza_type="get",
|
||||||
from_jid="user1@test.com",
|
from_jid="user1@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
disco_info = self.comp.disco_get_info("list", info_query)
|
disco_info = self.comp.disco_get_info("http://jabber.org/protocol/admin#get-disabled-users-num",
|
||||||
|
info_query)
|
||||||
self.assertEquals(len(self.comp.stream.sent), 0)
|
self.assertEquals(len(self.comp.stream.sent), 0)
|
||||||
self.assertTrue(disco_info.has_feature("http://jabber.org/protocol/commands"))
|
self.assertTrue(disco_info.has_feature("http://jabber.org/protocol/commands"))
|
||||||
self.assertEquals(len(disco_info.get_identities()), 1)
|
self.assertEquals(len(disco_info.get_identities()), 1)
|
||||||
@@ -544,7 +545,7 @@ class JCLComponent_TestCase(JCLTestCase):
|
|||||||
self.assertEquals(disco_info.get_identities()[0].get_type(),
|
self.assertEquals(disco_info.get_identities()[0].get_type(),
|
||||||
"command-node")
|
"command-node")
|
||||||
self.assertEquals(disco_info.get_identities()[0].get_name(),
|
self.assertEquals(disco_info.get_identities()[0].get_name(),
|
||||||
Lang.en.command_list)
|
Lang.en.command_get_disabled_users_num)
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# 'disco_get_items' tests
|
# 'disco_get_items' tests
|
||||||
@@ -742,15 +743,17 @@ class JCLComponent_TestCase(JCLTestCase):
|
|||||||
def test_disco_get_items_list_commands(self):
|
def test_disco_get_items_list_commands(self):
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
|
config_file = tempfile.mktemp(".conf", "jcltest", jcl.tests.DB_DIR)
|
||||||
|
self.comp.config = ConfigParser()
|
||||||
|
self.comp.config_file = config_file
|
||||||
|
self.comp.config.read(config_file)
|
||||||
|
self.comp.set_admins(["admin@test.com"])
|
||||||
info_query = Iq(stanza_type="get",
|
info_query = Iq(stanza_type="get",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
disco_items = self.comp.disco_get_items("http://jabber.org/protocol/commands",
|
disco_items = self.comp.disco_get_items("http://jabber.org/protocol/commands",
|
||||||
info_query)
|
info_query)
|
||||||
self.assertEquals(len(disco_items.get_items()), 25)
|
self.assertEquals(len(disco_items.get_items()), 24)
|
||||||
item = disco_items.get_items()[0]
|
|
||||||
self.assertEquals(item.get_node(), "list")
|
|
||||||
self.assertEquals(item.get_name(), Lang.en.command_list)
|
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# 'handle_get_version' tests
|
# 'handle_get_version' tests
|
||||||
@@ -2714,7 +2717,7 @@ class JCLComponent_TestCase(JCLTestCase):
|
|||||||
self.comp.config.read(self.comp.config_file)
|
self.comp.config.read(self.comp.config_file)
|
||||||
self.comp.config.write(open(self.comp.config_file, "w"))
|
self.comp.config.write(open(self.comp.config_file, "w"))
|
||||||
admins = self.comp.get_admins()
|
admins = self.comp.get_admins()
|
||||||
self.assertEquals(admins, None)
|
self.assertEquals(admins, [])
|
||||||
os.unlink(config_file)
|
os.unlink(config_file)
|
||||||
|
|
||||||
def test_set_new_admins(self):
|
def test_set_new_admins(self):
|
||||||
@@ -2751,11 +2754,17 @@ class JCLComponent_TestCase(JCLTestCase):
|
|||||||
def test_handle_command_execute_list(self):
|
def test_handle_command_execute_list(self):
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
|
config_file = tempfile.mktemp(".conf", "jcltest", jcl.tests.DB_DIR)
|
||||||
|
self.comp.config = ConfigParser()
|
||||||
|
self.comp.config_file = config_file
|
||||||
|
self.comp.config.read(config_file)
|
||||||
|
self.comp.set_admins(["admin@test.com"])
|
||||||
model.db_connect()
|
model.db_connect()
|
||||||
user1 = User(jid="user1@test.com")
|
user1 = User(jid="user1@test.com")
|
||||||
account11 = ExampleAccount(user=user1,
|
account11 = ExampleAccount(user=user1,
|
||||||
name="account11",
|
name="account11",
|
||||||
jid="account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
|
account11.enabled = False
|
||||||
account12 = Example2Account(user=user1,
|
account12 = Example2Account(user=user1,
|
||||||
name="account12",
|
name="account12",
|
||||||
jid="account12@jcl.test.com")
|
jid="account12@jcl.test.com")
|
||||||
@@ -2764,11 +2773,11 @@ class JCLComponent_TestCase(JCLTestCase):
|
|||||||
jid="account2@jcl.test.com")
|
jid="account2@jcl.test.com")
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
from_jid="user1@test.com",
|
from_jid="admin@test.com",
|
||||||
to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
command_node = info_query.set_new_content("http://jabber.org/protocol/commands",
|
command_node = info_query.set_new_content("http://jabber.org/protocol/commands",
|
||||||
"command")
|
"command")
|
||||||
command_node.setProp("node", "list")
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-disabled-users-num")
|
||||||
command_node.setProp("action", "execute")
|
command_node.setProp("action", "execute")
|
||||||
self.comp.handle_command(info_query)
|
self.comp.handle_command(info_query)
|
||||||
result = self.comp.stream.sent
|
result = self.comp.stream.sent
|
||||||
@@ -2778,10 +2787,13 @@ class JCLComponent_TestCase(JCLTestCase):
|
|||||||
{"c": "http://jabber.org/protocol/commands"})
|
{"c": "http://jabber.org/protocol/commands"})
|
||||||
self.assertEquals(len(command_result), 1)
|
self.assertEquals(len(command_result), 1)
|
||||||
self.assertEquals(command_result[0].prop("status"), "completed")
|
self.assertEquals(command_result[0].prop("status"), "completed")
|
||||||
items = result[0].xpath_eval("c:command/data:x/data:item",
|
fields = result[0].xpath_eval("c:command/data:x/data:field",
|
||||||
{"c": "http://jabber.org/protocol/commands",
|
{"c": "http://jabber.org/protocol/commands",
|
||||||
"data": "jabber:x:data"})
|
"data": "jabber:x:data"})
|
||||||
self.assertEquals(len(items), 2)
|
self.assertEquals(len(fields), 2)
|
||||||
|
self.assertEquals(fields[1].prop("var"), "disabledusersnum")
|
||||||
|
self.assertEquals(fields[1].children.name, "value")
|
||||||
|
self.assertEquals(fields[1].children.content, "1")
|
||||||
|
|
||||||
class Handler_TestCase(JCLTestCase):
|
class Handler_TestCase(JCLTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class Lang:
|
|||||||
get_gateway_desc = u"Please enter the email address of your contact"
|
get_gateway_desc = u"Please enter the email address of your contact"
|
||||||
get_gateway_prompt = u"Email address"
|
get_gateway_prompt = u"Email address"
|
||||||
|
|
||||||
command_list = u"List accounts"
|
command_get_disabled_users_num = u"get-disabled-users-num"
|
||||||
command_add_user = u"Create new account"
|
command_add_user = u"Create new account"
|
||||||
select_account_type = u"Select account type"
|
select_account_type = u"Select account type"
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ class Lang:
|
|||||||
get_gateway_desc = u"Entrer l'adresse email de votre contact"
|
get_gateway_desc = u"Entrer l'adresse email de votre contact"
|
||||||
get_gateway_prompt = u"Adresse email"
|
get_gateway_prompt = u"Adresse email"
|
||||||
|
|
||||||
command_list = u"Liste les comptes"
|
command_get_disabled_users_num = u"get_disabled_users_num"
|
||||||
command_add_user = u"Créer un compte"
|
command_add_user = u"Créer un compte"
|
||||||
select_account_type = u"Selectionner le type de comptes"
|
select_account_type = u"Selectionner le type de comptes"
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class Language_TestCase(unittest.TestCase):
|
|||||||
self.assertNotEquals(self.lang_class.get_gateway_desc, None)
|
self.assertNotEquals(self.lang_class.get_gateway_desc, None)
|
||||||
self.assertNotEquals(self.lang_class.get_gateway_prompt, None)
|
self.assertNotEquals(self.lang_class.get_gateway_prompt, None)
|
||||||
|
|
||||||
self.assertNotEquals(self.lang_class.command_list, None)
|
self.assertNotEquals(self.lang_class.command_get_disabled_users_num, None)
|
||||||
self.assertNotEquals(self.lang_class.command_add_user, None)
|
self.assertNotEquals(self.lang_class.command_add_user, None)
|
||||||
self.assertNotEquals(self.lang_class.select_account_type, None)
|
self.assertNotEquals(self.lang_class.select_account_type, None)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user