diff options
author | David Rousselie <david.rousselie@happycoders.org> | 2011-10-08 14:58:49 +0400 |
---|---|---|
committer | David Rousselie <david.rousselie@happycoders.org> | 2011-10-08 15:02:26 +0400 |
commit | ec929f5880dadc1b6c6834dfbce62befe50dbe4c (patch) | |
tree | 409ef0d2135dcba5ed1a625bf5ffd71c0a32ac49 | |
parent | 5ef25b59bbef1253eed2cf3a9b55025d1d52aac8 (diff) |
fix whitespace account name for ad-hoc command add-user
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | setup.py | 4 | ||||
-rw-r--r-- | src/jcl.egg-info/PKG-INFO | 2 | ||||
-rw-r--r-- | src/jcl.egg-info/requires.txt | 1 | ||||
-rw-r--r-- | src/jcl/jabber/command.py | 20 | ||||
-rw-r--r-- | src/jcl/jabber/tests/command.py | 59 |
6 files changed, 83 insertions, 10 deletions
diff --git a/debian/changelog b/debian/changelog index 0ec6ee7..1278e77 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +jcl (0.1rc2) unstable; urgency=low + + * JCL v0.1 RC2 + * Fix add_user ad-hoc command to refuse whitespace in account name + + -- David Rousselie <dax@happycoders.org> Sat, 08 Oct 2011 12:56:43 +0200 + jcl (0.1rc1) unstable; urgency=low * JCL v0.1 RC1 @@ -23,7 +23,7 @@ from setuptools import setup, find_packages setup(name='jcl', - version='0.1b3', + version='0.1rc2', description='Jabber Component Library', author='David Rousselie', author_email='dax@happycoders.org', @@ -46,4 +46,4 @@ setup(name='jcl', "tests.*", "tests"]), test_suite='jcl.tests.suite', - install_requires=['SQLObject>=0.8', 'pyxmpp>=1.0.1', 'pysqlite>=2.0']) + install_requires=['FormEncode', 'SQLObject>=0.8', 'pyxmpp>=1.0.1', 'pysqlite>=2.0']) diff --git a/src/jcl.egg-info/PKG-INFO b/src/jcl.egg-info/PKG-INFO index a0465b3..621c2df 100644 --- a/src/jcl.egg-info/PKG-INFO +++ b/src/jcl.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: jcl -Version: 0.1b3 +Version: 0.1rc2 Summary: Jabber Component Library Home-page: http://people.happycoders.org/dax/projects/jcl Author: David Rousselie diff --git a/src/jcl.egg-info/requires.txt b/src/jcl.egg-info/requires.txt index c6ae633..8722d3b 100644 --- a/src/jcl.egg-info/requires.txt +++ b/src/jcl.egg-info/requires.txt @@ -1,3 +1,4 @@ +FormEncode SQLObject>=0.8 pyxmpp>=1.0.1 pysqlite>=2.0
\ No newline at end of file diff --git a/src/jcl/jabber/command.py b/src/jcl/jabber/command.py index 6ef5835..a1791aa 100644 --- a/src/jcl/jabber/command.py +++ b/src/jcl/jabber/command.py @@ -34,6 +34,7 @@ from pyxmpp.jabber.dataforms import Form, Field from pyxmpp.message import Message from jcl.jabber.disco import DiscoHandler, RootDiscoGetInfoHandler +from jcl.jabber.register import SetRegisterHandler from jcl.model import account from jcl.model.account import Account, User @@ -579,13 +580,18 @@ class JCLCommandManager(CommandManager): {"c": "http://jabber.org/protocol/commands", "jxd" : "jabber:x:data"})[0] x_data = Form(x_node) - to_send = self.component.account_manager.create_account_from_type(\ - account_name=session_context["name"][0], - from_jid=JID(session_context["user_jid"][0]), - account_type=session_context["account_type"][0], - lang_class=lang_class, - x_data=x_data) - command_node.setProp("status", STATUS_COMPLETED) + errors = SetRegisterHandler(self.component).validate_form(\ + x_data, info_query, lang_class) + if errors is not None: + raise CommandError("bad-request") + else: + to_send = self.component.account_manager.create_account_from_type(\ + account_name=session_context["name"][0], + from_jid=JID(session_context["user_jid"][0]), + account_type=session_context["account_type"][0], + lang_class=lang_class, + x_data=x_data) + command_node.setProp("status", STATUS_COMPLETED) return (None, to_send) ########################################################################### diff --git a/src/jcl/jabber/tests/command.py b/src/jcl/jabber/tests/command.py index 5fd940d..0fa8acb 100644 --- a/src/jcl/jabber/tests/command.py +++ b/src/jcl/jabber/tests/command.py @@ -1020,6 +1020,63 @@ class JCLCommandManagerAddUserCommand_TestCase(JCLCommandManagerTestCase): self.check_step_3(result, session_id, "test4@test.com", "test4@test.com") + def test_execute_add_user_invalid_name(self): + """ + test 'add-user' ad-hoc command with an invalid name (with spaces). + """ + self.info_query.set_from("test4@test.com") + result = self.command_manager.apply_command_action(\ + self.info_query, + "http://jabber.org/protocol/admin#add-user", + "execute") + session_id = self.check_step_1(result, "test4@test.com") + + # Second step + info_query = prepare_submit(\ + node="http://jabber.org/protocol/admin#add-user", + session_id=session_id, + from_jid="test4@test.com", + fields=[Field(field_type="list-single", + name="account_type", + value="Example")]) + result = self.command_manager.apply_command_action(\ + info_query, + "http://jabber.org/protocol/admin#add-user", + "next") + context_session = self.check_step_2(result, session_id, + "test4@test.com", "test4@test.com") + + # Third step + info_query = prepare_submit(\ + node="http://jabber.org/protocol/admin#add-user", + session_id=session_id, + from_jid="test4@test.com", + fields=[Field(field_type="text-single", + name="name", + value="account 1"), + Field(field_type="text-single", + name="login", + value="login1"), + Field(field_type="text-private", + name="password", + value="pass1"), + Field(field_type="boolean", + name="store_password", + value="1"), + Field(field_type="list-single", + name="test_enum", + value="choice2"), + Field(field_type="text-single", + name="test_int", + value="42")], + action="complete") + result = self.command_manager.apply_command_action(\ + info_query, + "http://jabber.org/protocol/admin#add-user", + "execute") + self.assertEquals(result[0].get_type(), "error") + self.assertEquals(result[0].get_error().get_type(), "modify") + def test_execute_add_user_prev(self): """ test 'add-user' ad-hoc command with an admin user. Test 'prev' action. @@ -1079,6 +1136,8 @@ class JCLCommandManagerAddUserCommand_TestCase(JCLCommandManagerTestCase): other_session_id = self.check_step_1(result, "admin@test.com", is_admin=True) self.assertEquals(other_session_id, session_id) + + def test_execute_add_user_cancel(self): """ Test cancel 'add-user' ad-hoc command . |