permission-find no longer crashes with --targetgroup

Target Group parameter was not processed correctly which caused
permission-find to always crash when this search parameter was used.
Fix the crash and create a unit test case to avoid future regression.

https://fedorahosted.org/freeipa/ticket/3335
This commit is contained in:
Martin Kosek 2013-01-10 12:13:39 +01:00
parent 746181a88d
commit cb7e93bb91
2 changed files with 26 additions and 2 deletions

View File

@ -815,8 +815,9 @@ class aci_find(crud.Search):
found = False
if 'target' in a.target:
target = a.target['target']['expression']
if api.env.container_group in target:
targetdn = DN(target.replace('ldap:///',''))
targetdn = DN(target.replace('ldap:///',''))
group_container_dn = DN(api.env.container_group, api.env.basedn)
if targetdn.endswith(group_container_dn):
try:
cn = targetdn[0]['cn']
except (IndexError, KeyError):

View File

@ -697,6 +697,29 @@ class test_permission(Declarative):
),
dict(
desc='Search using --targetgroup',
command=('permission_find', [], {'targetgroup': u'ipausers'}),
expected=dict(
count=1,
truncated=False,
summary=u'1 permission matched',
result=[
{
'dn': DN(('cn','Add user to default group'),
api.env.container_permission, api.env.basedn),
'cn': [u'Add user to default group'],
'member_privilege': [u'User Administrators'],
'attrs': [u'member'],
'targetgroup': u'ipausers',
'memberindirect_role': [u'User Administrator'],
'permissions': [u'write']
}
],
),
),
dict(
desc='Delete %r' % permission1_renamed_ucase,
command=('permission_del', [permission1_renamed_ucase], {}),