def _check_username_password_local(username, password=None): """ Check a username and password against the local database. Return None if the username and password are not valid @type username: str @param username: the login of the user @type password: str or None @param password: password of the user, None => do not validate the password @rtype: L{pulp.server.db.model.User} instance or None @return: user corresponding to the credentials """ user = _user_manager.find_by_login(username) if user is None: _log.error('User [%s] specified in certificate was not found in the system' % username) return None if user['password'] is None and password is not None: _log.error('This is an ldap user %s' % user) return None if password is not None: if not check_password(user['password'], password): _log.error('Password for user [%s] was incorrect' % username) return None return user
def test_check_password(self): password = "******" hashed = hash_password(password) self.assertTrue(check_password(hashed, password))