2010-12-01 10:23:52 -06:00
|
|
|
# Authors:
|
|
|
|
# Rob Crittenden <rcritten@redhat.com>
|
|
|
|
# Pavel Zuna <pzuna@redhat.com>
|
2011-06-15 15:05:19 -05:00
|
|
|
# John Dennis <jdennis@redhat.com>
|
2010-12-01 10:23:52 -06:00
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
2010-12-09 06:59:11 -06:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2010-12-01 10:23:52 -06:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2010-12-09 06:59:11 -06:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-01 10:23:52 -06:00
|
|
|
"""
|
|
|
|
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
|
2011-06-15 15:05:19 -05:00
|
|
|
from ipalib.dn import *
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
search = u'test-role'
|
|
|
|
|
|
|
|
role1 = u'test-role-1'
|
2011-08-09 20:21:56 -05:00
|
|
|
role1_dn = DN(('cn',role1),api.env.container_rolegroup,
|
|
|
|
api.env.basedn)
|
2010-12-01 10:23:52 -06:00
|
|
|
renamedrole1 = u'test-role'
|
2012-02-29 12:31:20 -06:00
|
|
|
invalidrole1 = u' whitespace '
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
role2 = u'test-role-2'
|
2011-08-09 20:21:56 -05:00
|
|
|
role2_dn = DN(('cn',role2),api.env.container_rolegroup,
|
|
|
|
api.env.basedn)
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
group1 = u'testgroup1'
|
2011-08-09 20:21:56 -05:00
|
|
|
group1_dn = DN(('cn',group1),api.env.container_group,
|
|
|
|
api.env.basedn)
|
2010-12-01 10:23:52 -06:00
|
|
|
|
2011-06-15 15:05:19 -05:00
|
|
|
privilege1 = u'r,w privilege 1'
|
2011-08-09 20:21:56 -05:00
|
|
|
privilege1_dn = DN(('cn', privilege1), DN(api.env.container_privilege),
|
|
|
|
api.env.basedn)
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
class test_role(Declarative):
|
|
|
|
|
|
|
|
cleanup_commands = [
|
|
|
|
('role_del', [role1], {}),
|
|
|
|
('role_del', [role2], {}),
|
|
|
|
('group_del', [group1], {}),
|
|
|
|
('privilege_del', [privilege1], {}),
|
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to retrieve non-existent %r' % role1,
|
|
|
|
command=('role_show', [role1], {}),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(reason=u'%s: role not found' % role1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to update non-existent %r' % role1,
|
|
|
|
command=('role_mod', [role1], dict(description=u'Foo')),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(reason=u'%s: role not found' % role1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to delete non-existent %r' % role1,
|
|
|
|
command=('role_del', [role1], {}),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(reason=u'%s: role not found' % role1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to rename non-existent %r' % role1,
|
2012-03-14 10:33:41 -05:00
|
|
|
command=('role_mod', [role1], dict(setattr=u'cn=%s' % renamedrole1)),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(reason=u'%s: role not found' % role1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for non-existent %r' % role1,
|
|
|
|
command=('role_find', [role1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 roles matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-02-29 12:31:20 -06:00
|
|
|
dict(
|
|
|
|
desc='Create invalid %r' % invalidrole1,
|
|
|
|
command=('role_add', [invalidrole1],
|
|
|
|
dict(description=u'role desc 1')
|
|
|
|
),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.ValidationError(name='name',
|
|
|
|
error=u'Leading and trailing spaces are not allowed'),
|
2012-02-29 12:31:20 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Create %r' % role1,
|
|
|
|
command=('role_add', [role1],
|
|
|
|
dict(description=u'role desc 1')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=role1,
|
|
|
|
summary=u'Added role "%s"' % role1,
|
|
|
|
result=dict(
|
2011-08-09 20:21:56 -05:00
|
|
|
dn=lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[role1],
|
|
|
|
description=[u'role desc 1'],
|
|
|
|
objectclass=objectclasses.role,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r' % role1,
|
|
|
|
command=('role_show', [role1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=role1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
2011-08-09 20:21:56 -05:00
|
|
|
dn=lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[role1],
|
|
|
|
description=[u'role desc 1'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % group1,
|
|
|
|
command=(
|
|
|
|
'group_add', [group1], dict(description=u'group desc 1',
|
|
|
|
nonposix=True,)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=group1,
|
|
|
|
summary=u'Added group "testgroup1"',
|
|
|
|
result=dict(
|
2011-08-09 20:21:56 -05:00
|
|
|
dn=lambda x: DN(x) == group1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[group1],
|
|
|
|
description=[u'group desc 1'],
|
|
|
|
objectclass=objectclasses.group,
|
|
|
|
ipauniqueid=[fuzzy_uuid],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % privilege1,
|
|
|
|
command=('privilege_add', [privilege1],
|
|
|
|
dict(description=u'privilege desc. 1')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=privilege1,
|
|
|
|
summary=u'Added privilege "%s"' % privilege1,
|
|
|
|
result=dict(
|
2011-08-09 20:21:56 -05:00
|
|
|
dn=lambda x: DN(x) == privilege1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[privilege1],
|
|
|
|
description=[u'privilege desc. 1'],
|
|
|
|
objectclass=objectclasses.privilege,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Add privilege %r to role %r' % (privilege1, role1),
|
|
|
|
command=('role_add_privilege', [role1],
|
Only split CSV in the client, quote instead of escaping
Splitting on commas is not an idempotent operation:
'a,b\,c' -> ('a', 'b,c') -> ('a', 'b', 'c')
That means we can't do it when the call is forwarded, so this is only
done on the CLI. The UI already sends values as a tuple.
Replace escaping in the csv parser with quoting. Quoted strings can have
embedded commas instead of having to escape them. This prevents the csv
parser from eating all escape characters.
Also, document Param's csv arguments, and update tests.
https://fedorahosted.org/freeipa/ticket/2417
https://fedorahosted.org/freeipa/ticket/2227
2012-02-23 06:29:47 -06:00
|
|
|
dict(privilege=privilege1)
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
completed=1,
|
|
|
|
failed=dict(
|
|
|
|
member=dict(
|
|
|
|
privilege=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'role desc 1'],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Add member %r to %r' % (group1, role1),
|
|
|
|
command=('role_add_member', [role1], dict(group=group1)),
|
|
|
|
expected=dict(
|
|
|
|
completed=1,
|
|
|
|
failed=dict(
|
|
|
|
member=dict(
|
|
|
|
user=[],
|
|
|
|
group=[],
|
|
|
|
host=[],
|
|
|
|
hostgroup=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'role desc 1'],
|
|
|
|
'member_group': [group1],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r to verify member-add' % role1,
|
|
|
|
command=('role_show', [role1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=role1,
|
|
|
|
summary=None,
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'role desc 1'],
|
|
|
|
'member_group': [group1],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r' % role1,
|
|
|
|
command=('role_find', [role1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 role matched',
|
|
|
|
result=[
|
|
|
|
{
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'role desc 1'],
|
|
|
|
'member_group': [group1],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r' % search,
|
|
|
|
command=('role_find', [search], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 role matched',
|
|
|
|
result=[
|
|
|
|
{
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'role desc 1'],
|
|
|
|
'member_group': [group1],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % role2,
|
|
|
|
command=('role_add', [role2],
|
|
|
|
dict(description=u'role desc 2')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=role2,
|
|
|
|
summary=u'Added role "%s"' % role2,
|
|
|
|
result=dict(
|
2011-08-09 20:21:56 -05:00
|
|
|
dn=lambda x: DN(x) == role2_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[role2],
|
|
|
|
description=[u'role desc 2'],
|
|
|
|
objectclass=objectclasses.role,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r' % role1,
|
|
|
|
command=('role_find', [role1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 role matched',
|
|
|
|
result=[
|
|
|
|
{
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'role desc 1'],
|
|
|
|
'member_group': [group1],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r' % search,
|
|
|
|
command=('role_find', [search], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=2,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'2 roles matched',
|
|
|
|
result=[
|
|
|
|
{
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'role desc 1'],
|
|
|
|
'member_group': [group1],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
{
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role2_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role2],
|
|
|
|
'description': [u'role desc 2'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Update %r' % role1,
|
|
|
|
command=(
|
|
|
|
'role_mod', [role1], dict(description=u'New desc 1')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=role1,
|
|
|
|
summary=u'Modified role "%s"' % role1,
|
|
|
|
result=dict(
|
|
|
|
cn=[role1],
|
|
|
|
description=[u'New desc 1'],
|
|
|
|
member_group=[group1],
|
|
|
|
memberof_privilege=[privilege1],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r to verify update' % role1,
|
|
|
|
command=('role_show', [role1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=role1,
|
|
|
|
summary=None,
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'New desc 1'],
|
|
|
|
'member_group': [group1],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove member %r from %r' % (group1, role1),
|
|
|
|
command=('role_remove_member', [role1], dict(group=group1)),
|
|
|
|
expected=dict(
|
|
|
|
completed=1,
|
|
|
|
failed=dict(
|
|
|
|
member=dict(
|
|
|
|
user=[],
|
|
|
|
group=[],
|
|
|
|
host=[],
|
|
|
|
hostgroup=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'New desc 1'],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r to verify member-del' % role1,
|
|
|
|
command=('role_show', [role1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=role1,
|
|
|
|
summary=None,
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'New desc 1'],
|
|
|
|
'memberof_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % group1,
|
|
|
|
command=('group_del', [group1], {}),
|
|
|
|
expected=dict(
|
2011-01-07 10:17:55 -06:00
|
|
|
result=dict(failed=u''),
|
2010-12-01 10:23:52 -06:00
|
|
|
value=group1,
|
|
|
|
summary=u'Deleted group "testgroup1"',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Rename %r' % role1,
|
|
|
|
command=('role_mod', [role1], dict(setattr=u'cn=%s' % renamedrole1)),
|
|
|
|
expected=dict(
|
|
|
|
value=role1,
|
|
|
|
result=dict(
|
|
|
|
cn=[renamedrole1],
|
|
|
|
description=[u'New desc 1'],
|
|
|
|
memberof_privilege=[privilege1],
|
|
|
|
),
|
|
|
|
summary=u'Modified role "%s"' % role1
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Rename %r back' % renamedrole1,
|
|
|
|
command=('role_mod', [renamedrole1], dict(setattr=u'cn=%s' % role1)),
|
|
|
|
expected=dict(
|
|
|
|
value=renamedrole1,
|
|
|
|
result=dict(
|
|
|
|
cn=[role1],
|
|
|
|
description=[u'New desc 1'],
|
|
|
|
memberof_privilege=[privilege1],
|
|
|
|
),
|
|
|
|
summary=u'Modified role "%s"' % renamedrole1
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove privilege %r from role %r' % (privilege1, role1),
|
|
|
|
command=('role_remove_privilege', [role1],
|
Only split CSV in the client, quote instead of escaping
Splitting on commas is not an idempotent operation:
'a,b\,c' -> ('a', 'b,c') -> ('a', 'b', 'c')
That means we can't do it when the call is forwarded, so this is only
done on the CLI. The UI already sends values as a tuple.
Replace escaping in the csv parser with quoting. Quoted strings can have
embedded commas instead of having to escape them. This prevents the csv
parser from eating all escape characters.
Also, document Param's csv arguments, and update tests.
https://fedorahosted.org/freeipa/ticket/2417
https://fedorahosted.org/freeipa/ticket/2227
2012-02-23 06:29:47 -06:00
|
|
|
dict(privilege=privilege1)
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
completed=1,
|
|
|
|
failed=dict(
|
|
|
|
member=dict(
|
|
|
|
privilege=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'New desc 1'],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove privilege %r from role %r again' % (privilege1, role1),
|
|
|
|
command=('role_remove_privilege', [role1],
|
Only split CSV in the client, quote instead of escaping
Splitting on commas is not an idempotent operation:
'a,b\,c' -> ('a', 'b,c') -> ('a', 'b', 'c')
That means we can't do it when the call is forwarded, so this is only
done on the CLI. The UI already sends values as a tuple.
Replace escaping in the csv parser with quoting. Quoted strings can have
embedded commas instead of having to escape them. This prevents the csv
parser from eating all escape characters.
Also, document Param's csv arguments, and update tests.
https://fedorahosted.org/freeipa/ticket/2417
https://fedorahosted.org/freeipa/ticket/2227
2012-02-23 06:29:47 -06:00
|
|
|
dict(privilege=privilege1)
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
completed=0,
|
|
|
|
failed=dict(
|
|
|
|
member=dict(
|
|
|
|
privilege=[(u'%s' % privilege1, u'This entry is not a member'),],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
result={
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role1],
|
|
|
|
'description': [u'New desc 1'],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % role1,
|
|
|
|
command=('role_del', [role1], {}),
|
|
|
|
expected=dict(
|
2011-01-07 10:17:55 -06:00
|
|
|
result=dict(failed=u''),
|
2010-12-01 10:23:52 -06:00
|
|
|
value=role1,
|
|
|
|
summary=u'Deleted role "%s"' % role1,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to delete non-existent %r' % role1,
|
|
|
|
command=('role_del', [role1], {}),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(reason=u'%s: role not found' % role1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2012-03-27 08:27:11 -05:00
|
|
|
desc='Try to show non-existent %r' % role1,
|
|
|
|
command=('role_show', [role1], {}),
|
|
|
|
expected=errors.NotFound(reason=u'%s: role not found' % role1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to update non-existent %r' % role1,
|
|
|
|
command=('role_mod', [role1], dict(description=u'Foo')),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(reason=u'%s: role not found' % role1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r' % search,
|
|
|
|
command=('role_find', [search], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 role matched',
|
|
|
|
result=[
|
|
|
|
{
|
2011-08-09 20:21:56 -05:00
|
|
|
'dn': lambda x: DN(x) == role2_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [role2],
|
|
|
|
'description': [u'role desc 2'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % role2,
|
|
|
|
command=('role_del', [role2], {}),
|
|
|
|
expected=dict(
|
2011-01-07 10:17:55 -06:00
|
|
|
result=dict(failed=u''),
|
2010-12-01 10:23:52 -06:00
|
|
|
value=role2,
|
|
|
|
summary=u'Deleted role "%s"' % role2,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r' % search,
|
|
|
|
command=('role_find', [search], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 roles matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|