|
22 | 22 |
|
23 | 23 |
|
24 | 24 | class NVDServiceTests(TestCase): |
| 25 | + @override_settings(VULN_INTEL_RUST_ONLY=False) |
25 | 26 | def test_import_cve_collection_upserts_records(self): |
26 | 27 | payload = { |
27 | 28 | 'totalResults': 1, |
@@ -52,6 +53,10 @@ def test_import_cve_collection_upserts_records(self): |
52 | 53 | self.assertEqual(result['imported_records'], 1) |
53 | 54 | self.assertEqual(CVERecord.objects.filter(cve_id='CVE-2026-0001').count(), 1) |
54 | 55 |
|
| 56 | + def test_import_cve_collection_rejects_python_path_when_rust_only_enabled(self): |
| 57 | + with self.assertRaisesRegex(RuntimeError, 'Python-NVD-Collection-Import'): |
| 58 | + NVDService.import_cve_collection(results_per_page=1, max_pages=1) |
| 59 | + |
55 | 60 | def test_request_payload_retries_on_http_429(self): |
56 | 61 | query = {'cveId': 'CVE-2026-0002'} |
57 | 62 | response_mock = Mock() |
@@ -313,6 +318,56 @@ def test_import_via_rust_delegates_to_rust_cli(self): |
313 | 318 | mocked.assert_called_once() |
314 | 319 |
|
315 | 320 |
|
| 321 | +class RustPrimaryCollectionCommandTests(TestCase): |
| 322 | + def test_import_nvd_cves_delegates_collection_import_to_rust_cli(self): |
| 323 | + with patch( |
| 324 | + 'apps.vulnerability_intelligence.management.commands.import_nvd_cves.run_rust_canary', |
| 325 | + return_value='{"seen_records":1,"imported_records":1}', |
| 326 | + ) as mocked: |
| 327 | + call_command( |
| 328 | + 'import_nvd_cves', |
| 329 | + '--results-per-page=10', |
| 330 | + '--max-pages=2', |
| 331 | + '--has-kev', |
| 332 | + '--skip-healthcheck', |
| 333 | + ) |
| 334 | + |
| 335 | + mocked.assert_called_once_with( |
| 336 | + subcommand='import-collection', |
| 337 | + args=[ |
| 338 | + '--results-per-page', '10', |
| 339 | + '--max-pages', '2', |
| 340 | + '--has-kev', |
| 341 | + '--skip-healthcheck', |
| 342 | + ], |
| 343 | + ) |
| 344 | + |
| 345 | + def test_sync_nvd_recent_delegates_recent_sync_to_rust_cli(self): |
| 346 | + with patch( |
| 347 | + 'apps.vulnerability_intelligence.management.commands.sync_nvd_recent.run_rust_canary', |
| 348 | + return_value='{"seen_records":1,"imported_records":1}', |
| 349 | + ) as mocked: |
| 350 | + call_command( |
| 351 | + 'sync_nvd_recent', |
| 352 | + '--hours=6', |
| 353 | + '--results-per-page=25', |
| 354 | + '--max-pages=3', |
| 355 | + '--cve-tag=disputed', |
| 356 | + '--skip-healthcheck', |
| 357 | + ) |
| 358 | + |
| 359 | + mocked.assert_called_once_with( |
| 360 | + subcommand='sync-recent', |
| 361 | + args=[ |
| 362 | + '--hours', '6', |
| 363 | + '--results-per-page', '25', |
| 364 | + '--max-pages', '3', |
| 365 | + '--cve-tag', 'disputed', |
| 366 | + '--skip-healthcheck', |
| 367 | + ], |
| 368 | + ) |
| 369 | + |
| 370 | + |
316 | 371 | class CanaryParityReportTests(TestCase): |
317 | 372 | @override_settings(RUST_BACKEND_URL='http://rust-backend:9000') |
318 | 373 | def test_report_command_delegates_to_rust_cli(self): |
|
0 commit comments