|
35 | 35 | --output trivy-alpine-3.17-sbom.json alpine:3.17.0 |
36 | 36 |
|
37 | 37 | 2. Save the SBOM file under: |
38 | | - tests/data/sca-integrations/ |
| 38 | + tests/data/integrations-sca/ |
39 | 39 |
|
40 | | -3. Add expected counts for that SBOM to ``SCA_INTEGRATIONS_TEST_DATA`` below. |
| 40 | +3. Add expected counts for that SBOM to `TEST_DATA`` below. |
41 | 41 |
|
42 | 42 | Example: |
43 | 43 | "trivy-alpine-3.17-sbom.json": { |
|
55 | 55 |
|
56 | 56 | 4. Run the test suite: |
57 | 57 |
|
58 | | - ./manage.py test scanpipe.tests.test_sca_integrations |
| 58 | + ./manage.py test scanpipe.tests.test_integrations_sca |
59 | 59 |
|
60 | 60 | 5. Commit both the SBOM file and dictionary entry. |
61 | 61 |
|
|
76 | 76 | # - ``packages_vulnerable``: Vulnerable DiscoveredPackages |
77 | 77 | # - ``dependencies``: DiscoveredDependencies |
78 | 78 | # - ``purls``: The list of PURLs present in the SBOM |
79 | | -SCA_INTEGRATIONS_TEST_DATA = { |
| 79 | +TEST_DATA = { |
80 | 80 | ### Anchore Grype |
81 | 81 | # $ grype -v -o cyclonedx-json \ |
82 | 82 | # --file anchore-alpine-3.17-sbom.json alpine:3.17.0 |
|
349 | 349 | } |
350 | 350 |
|
351 | 351 |
|
352 | | -class ScanPipeSCAIntegrationsTest(TestCase): |
| 352 | +class ScanPipeIntegrationsBaseTest(TestCase): |
353 | 353 | """ |
354 | 354 | Run consistency checks across all SBOM integration test files. |
355 | 355 |
|
356 | | - For each SBOM listed in ``SCA_INTEGRATIONS_TEST_DATA``, this test: |
| 356 | + For each SBOM listed in ``TEST_DATA``, this test: |
357 | 357 | - Loads the SBOM into a temporary ScanCode.io project. |
358 | 358 | - Executes the ``load_sbom`` pipeline. |
359 | 359 | - Verifies that the number of resources, packages, vulnerable packages, |
360 | 360 | and dependencies match the expected values. |
361 | 361 | """ |
362 | 362 |
|
363 | | - data = Path(__file__).parent / "data" |
364 | | - |
365 | | - def test_scanpipe_sca_integrations_tools(self): |
366 | | - """Loop through all SBOM files and run integration checks.""" |
367 | | - for sbom_filename, expected_results in SCA_INTEGRATIONS_TEST_DATA.items(): |
368 | | - self._test_scanpipe_sca_integrations_tool(sbom_filename, expected_results) |
| 363 | + data = None |
369 | 364 |
|
370 | 365 | def _test_scanpipe_sca_integrations_tool(self, sbom_filename, expected_results): |
371 | 366 | """Run a single SBOM integration test.""" |
372 | | - input_location = self.data / "sca-integrations" / sbom_filename |
| 367 | + input_location = self.data / sbom_filename |
373 | 368 |
|
374 | 369 | # Create a fresh project and load the SBOM into it |
375 | 370 | project = make_project() |
@@ -410,3 +405,12 @@ def _test_scanpipe_sca_integrations_tool(self, sbom_filename, expected_results): |
410 | 405 | purls_diff = benchmark.compare_purls(project, expected_purls) |
411 | 406 | formatted_diff = "\n".join(purls_diff) |
412 | 407 | self.assertFalse(purls_diff, msg=f"\n{sbom_filename}\n{formatted_diff}") |
| 408 | + |
| 409 | + |
| 410 | +class ScanPipeIntegrationsSCAToolsTest(ScanPipeIntegrationsBaseTest): |
| 411 | + data = Path(__file__).parent / "data" / "integrations-sca" |
| 412 | + |
| 413 | + def test_scanpipe_integrations_sca_tools(self): |
| 414 | + """Loop through all SBOM files and run integration checks.""" |
| 415 | + for sbom_filename, expected_results in TEST_DATA.items(): |
| 416 | + self._test_scanpipe_sca_integrations_tool(sbom_filename, expected_results) |
0 commit comments