Skip to content

Commit

Permalink
Fix tests when there's no test_private_key for the RSA tests
Browse files Browse the repository at this point in the history
  • Loading branch information
derek73 committed Dec 11, 2010
1 parent 9993305 commit 7593591
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion urlcrypt/__init__.py
@@ -1,3 +1,3 @@
VERSION = (0, 1, 4)
VERSION = (0, 1, 5)
__version__ = '.'.join(map(str, VERSION))

3 changes: 3 additions & 0 deletions urlcrypt/conf.py
Expand Up @@ -12,6 +12,9 @@
else:
URLCRYPT_PRIVATE_KEY_PATH = getattr(settings, 'URLCRYPT_PRIVATE_KEY_PATH', None)

if not os.path.exists(URLCRYPT_PRIVATE_KEY_PATH):
URLCRYPT_PRIVATE_KEY_PATH = None

URLCRYPT_USE_RSA_ENCRYPTION = URLCRYPT_PRIVATE_KEY_PATH is not None
URLCRYPT_LOGIN_URL = getattr(settings, 'URLCRYPT_LOGIN_URL', settings.LOGIN_URL)
URLCRYPT_RATE_LIMIT = getattr(settings, 'URLCRYPT_RATE_LIMIT', 60)
9 changes: 5 additions & 4 deletions urlcrypt/tests.py
Expand Up @@ -6,8 +6,7 @@

from django.test import TestCase
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
from urlcrypt.conf import URLCRYPT_LOGIN_URL, URLCRYPT_USE_RSA_ENCRYPTION

class UrlCryptTests(TestCase):

Expand All @@ -22,8 +21,10 @@ def test_login_token(self):
self.assertEquals(data['url'], u'/users/following')

def test_rsa(self):
assert rsa.decrypt(rsa.encrypt("test")) == "test"
assert rsa.decrypt(rsa.encrypt("test"*100)) == "test"*100
if URLCRYPT_USE_RSA_ENCRYPTION:
from urlcrypt import rsa
assert rsa.decrypt(rsa.encrypt("test")) == "test"
assert rsa.decrypt(rsa.encrypt("test"*100)) == "test"*100

def test_login_token_failed_hax0r(self):
fake_token = 'asdf;lhasdfdso'
Expand Down

0 comments on commit 7593591

Please sign in to comment.