diff --git a/vulnerabilities/api_v2.py b/vulnerabilities/api_v2.py index 232d365cc..e8361c092 100644 --- a/vulnerabilities/api_v2.py +++ b/vulnerabilities/api_v2.py @@ -185,9 +185,9 @@ def list(self, request, *args, **kwargs): serializer = self.get_serializer(page, many=True) data = serializer.data # Use 'self.get_paginated_response' to include pagination data - return self.get_paginated_response({"purls": data}) + return self.get_paginated_response({"packages": data}) # If pagination is not applied serializer = self.get_serializer(queryset, many=True) data = serializer.data - return Response({"purls": data}) + return Response({"packages": data}) diff --git a/vulnerabilities/tests/test_api_v2.py b/vulnerabilities/tests/test_api_v2.py index a2a8bda98..eeaa18776 100644 --- a/vulnerabilities/tests/test_api_v2.py +++ b/vulnerabilities/tests/test_api_v2.py @@ -198,8 +198,8 @@ def test_list_packages(self): url = reverse("package-v2-list") response = self.client.get(url, format="json") self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertIn("purls", response.data["results"]) - self.assertEqual(len(response.data["results"]["purls"]), 2) + self.assertIn("packages", response.data["results"]) + self.assertEqual(len(response.data["results"]["packages"]), 2) def test_filter_packages_by_purl(self): """ @@ -208,8 +208,8 @@ def test_filter_packages_by_purl(self): url = reverse("package-v2-list") response = self.client.get(url, {"purl": "pkg:pypi/django@3.2"}, format="json") self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.data["results"]["purls"]), 1) - self.assertEqual(response.data["results"]["purls"][0]["purl"], "pkg:pypi/django@3.2") + self.assertEqual(len(response.data["results"]["packages"]), 1) + self.assertEqual(response.data["results"]["packages"][0]["purl"], "pkg:pypi/django@3.2") def test_filter_packages_by_affected_vulnerability(self): """ @@ -218,8 +218,8 @@ def test_filter_packages_by_affected_vulnerability(self): url = reverse("package-v2-list") response = self.client.get(url, {"affected_by_vulnerability": "VCID-1234"}, format="json") self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.data["results"]["purls"]), 1) - self.assertEqual(response.data["results"]["purls"][0]["purl"], "pkg:pypi/django@3.2") + self.assertEqual(len(response.data["results"]["packages"]), 1) + self.assertEqual(response.data["results"]["packages"][0]["purl"], "pkg:pypi/django@3.2") def test_filter_packages_by_fixing_vulnerability(self): """ @@ -228,8 +228,8 @@ def test_filter_packages_by_fixing_vulnerability(self): url = reverse("package-v2-list") response = self.client.get(url, {"fixing_vulnerability": "VCID-5678"}, format="json") self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.data["results"]["purls"]), 1) - self.assertEqual(response.data["results"]["purls"][0]["purl"], "pkg:npm/lodash@4.17.20") + self.assertEqual(len(response.data["results"]["packages"]), 1) + self.assertEqual(response.data["results"]["packages"][0]["purl"], "pkg:npm/lodash@4.17.20") def test_package_serializer_fields(self): """ @@ -276,7 +276,7 @@ def test_invalid_vulnerability_filter(self): url = reverse("package-v2-list") response = self.client.get(url, {"affected_by_vulnerability": "VCID-9999"}, format="json") self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.data["results"]["purls"]), 0) + self.assertEqual(len(response.data["results"]["packages"]), 0) def test_invalid_purl_filter(self): """ @@ -286,7 +286,7 @@ def test_invalid_purl_filter(self): url = reverse("package-v2-list") response = self.client.get(url, {"purl": "pkg:nonexistent/package@1.0.0"}, format="json") self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.data["results"]["purls"]), 0) + self.assertEqual(len(response.data["results"]["packages"]), 0) def test_get_affected_by_vulnerabilities(self): """