def topic(self): config = Config(FILE_STORAGE_ROOT_PATH="/tmp/thumbor/file_storage/", STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True) storage = FileStorage(Context(config=config, server=get_server('ACME-SEC'))) storage.put(IMAGE_URL % 6, IMAGE_BYTES) storage.put_crypto(IMAGE_URL % 6) return storage.get_crypto(IMAGE_URL % 6)
def get_app(self): cfg = Config(SECURITY_KEY='MYKEY') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.ALLOW_UNSAFE_URL = False cfg.ALLOW_OLD_URLS = True cfg.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8891, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'MYKEY' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) storage = FileStorage(Context(config=cfg, server=server)) # Store fixtures (image.jpg and image.txt) into the file storage storage.put('image.jpg', file(join(storage_path, 'image.jpg')).read()) storage.put_crypto( 'image.jpg' ) # Write a file on the file storage containing the security key return application
def test_does_not_store_if_config_says_not_to(self): iurl = self.get_image_url('image_5.jpg') ibytes = self.get_image_bytes('image.jpg') storage = FileStorage(self.context) storage.put(iurl, ibytes) storage.put_crypto(iurl) got = yield storage.get_crypto(iurl) expect(got).to_be_null()
def topic(self): config = Config( FILE_STORAGE_ROOT_PATH="/tmp/thumbor/file_storage/") storage = FileStorage( Context(config=config, server=get_server('ACME-SEC'))) storage.put(IMAGE_URL % 5, IMAGE_BYTES) storage.put_crypto(IMAGE_URL % 5) return storage.get_crypto(IMAGE_URL % 5)
def test_can_store_crypto(self): iurl = self.get_image_url('image_6.jpg') ibytes = self.get_image_bytes('image.jpg') storage = FileStorage(self.context) storage.put(iurl, ibytes) storage.put_crypto(iurl) got = yield storage.get_crypto(iurl) expect(got).not_to_be_null() expect(got).not_to_be_an_error() expect(got).to_equal('ACME-SEC')
def test_should_be_an_error(self): iurl = self.get_image_url('image_3.jpg') ibytes = self.get_image_bytes('image.jpg') storage = FileStorage(self.context) storage.put(iurl, ibytes) with expect.error_to_happen( RuntimeError, message="STORES_CRYPTO_KEY_FOR_EACH_IMAGE can't be True if no SECURITY_KEY specified" ): storage.put_crypto(iurl)
def test_should_be_an_error(self): iurl = self.get_image_url('image_3.jpg') ibytes = self.get_image_bytes('image.jpg') storage = FileStorage(self.context) storage.put(iurl, ibytes) msg = "STORES_CRYPTO_KEY_FOR_EACH_IMAGE can't be True if no SECURITY_KEY specified" with expect.error_to_happen( RuntimeError, message=msg, ): storage.put_crypto(iurl)
def get_app(self): cfg = Config(SECURITY_KEY='MYKEY') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.ALLOW_UNSAFE_URL = False cfg.ALLOW_OLD_URLS = True cfg.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8891, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'MYKEY' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) storage = FileStorage(Context(config=cfg, server=server)) # Store fixtures (image.jpg and image.txt) into the file storage storage.put('image.jpg', open(join(storage_path, 'image.jpg')).read()) storage.put_crypto('image.jpg') # Write a file on the file storage containing the security key return application
def get_app(self): cfg = Config(SECURITY_KEY="MYKEY") cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.ALLOW_UNSAFE_URL = False cfg.ALLOW_OLD_URLS = True cfg.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8891, "localhost", "thumbor.conf", None, "info", None) server.security_key = "MYKEY" ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) logger.exception = Mock() storage = FileStorage(Context(config=cfg, server=server)) # Store fixtures (image.jpg and image.txt) into the file storage storage.put_crypto("image.jpg") # Write a file on the file storage containing the security key return application
def topic(self): config = Config(FILE_STORAGE_ROOT_PATH="/tmp/thumbor/file_storage/") storage = FileStorage(Context(config=config, server=get_server('ACME-SEC'))) storage.put(IMAGE_URL % 5, IMAGE_BYTES) storage.put_crypto(IMAGE_URL % 5) return storage.get_crypto(IMAGE_URL % 5)