Skip to content

Commit

Permalink
urlencode for test
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherhesse committed Nov 3, 2010
1 parent f7254e7 commit 988c5a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions urlcrypt/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

SECRET_KEY = getattr(settings, 'SECRET_KEY', 'sekrit')
RUNNING_TESTS = getattr(settings, 'RUNNING_TESTS', False)
RUNNING_TESTS = True

# Changing this setting, or SECRET_KEY, invalidates existing tokens, the pycrypto library is required if enabled
URLCRYPT_USE_RSA_ENCRYPTION = getattr(settings, 'URLCRYPT_USE_RSA_ENCRYPTION', False)
Expand Down
6 changes: 4 additions & 2 deletions urlcrypt/tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import time

from django import template
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

from django.test import TestCase
from urlcrypt.lib import generate_login_token, decode_login_token, encode_token, secret_key_f
from urlcrypt.lib import generate_login_token, decode_login_token, encode_token, secret_key_f, base64url_encode
from urlcrypt.conf import URLCRYPT_LOGIN_URL
from urlcrypt import rsa

Expand All @@ -28,7 +30,7 @@ def test_login_token_failed_hax0r(self):
response = self.client.get(reverse('urlcrypt_redirect', args=(fake_token,)))
self.assertRedirects(response, URLCRYPT_LOGIN_URL)

fake_token = encode_token([str(self.test_user.id), reverse('urlcrypt_test_view'), str(int(time.time()))], secret_key_f)
fake_token = base64url_encode(encode_token([str(self.test_user.id), reverse('urlcrypt_test_view'), str(int(time.time()))], secret_key_f))
response = self.client.get(reverse('urlcrypt_redirect', args=(fake_token,)))
self.assertRedirects(response, URLCRYPT_LOGIN_URL)

Expand Down

0 comments on commit 988c5a6

Please sign in to comment.