mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-25 10:44:30 +01:00
fix unit test and fix the way ldap connexion options are handled
This commit is contained in:
parent
68a3dad2d7
commit
c2288eecf5
@ -61,17 +61,17 @@ class Backend(ldapcherry.backend.Backend):
|
|||||||
ldap_client.set_option(ldap.OPT_REFERRALS, 0)
|
ldap_client.set_option(ldap.OPT_REFERRALS, 0)
|
||||||
ldap_client.set_option(ldap.OPT_TIMEOUT, self.timeout)
|
ldap_client.set_option(ldap.OPT_TIMEOUT, self.timeout)
|
||||||
if self.starttls == 'on':
|
if self.starttls == 'on':
|
||||||
ldap.set_option(ldap.OPT_X_TLS_DEMAND, True)
|
ldap_client.set_option(ldap.OPT_X_TLS_DEMAND, True)
|
||||||
else:
|
else:
|
||||||
ldap.set_option(ldap.OPT_X_TLS_DEMAND, False)
|
ldap_client.set_option(ldap.OPT_X_TLS_DEMAND, False)
|
||||||
if self.ca and self.checkcert == 'on':
|
if self.ca and self.checkcert == 'on':
|
||||||
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, self.ca)
|
ldap_client.set_option(ldap.OPT_X_TLS_CACERTFILE, self.ca)
|
||||||
#else:
|
#else:
|
||||||
# ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, '')
|
# ldap_client.set_option(ldap.OPT_X_TLS_CACERTFILE, '')
|
||||||
if self.checkcert == 'off':
|
if self.checkcert == 'off':
|
||||||
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
|
ldap_client.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)
|
||||||
else:
|
else:
|
||||||
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND)
|
ldap_client.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND)
|
||||||
if self.starttls == 'on':
|
if self.starttls == 'on':
|
||||||
try:
|
try:
|
||||||
ldap_client.start_tls_s()
|
ldap_client.start_tls_s()
|
||||||
|
@ -44,13 +44,13 @@ 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):
|
def testConnectSSLNoCheck(self):
|
||||||
# cfg2 = cfg.copy()
|
cfg2 = cfg.copy()
|
||||||
# cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
|
cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
|
||||||
# cfg2['checkcert'] = 'off'
|
cfg2['checkcert'] = 'off'
|
||||||
# inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
# ldap = inv._connect()
|
ldap = inv._connect()
|
||||||
# ldap.simple_bind_s(inv.binddn, inv.bindpassword)
|
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')
|
||||||
@ -60,7 +60,7 @@ class TestError(object):
|
|||||||
|
|
||||||
def testConnectSSL(self):
|
def testConnectSSL(self):
|
||||||
cfg2 = cfg.copy()
|
cfg2 = cfg.copy()
|
||||||
cfg2['uri'] = 'ldaps://ldap.ldapcherry.org:637'
|
cfg2['uri'] = 'ldaps://ldap.dnscherry.org:637'
|
||||||
cfg2['checkcert'] = 'on'
|
cfg2['checkcert'] = 'on'
|
||||||
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
inv = Backend(cfg2, cherrypy.log, 'ldap', attr, 'uid')
|
||||||
ldap = inv._connect()
|
ldap = inv._connect()
|
||||||
|
Loading…
Reference in New Issue
Block a user