|
5 | 5 |
|
6 | 6 |
|
7 | 7 | from codeinsight_sdk import CodeInsightClient |
8 | | -from codeinsight_sdk.exceptions import CodeInsightError |
9 | 8 |
|
10 | 9 | logger = logging.getLogger(__name__) |
11 | 10 |
|
12 | 11 | ## CHANGE ME ## |
13 | 12 | TEST_URL = "https://api.revenera.com" |
14 | 13 | TEST_API_TOKEN = "your_api_token" |
15 | 14 |
|
| 15 | + |
16 | 16 | class TestExperimental: |
17 | 17 | @pytest.fixture |
18 | 18 | def client(self): |
19 | 19 | return CodeInsightClient(TEST_URL, TEST_API_TOKEN, experimental=True) |
20 | | - |
| 20 | + |
21 | 21 | def test_experimental_enabled(self, client): |
22 | 22 | assert client.experimental_enabled == True |
23 | | - |
| 23 | + |
24 | 24 | def test_get_project_vulnerabilities(self, client): |
25 | 25 | project_id = 1 |
26 | 26 | total_pages = 4 |
@@ -86,11 +86,21 @@ def test_get_project_vulnerabilities(self, client): |
86 | 86 | "vulnerabilityCvssV3Severity":"CRITICAL"} ] } |
87 | 87 | """ |
88 | 88 | with requests_mock.Mocker() as m: |
89 | | - m.get(f"{TEST_URL}/codeinsight/api/projects/{project_id}/inventorySummary", |
90 | | - text=fake_response_json, headers=response_header) |
91 | | - m.get(f"{TEST_URL}/codeinsight/api/inventories/12346/vulnerabilities", |
92 | | - text=mock_resp_vuln, headers=response_header) |
93 | | - vulnerable_items = client.experimental.get_project_vulnerabilities(project_id) |
| 89 | + m.get( |
| 90 | + f"{TEST_URL}/codeinsight/api/projects/{project_id}/inventorySummary", |
| 91 | + text=fake_response_json, |
| 92 | + headers=response_header, |
| 93 | + ) |
| 94 | + m.get( |
| 95 | + f"{TEST_URL}/codeinsight/api/inventories/12346/vulnerabilities", |
| 96 | + text=mock_resp_vuln, |
| 97 | + headers=response_header, |
| 98 | + ) |
| 99 | + vulnerable_items = client.experimental.get_project_vulnerabilities( |
| 100 | + project_id |
| 101 | + ) |
94 | 102 | assert len(vulnerable_items) > 0 |
95 | 103 | assert vulnerable_items[0].vulnerabilities is not None |
96 | | - assert vulnerable_items[0].vulnerabilities[1].vulnerabilityName == "CVE-987-65432" |
| 104 | + assert ( |
| 105 | + vulnerable_items[0].vulnerabilities[1].vulnerabilityName == "CVE-987-65432" |
| 106 | + ) |
0 commit comments