mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-25 10:44:30 +01:00
list of roles and not a uniq role for get_groups
This commit is contained in:
parent
af5fd8eeae
commit
01de849204
@ -307,11 +307,17 @@ class Roles:
|
||||
raise MissingRole(role)
|
||||
return self.flatten[role]['display_name']
|
||||
|
||||
def get_groups(self, role):
|
||||
def get_groups(self, roles):
|
||||
"""get the list of groups from role"""
|
||||
ret = {}
|
||||
for role in roles:
|
||||
if not role in self.flatten:
|
||||
raise MissingRole(role)
|
||||
return self.flatten[role]['backends_groups']
|
||||
for b in self.flatten[role]['backends_groups']:
|
||||
if b not in ret:
|
||||
ret[b] = []
|
||||
ret[b] = ret[b] + self.flatten[role]['backends_groups'][b]
|
||||
return ret
|
||||
|
||||
def is_admin(self, roles):
|
||||
"""determine from a list of roles if is ldapcherry administrator"""
|
||||
|
@ -69,7 +69,7 @@ class TestError(object):
|
||||
|
||||
def testGetGroup(self):
|
||||
inv = Roles('./tests/cfg/roles.yml')
|
||||
res = inv.get_groups('users')
|
||||
res = inv.get_groups(['users'])
|
||||
expected = {
|
||||
'ad': ['Domain Users'],
|
||||
'ldap': ['cn=users,ou=group,dc=example,dc=com']
|
||||
|
Loading…
Reference in New Issue
Block a user