fix whitespace account name for ad-hoc command add-user
This commit is contained in:
7
debian/changelog
vendored
7
debian/changelog
vendored
@@ -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
|
||||
|
||||
4
setup.py
4
setup.py
@@ -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'])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
FormEncode
|
||||
SQLObject>=0.8
|
||||
pyxmpp>=1.0.1
|
||||
pysqlite>=2.0
|
||||
@@ -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,6 +580,11 @@ class JCLCommandManager(CommandManager):
|
||||
{"c": "http://jabber.org/protocol/commands",
|
||||
"jxd" : "jabber:x:data"})[0]
|
||||
x_data = Form(x_node)
|
||||
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]),
|
||||
|
||||
@@ -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 .
|
||||
|
||||
Reference in New Issue
Block a user