def test_can_get_crypto(self): key = '/some/path/to/file.jpg' storage = Storage(self.context) self.memcached.set(storage.crypto_key_for(key), 'test-crypto-data') data = storage.get_crypto(key).result() expect(data).to_equal('test-crypto-data')
def test_put_crypto_when_valid_data(self): ctx = mock.Mock( config=mock.Mock( MEMCACHE_STORAGE_SERVERS=[ 'localhost:5555', ], STORAGE_EXPIRATION_SECONDS=120, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True, ), server=mock.Mock(security_key='some-key'), ) storage = Storage(ctx) storage.put_crypto('/some/path/to/file.jpg') data = self.memcached.get( storage.crypto_key_for('/some/path/to/file.jpg')) expect(data).to_equal('some-key')
def test_put_crypto_when_valid_data(self): ctx = mock.Mock( config=mock.Mock( MEMCACHE_STORAGE_SERVERS=[ 'localhost:5555', ], STORAGE_EXPIRATION_SECONDS=120, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True, ), server=mock.Mock( security_key='some-key' ), ) storage = Storage(ctx) storage.put_crypto('/some/path/to/file.jpg') data = self.memcached.get(storage.crypto_key_for('/some/path/to/file.jpg')) expect(data).to_equal('some-key')
def test_can_get_crypto_key_for_url(self): storage = Storage(self.context) key = 'thumbor-crypto-http://www.globo.com/' expected = hashlib.sha1(key).hexdigest() expect(storage.crypto_key_for('http://www.globo.com/')).to_equal(expected)
def test_can_get_crypto_key_for_url(self): storage = Storage(self.context) key = 'thumbor-crypto-http://www.globo.com/' expected = hashlib.sha1(key).hexdigest() expect( storage.crypto_key_for('http://www.globo.com/')).to_equal(expected)