Skip to content

Commit a91237e

Browse files
committed
Fix tests
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 8222cc5 commit a91237e

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

etc/nginx/conf.d/default.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ server {
1313
client_max_body_size 10G;
1414
proxy_read_timeout 600s;
1515
proxy_set_header X-Forwarded-Proto $scheme;
16+
proxy_set_header X-Forwarded-Host $host;
1617
}
1718

1819
location /static/ {

vulnerabilities/pipes/osv_v2.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,19 @@ def parse_advisory_data_v3(
6969
Return an AdvisoryData build from a ``raw_data`` mapping of OSV advisory and
7070
a ``supported_ecosystem`` string.
7171
"""
72-
if not advisory_id:
73-
advisory_id = raw_data.get("id") or ""
74-
if not advisory_id:
72+
adv_id = raw_data.get("id")
73+
if not adv_id:
7574
logger.error(f"Missing advisory id in OSV data: {raw_data}")
7675
return None
76+
aliases = raw_data.get("aliases") or []
77+
if not advisory_id:
78+
advisory_id = adv_id
79+
else:
80+
aliases.append(adv_id)
7781
summary = raw_data.get("summary") or ""
7882
details = raw_data.get("details") or ""
7983
summary = build_description(summary=summary, description=details)
80-
aliases = raw_data.get("aliases") or []
8184
aliases.extend(raw_data.get("upstream", []))
82-
8385
date_published = get_published_date(raw_data=raw_data)
8486
severities = list(get_severities(raw_data=raw_data, url=advisory_url))
8587
references = get_references_v2(raw_data=raw_data)

vulnerabilities/tests/test_api_v2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def test_list_vulnerabilities_pagination(self):
185185
self.assertIn("previous", response.data)
186186
# The 'vulnerabilities' dictionary should contain vulnerabilities up to the page limit
187187
self.assertEqual(
188-
len(response.data["results"]["vulnerabilities"]), 10
189-
) # Assuming default page size is 10
188+
len(response.data["results"]["vulnerabilities"]), 14
189+
) # Assuming default page size is 100
190190

191191

192192
class PackageV2ViewSetTest(APITestCase):
@@ -346,8 +346,8 @@ def test_list_packages_pagination(self):
346346
self.assertIn("next", response.data)
347347
self.assertIn("previous", response.data)
348348
self.assertEqual(
349-
len(response.data["results"]["packages"]), 10
350-
) # Assuming default page size is 10
349+
len(response.data["results"]["packages"]), 14
350+
) # Assuming default page size is 100
351351

352352
def test_invalid_vulnerability_filter(self):
353353
"""

vulnerabilities/tests/test_api_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_advisories_post(self):
182182
)
183183

184184
self.assertEqual(response.status_code, status.HTTP_200_OK)
185-
self.assertEqual(len(response.data["results"]), 10)
185+
self.assertEqual(len(response.data["results"]), 100)
186186
advisory = response.data["results"][0]
187187
self.assertEqual(advisory["advisory_id"], "ghsa_importer/GHSA-12341")
188188

@@ -229,5 +229,5 @@ def test_get_all_vulnerable_purls(self):
229229
self.assertEqual(response.status_code, status.HTTP_200_OK)
230230

231231
results = response.data["results"]
232-
self.assertEqual(len(results), 10)
232+
self.assertEqual(len(results), 100)
233233
self.assertIn("next", response.data)

0 commit comments

Comments
 (0)