diff --git a/ldapcherry/roles.py b/ldapcherry/roles.py index 2c38225..7726d34 100644 --- a/ldapcherry/roles.py +++ b/ldapcherry/roles.py @@ -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""" - if not role in self.flatten: - raise MissingRole(role) - return self.flatten[role]['backends_groups'] + ret = {} + for role in roles: + if not role in self.flatten: + raise MissingRole(role) + 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""" diff --git a/tests/test_Roles.py b/tests/test_Roles.py index 043551b..6489c30 100644 --- a/tests/test_Roles.py +++ b/tests/test_Roles.py @@ -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']