mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
Fix minor bugs, typos, etc. discovered by unit tests in plugins.
This commit is contained in:
parent
341a47f5a3
commit
57123f2a99
@ -238,7 +238,7 @@ class basegroup_mod(crud.Update):
|
||||
ldap = self.api.Backend.ldap2
|
||||
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container_dn
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
|
||||
entry_attrs = self.args_options_2_entry(cn, **kw)
|
||||
|
@ -277,7 +277,7 @@ class LDAPDelete(crud.Delete):
|
||||
None, [''], dn, ldap.SCOPE_ONELEVEL
|
||||
)
|
||||
except errors.NotFound:
|
||||
pass
|
||||
break
|
||||
else:
|
||||
for (dn_, entry_attrs) in subentries:
|
||||
ldap.delete_entry(dn_)
|
||||
@ -367,7 +367,7 @@ class LDAPSearch(crud.Search):
|
||||
except errors.NotFound:
|
||||
(entries, truncated) = (tuple(), False)
|
||||
|
||||
self.post_callback(self, ldap, entries, *args, **options)
|
||||
self.post_callback(self, ldap, entries, truncated, *args, **options)
|
||||
|
||||
return (entries, truncated)
|
||||
|
||||
@ -393,6 +393,6 @@ class LDAPSearch(crud.Search):
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
|
||||
return filter
|
||||
|
||||
def post_callback(self, ldap, entries, *args, **options):
|
||||
def post_callback(self, ldap, entries, truncated, *args, **options):
|
||||
pass
|
||||
|
||||
|
@ -105,14 +105,16 @@ class group_del(basegroup_del):
|
||||
:param kw: Unused
|
||||
"""
|
||||
ldap = self.api.Backend.ldap2
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
|
||||
# Don't allow the default user group to be removed
|
||||
try:
|
||||
config = ldap.get_ipa_config()[1]
|
||||
def_group_cn = config.get('ipadefaultprimarygroup')
|
||||
def_group_dn = get_dn_by_attr(
|
||||
ldap, 'cn', def_group_cn, self.filter_class, self.container
|
||||
(def_group_dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', def_group_cn, self.filter_class, [''], self.container
|
||||
)
|
||||
if dn == def_group_dn:
|
||||
raise errors.DefaultGroup()
|
||||
@ -154,8 +156,9 @@ class group_mod(basegroup_mod):
|
||||
ldap = self.api.Backend.ldap2
|
||||
|
||||
if kw['posix'] or 'gidnumber' in kw:
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.get_entry(dn, ['objectclass'])
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, ['objectclass'], self.container
|
||||
)
|
||||
if 'posixgroup' in entry_attrs['objectclass']:
|
||||
if kw['posix'] in entry_attrs['objectclass']:
|
||||
raise errors.AlreadyPosixGroup()
|
||||
@ -176,8 +179,8 @@ class group_find(basegroup_find):
|
||||
container = _container_dn
|
||||
filter_class = _default_class
|
||||
|
||||
def execute(self, cn, **kw):
|
||||
return super(group_find, self).execute(cn, **kw)
|
||||
def execute(self, term, **kw):
|
||||
return super(group_find, self).execute(term, **kw)
|
||||
|
||||
api.register(group_find)
|
||||
|
||||
|
@ -212,10 +212,10 @@ class host_del(crud.Delete):
|
||||
dn = get_host(ldap, hostname)
|
||||
|
||||
# Remove all service records for this host
|
||||
services = api.Command['service2_find'](hostname)
|
||||
(services, truncated) = api.Command['service_find'](hostname)
|
||||
for (dn, entry_attrs) in services:
|
||||
principal = entry_attrs['krbprincipalname']
|
||||
api.Command['service2_del'](principal)
|
||||
api.Command['service_del'](principal)
|
||||
|
||||
ldap.delete_entry(dn)
|
||||
|
||||
@ -298,6 +298,10 @@ class host_find(crud.Search):
|
||||
search_kw[a] = term
|
||||
term_filter = ldap.make_filter(search_kw, exact=False)
|
||||
|
||||
filter = ldap.combine_filters(
|
||||
(filter, term_filter), rules=ldap.MATCH_ALL
|
||||
)
|
||||
|
||||
if kw['all']:
|
||||
attrs_list = ['*']
|
||||
else:
|
||||
@ -310,7 +314,7 @@ class host_find(crud.Search):
|
||||
except errors.NotFound:
|
||||
(entries, truncated) = (tuple(), False)
|
||||
|
||||
return entries
|
||||
return (entries, truncated)
|
||||
|
||||
def output_for_cli(self, textui, result, term, **options):
|
||||
(entries, truncated) = result
|
||||
|
@ -80,8 +80,8 @@ class hostgroup_find(basegroup_find):
|
||||
"""
|
||||
container = _container_dn
|
||||
|
||||
def execute(self, cn, **kw):
|
||||
return super(hostgroup_find, self).execute(cn, **kw)
|
||||
def execute(self, term, **kw):
|
||||
return super(hostgroup_find, self).execute(term, **kw)
|
||||
|
||||
api.register(hostgroup_find)
|
||||
|
||||
@ -132,7 +132,9 @@ class hostgroup_add_member(basegroup_add_member):
|
||||
"""
|
||||
assert self.container
|
||||
ldap = self.api.Backend.ldap2
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
to_add = []
|
||||
add_failed = []
|
||||
completed = 0
|
||||
@ -202,7 +204,9 @@ class hostgroup_del_member(basegroup_del_member):
|
||||
"""
|
||||
assert self.container
|
||||
ldap = self.api.Backend.ldap2
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
to_remove = []
|
||||
remove_failed = []
|
||||
completed = 0
|
||||
|
@ -115,8 +115,8 @@ class netgroup_find(basegroup_find):
|
||||
container = _container_dn
|
||||
filter_class = _default_class
|
||||
|
||||
def execute(self, cn, **kw):
|
||||
return super(netgroup_find, self).execute(cn, **kw)
|
||||
def execute(self, term, **kw):
|
||||
return super(netgroup_find, self).execute(term, **kw)
|
||||
|
||||
api.register(netgroup_find)
|
||||
|
||||
@ -160,7 +160,7 @@ class netgroup_add_member(basegroup_add_member):
|
||||
|
||||
def _add_external(self, ldap, completed, members, group_dn):
|
||||
add_failed = []
|
||||
entry_attrs = ldap.get_entry(group_dn, ['externalhost'])
|
||||
(dn, entry_attrs) = ldap.get_entry(group_dn, ['externalhost'])
|
||||
external_hosts = entry_attrs.get('externalhost', [])
|
||||
|
||||
for m in members:
|
||||
@ -172,7 +172,7 @@ class netgroup_add_member(basegroup_add_member):
|
||||
add_failed.append(m)
|
||||
|
||||
try:
|
||||
ldap.update_entry(group_dn, **{'externalhost': external_hosts})
|
||||
ldap.update_entry(group_dn, {'externalhost': external_hosts})
|
||||
except errors.EmptyModlist:
|
||||
pass
|
||||
|
||||
@ -192,7 +192,9 @@ class netgroup_add_member(basegroup_add_member):
|
||||
"""
|
||||
assert self.container
|
||||
ldap = self.api.Backend.ldap2
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
to_add = []
|
||||
add_failed = []
|
||||
completed = 0
|
||||
@ -215,6 +217,7 @@ class netgroup_add_member(basegroup_add_member):
|
||||
ldap, completed, to_add, add_failed, dn, 'member'
|
||||
)
|
||||
|
||||
add_failed = []
|
||||
members = kw.get('hosts', [])
|
||||
(to_add, add_failed) = find_members(
|
||||
ldap, add_failed, members, 'cn', 'ipahost',
|
||||
@ -278,7 +281,7 @@ class netgroup_del_member(basegroup_del_member):
|
||||
|
||||
def _del_external(self, ldap, completed, members, group_dn):
|
||||
rem_failed = []
|
||||
entry_attrs = ldap.get_entry(group_dn, ['externalhost'])
|
||||
(dn, entry_attrs) = ldap.get_entry(group_dn, ['externalhost'])
|
||||
external_hosts = entry_attrs.get('externalhost', [])
|
||||
|
||||
for m in members:
|
||||
@ -290,7 +293,7 @@ class netgroup_del_member(basegroup_del_member):
|
||||
rem_failed.append(m)
|
||||
|
||||
try:
|
||||
ldap.update_entry(group_dn, **{'externalhost': external_hosts})
|
||||
ldap.update_entry(group_dn, {'externalhost': external_hosts})
|
||||
except errors.EmptyModlist:
|
||||
pass
|
||||
|
||||
@ -310,7 +313,9 @@ class netgroup_del_member(basegroup_del_member):
|
||||
"""
|
||||
assert self.container
|
||||
ldap = self.api.Backend.ldap2
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
to_rem = []
|
||||
rem_failed = []
|
||||
completed = 0
|
||||
|
@ -294,7 +294,7 @@ class service_find(crud.Search):
|
||||
except errors.NotFound:
|
||||
(entries, truncated) = (tuple(), False)
|
||||
|
||||
return entries
|
||||
return (entries, truncated)
|
||||
|
||||
def output_for_cli(self, textui, result, principal, **options):
|
||||
(entries, truncated) = result
|
||||
|
@ -107,7 +107,9 @@ class taskgroup_add_member(basegroup_add_member):
|
||||
"""
|
||||
assert self.container
|
||||
ldap = self.api.Backend.ldap2
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
to_add = []
|
||||
add_failed = []
|
||||
completed = 0
|
||||
@ -133,7 +135,7 @@ class taskgroup_add_member(basegroup_add_member):
|
||||
members = kw.get('rolegroups', [])
|
||||
(to_add, add_failed) = find_members(
|
||||
ldap, add_failed, members, 'cn', self.filter_class,
|
||||
self.api.env.container_rolegroups
|
||||
self.api.env.container_rolegroup
|
||||
)
|
||||
(completed, add_failed) = add_members(
|
||||
ldap, completed, to_add, add_failed, dn, 'member'
|
||||
@ -169,7 +171,9 @@ class taskgroup_del_member(basegroup_del_member):
|
||||
"""
|
||||
assert self.container
|
||||
ldap = self.api.Backend.ldap2
|
||||
dn = get_dn_by_attr(ldap, 'cn', cn, self.filter_class, self.container)
|
||||
(dn, entry_attrs) = ldap.find_entry_by_attr(
|
||||
'cn', cn, self.filter_class, [''], self.container
|
||||
)
|
||||
to_remove = []
|
||||
remove_failed = []
|
||||
completed = 0
|
||||
@ -195,7 +199,7 @@ class taskgroup_del_member(basegroup_del_member):
|
||||
members = kw.get('rolegroups', [])
|
||||
(to_remove, remove_failed) = find_members(
|
||||
ldap, remove_failed, members, 'cn', self.filter_class,
|
||||
self.api.env.container_rolegroups
|
||||
self.api.env.container_rolegroup
|
||||
)
|
||||
(completed, remove_failed) = del_members(
|
||||
ldap, completed, to_remove, remove_failed, dn, 'member'
|
||||
|
Loading…
Reference in New Issue
Block a user