def generate(self, **options): """Generates an encrypted URL with the specified options""" if options.get("unsafe", False): return unsafe_url(**options) return self.generate_new(options)
def generate(self, **options): '''Generates an encrypted URL with the specified options''' if options.get('unsafe', False): return unsafe_url(**options) else: return self.generate_new(options)
def generate(self, **options): '''Generates an encrypted URL with the specified options''' if options.get('unsafe', False): return unsafe_url(**options) else: is_old = options.get('old', False) if is_old: return self.generate_old(options) return self.generate_new(options)
def generate(self, **options): """ Generates an encrypted URL with the specified options. """ if options.get('unsafe', False): return unsafe_url(**options) else: is_old = options.get('old', False) if is_old: return self.generate_old(options) return self.generate_new(options)
def generate(self, **options): '''Generates an encrypted URL with the specified options''' if options.get('unsafe', False): return unsafe_url(**options) else: url = url_for(**options) pad = lambda s: s + (16 - len(s) % 16) * "{" cypher = AES.new(self.computed_key) encrypted = base64.urlsafe_b64encode(cypher.encrypt(pad(url))) return "/%s/%s" % (encrypted, options['image_url'])
def test_should_return_an_unsafe_url_with_crop_and_smart(self): self.assertEqual('unsafe/100x140/smart/%s' % IMAGE_URL, unsafe_url(image_url=IMAGE_URL, width=100, height=140, smart=True))
def test_should_return_an_unsafe_url_with_width_and_height(self): self.assertEqual('unsafe/100x140/%s' % IMAGE_URL, unsafe_url(image_url=IMAGE_URL, width=100, height=140))
def test_should_return_a_valid_unsafe_url_with_no_params(self): self.assertEqual('unsafe/%s' % IMAGE_URL, unsafe_url(image_url=IMAGE_URL))
def test_should_return_an_unsafe_url_with_crop_and_smart(self): self.assertEqual( 'unsafe/100x140/smart/%s' % IMAGE_URL, unsafe_url(image_url=IMAGE_URL, width=100, height=140, smart=True))
def test_should_return_an_unsafe_url_with_width_and_height(self): self.assertEqual( 'unsafe/100x140/%s' % IMAGE_URL, unsafe_url(image_url=IMAGE_URL, width=100, height=140))
def test_should_return_an_unsafe_url_with_crop_and_smart(self): expect("unsafe/100x140/smart/%s" % IMAGE_URL).to_equal( unsafe_url(image_url=IMAGE_URL, width=100, height=140, smart=True), )
def test_should_return_an_unsafe_url_with_width_and_height(self): expect("unsafe/100x140/%s" % IMAGE_URL).to_equal( unsafe_url(image_url=IMAGE_URL, width=100, height=140), )
def test_should_return_a_valid_unsafe_url_with_no_params(self): expect("unsafe/%s" % IMAGE_URL).to_equal(unsafe_url(image_url=IMAGE_URL))