mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
parent
4f7f400043
commit
42c78a383d
@ -188,7 +188,6 @@ class group_mod(LDAPUpdate):
|
|||||||
"""
|
"""
|
||||||
Modify a group.
|
Modify a group.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
msg_summary = _('Modified group "%(value)s"')
|
msg_summary = _('Modified group "%(value)s"')
|
||||||
|
|
||||||
takes_options = LDAPUpdate.takes_options + (
|
takes_options = LDAPUpdate.takes_options + (
|
||||||
@ -218,11 +217,39 @@ class group_find(LDAPSearch):
|
|||||||
"""
|
"""
|
||||||
Search for groups.
|
Search for groups.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
msg_summary = ngettext(
|
msg_summary = ngettext(
|
||||||
'%(count)d group matched', '%(count)d groups matched', 0
|
'%(count)d group matched', '%(count)d groups matched', 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
takes_options = LDAPSearch.takes_options + (
|
||||||
|
Flag('private',
|
||||||
|
cli_name='private',
|
||||||
|
doc=_('search for private groups'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
|
||||||
|
# if looking for private groups, we need to create a new search filter,
|
||||||
|
# because private groups have different object classes
|
||||||
|
if options['private']:
|
||||||
|
# filter based on options, oflt
|
||||||
|
search_kw = self.args_options_2_entry(**options)
|
||||||
|
search_kw['objectclass'] = ['posixGroup', 'mepManagedEntry']
|
||||||
|
oflt = ldap.make_filter(search_kw, rules=ldap.MATCH_ALL)
|
||||||
|
|
||||||
|
# filter based on 'criteria' argument
|
||||||
|
search_kw = {}
|
||||||
|
config = ldap.get_ipa_config()[1]
|
||||||
|
attrs = config.get(self.obj.search_attributes_config, [])
|
||||||
|
if len(attrs) == 1 and isinstance(attrs[0], basestring):
|
||||||
|
search_attrs = attrs[0].split(',')
|
||||||
|
for a in search_attrs:
|
||||||
|
search_kw[a] = args[-1]
|
||||||
|
cflt = ldap.make_filter(search_kw, exact=False)
|
||||||
|
|
||||||
|
filter = ldap.combine_filters((oflt, cflt), rules=ldap.MATCH_ALL)
|
||||||
|
return filter
|
||||||
|
|
||||||
api.register(group_find)
|
api.register(group_find)
|
||||||
|
|
||||||
|
|
||||||
|
@ -571,12 +571,31 @@ class test_group(Declarative):
|
|||||||
cn=[user1],
|
cn=[user1],
|
||||||
description=[u'User private group for %s' % user1],
|
description=[u'User private group for %s' % user1],
|
||||||
gidnumber=[fuzzy_digits],
|
gidnumber=[fuzzy_digits],
|
||||||
dn=u'cn=%s,cn=groups,cn=accounts,%s' % (user1, api.env.basedn),
|
dn=u'cn=%s,cn=groups,cn=accounts,%s' % (user1, api.env.basedn),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
|
dict(
|
||||||
|
desc='Verify that managed group %r can be found' % user1,
|
||||||
|
command=('group_find', [], {'cn': user1, 'private': True}),
|
||||||
|
expected=dict(
|
||||||
|
count=1,
|
||||||
|
truncated=False,
|
||||||
|
result=[
|
||||||
|
dict(
|
||||||
|
dn=u'cn=%s,cn=groups,cn=accounts,%s' % (user1, api.env.basedn),
|
||||||
|
cn=[user1],
|
||||||
|
description=[u'User private group for %s' % user1],
|
||||||
|
gidnumber=[fuzzy_digits],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
summary=u'1 group matched',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
dict(
|
dict(
|
||||||
desc='Try to delete a managed group %r' % user1,
|
desc='Try to delete a managed group %r' % user1,
|
||||||
command=('group_del', [user1], {}),
|
command=('group_del', [user1], {}),
|
||||||
|
@ -30,6 +30,7 @@ from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid
|
|||||||
|
|
||||||
user_memberof = (u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn,)
|
user_memberof = (u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn,)
|
||||||
user1=u'tuser1'
|
user1=u'tuser1'
|
||||||
|
user2=u'tuser2'
|
||||||
|
|
||||||
invaliduser1=u'+tuser1'
|
invaliduser1=u'+tuser1'
|
||||||
invaliduser2=u'tuser1234567890123456789012345678901234567890'
|
invaliduser2=u'tuser1234567890123456789012345678901234567890'
|
||||||
@ -38,7 +39,7 @@ invaliduser2=u'tuser1234567890123456789012345678901234567890'
|
|||||||
class test_user(Declarative):
|
class test_user(Declarative):
|
||||||
|
|
||||||
cleanup_commands = [
|
cleanup_commands = [
|
||||||
('user_del', [user1], {}),
|
('user_del', [user1, user2], {}),
|
||||||
]
|
]
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
@ -67,7 +68,7 @@ class test_user(Declarative):
|
|||||||
dict(
|
dict(
|
||||||
desc='Create %r' % user1,
|
desc='Create %r' % user1,
|
||||||
command=(
|
command=(
|
||||||
'user_add', [], dict(givenname=u'Test', sn=u'User1')
|
'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
|
||||||
),
|
),
|
||||||
expected=dict(
|
expected=dict(
|
||||||
value=user1,
|
value=user1,
|
||||||
@ -92,7 +93,7 @@ class test_user(Declarative):
|
|||||||
dict(
|
dict(
|
||||||
desc='Try to create duplicate %r' % user1,
|
desc='Try to create duplicate %r' % user1,
|
||||||
command=(
|
command=(
|
||||||
'user_add', [], dict(givenname=u'Test', sn=u'User1')
|
'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
|
||||||
),
|
),
|
||||||
expected=errors.DuplicateEntry(),
|
expected=errors.DuplicateEntry(),
|
||||||
),
|
),
|
||||||
@ -317,6 +318,64 @@ class test_user(Declarative):
|
|||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
|
dict(
|
||||||
|
desc='Create %r' % user1,
|
||||||
|
command=(
|
||||||
|
'user_add', [user1], dict(givenname=u'Test', sn=u'User1')
|
||||||
|
),
|
||||||
|
expected=dict(
|
||||||
|
value=user1,
|
||||||
|
summary=u'Added user "tuser1"',
|
||||||
|
result=dict(
|
||||||
|
gecos=[user1],
|
||||||
|
givenname=[u'Test'],
|
||||||
|
homedirectory=[u'/home/tuser1'],
|
||||||
|
krbprincipalname=[u'tuser1@' + api.env.realm],
|
||||||
|
loginshell=[u'/bin/sh'],
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
dict(
|
||||||
|
desc='Create %r' % user2,
|
||||||
|
command=(
|
||||||
|
'user_add', [user2], dict(givenname=u'Test', sn=u'User2')
|
||||||
|
),
|
||||||
|
expected=dict(
|
||||||
|
value=user2,
|
||||||
|
summary=u'Added user "tuser2"',
|
||||||
|
result=dict(
|
||||||
|
gecos=[user2],
|
||||||
|
givenname=[u'Test'],
|
||||||
|
homedirectory=[u'/home/tuser2'],
|
||||||
|
krbprincipalname=[u'tuser2@' + api.env.realm],
|
||||||
|
loginshell=[u'/bin/sh'],
|
||||||
|
objectclass=objectclasses.user,
|
||||||
|
sn=[u'User2'],
|
||||||
|
uid=[user2],
|
||||||
|
uidnumber=[fuzzy_digits],
|
||||||
|
ipauniqueid=[fuzzy_uuid],
|
||||||
|
dn=u'uid=tuser2,cn=users,cn=accounts,' + api.env.basedn,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
dict(
|
||||||
|
desc='Delete %r and %r at the same time' % (user1, user2),
|
||||||
|
command=('user_del', [user1, user2], {}),
|
||||||
|
expected=dict(
|
||||||
|
result=True,
|
||||||
|
summary=u'Deleted user "tuser1,tuser2"',
|
||||||
|
value=u','.join((user1, user2)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
dict(
|
dict(
|
||||||
desc='Try to retrieve non-existent %r' % user1,
|
desc='Try to retrieve non-existent %r' % user1,
|
||||||
command=('user_show', [user1], {}),
|
command=('user_show', [user1], {}),
|
||||||
|
Loading…
Reference in New Issue
Block a user