1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 01:14:21 +01:00

code multi-backends setups tests + new unit test

* add a ldap+ad setup and code for direct, only AD manipulation
* add unit test for _deleteuser if it doesn't exist in all backends
This commit is contained in:
kakwa 2016-07-31 10:10:51 +02:00
parent fec09b1543
commit 01aaf476c1

View File

@ -13,6 +13,7 @@ from sets import Set
from ldapcherry import LdapCherry from ldapcherry import LdapCherry
from ldapcherry.exceptions import * from ldapcherry.exceptions import *
from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError
import ldapcherry.backend.backendAD
import cherrypy import cherrypy
from cherrypy.process import plugins, servers from cherrypy.process import plugins, servers
from cherrypy import Application from cherrypy import Application
@ -23,6 +24,27 @@ import json
cherrypy.session = {} cherrypy.session = {}
adcfg = {
'display_name': u'test☭',
'domain': 'DC.LDAPCHERRY.ORG',
'login': 'Administrator',
'password': 'qwertyP455',
'uri': 'ldaps://ad.ldapcherry.org',
'checkcert': 'off',
}
adattr = ['shell', 'cn', 'sAMAccountName', 'uidNumber', 'gidNumber', 'home', 'unicodePwd', 'givenName', 'email', 'sn']
addefault_user = {
'sAMAccountName': u'☭default_user',
'sn': u'test☭1',
'cn': u'test☭2',
'unicodePwd': u'test☭P666',
'uidNumber': '42',
'gidNumber': '42',
'homeDirectory': '/home/test/'
}
# monkey patching cherrypy to disable config interpolation # monkey patching cherrypy to disable config interpolation
def new_as_dict(self, raw=True, vars=None): def new_as_dict(self, raw=True, vars=None):
"""Convert an INI file to a dictionary""" """Convert an INI file to a dictionary"""
@ -287,6 +309,14 @@ class TestError(object):
app._deleteuser('test') app._deleteuser('test')
htmlvalidator(page[0]) htmlvalidator(page[0])
@travis_disabled
def testDeleteUserOneBackend(self):
app = LdapCherry()
loadconf('./tests/cfg/ldapcherry_adldap.cfg', app)
inv = ldapcherry.backend.backendAD.Backend(adcfg, cherrypy.log, u'test☭', adattr, 'sAMAccountName')
inv.add_user(addefault_user.copy())
app._deleteuser(u'☭default_user')
def testLogger(self): def testLogger(self):
app = LdapCherry() app = LdapCherry()
loadconf('./tests/cfg/ldapcherry.ini', app) loadconf('./tests/cfg/ldapcherry.ini', app)