Beispiel #1
0
 def test_token_check(self):
     token = yield User.update_token(self.user_id)
     voucher = User.encrypt_by_token(token, "here is salt")
     true_result = yield User.check_token(
         self.user_id, "here is salt", voucher)
     assert true_result is not False
     false_result = yield User.check_token(
         self.user_id, "here is fake salt", voucher)
     assert false_result is False
     false_result = yield User.check_token(
         self.user_id, "here is salt", "here is a fake voucher")
     assert false_result is False
     false_result = yield User.check_token(
         self.user_id, None, "here is a fake voucher")
     assert false_result is False
     false_result = yield User.check_token(
         "0123456789ab0123456789ab", "here is salt", "here is a fake voucher")
     assert false_result is False
Beispiel #2
0
 def test_token_from_wrong_id(self):
     token = yield User.update_token("0123456789ab0123456789ab")
     assert token is None
Beispiel #3
0
 def test_user_token(self):
     token = yield User.update_token(self.user_id)
     assert token is not None