Skip to content

Commit

Permalink
Merge pull request #1 from kakwa/garbage
Browse files Browse the repository at this point in the history
Garbage
  • Loading branch information
kakwa committed Jun 17, 2015
2 parents 9dd9a98 + a8f1b7b commit af5fd8e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/cfg/ldapcherry.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ldap.groupdn = 'ou=groups,dc=example,dc=org'
ldap.userdn = 'ou=people,dc=example,dc=org'
ldap.binddn = 'cn=dnscherry,dc=example,dc=org'
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.starttls = 'off'
ldap.checkcert = 'off'
Expand Down
8 changes: 8 additions & 0 deletions tests/disable.py
Original file line number Diff line number Diff line change
@@ -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
37 changes: 27 additions & 10 deletions tests/test_BackendLdap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from sets import Set
from ldapcherry.backend.backendLdap import Backend, DelUserDontExists
from ldapcherry.exceptions import *
from disable import travis_disabled
import cherrypy
import logging
import ldap
Expand All @@ -20,7 +21,7 @@
'binddn' : 'cn=dnscherry,dc=example,dc=org',
'password' : 'password',
'uri' : 'ldap://ldap.dnscherry.org:390',
'ca' : './tests/test_env/etc/ldapcherry/TEST-cacert.pem',
'ca' : './test/cfg/ca.crt',
'starttls' : 'off',
'checkcert' : 'off',
'user_filter_tmpl' : '(uid=%(username)s)',
Expand All @@ -45,20 +46,22 @@ def testNominal(self):
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
return True

# def testConnectSSLNoCheck(self):
# cfg2 = cfg.copy()
# cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
# cfg2['checkcert'] = 'off'
# inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
# ldap = inv._connect()
# ldap.simple_bind_s(inv.binddn, inv.bindpassword)
@travis_disabled
def testConnectSSLNoCheck(self):
cfg2 = cfg.copy()
cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
cfg2['checkcert'] = 'off'
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
ldap = inv._connect()
ldap.simple_bind_s(inv.binddn, inv.bindpassword)

def testConnect(self):
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
ldap = inv._connect()
ldap.simple_bind_s(inv.binddn, inv.bindpassword)
return True

@travis_disabled
def testConnectSSL(self):
cfg2 = cfg.copy()
cfg2['uri'] = 'ldaps://ldap.dnscherry.org:637'
Expand All @@ -71,7 +74,6 @@ def testLdapUnavaible(self):
cfg2 = cfg.copy()
cfg2['uri'] = 'ldaps://notaldap:637'
cfg2['checkcert'] = 'on'
cfg2['ca'] = './cfg/ca.crt'
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
ldapc = inv._connect()
try:
Expand All @@ -81,11 +83,26 @@ def testLdapUnavaible(self):
else:
raise AssertionError("expected an exception")

@travis_disabled
def testConnectSSLWrongCA(self):
cfg2 = cfg.copy()
cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
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')
ldapc = inv._connect()
try:
Expand Down

0 comments on commit af5fd8e

Please sign in to comment.