Display the value of memberOf ACIs in permission plugin.

There were two problems:

1. memberof wasn't in the list of things we looked for in the return value
   from aci_show()
2. The value wasn't being translated into a group name.

Use the DN class to retrieve the group name from the memberof URI.

Note that I changed the parsing for targetgroup as well. We now save a lookup
and potentially returning a NotFound if an aci points to a group that no
longer exists.

https://fedorahosted.org/freeipa/ticket/2100
This commit is contained in:
Rob Crittenden
2011-12-06 18:15:41 -05:00
parent de0444defe
commit 64ee2464e8
3 changed files with 70 additions and 7 deletions

View File

@@ -290,7 +290,7 @@ class test_permission(Declarative):
dict(
desc='Update %r' % permission1,
command=(
'permission_mod', [permission1], dict(permissions=u'read')
'permission_mod', [permission1], dict(permissions=u'read', memberof=u'ipausers')
),
expected=dict(
value=permission1,
@@ -301,6 +301,7 @@ class test_permission(Declarative):
member_privilege=[privilege1],
type=u'user',
permissions=[u'read'],
memberof=u'ipausers',
),
),
),
@@ -318,6 +319,7 @@ class test_permission(Declarative):
'member_privilege': [privilege1],
'type': u'user',
'permissions': [u'read'],
'memberof': u'ipausers',
},
),
),
@@ -347,6 +349,7 @@ class test_permission(Declarative):
'member_privilege': [privilege1],
'type': u'user',
'permissions': [u'read'],
'memberof': u'ipausers',
},
),
),
@@ -368,6 +371,7 @@ class test_permission(Declarative):
'member_privilege': [privilege1],
'type': u'user',
'permissions': [u'all'],
'memberof': u'ipausers',
},
),
),
@@ -438,4 +442,60 @@ class test_permission(Declarative):
)
),
dict(
desc='Create memberof permission %r' % permission1,
command=(
'permission_add', [permission1], dict(
memberof=u'editors',
permissions=u'write',
)
),
expected=dict(
value=permission1,
summary=u'Added permission "%s"' % permission1,
result=dict(
dn=lambda x: DN(x) == permission1_dn,
cn=[permission1],
objectclass=objectclasses.permission,
memberof=u'editors',
permissions=[u'write'],
),
),
),
dict(
desc='Delete %r' % permission1,
command=('permission_del', [permission1], {}),
expected=dict(
result=dict(failed=u''),
value=permission1,
summary=u'Deleted permission "%s"' % permission1,
)
),
dict(
desc='Create targetgroup permission %r' % permission1,
command=(
'permission_add', [permission1], dict(
targetgroup=u'editors',
permissions=u'write',
)
),
expected=dict(
value=permission1,
summary=u'Added permission "%s"' % permission1,
result=dict(
dn=lambda x: DN(x) == permission1_dn,
cn=[permission1],
objectclass=objectclasses.permission,
targetgroup=u'editors',
permissions=[u'write'],
),
),
),
]