Exemple #1
0
 def test_wrong_pwd(self):
     """
     Wrong password is provided, authentication should fail.
     """
     self.assertFalse(cc_ldap.auth_user(self.ldap_config,
                                        'user2',
                                        'wrong_password'))
Exemple #2
0
 def test_successful_auth(self):
     """
     Successful user authentication.
     """
     self.assertTrue(cc_ldap.auth_user(self.ldap_config,
                                       'user2',
                                       'user2pw'))
Exemple #3
0
    def __try_auth_ldap(self, auth_string):
        """
        Try to authenticate user to all the configured authorities.
        """
        if self.__is_method_enabled("ldap"):
            username, password = auth_string.split(":")

            ldap_authorities = self.__auth_config["method_ldap"] \
                .get("authorities")
            for ldap_conf in ldap_authorities:
                if cc_ldap.auth_user(ldap_conf, username, password):
                    return True
        return False
Exemple #4
0
    def __try_auth_ldap(self, auth_string):
        """
        Try to authenticate user to all the configured authorities.
        """
        if self.__is_method_enabled('ldap'):
            username, password = auth_string.split(':')

            ldap_authorities = self.__auth_config['method_ldap'] \
                .get('authorities')
            for ldap_conf in ldap_authorities:
                if cc_ldap.auth_user(ldap_conf, username, password):
                    groups = cc_ldap.get_groups(ldap_conf, username, password)
                    return {'username': username, 'groups': groups}

        return False
Exemple #5
0
 def test_empty_pwd(self):
     """
     Try to authenticate with empty password.
     """
     self.assertFalse(cc_ldap.auth_user(self.ldap_config, 'user2', ''))
Exemple #6
0
 def test_missing_pwd(self):
     """
     Password is missing when auth_user function is called.
     """
     self.assertFalse(cc_ldap.auth_user(self.ldap_config, 'user2'))