1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-12-25 14:20:04 +01:00

adding unit tests

This commit is contained in:
kakwa 2015-06-05 01:01:35 +02:00
parent 46470a0924
commit 30cfd248f7
2 changed files with 31 additions and 0 deletions

26
tests/cfg/nested.yml Normal file
View File

@ -0,0 +1,26 @@
users:
backends_groups:
ad: [Domain Users]
ldap: ['cn=users,ou=group,dc=example,dc=com']
display_name: Simple Users
subroles:
admin-lv2:
LC_admins: true
backends_groups:
ad: [Domain Users]
ldap: ['cn=nagios admins,ou=group,dc=example,dc=com']
display_name: Administrators Level 2
subroles:
admin-lv3:
backends_groups:
ad: [Domain Users, Administrators, Domain Controllers]
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',]
display_name: Administrators Level 3
subroles: {}
developpers:
backends_groups:
ad: [Domain Users]
ldap: ['cn=developpers,ou=group,dc=example,dc=com']
display_name: Developpers
subroles: {}

View File

@ -67,6 +67,11 @@ class TestError(object):
}
assert res == expected
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'}, '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'}, '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', 'LC_admins': True}, 'users': {'backends_groups': {'ad': ['Domain Users'], 'ldap': ['cn=users,ou=group,dc=example,dc=com']}, 'display_name': 'Simple Users'}}
assert expected == inv.flatten
def testGetGroupMissingRole(self):
inv = Roles('./tests/cfg/roles.yml')
try: