Пример #1
0
 def test_valid_reset_token(self):
     """Test a user can reset their password given a valid reset token"""
     u = UserAccount(username="******",
                     email="*****@*****.**",
                     password='******')
     db.session.add(u)
     db.session.commit()
     token = u.generate_reset_token()
     self.assertTrue(u.reset_password(token, 'dog'))
     self.assertTrue(u.verify_password('dog'))
Пример #2
0
 def test_invalid_reset_token(self):
     """Test that valid reset token from one user can not reset another users password"""
     u1 = UserAccount(username="******", email="*****@*****.**", password='******')
     u2 = UserAccount(username="******",
                      email="*****@*****.**",
                      password='******')
     db.session.add(u1)
     db.session.add(u2)
     db.session.commit()
     token = u1.generate_reset_token()
     self.assertFalse(u2.reset_password(token, "horse"))
     self.assertTrue(u2.verify_password("doge"))