summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Dennis <jdennis@redhat.com>2011-06-15 16:05:19 -0400
committerRob Crittenden <rcritten@redhat.com>2011-06-22 02:06:02 -0400
commitd9d00f152267780d8251ee6e935645f397f2c0d7 (patch)
treeab3fcfc8e01839f0af715a1f6491322e542c7779 /tests
parent8c95eb68d2315217ff1d2564b5b300aa106f4bbd (diff)
downloadfreeipa-d9d00f152267780d8251ee6e935645f397f2c0d7.tar.gz
freeipa-d9d00f152267780d8251ee6e935645f397f2c0d7.tar.xz
freeipa-d9d00f152267780d8251ee6e935645f397f2c0d7.zip
Update test_role_plugin test to include a comma in a privilege
Introduce a comma into a privilege name to assure we can handle commas. Commas must be escaped for some parameters, add escape_comma() utility and invoke it for the necessary parameters. Utilize a DN object to properly construct a DN and most importantly to allow equality testing beween the DN we expect and the one returned. This is necessary because a DN can be encoded according to different encoding syntaxes all of which are valid. DN objects always decode from their input. DN objects can test for equality between DN's without being affected by DN encoding. Add a equality callback for the dn in the expected dict. When the test framework tests for equality between the expected value and the returned value it will call back into a function we provide which will convert the returned dn into a DN object. An equality test is then performed between two DN objects. This is the only way to properly compare two dn's.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xmlrpc/test_role_plugin.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/test_xmlrpc/test_role_plugin.py b/tests/test_xmlrpc/test_role_plugin.py
index 28d1c6b43..82342c340 100644
--- a/tests/test_xmlrpc/test_role_plugin.py
+++ b/tests/test_xmlrpc/test_role_plugin.py
@@ -1,6 +1,7 @@
# Authors:
# Rob Crittenden <rcritten@redhat.com>
# Pavel Zuna <pzuna@redhat.com>
+# John Dennis <jdennis@redhat.com>
#
# Copyright (C) 2009 Red Hat
# see file 'COPYING' for use and warranty information
@@ -24,6 +25,7 @@ Test the `ipalib/plugins/role.py` module.
from ipalib import api, errors
from tests.test_xmlrpc import objectclasses
from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid
+from ipalib.dn import *
search = u'test-role'
@@ -41,9 +43,11 @@ role2_dn = u'cn=%s,%s,%s' % (
group1 = u'testgroup1'
group1_dn = u'cn=%s,%s,%s' % (group1, api.env.container_group, api.env.basedn)
-privilege1 = u'testpriv1'
-privilege1_dn = u'cn=%s,%s,%s' % (privilege1, api.env.container_privilege, api.env.basedn)
+privilege1 = u'r,w privilege 1'
+privilege1_dn = DN('cn', privilege1, DN(api.env.container_privilege), DN(api.env.basedn))
+def escape_comma(value):
+ return value.replace(',', '\\,')
class test_role(Declarative):
@@ -158,7 +162,7 @@ class test_role(Declarative):
value=privilege1,
summary=u'Added privilege "%s"' % privilege1,
result=dict(
- dn=privilege1_dn,
+ dn=lambda got: DN(got) == privilege1_dn,
cn=[privilege1],
description=[u'privilege desc. 1'],
objectclass=objectclasses.privilege,
@@ -170,7 +174,7 @@ class test_role(Declarative):
dict(
desc='Add privilege %r to role %r' % (privilege1, role1),
command=('role_add_privilege', [role1],
- dict(privilege=privilege1)
+ dict(privilege=escape_comma(privilege1))
),
expected=dict(
completed=1,
@@ -451,7 +455,7 @@ class test_role(Declarative):
dict(
desc='Remove privilege %r from role %r' % (privilege1, role1),
command=('role_remove_privilege', [role1],
- dict(privilege=privilege1)
+ dict(privilege=escape_comma(privilege1))
),
expected=dict(
completed=1,
@@ -472,7 +476,7 @@ class test_role(Declarative):
dict(
desc='Remove privilege %r from role %r again' % (privilege1, role1),
command=('role_remove_privilege', [role1],
- dict(privilege=privilege1)
+ dict(privilege=escape_comma(privilege1))
),
expected=dict(
completed=0,