Skip to content

Commit

Permalink
Verifying libthumbor url matches thumbor url for same image and same key
Browse files Browse the repository at this point in the history
  • Loading branch information
heynemann committed Mar 31, 2011
1 parent 82c4721 commit ca82cc4
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/test_libthumbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,34 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 Bernardo Heynemann heynemann@gmail.com

from thumbor.crypto import Crypto
from libthumbor import CryptoURL

def test_usage():
crypto = CryptoURL(key='my-security-key')
key = "my-security-key"
image = "s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"
thumbor_crypto = Crypto(salt=key)

thumbor_options = thumbor_crypto.encrypt(
300,
200,
True,
False,
False,
'center',
'middle',
0, 0, 0, 0,
image=image
)
thumbor_url = "/%s/%s" % (thumbor_options, image)

crypto = CryptoURL(key=key)

url = crypto.generate(
width=300,
height=200,
smart=True,
image_url='s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg'
image_url=image
)

assert url == "/mjFhjvFRAj7oAfr1UZuGLXXjEI9yKAoTkrDhF5xnXLeF6CSX6_ZPbpqlBE_AhwZT/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"
assert url == thumbor_url

0 comments on commit ca82cc4

Please sign in to comment.