def post(self, project_id, test_id): """ Run test """ args = self.post_parser.parse_args(strict=False) project = Project.get_or_404(project_id) # if isinstance(test_id, int): _filter = and_(SecurityTestsSAST.project_id == project.id, SecurityTestsSAST.id == test_id) else: _filter = and_(SecurityTestsSAST.project_id == project.id, SecurityTestsSAST.test_uid == test_id) task = SecurityTestsSAST.query.filter(_filter).first() # execution = bool(args["type"] and args["type"] == "config") # event = list() event.append(task.configure_execution_json("cc", execution=execution)) # if args["type"] and args["type"] == "config": return event[0] # response = run_task(project.id, event) response["redirect"] = f"/task/{response['task_id']}/results" # statistic = Statistic.query.filter_by(project_id=project_id).first() statistic.sast_scans += 1 statistic.commit() # return response
def post(self, project_id, test_id): project = Project.get_or_404(project_id) args = self.post_parser.parse_args(strict=False) if isinstance(test_id, int): _filter = and_(PerformanceTests.project_id == project.id, PerformanceTests.id == test_id) else: _filter = and_(PerformanceTests.project_id == project.id, PerformanceTests.test_uid == test_id) task = PerformanceTests.query.filter(_filter).first() event = list() execution = True if args['type'] and args["type"] == "config" else False event.append( task.configure_execution_json( output='cc', test_type=args.get("test_type"), params=loads(args.get("params", None)), env_vars=loads(args.get("env_vars", None)), reporting=args.get("reporter", None), customization=loads(args.get("customization", None)), cc_env_vars=loads(args.get("cc_env_vars", None)), parallel=args.get("parallel", None), region=args.get("region", "default"), execution=execution, emails=args.get("emails", None))) if args['type'] and args["type"] == "config": return event[0] for each in event: each["test_id"] = task.test_uid response = run_task(project.id, event) response["redirect"] = f'/task/{response["task_id"]}/results' return response
def post(self, project_id, test_id): project = Project.get_or_404(project_id) args = self.post_parser.parse_args(strict=False) if isinstance(test_id, int): _filter = and_(UIPerformanceTests.project_id == project.id, UIPerformanceTests.id == test_id) else: _filter = and_(UIPerformanceTests.project_id == project.id, UIPerformanceTests.test_uid == test_id) task = UIPerformanceTests.query.filter(_filter).first() event = list() execution = True if args['type'] and args["type"] == "config" else False for browser in list(map(lambda x: x.strip(), task.browser.split(","))): event.append(task.configure_execution_json(output='cc', browser=browser, test_type=args.get("test_type"), params=loads(args.get("params", None)), env_vars=loads(args.get("env_vars", None)), reporting=args.get("reporter", None), customization=loads(args.get("customization", None)), cc_env_vars=loads(args.get("cc_env_vars", None)), parallel=args.get("parallel", None), execution=execution)) current_app.logger.error(f"Observer event sent {event}") if args['type'] and args["type"] == "config": return event[0] response = run_task(project.id, event) response["redirect"] = f'/task/{response["task_id"]}/results' statistic = Statistic.query.filter_by(project_id=project_id).first() statistic.ui_performance_test_runs += 1 statistic.commit() return response
def post(self, project_id: int): args = self._parser_post.parse_args(strict=False) project = Project.get_or_404(project_id) report = APIReport.query.filter_by( project_id=project_id, id=args.get("report_id")).first().to_json() event = { "galloper_url": "{{secret.galloper_url}}", "project_id": project.id, "token": "{{secret.auth_token}}", "report_id": args["report_id"], "influx_host": "{{secret.influx_ip}}", "config_file": "{}", "bucket": str(report["name"]).lower().replace(" ", "").replace("_", "").replace( "-", ""), "prefix": f'test_results_{uuid4()}_', } task = PerformanceTests.query.filter( and_(PerformanceTests.project_id == project.id, PerformanceTests.test_uid == report["test_uid"])).first() event["email_recipients"] = task.emails integration = [] for each in ["jira", "report_portal", "email", "azure_devops"]: if each in task.reporting: integration.append(each) junit = True if "junit" in task.reporting else False event["integration"] = integration event["junit"] = junit secrets = get_project_secrets(project_id) if "post_processor_id" not in secrets: secrets = get_project_hidden_secrets(project_id) return run_task(project.id, event, secrets["post_processor_id"])
def post(self, project_id: int, task_id: str): task = Task.query.filter_by(task_id=task_id).first() project = Project.get_or_404(project_id) event = request.get_json() return run_task(project.id, event, task.task_id)