def post_export(self, request): """ Mock POST /configurations/exports/ """ if '"playbooks": true' in request.text: return requests_mock.create_response(request, status_code=200, json=read_mock_json("export-with-playbook.JSON")) return requests_mock.create_response(request, status_code=200, json=read_mock_json("export.JSON"))
def post_export(self, request): """ Mock POST /configurations/exports/ """ return requests_mock.create_response(request, status_code=200, json=read_mock_json("export.JSON"))
def get_org(self, request): """ Mock GET /orgs/<org_id> """ return requests_mock.create_response(request, status_code=200, json=read_mock_json("orgs.JSON"))
def get_const(self, request): """ Mock POST /const/ """ return requests_mock.create_response(request, status_code=200, json=read_mock_json("export.JSON"))
def post_session(self, request): """ Mock POST /rest/session """ return requests_mock.create_response(request, status_code=200, cookies=requests.cookies.cookiejar_from_dict({'JSESSIONID': 'FakeSessionId'}), json=read_mock_json("session.JSON"))
from argparse import Namespace import copy from mock import patch import pytest from resilient_sdk.cmds import base_cmd, CmdClone from resilient_sdk.util.resilient_objects import ResilientObjMap from resilient_sdk.util.sdk_exception import SDKException from tests.helpers import read_mock_json TEST_OBJ = { "uuid": uuid.uuid4(), "export_key": "TEST_OBJ", "name": "My test Obj" } TEST_EXPORT = read_mock_json("export.JSON") # Mandatory keys for a configuration import MANDATORY_KEYS = ["incident_types", "fields"] # Map from export object keys to each objects unique identifier EXPORT_TYPE_MAP = { 'actions': ResilientObjMap.RULES, 'functions': ResilientObjMap.FUNCTIONS, 'workflows': ResilientObjMap.WORKFLOWS } TEST_CLONE_FAILURE_DATA = [ (("bad_function", "new_func"), "Function", ResilientObjMap.FUNCTIONS, 'functions', CmdClone.replace_function_object_attrs), (("bad_rule", "new_rule"), "Rule", ResilientObjMap.RULES, 'actions', CmdClone.replace_rule_object_attrs), (("bad_md", "new_md"), "Message Destination", ResilientObjMap.MESSAGE_DESTINATIONS,