예제 #1
0
 def setUpClass(cls, sde_cmd, mapping_file, report_file, integrator_cls, test_files_dir=TEST_FILES_DIR):
     cls.sde_cmd = sde_cmd
     cls.mapping_file = mapping_file
     cls.report_file = report_file
     cls.integrator_cls = integrator_cls
     cls.test_file_dir = os.path.join(get_directory_of_current_module(cls), test_files_dir)
     cls.mock_sde_response = MOCK_SDE_RESPONSE
예제 #2
0
    def __init__(self, rest_api_targets, resource_templates, test_dir=None):
        """Initializes commonly used variables.

        Keyword arguments:
        rest_api_targets    -- Dict object containing key-value pairs used in get_response to triage API calls
                               to its corresponding response generating method.
                               Expected format:
                                 "regex_pattern_of_api_target": "method_to_call_on_match"
        resource_templates  -- List of resources we want to store. Specify the filename of the resource template.
        test_dir            -- Directory containing current test; used to locate response files
        base_path           -- URL that will be prepended to each rest api target.
                               Expected format:
                                 "/BASE_PATH/"

        """
        if test_dir is None:
            test_dir = get_directory_of_current_module(self)

        self.target = None
        self.resources = {}
        self.test_dir = test_dir
        self.rest_api_targets = rest_api_targets

        for resource in resource_templates:
            resource_name, file_type = resource.split('.')
            self.resources[resource_name] = {
                'resources': {},
                'file_type': file_type
            }

        self.init_with_resources()
예제 #3
0
 def setUp(self):
     self.ret_chn = ReturnChannel(stdout_callback, {})
     command_list = load_modules()
     self.conf_path = os.path.join(get_directory_of_current_module(self), CONF_FILE_LOCATION)
     self.ret_chn = ReturnChannel(stdout_callback, {})
     self.config = Config('help', '', command_list, [], self.ret_chn, 'shell')
     self.rest_client = RESTBase('sde', 'conf_name', self.config)
     self.config.import_custom_options()
     Config.parse_config_file(self.config, self.conf_path)
예제 #4
0
 def setUpClass(cls):
     sde_cmd = "import_appscan"
     mapping_file = 'mapping.xml'
     report_file = 'appscan.xml'
     integrator = AppScanIntegrator
     cls.generator_cls = AppScanResponseGenerator
     cls.test_dir = get_directory_of_current_module(cls)
     cls.mock_sde_response = MOCK_SDE_RESPONSE
     cls.mock_alm_response = MOCK_ALM_RESPONSE
     super(TestAppScanIntegration, cls).setUpClass(sde_cmd, mapping_file, report_file, integrator)
예제 #5
0
    def setUpClass(cls):
        sde_cmd = "import_checkmarx"
        mapping_file = 'mapping.csv'
        report_file = 'checkmarx.xml'
        integrator = CheckmarxIntegrator

        cls.test_dir = get_directory_of_current_module(cls)
        cls.mock_sde_response = MOCK_SDE_RESPONSE
        cls.mock_alm_response = MOCK_ALM_RESPONSE

        # Patch Suds client for offline tests
        mock_soap = MockSoap
        patch('sdetools.modules.import_checkmarx.checkmarx_integrator.Client', mock_soap).start()

        super(TestCheckmarxIntegration, cls).setUpClass(sde_cmd, mapping_file, report_file, integrator)
예제 #6
0
    def setUpClass(cls, test_dir=None, conf_file_location=CONF_FILE_LOCATION, alm_classes=[None, None, None]):
        """
            test_dir             - The directory where we will look for the test config file.
                                   Default is the directory of the calling class
            conf_file_location   - The relative path from the test_dir to the conf file.
                                   Default is the value of CONF_FILE_LOCATION
            classes              - Pass the class name of the connector, api and response generator
                                   to use the default initializer.
                                   Expects:
                                        [alm_connector, alm_api, alm_response_generator
        """
        if test_dir is None:
            test_dir = get_directory_of_current_module(cls)

        cls.connector_cls, cls.api_cls, cls.generator_cls = alm_classes
        cls.test_dir = test_dir
        cls.conf_path = os.path.join(cls.test_dir, conf_file_location)
        cls.mock_sde_response = MOCK_SDE_RESPONSE
        cls.mock_alm_response = MOCK_ALM_RESPONSE
        cls.ret_chn = ReturnChannel(stdout_callback, {})
예제 #7
0
 def GetScanReport(self, session_id, report_id):
     # Read in checkmarx sample report file
     results = open(os.path.join(get_directory_of_current_module(self), "files/checkmarx.xml")).read()
     encoded_results = base64.b64encode(results)  # Encode results in base64 as checkmarx does
     return type('', (object,), {"IsSuccesfull": True, "ScanResults": encoded_results})()