예제 #1
0
 def testMissingParam(self):
     cfg2 = {}
     return True
     try:
         inv = Auth(cfg2, cherrypy.log)
     except MissingKey:
         return
예제 #2
0
 def testConnectSSL(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://ldap.dnscherry.org:636'
     cfg2['checkcert'] = 'on'
     inv = Auth(cfg2, cherrypy.log)
     ldap = inv._connect()
     ldap.simple_bind_s(inv.binddn, inv.bindpassword)
예제 #3
0
 def testConnectStartTLS(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldap://ldap.dnscherry.org:390'
     cfg2['checkcert'] = 'off'
     cfg2['starttls'] = 'on'
     cfg2['ca'] = './test/cfg/ca.crt'
     inv = Auth(cfg2, cherrypy.log)
     ldapc = inv._connect()
     ldapc.simple_bind_s(inv.binddn, inv.bindpassword)
예제 #4
0
 def testMissingCA(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://ldap.dnscherry.org:636'
     cfg2['checkcert'] = 'on'
     cfg2['ca'] = './test/cfg/not_a_ca.crt'
     try:
         inv = Auth(cfg2, cherrypy.log)
         ldapc = inv._connect()
     except CaFileDontExist as e:
         return
예제 #5
0
 def testLdapUnavaible(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://notaldap:636'
     cfg2['checkcert'] = 'on'
     inv = Auth(cfg2, cherrypy.log)
     try:
         ldapc = inv._connect()
         ldapc.simple_bind_s(inv.binddn, inv.bindpassword)
     except ldap.SERVER_DOWN as e:
         return
예제 #6
0
 def testConnectSSLWrongCA(self):
     cfg2 = cfg.copy()
     cfg2['uri'] = 'ldaps://ldap.dnscherry.org:636'
     cfg2['checkcert'] = 'on'
     inv = Auth(cfg2, cherrypy.log)
     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'
예제 #7
0
 def testConnect(self):
     inv = Auth(cfg, cherrypy.log)
     ldap = inv._connect()
     ldap.simple_bind_s(inv.binddn, inv.bindpassword)
     return True
예제 #8
0
 def testNominal(self):
     inv = Auth(cfg, cherrypy.log)
     return True
예제 #9
0
 def testAuthFailure(self):
     inv = Auth(cfg, cherrypy.log)
     res = inv.check_credentials('notauser',
                                 'password') or inv.check_credentials(
                                     'jwatson', 'notapassword')
     assert res == False
예제 #10
0
 def testAuthSuccess(self):
     inv = Auth(cfg, cherrypy.log)
     ret = inv.check_credentials('jwatson', 'passwordwatson')
     assert ret == True