Пример #1
0
 def test_auth_token_generation(self):
     wrong_email_data = dict(email='*****@*****.**', password='******')
     wrong_pass_data = dict(email='*****@*****.**', password='******')
     correct_data = dict(email='*****@*****.**', password='******')
     with self.assertRaises(NotFound):
         User.generate_auth_token(**wrong_email_data)
     with self.assertRaises(BadRequest):
         User.generate_auth_token(**wrong_pass_data)
     self.assertTrue(User.generate_auth_token(**correct_data))
Пример #2
0
 def test_verify_auth_token(self):
     correct_data = dict(email='*****@*****.**', password='******')
     token = User.generate_auth_token(**correct_data)
     self.assertEqual(self.user, User.verify_auth_token(token))
     with self.assertRaises(BadSignature):
         User.verify_auth_token(token[:-5])