ldapcherry/tests/test_BackendLdap.py

75 lines
1.9 KiB
Python
Raw Normal View History

2015-05-21 08:33:56 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import with_statement
from __future__ import unicode_literals
import pytest
import sys
from sets import Set
2015-05-21 08:54:28 +02:00
from ldapcherry.backend.backendLdap import Backend
from ldapcherry import syslog_error
2015-05-21 08:33:56 +02:00
from ldapcherry.exceptions import *
import cherrypy
cfg = {
'module' : 'ldapcherry.backend.ldap',
'groupdn' : 'ou=group,dc=example,dc=com',
'people' : 'ou=group,dc=example,dc=com',
'binddn' : 'cn=ldapcherry,dc=example,dc=com',
2015-05-21 08:33:56 +02:00
'password' : 'password',
'uri' : 'ldaps://ldap.ldapcherry.org',
'ca' : '/etc/dnscherry/TEST-cacert.pem',
'starttls' : 'off',
2015-05-21 08:33:56 +02:00
'checkcert' : 'off',
'user_filter_tmpl' : '(uid=%(username)s)',
'group_filter_tmpl' : '(member=%(userdn)s)',
2015-05-21 08:33:56 +02:00
}
cherrypy.log.error = syslog_error
2015-05-21 08:33:56 +02:00
class TestError(object):
def testNominal(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
return True
def testConnect(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:54:28 +02:00
inv._connect()
2015-05-21 08:33:56 +02:00
return True
def testConnectSSL(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
return True
def testConnectSSLNoCheck(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
return True
def testAuthSuccess(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
return True
def testAuthSuccess(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
return True
def testAuthFailure(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
return True
def testMissingParam(self):
cfg2 = {}
return True
try:
inv = Backend(cfg2, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
except MissingKey:
return
else:
raise AssertionError("expected an exception")
def testGetUser(self):
inv = Backend(cfg, cherrypy.log, 'ldap')
2015-05-21 08:33:56 +02:00
return True