(event_loop, aiohttp_client, contact_svc)
| 333 | |
| 334 | @pytest.fixture |
| 335 | async def api_v2_client(event_loop, aiohttp_client, contact_svc): |
| 336 | def make_app(svcs): |
| 337 | warnings.filterwarnings( |
| 338 | "ignore", |
| 339 | message="Multiple schemas resolved to the name" |
| 340 | ) |
| 341 | |
| 342 | app = web.Application( |
| 343 | middlewares=[ |
| 344 | authentication_required_middleware_factory(svcs['auth_svc']), |
| 345 | json_request_validation_middleware |
| 346 | ] |
| 347 | ) |
| 348 | AgentApi(svcs).add_routes(app) |
| 349 | AbilityApi(svcs).add_routes(app) |
| 350 | OperationApi(svcs).add_routes(app) |
| 351 | AdversaryApi(svcs).add_routes(app) |
| 352 | ContactApi(svcs).add_routes(app) |
| 353 | ObjectiveApi(svcs).add_routes(app) |
| 354 | ObfuscatorApi(svcs).add_routes(app) |
| 355 | PluginApi(svcs).add_routes(app) |
| 356 | FactApi(svcs).add_routes(app) |
| 357 | FactSourceApi(svcs).add_routes(app) |
| 358 | PlannerApi(svcs).add_routes(app) |
| 359 | HealthApi(svcs).add_routes(app) |
| 360 | ScheduleApi(svcs).add_routes(app) |
| 361 | PayloadApi(svcs).add_routes(app) |
| 362 | return app |
| 363 | |
| 364 | async def initialize(): |
| 365 | with open(Path(__file__).parents[1] / 'conf' / 'default.yml', 'r') as fle: |
| 366 | BaseWorld.apply_config('main', yaml.safe_load(fle)) |
| 367 | with open(Path(__file__).parents[1] / 'conf' / 'payloads.yml', 'r') as fle: |
| 368 | BaseWorld.apply_config('payloads', yaml.safe_load(fle)) |
| 369 | |
| 370 | app_svc = AppService(web.Application(client_max_size=5120 ** 2)) |
| 371 | _ = DataService() |
| 372 | _ = RestService() |
| 373 | _ = PlanningService() |
| 374 | _ = KnowledgeService() |
| 375 | _ = LearningService() |
| 376 | auth_svc = AuthService() |
| 377 | _ = FileSvc() |
| 378 | _ = EventService() |
| 379 | services = app_svc.get_services() |
| 380 | os.chdir(str(Path(__file__).parents[1])) |
| 381 | |
| 382 | _ = await RestApi(services).enable() |
| 383 | await app_svc.register_contacts() |
| 384 | await auth_svc.apply(app_svc.application, auth_svc.get_config('users')) |
| 385 | await auth_svc.set_login_handlers(services) |
| 386 | |
| 387 | app_svc.register_subapp('/api/v2', make_app(svcs=services)) |
| 388 | aiohttp_apispec.setup_aiohttp_apispec( |
| 389 | app=app_svc.application, |
| 390 | title='Caldera', |
| 391 | version=version.get_version(), |
| 392 | swagger_path='/api/docs', |
nothing calls this directly
no test coverage detected