Example #1
0
 def test_starttls(self):
     session = pyldap_orm.LDAPSession(backend='ldap://localhost:9389',
                                      cacertdir=None,
                                      mode=pyldap_orm.LDAPSession.STARTTLS)
     session.authenticate(
         'cn=ldapmanager,ou=Services,ou=People,dc=example,dc=com',
         'password')
Example #2
0
 def test_whoami(self):
     session = pyldap_orm.LDAPSession(backend='ldap://localhost:9389')
     session.authenticate(
         'cn=ldapmanager,ou=Services,ou=People,dc=example,dc=com',
         'password')
     assert session.whoami(
     ) == 'cn=ldapmanager,ou=Services,ou=People,dc=example,dc=com'
Example #3
0
 def test_no_cert(self):
     cwd = os.path.dirname(os.path.realpath(__file__))
     with pytest.raises(pyldap_orm.exceptions.LDAPSessionException):
         pyldap_orm.LDAPSession(backend='ldap://localhost:9389',
                                cacertdir=None,
                                cert='/dev/null',
                                key='{}/extra/tls/client.pem'.format(cwd),
                                mode=pyldap_orm.LDAPSession.STARTTLS)
Example #4
0
 def test_sasl_external(self):
     cwd = os.path.dirname(os.path.realpath(__file__))
     session = pyldap_orm.LDAPSession(
         backend='ldaps://localhost:9636',
         cacertdir=None,
         cert='{}/extra/tls/client.pem'.format(cwd),
         key='{}/extra/tls/client.pem'.format(cwd))
     session.authenticate(mode=pyldap_orm.LDAPSession.AUTH_SASL_EXTERNAL)
     assert session.whoami(
     ) == 'cn=Bruno Bonfils,ou=Employees,ou=People,dc=example,dc=com'
Example #5
0
 def setup_class(self):
     self.session = pyldap_orm.LDAPSession(backend='ldap://localhost:9389')
     self.session.authenticate(
         'cn=ldapmanager,ou=Services,ou=People,dc=example,dc=com',
         'password')
Example #6
0
 def test_sasl_external_wo_cert(self):
     with pytest.raises(pyldap_orm.exceptions.LDAPSessionException):
         session = pyldap_orm.LDAPSession(backend='ldaps://localhost:9636',
                                          cacertdir=None)
         session.authenticate(
             mode=pyldap_orm.LDAPSession.AUTH_SASL_EXTERNAL)
Example #7
0
 def test_ldaps(self):
     session = pyldap_orm.LDAPSession(backend='ldaps://localhost:9636',
                                      cacertdir=None)
     session.authenticate(
         'cn=ldapmanager,ou=Services,ou=People,dc=example,dc=com',
         'password')
Example #8
0
 def test_server_down(self):
     with pytest.raises(ldap.SERVER_DOWN):
         session = pyldap_orm.LDAPSession(backend='ldap://localhost:1')
         session.authenticate()
Example #9
0
 def test_failure_authentication(self):
     session = pyldap_orm.LDAPSession(backend='ldap://localhost:9389')
     with pytest.raises(ldap.INVALID_CREDENTIALS):
         session.authenticate(
             'cn=ldapmanager,ou=Services,ou=People,dc=example,dc=com',
             'invalid')