(self)
| 32 | |
| 33 | class APIV3TestCase(APITestCase): |
| 34 | def setUp(self): |
| 35 | from vulnerabilities.models import ImpactedPackage |
| 36 | |
| 37 | self.logger = TestLogger() |
| 38 | self.advisory = insert_advisory_v2( |
| 39 | advisory=AdvisoryDataV2( |
| 40 | summary="summary", |
| 41 | advisory_id="GHSA-1234", |
| 42 | url="https://example.com/advisory", |
| 43 | ), |
| 44 | pipeline_id="ghsa_pipeline_v2", |
| 45 | datasource_id="ghsa", |
| 46 | logger=self.logger.write, |
| 47 | ) |
| 48 | self.advisory.save() |
| 49 | |
| 50 | self.package = PackageV2.objects.from_purl(purl="pkg:pypi/sample@1.0.0") |
| 51 | self.impact = ImpactedPackage.objects.create( |
| 52 | advisory=self.advisory, |
| 53 | base_purl="pkg:pypi/sample", |
| 54 | ) |
| 55 | self.impact.affecting_packages.add(self.package) |
| 56 | |
| 57 | self.client = APIClient(enforce_csrf_checks=True) |
| 58 | |
| 59 | self.allow_request_patcher = patch( |
| 60 | "vulnerabilities.throttling.PermissionBasedUserRateThrottle.allow_request", |
| 61 | return_value=True, |
| 62 | ) |
| 63 | self.allow_request_patcher.start() |
| 64 | self.addCleanup(self.allow_request_patcher.stop) |
| 65 | |
| 66 | self.anon_patcher = patch( |
| 67 | "rest_framework.throttling.AnonRateThrottle.allow_request", |
| 68 | return_value=True, |
| 69 | ) |
| 70 | self.anon_patcher.start() |
| 71 | self.addCleanup(self.anon_patcher.stop) |
| 72 | |
| 73 | def test_packages_post_without_details(self): |
| 74 | url = reverse("package-v3-list") |
nothing calls this directly
no test coverage detected