def test_wrong_pwd(self): """ Wrong password is provided, authentication should fail. """ self.assertFalse(cc_ldap.auth_user(self.ldap_config, 'user2', 'wrong_password'))
def test_successful_auth(self): """ Successful user authentication. """ self.assertTrue(cc_ldap.auth_user(self.ldap_config, 'user2', 'user2pw'))
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
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
def test_empty_pwd(self): """ Try to authenticate with empty password. """ self.assertFalse(cc_ldap.auth_user(self.ldap_config, 'user2', ''))
def test_missing_pwd(self): """ Password is missing when auth_user function is called. """ self.assertFalse(cc_ldap.auth_user(self.ldap_config, 'user2'))