async def initialize(): with open(Path(__file__).parents[2] / 'conf' / 'default.yml', 'r') as fle: BaseWorld.apply_config('main', yaml.safe_load(fle)) with open(Path(__file__).parents[2] / 'conf' / 'payloads.yml', 'r') as fle: BaseWorld.apply_config('payloads', yaml.safe_load(fle)) app_svc = AppService(web.Application()) _ = DataService() _ = RestService() _ = PlanningService() _ = LearningService() auth_svc = AuthService() _ = ContactService() _ = FileSvc() services = app_svc.get_services() os.chdir(str(Path(__file__).parents[2])) await app_svc.register_contacts() await app_svc.load_plugins(['sandcat', 'ssl']) _ = await RestApi(services).enable() await auth_svc.apply(app_svc.application, auth_svc.get_config('users')) await auth_svc.set_login_handlers(services) return app_svc.application
def initialize(self): self.app_svc = AppService(None) self.data_svc = DataService() self.rest_svc = RestService() self.planning_svc = PlanningService() self.learning_svc = LearningService() self.services = [self.app_svc.get_services()]
async def test_save_ability_hooks(self, setup_contact_service, contact_svc): test_string = b'test_string' link = setup_contact_service rest_svc = RestService() result = dict(id=link.id, output=str( base64.b64encode(base64.b64encode(test_string)), 'utf-8'), pid=0, status=0) await contact_svc._save(Result(**result)) result = await rest_svc.display_result(dict(link_id=link.id)) assert base64.b64decode(result['output']) == test_string # cleanup test try: os.remove(os.path.join('data', 'results', link.id)) except FileNotFoundError: print('Unable to cleanup test_save_ability_hooks result file')
async def initialize(): with open(Path(__file__).parents[1] / 'conf' / 'default.yml', 'r') as fle: BaseWorld.apply_config('main', yaml.safe_load(fle)) with open(Path(__file__).parents[1] / 'conf' / 'payloads.yml', 'r') as fle: BaseWorld.apply_config('payloads', yaml.safe_load(fle)) app_svc = AppService(web.Application(client_max_size=5120**2)) _ = DataService() _ = RestService() _ = PlanningService() _ = LearningService() auth_svc = AuthService() _ = FileSvc() _ = EventService() services = app_svc.get_services() os.chdir(str(Path(__file__).parents[1])) _ = await RestApi(services).enable() await app_svc.register_contacts() await auth_svc.apply(app_svc.application, auth_svc.get_config('users')) await auth_svc.set_login_handlers(services) app_svc.register_subapp('/api/v2', make_app(svcs=services)) aiohttp_apispec.setup_aiohttp_apispec(app=app_svc.application, title='CALDERA', version=version.get_version(), swagger_path='/api/docs', url='/api/docs/swagger.json', static_path='/static/swagger') app_svc.application.middlewares.append( apispec_request_validation_middleware) app_svc.application.middlewares.append(validation_middleware) return app_svc
parser = argparse.ArgumentParser('Welcome to the system') parser.add_argument('-E', '--environment', required=False, default='local', help='Select an env. file to use') parser.add_argument('--fresh', action='store_true', required=False, default=False, help='remove object_store on start') args = parser.parse_args() config = args.environment if pathlib.Path( 'conf/%s.yml' % args.environment).exists() else 'default' with open('conf/%s.yml' % config) as c: BaseWorld.apply_config(yaml.load(c, Loader=yaml.FullLoader)) data_svc = DataService() contact_svc = ContactService( BaseWorld.strip_yml('conf/agents.yml')[0]['agent_config']) planning_svc = PlanningService() rest_svc = RestService() auth_svc = AuthService() file_svc = FileSvc( BaseWorld.strip_yml('conf/payloads.yml')[0]['payload_config']) learning_svc = LearningService() app_svc = AppService(application=web.Application()) if args.fresh: asyncio.get_event_loop().run_until_complete(data_svc.destroy()) run_tasks(services=app_svc.get_services())
async def _init_rest_svc(): return RestService()