def test_reset_password_bad_token_or_wrong_user(self, app): """reset_password returns false with a bad token or wrong user.""" user1 = User() user1.id = 42 user2 = User() user2.id = 33 token = user1.generate_password_reset_token() assert not user2.reset_password(token, 'foo') assert not user1.reset_password('badtoken', 'foo')
def test_password_reset(self, app): """Password should be reset if given a valid token and a new pass.""" user = User() user.id = 42 user.set_password('hunter2') token = user.generate_password_reset_token() newpass = '******' assert user.reset_password(token, newpass) assert user.verify_password(newpass)
def test_reset_password_with_valid_token(self, app): """reset_password returns true with a valid token.""" user = User() user.id = 42 token = user.generate_password_reset_token() assert user.reset_password(token, 'foo')