1
0
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:
kakwa 2015-06-18 10:04:20 +02:00
parent af5fd8eeae
commit 01de849204
2 changed files with 11 additions and 5 deletions

View File

@ -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"""

View File

@ -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']