def test_get_finding_group_count(self, mock_get_finding_group_count): mock_get_finding_group_count.return_value = JSONMock() mock_get_finding_group_count.return_value.data = [{"test": "data"}] filters = {"filter": {"detectionMethod": 1, "severity": "Medium"}} result = self.findings_api.get_finding_group_count( self.test_project, filters) self.assertIsInstance(result, list)
def test_get_finding_count(self, mock_get_finding_count): mock_get_finding_count.return_value = JSONMock() result = self.findings_api.get_finding_count(self.test_project) self.assertIsInstance(result, dict) result = self.findings_api.get_finding_count( project=self.test_project, req_body=self.request_filters) self.assertIsInstance(result, dict)
def test_get_finding_flow(self, mock_get_finding_flow): mock_get_finding_flow.return_value = JSONMock() mock_get_finding_flow.return_value.data = [{"findings": "test"}] filters = {"filter": {"detectionMethod": 1, "severity": "Medium"}} result = self.findings_api.get_finding_flow(self.test_project, filters) self.assertIsInstance(result, list) with self.assertRaises(Exception): self.findings_api.get_finding_flow(self.test_project)
def test_upload_analysis(self, mock_upload_analysis): mock_upload_analysis.return_value = JSONMock() mock_upload_analysis.return_value.status_code = 202 test_prep_id = "myTestPrep" test_file_name = os.path.join(os.path.dirname(__file__), 'testdata.xml') result = self.analysis_api.upload_analysis(self.prep_id, test_file_name) with self.assertRaises(Exception): self.analysis_api.upload_analysis(self.prep_id, "Not a valid file name") with self.assertRaises(Exception): self.analysis_api.upload_analysis(self.prep_id, "not_valid_ext.html")
def test_get_finding_table(self, mock_get_finding_table): mock_get_finding_table.return_value = JSONMock() mock_get_finding_table.return_value.data = ["findings"] result = self.findings_api.get_finding_table(self.test_project) self.assertIsInstance(result, list) result = self.findings_api.get_finding_table(self.test_project, ['description']) self.assertIsInstance(result, list) result = self.findings_api.get_finding_table( project=self.test_project, req_body=self.request_filters) self.assertIsInstance(result, list) result = self.findings_api.get_finding_table( project=self.test_project, options=["issue"], req_body=self.request_filters) self.assertIsInstance(result, list)
def test_query_project(self, mock_query_projects): mock_query_projects.return_value = JSONMock() mock_query_projects.return_value.data = [{ "project": "test" }, { "project2": "test" }] filters = { "name": "WebGoat", "metadata": { "Project Owner": "Jim", "id:5": "Medium", "My Tag Field": "hello goodbye " } } result = self.proj_api.query_projects(filters) self.assertIsInstance(result, list) result = self.proj_api.query_projects(filters, 5, 2) self.assertIsInstance(result, list)
def test_project_roles(self, mock_project_roles): mock_project_roles.return_value = JSONMock() mock_project_roles.return_value.data = ["Admin", "Creator"] result = self.proj_api.project_roles(0)
def test_project_files(self, mock_project_files): mock_project_files.return_value = JSONMock() mock_project_files.return_value.data = ["file1", "file2"] result = self.proj_api.project_files(0) self.assertIsInstance(result, list)
def test_file_mappings(self, mock_file_mappings): mock_file_mappings.return_value = JSONMock() result = self.proj_api.file_mappings(0, {"files": "/Proj/foo"}) self.assertIsInstance(result, dict)
def test_get_finding_description(self, mock_get_finding_description): mock_get_finding_description.return_value = JSONMock() result = self.findings_api.get_finding_description(5) self.assertIsInstance(result, dict)
def test_get_all_analysis(self, mock_get_all_analysis): mock_get_all_analysis.return_value = JSONMock() result = self.analysis_api.get_all_analysis(self.test_project) self.assertIsInstance(result, dict)
def test_get_input_metadata(self, mock_get_input_metadata): mock_get_input_metadata.return_value = JSONMock() result = self.analysis_api.get_input_metadata('1234', 'TEST') self.assertIsInstance(result, dict)
def test_get_projects(self, mock_get_projects): # Creating Mock mock_get_projects.return_value = JSONMock() projs = self.proj_api.get_projects() self.assertIsInstance(projs, dict)
def test_get_project_id(self, mock_get_id): mock_get_id.return_value = JSONMock() mock_result = [{"id": 0, "name": "Webgoat"}] mock_get_id.return_value.data = mock_result result = self.proj_api.get_project_id("Webgoat") self.assertEqual(result, mock_result[0]["id"])
def test_get_finding_history(self, mock_get_finding_history): mock_get_finding_history.return_value = JSONMock() mock_get_finding_history.return_value.data = ["findings"] result = self.findings_api.get_finding_history(5) self.assertIsInstance(result, list)
def test_project_user(self, mock_project_user): mock_project_user.return_value = JSONMock() result = self.proj_api.project_user(0, 0) self.assertIsInstance(result, dict)
def test_get_prep(self, mock_get_prep): mock_get_prep.return_value = JSONMock() result = self.analysis_api.get_prep(self.prep_id)
def test_create_project(self, mock_create_project): mock_create_project.return_value = JSONMock() test_name = "CreateTest" result = self.proj_api.create_project(test_name) self.assertIsInstance(result, dict)
def test_run_analysis(self, mock_run_analysis): mock_run_analysis.return_value = JSONMock() mock_run_analysis.return_value.status_code = 202 result = self.analysis_api.run_analysis(self.prep_id) self.assertIsInstance(result, dict)
def test_query_count(self, mock_query_count): mock_query_count.return_value = JSONMock() mock_query_count.return_value.data = 5 filters = {"name": "WebGoat"} result = self.proj_api.query_count(filters) self.assertIsInstance(result, int)
def test_disable_display_tag(self, mock_disable_display_tag): mock_disable_display_tag.return_value = JSONMock() result = self.analysis_api.disable_display_tag('1234', 'inputId', 'tagID') self.assertIsInstance(result, dict)
def test_project_status(self, mock_project_status): mock_project_status.return_value = JSONMock() result = self.proj_api.project_status(0) self.assertIsInstance(result, dict)
def test_job_status(self, mock_job_status): mock_job_status.return_value = JSONMock() test_job = "string" result = self.job_api.job_status(test_job) self.assertIsInstance(result, dict)
def test_get_finding(self, mock_get_finding): mock_get_finding.return_value = JSONMock() result = self.findings_api.get_finding(5) self.assertIsInstance(result, dict) result = self.findings_api.get_finding(5, ["triage-time"]) self.assertIsInstance(result, dict)