summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-07-27 16:35:23 -0400
committerRob Crittenden <rcritten@redhat.com>2010-08-06 15:32:37 -0400
commit2d7d047cbf9375a4c75196f13ac1e0c439ae9e8b (patch)
treec30749ec5472dcbfb54165ec5f0c28f87377fe08 /tests
parent252b73fb3ec3cfb6c5efb4b93db321eedd3745e1 (diff)
downloadfreeipa-2d7d047cbf9375a4c75196f13ac1e0c439ae9e8b.tar.gz
freeipa-2d7d047cbf9375a4c75196f13ac1e0c439ae9e8b.tar.xz
freeipa-2d7d047cbf9375a4c75196f13ac1e0c439ae9e8b.zip
Add optional error message to pattern validator
The pattern validator by default displays the pattern that is being matched against. This isn't helpful, particularly for very hairy patterns. This adds a new parameter, pattern_errmsg, that is displayed on errors if set. ticket #11
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xmlrpc/test_group_plugin.py17
-rw-r--r--tests/test_xmlrpc/test_user_plugin.py19
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py
index 620f3eac..a8940a0d 100644
--- a/tests/test_xmlrpc/test_group_plugin.py
+++ b/tests/test_xmlrpc/test_group_plugin.py
@@ -28,6 +28,9 @@ from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid
group1 = u'testgroup1'
group2 = u'testgroup2'
+invalidgroup1=u'+tgroup1'
+invalidgroup2=u'tgroup1234567890123456789012345678901234567890'
+
class test_group(Declarative):
cleanup_commands = [
@@ -511,4 +514,18 @@ class test_group(Declarative):
expected=errors.NotFound(reason='no such entry'),
),
+ dict(
+ desc='Test an invalid group name %r' % invalidgroup1,
+ command=('group_add', [invalidgroup1], dict(description=u'Test')),
+ expected=errors.ValidationError(name='cn', error='may only include letters, numbers, _, -, . and $'),
+ ),
+
+
+ dict(
+ desc='Test a group name that is too long %r' % invalidgroup2,
+ command=('group_add', [invalidgroup2], dict(description=u'Test')),
+ expected=errors.ValidationError(name='cn', error='can be at most 33 characters'),
+ ),
+
+
]
diff --git a/tests/test_xmlrpc/test_user_plugin.py b/tests/test_xmlrpc/test_user_plugin.py
index 467eacf4..18c5b45f 100644
--- a/tests/test_xmlrpc/test_user_plugin.py
+++ b/tests/test_xmlrpc/test_user_plugin.py
@@ -31,6 +31,9 @@ from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid
user_memberof = (u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn,)
user1=u'tuser1'
+invaliduser1=u'+tuser1'
+invaliduser2=u'tuser1234567890123456789012345678901234567890'
+
class test_user(Declarative):
@@ -78,6 +81,7 @@ class test_user(Declarative):
objectclass=objectclasses.user,
sn=[u'User1'],
uid=[user1],
+ uidnumber=[fuzzy_digits],
ipauniqueid=[fuzzy_uuid],
dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
),
@@ -183,6 +187,8 @@ class test_user(Declarative):
sn=[u'Administrator'],
uid=[u'admin'],
memberof_group=[u'admins'],
+ memberof_rolegroup=[u'replicaadmin'],
+ memberof_taskgroup=[u'managereplica', u'deletereplica'],
),
dict(
dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
@@ -299,4 +305,17 @@ class test_user(Declarative):
),
+ dict(
+ desc='Test an invalid login name %r' % invaliduser1,
+ command=('user_add', [invaliduser1], dict(givenname=u'Test', sn=u'User1')),
+ expected=errors.ValidationError(name='uid', error='may only include letters, numbers, _, -, . and $'),
+ ),
+
+
+ dict(
+ desc='Test a login name that is too long %r' % invaliduser2,
+ command=('user_add', [invaliduser2], dict(givenname=u'Test', sn=u'User1')),
+ expected=errors.ValidationError(name='uid', error='can be at most 33 characters'),
+ ),
+
]