예제 #1
0
 def test_empty_config(self):
     """
     At least a connection_url is required in the ldap config.
     Without it no connection can be initialized.
     """
     with cc_ldap.LDAPConnection({}, None, None) as connection:
         self.assertIsNone(connection)
예제 #2
0
 def test_ldap_conn_context_anonym_no_pass_bind(self):
     """
     Username and credentials are missing from the ldap config
     but username is provided at context initialization.
     """
     ldap_config = {"connection_url": "ldap://localhost/"}
     with cc_ldap.LDAPConnection(ldap_config,
                                 'cn=service_user,ou=example,o=test',
                                 '') as connection:
         self.assertIsNone(connection)
예제 #3
0
    def test_ldap_conn_context_bind_with_cred(self):
        """
        Bind to LDAP server with username and credentials.
        """
        ldap_config = {"connection_url": "ldap://localhost/"}

        with cc_ldap.LDAPConnection(ldap_config,
                                    'cn=service_user,ou=example,o=test',
                                    'servicepw') as connection:
            self.assertIsNotNone(connection)
예제 #4
0
    def test_get_user_dn(self):
        """
        Search for the full user DN.
        """
        ldap_config = {"connection_url": "ldap://localhost/"}
        with cc_ldap.LDAPConnection(ldap_config,
                                    'cn=service_user,ou=example,o=test') \
                as connection:
            self.assertIsNotNone(connection)

            ret = cc_ldap.get_user_dn(connection, 'ou=other,o=test',
                                      '(cn=user2)')

            self.assertEqual(ret, 'cn=user2,ou=other,o=test')
예제 #5
0
 def test_anonymous_bind(self):
     """
     Anonymous bind, without username and credentials.
     """
     with cc_ldap.LDAPConnection(self.ldap_config) as connection:
         self.assertIsNotNone(connection)