def test_scan_scan_url_invalid_get_json_response(self, get_mock): get_mock.side_effect = requests.exceptions.HTTPError try: get_json_response(self.scan_url_dummy, self.api_auth_token_dummy, True) except requests.exceptions.RequestException as e: pass else: self.fail("Scan URL invalid.")
def test_scan_url_empty_get_json_response(self, get_mock): get_mock.side_effect = requests.exceptions.RequestException url = None try: get_json_response(url, self.api_auth_token_dummy, True) except requests.exceptions.RequestException as e: pass else: self.fail("URL empty exception test case failed.")
def test_scan_vulnerabilities_json_response(self): scan_vulnerabilities_url = self.scan_url + "/results/" + self.scan_session_id + "/vulnerabilities" scan_vulnerabilities_json_response = get_json_response( url=scan_vulnerabilities_url, api_auth_token=self.api_auth_token, disable_ssl_warnings=True) self.assertTrue( 'vulnerabilities' in scan_vulnerabilities_json_response.keys())
def test_get_scan_vulnerabilities_json_report(self): scan_vulnerabilities_url = self.scan_url + "/results/" + self.scan_session_id + "/vulnerabilities" scan_vulnerabilities_json_response = get_json_response( url=scan_vulnerabilities_url, api_auth_token=self.api_auth_token, disable_ssl_warnings=True) scan_vulnerabilities_ids = get_scan_vulnerabilities_ids( scan_vulnerabilities_json_response) vulnerabilities_details = get_vulnerabilities_details( scan_vulnerabilities_url, self.api_auth_token, scan_vulnerabilities_ids, True) json_response = get_json_response(self.scan_url, self.api_auth_token, True) scan_vulnerabilities_json_report = get_scan_vulnerabilities_json_report( json_response, vulnerabilities_details) scan_vulnerabilities = json.loads(scan_vulnerabilities_json_report) self.assertEqual(scan_vulnerabilities['scan_id'], self.scan_id) self.assertEqual(len(scan_vulnerabilities['issues']), 5)
def test_get_scan_vulnerabilities_ids(self): scan_vulnerabilities_url = self.scan_url + "/results/" + self.scan_session_id + "/vulnerabilities" scan_vulnerabilities_json_response = get_json_response( url=scan_vulnerabilities_url, api_auth_token=self.api_auth_token, disable_ssl_warnings=True) self.assertEqual( get_scan_vulnerabilities_ids(scan_vulnerabilities_json_response), self.scan_vulnerabilities_ids)
def test_get_vulnerabilities_details(self): scan_vulnerabilities_url = self.scan_url + "/results/" + self.scan_session_id + "/vulnerabilities" scan_vulnerabilities_json_response = get_json_response( url=scan_vulnerabilities_url, api_auth_token=self.api_auth_token, disable_ssl_warnings=True) scan_vulnerabilities_ids = get_scan_vulnerabilities_ids( scan_vulnerabilities_json_response) vulnerabilities_details = get_vulnerabilities_details( scan_vulnerabilities_url, self.api_auth_token, scan_vulnerabilities_ids, True) vulnerability_detail_1 = vulnerabilities_details[0] self.assertEqual(len(vulnerabilities_details), 5) self.assertTrue('cvss_score' in vulnerability_detail_1.keys())
def test_get_scan_session_id(self): json_response = get_json_response(self.scan_url, self.api_auth_token, self.disable_ssl_warnings) self.assertEqual(get_scan_session_id(json_response), self.scan_session_id)
def test_disable_ssl_warnings_false_scan_get_json_response(self): json_response = get_json_response(self.scan_url, self.api_auth_token, False) self.check_scan_json_reponse(json_response)
def test_scan_get_json_response(self): json_response = get_json_response(self.scan_url, self.api_auth_token, True) self.check_scan_json_reponse(json_response)