コード例 #1
0
    def test_nearly_expired_token(self, now_func):
        n = datetime.datetime.now()
        now_func.side_effect = [n, n + datetime.timedelta(seconds=settings.TOKEN_VALIDITY_SECONDS - 60)]

        user = User.objects.create_user('testing', email='*****@*****.**')
        token = make_token(user, self.ip)
        self.assertEqual(check_token_get_user(token, self.ip), user)
コード例 #2
0
 def test_invalid_time_stamp_token(self):
     user = User.objects.create_user('testing', email='*****@*****.**')
     token = make_token(user, self.ip)
     secs, uid, hash = token.split('-')
     new_secs = base36_to_int(secs) - 10
     new_secs = int_to_base36(new_secs)
     wrong_token = '%s-%s-%s' % (new_secs, uid, hash)
     self.assertFalse(check_token_get_user(wrong_token, self.ip))
コード例 #3
0
 def test_ip_change_token(self):
     user = User.objects.create_user('testing', email='*****@*****.**')
     token = make_token(user, self.ip)
     self.assertFalse(check_token_get_user(token, '127.0.0.2'))
コード例 #4
0
 def test_invalid_base64_token(self):
     user = User.objects.create_user('testing', email='*****@*****.**')
     token = make_token(user, self.ip)
     secs, uid, hash = token.split('-')
     wrong_token = '%s-%s-%s' % (secs, '@;[]_+.', hash)
     self.assertFalse(check_token_get_user(wrong_token, self.ip))
コード例 #5
0
 def test_valid_token(self):
     user = User.objects.create_user('testing', email='*****@*****.**')
     token = make_token(user, self.ip)
     self.assertEqual(check_token_get_user(token, self.ip), user)
コード例 #6
0
 def test_null_token(self):
     self.assertFalse(check_token_get_user('null', self.ip))