mirror of
https://github.com/kakwa/ldapcherry
synced 2024-12-22 21:00:04 +01:00
adding test cases and reworking test env
This commit is contained in:
parent
1fe95799a3
commit
2d1fdfe1da
@ -8,7 +8,7 @@ before_install:
|
||||
- sudo /sbin/ifconfig
|
||||
- sudo apt-get update -qq
|
||||
- sudo rm /etc/dpkg/dpkg.cfg.d/multiarch
|
||||
- sudo ./tests/cfg/deploy.sh
|
||||
- sudo ./tests/test_env/deploy.sh
|
||||
|
||||
language: python
|
||||
python:
|
||||
|
48
tests/cfg/roles.yml
Normal file
48
tests/cfg/roles.yml
Normal file
@ -0,0 +1,48 @@
|
||||
admin-lv3:
|
||||
display_name: Administrators Level 3
|
||||
LC_admins: True
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- 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
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
- Administrators
|
||||
- Domain Controllers
|
||||
|
||||
admin-lv2:
|
||||
display_name: Administrators Level 2
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
|
||||
developpers:
|
||||
diplay_name: Developpers
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=nagios user,ou=group,dc=example,dc=com
|
||||
- cn=developpers,ou=group,dc=example,dc=com
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
|
||||
users:
|
||||
diplay_name: Simple Users
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
20
tests/cfg/roles_content_dump.yml
Normal file
20
tests/cfg/roles_content_dump.yml
Normal file
@ -0,0 +1,20 @@
|
||||
users2:
|
||||
diplay_name: Simple Users2
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
|
||||
users:
|
||||
diplay_name: Simple Users
|
||||
LC_admins: True
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
26
tests/cfg/roles_key_dump.yml
Normal file
26
tests/cfg/roles_key_dump.yml
Normal file
@ -0,0 +1,26 @@
|
||||
admin-lv2:
|
||||
display_name: Administrators Level 3
|
||||
LC_admins: True
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- 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
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
- Administrators
|
||||
- Domain Controllers
|
||||
|
||||
admin-lv2:
|
||||
display_name: Administrators Level 2
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
47
tests/cfg/roles_missing_diplay_name.yml
Normal file
47
tests/cfg/roles_missing_diplay_name.yml
Normal file
@ -0,0 +1,47 @@
|
||||
admin-lv3:
|
||||
display_name: Administrators Level 3
|
||||
LC_admins: True
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- 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
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
- Administrators
|
||||
- Domain Controllers
|
||||
|
||||
admin-lv2:
|
||||
display_name: Administrators Level 2
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=nagios admins,ou=group,dc=example,dc=com
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
|
||||
developpers:
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=nagios user,ou=group,dc=example,dc=com
|
||||
- cn=developpers,ou=group,dc=example,dc=com
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
||||
|
||||
users:
|
||||
diplay_name: Simple Users
|
||||
backends:
|
||||
- backend_name: ldap
|
||||
groups:
|
||||
- cn=users,ou=group,dc=example,dc=com
|
||||
- backend_name: ad
|
||||
groups:
|
||||
- Domain Users
|
43
tests/test_Roles.py
Normal file
43
tests/test_Roles.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import with_statement
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
from ldapcherry.roles import Roles
|
||||
from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError
|
||||
|
||||
|
||||
class TestError(object):
|
||||
|
||||
def testNominal(self):
|
||||
inv = Roles('./tests/cfg/roles.yml')
|
||||
print inv.roles
|
||||
return True
|
||||
|
||||
def testMissingDisplayName(self):
|
||||
try:
|
||||
inv = Roles('./cfg/roles_missing_diplay_name.yml')
|
||||
except MissingKey:
|
||||
return
|
||||
else:
|
||||
raise AssertionError("expected an exception")
|
||||
|
||||
def testRoleKeyDuplication(self):
|
||||
try:
|
||||
inv = Roles('./tests/cfg/roles_key_dup.yml')
|
||||
except DumplicateRoleKey:
|
||||
return
|
||||
else:
|
||||
raise AssertionError("expected an exception")
|
||||
|
||||
def testRoleContentDuplication(self):
|
||||
try:
|
||||
inv = Roles('./tests/cfg/roles_content_dump.yml')
|
||||
except DumplicateRoleContent:
|
||||
return
|
||||
else:
|
||||
raise AssertionError("expected an exception")
|
||||
|
Loading…
x
Reference in New Issue
Block a user