def setUp(self): # Enable direct download in fake storage. storage.put_content(['local_us'], 'supports_direct_download', 'true') # Have fake storage say all files exist for the duration of the test. storage.put_content(['local_us'], 'all_files_exist', 'true') # Setup the database with fake storage. setup_database_for_testing(self) self.app = app.test_client() self.ctx = app.test_request_context() self.ctx.__enter__() instance_keys = InstanceKeys(app) self.api = SecurityScannerAPI(app.config, storage, app.config['SERVER_HOSTNAME'], app.config['HTTPCLIENT'], uri_creator=get_blob_download_uri_getter( app.test_request_context('/'), url_scheme_and_hostname), instance_keys=instance_keys)
# Register custom converters. app.url_map.converters["regex"] = RegexConverter app.url_map.converters["repopath"] = RepositoryPathConverter app.url_map.converters["apirepopath"] = APIRepositoryPathConverter Principal(app, use_sessions=False) tf = app.config["DB_TRANSACTION_FACTORY"] model_cache = get_model_cache(app.config) avatar = Avatar(app) login_manager = LoginManager(app) mail = Mail(app) prometheus = PrometheusPlugin(app) chunk_cleanup_queue = WorkQueue(app.config["CHUNK_CLEANUP_QUEUE_NAME"], tf) instance_keys = InstanceKeys(app) ip_resolver = IPResolver(app) storage = Storage(app, chunk_cleanup_queue, instance_keys, config_provider, ip_resolver) userfiles = Userfiles(app, storage) log_archive = LogArchive(app, storage) analytics = Analytics(app) user_analytics = UserAnalytics(app) billing = Billing(app) sentry = Sentry(app) build_logs = BuildLogs(app) authentication = UserAuthentication(app, config_provider, OVERRIDE_CONFIG_DIRECTORY) userevents = UserEventsBuilderModule(app) superusers = SuperUserManager(app) signer = Signer(app, config_provider) instance_keys = InstanceKeys(app) label_validator = LabelValidator(app)
def instance_keys(liveserver_app): return InstanceKeys(liveserver_app)
def __init__(self, app, config, client=None): self._app = app self._instance_keys = InstanceKeys(app) self._config = config self._client = client or config['HTTPCLIENT'] self._gun_prefix = config['TUF_GUN_PREFIX'] or config['SERVER_HOSTNAME']