mirror of
https://github.com/kakwa/ldapcherry
synced 2024-12-22 12:50:18 +01:00
force the groups in flatten roles to be sorted
* sorting the groups helps debuggability and also permits testing that doesn't rely on python ordering (which is different between 2 and 3).
This commit is contained in:
parent
baa3430e63
commit
05aace0e9d
@ -58,6 +58,7 @@ class Roles:
|
||||
ret[b].add(group)
|
||||
for b in ret:
|
||||
ret[b] = list(ret[b])
|
||||
ret[b].sort()
|
||||
return ret
|
||||
|
||||
def _flatten(self, roles=None, groups=None):
|
||||
|
@ -79,7 +79,50 @@ class TestError(object):
|
||||
|
||||
def testNested(self):
|
||||
inv = Roles('./tests/cfg/nested.yml')
|
||||
expected = {'developpers': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=developpers,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Developpers', 'description': 'description'}, 'admin-lv3': {'backends_groups': {'ad': ['Domain Users', 'Administrators', 'Domain Controllers'], 'ldap': ['cn=nagios admins,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com', 'cn=puppet admins,ou=group,dc=example,dc=com', 'cn=dns admins,ou=group,dc=example,dc=com']}, 'display_name': 'Administrators Level 3', 'description': 'description'}, 'admin-lv2': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=nagios admins,ou=group,dc=example,dc=com', 'cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Administrators Level 2', 'description': 'description', 'LC_admins': True}, 'users': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Simple Users', 'description': 'description'}}
|
||||
expected = {
|
||||
'admin-lv2': {
|
||||
'LC_admins': True,
|
||||
'backends_groups': {
|
||||
'ad': ['Domain Users'],
|
||||
'ldap': ['cn=nagios '
|
||||
'admins,ou=group,dc=example,dc=com',
|
||||
'cn=users,ou=group,dc=example,dc=com']
|
||||
},
|
||||
'description': 'description',
|
||||
'display_name': 'Administrators Level 2'
|
||||
},
|
||||
'admin-lv3': {
|
||||
'backends_groups': {
|
||||
'ad': ['Administrators',
|
||||
'Domain Controllers',
|
||||
'Domain Users'],
|
||||
'ldap': ['cn=dns '
|
||||
'admins,ou=group,dc=example,dc=com',
|
||||
'cn=nagios '
|
||||
'admins,ou=group,dc=example,dc=com',
|
||||
'cn=puppet '
|
||||
'admins,ou=group,dc=example,dc=com',
|
||||
'cn=users,ou=group,dc=example,dc=com']
|
||||
},
|
||||
'description': 'description',
|
||||
'display_name': 'Administrators Level 3'
|
||||
},
|
||||
'developpers': {
|
||||
'backends_groups': {
|
||||
'ad': ['Domain Users'],
|
||||
'ldap': ['cn=developpers,ou=group,dc=example,dc=com',
|
||||
'cn=users,ou=group,dc=example,dc=com']},
|
||||
'description': 'description',
|
||||
'display_name': 'Developpers'
|
||||
},
|
||||
'users': {
|
||||
'backends_groups': {
|
||||
'ad': ['Domain Users'],
|
||||
'ldap': ['cn=users,ou=group,dc=example,dc=com']},
|
||||
'description': 'description',
|
||||
'display_name': 'Simple Users'
|
||||
}
|
||||
}
|
||||
assert expected == inv.flatten
|
||||
|
||||
def testGetGroupMissingRole(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user