mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
commit
af5fd8eeae
@ -71,7 +71,7 @@ ldap.groupdn = 'ou=groups,dc=example,dc=org'
|
|||||||
ldap.userdn = 'ou=people,dc=example,dc=org'
|
ldap.userdn = 'ou=people,dc=example,dc=org'
|
||||||
ldap.binddn = 'cn=dnscherry,dc=example,dc=org'
|
ldap.binddn = 'cn=dnscherry,dc=example,dc=org'
|
||||||
ldap.password = 'password'
|
ldap.password = 'password'
|
||||||
ldap.uri = 'ldap://ldap.ldapcherry.org:637'
|
ldap.uri = 'ldap://ldap.ldapcherry.org:390'
|
||||||
ldap.ca = '/etc/dnscherry/TEST-cacert.pem'
|
ldap.ca = '/etc/dnscherry/TEST-cacert.pem'
|
||||||
ldap.starttls = 'off'
|
ldap.starttls = 'off'
|
||||||
ldap.checkcert = 'off'
|
ldap.checkcert = 'off'
|
||||||
|
8
tests/disable.py
Normal file
8
tests/disable.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import os
|
||||||
|
def travis_disabled(f):
|
||||||
|
def _decorator(f):
|
||||||
|
print 'test has been disabled on travis'
|
||||||
|
if 'TRAVIS' in os.environ and os.environ['TRAVIS'] == 'yes':
|
||||||
|
return _decorator
|
||||||
|
else:
|
||||||
|
return f
|
@ -9,6 +9,7 @@ import sys
|
|||||||
from sets import Set
|
from sets import Set
|
||||||
from ldapcherry.backend.backendLdap import Backend, DelUserDontExists
|
from ldapcherry.backend.backendLdap import Backend, DelUserDontExists
|
||||||
from ldapcherry.exceptions import *
|
from ldapcherry.exceptions import *
|
||||||
|
from disable import travis_disabled
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import logging
|
import logging
|
||||||
import ldap
|
import ldap
|
||||||
@ -20,7 +21,7 @@ cfg = {
|
|||||||
'binddn' : 'cn=dnscherry,dc=example,dc=org',
|
'binddn' : 'cn=dnscherry,dc=example,dc=org',
|
||||||
'password' : 'password',
|
'password' : 'password',
|
||||||
'uri' : 'ldap://ldap.dnscherry.org:390',
|
'uri' : 'ldap://ldap.dnscherry.org:390',
|
||||||
'ca' : './tests/test_env/etc/ldapcherry/TEST-cacert.pem',
|
'ca' : './test/cfg/ca.crt',
|
||||||
'starttls' : 'off',
|
'starttls' : 'off',
|
||||||
'checkcert' : 'off',
|
'checkcert' : 'off',
|
||||||
'user_filter_tmpl' : '(uid=%(username)s)',
|
'user_filter_tmpl' : '(uid=%(username)s)',
|
||||||
@ -45,13 +46,14 @@ class TestError(object):
|
|||||||
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
|
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# def testConnectSSLNoCheck(self):
|
@travis_disabled
|
||||||
# cfg2 = cfg.copy()
|
def testConnectSSLNoCheck(self):
|
||||||
# cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
|
cfg2 = cfg.copy()
|
||||||
# cfg2['checkcert'] = 'off'
|
cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
|
||||||
# inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
cfg2['checkcert'] = 'off'
|
||||||
# ldap = inv._connect()
|
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
# ldap.simple_bind_s(inv.binddn, inv.bindpassword)
|
ldap = inv._connect()
|
||||||
|
ldap.simple_bind_s(inv.binddn, inv.bindpassword)
|
||||||
|
|
||||||
def testConnect(self):
|
def testConnect(self):
|
||||||
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
|
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
@ -59,6 +61,7 @@ class TestError(object):
|
|||||||
ldap.simple_bind_s(inv.binddn, inv.bindpassword)
|
ldap.simple_bind_s(inv.binddn, inv.bindpassword)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@travis_disabled
|
||||||
def testConnectSSL(self):
|
def testConnectSSL(self):
|
||||||
cfg2 = cfg.copy()
|
cfg2 = cfg.copy()
|
||||||
cfg2['uri'] = 'ldaps://ldap.dnscherry.org:637'
|
cfg2['uri'] = 'ldaps://ldap.dnscherry.org:637'
|
||||||
@ -71,7 +74,6 @@ class TestError(object):
|
|||||||
cfg2 = cfg.copy()
|
cfg2 = cfg.copy()
|
||||||
cfg2['uri'] = 'ldaps://notaldap:637'
|
cfg2['uri'] = 'ldaps://notaldap:637'
|
||||||
cfg2['checkcert'] = 'on'
|
cfg2['checkcert'] = 'on'
|
||||||
cfg2['ca'] = './cfg/ca.crt'
|
|
||||||
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
ldapc = inv._connect()
|
ldapc = inv._connect()
|
||||||
try:
|
try:
|
||||||
@ -81,11 +83,26 @@ class TestError(object):
|
|||||||
else:
|
else:
|
||||||
raise AssertionError("expected an exception")
|
raise AssertionError("expected an exception")
|
||||||
|
|
||||||
|
@travis_disabled
|
||||||
def testConnectSSLWrongCA(self):
|
def testConnectSSLWrongCA(self):
|
||||||
cfg2 = cfg.copy()
|
cfg2 = cfg.copy()
|
||||||
cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
|
cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
|
||||||
cfg2['checkcert'] = 'on'
|
cfg2['checkcert'] = 'on'
|
||||||
cfg2['ca'] = './cfg/wrong_ca.crt'
|
cfg2['ca'] = './test/cfg/wrong_ca.crt'
|
||||||
|
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
|
ldapc = inv._connect()
|
||||||
|
try:
|
||||||
|
ldapc.simple_bind_s(inv.binddn, inv.bindpassword)
|
||||||
|
except ldap.SERVER_DOWN as e:
|
||||||
|
assert e[0]['info'] == 'TLS: hostname does not match CN in peer certificate'
|
||||||
|
|
||||||
|
@travis_disabled
|
||||||
|
def testConnectStartTLS(self):
|
||||||
|
cfg2 = cfg.copy()
|
||||||
|
cfg2['uri'] = 'ldap://ldap.ldapcherry.org:390'
|
||||||
|
cfg2['checkcert'] = 'off'
|
||||||
|
cfg2['starttls'] = 'on'
|
||||||
|
cfg2['ca'] = './test/cfg/ca.crt'
|
||||||
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
ldapc = inv._connect()
|
ldapc = inv._connect()
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user