diff --git a/vulnerabilities/tests/conftest.py b/vulnerabilities/tests/conftest.py index de7bb560a..bfd59e045 100644 --- a/vulnerabilities/tests/conftest.py +++ b/vulnerabilities/tests/conftest.py @@ -25,7 +25,6 @@ def no_rmtree(monkeypatch): # Step 2: Run test for importer only if it is activated (pytestmark = pytest.mark.skipif(...)) # Step 3: Migrate all the tests collect_ignore = [ - "test_models.py", "test_package_managers.py", "test_ruby.py", "test_rust.py", diff --git a/vulnerabilities/tests/test_models.py b/vulnerabilities/tests/test_models.py index 0443a6968..1864d1e5c 100644 --- a/vulnerabilities/tests/test_models.py +++ b/vulnerabilities/tests/test_models.py @@ -20,6 +20,7 @@ from packageurl import PackageURL from univers import versions from univers.version_range import RANGE_CLASS_BY_SCHEMES +from univers.version_range import AlpineLinuxVersionRange from vulnerabilities import models from vulnerabilities.models import Alias @@ -62,8 +63,9 @@ def test_vulnerability_save_without_vulnerability_id(self): == 1 ) + @pytest.mark.django_db def test_cwe_not_present_in_weaknesses_db(self): - w1 = models.Weakness.objects.create(name="189") + w1 = models.Weakness.objects.create(cwe_id=189) assert w1.weakness is None assert w1.name is "" assert w1.description is "" @@ -239,7 +241,7 @@ def test_fixed_package_details(self): name="redis", version="4.1.1", ), - "closest_non_vulnerable": PackageURL( + "next_non_vulnerable": PackageURL( type="pypi", name="redis", version="5.0.0b1", @@ -255,26 +257,38 @@ def test_fixed_package_details(self): "vulnerabilities": [ { "vulnerability": self.vuln_VCID_g2fu_45jw_aaan, - "fixed_by_purl": PackageURL( - type="pypi", - namespace=None, - name="redis", - version="4.3.6", - qualifiers={}, - subpath=None, - ), - "fixed_by_purl_vulnerabilities": [self.vuln_VCID_rqe1_dkmg_aaad], + "fixed_by_package_details": [ + { + "fixed_by_purl": PackageURL( + type="pypi", + namespace=None, + name="redis", + version="4.3.6", + qualifiers={}, + subpath=None, + ), + "fixed_by_purl_vulnerabilities": [self.vuln_VCID_rqe1_dkmg_aaad], + } + ], + "fixed_by_purl": [], + "fixed_by_purl_vulnerabilities": [], }, { "vulnerability": self.vuln_VCID_rqe1_dkmg_aaad, - "fixed_by_purl": PackageURL( - type="pypi", - namespace=None, - name="redis", - version="5.0.0b1", - qualifiers={}, - subpath=None, - ), + "fixed_by_package_details": [ + { + "fixed_by_purl": PackageURL( + type="pypi", + namespace=None, + name="redis", + version="5.0.0b1", + qualifiers={}, + subpath=None, + ), + "fixed_by_purl_vulnerabilities": [], + } + ], + "fixed_by_purl": [], "fixed_by_purl_vulnerabilities": [], }, ], @@ -282,15 +296,6 @@ def test_fixed_package_details(self): assert searched_for_package_details == package_details - assert searched_for_package_details.get("closest_non_vulnerable") == PackageURL( - type="pypi", - namespace=None, - name="redis", - version="5.0.0b1", - qualifiers={}, - subpath=None, - ) - assert searched_for_package_details.get("latest_non_vulnerable") == PackageURL( type="pypi", namespace=None, @@ -401,6 +406,7 @@ def test_univers_version_class(self): pypi_package_version = RANGE_CLASS_BY_SCHEMES[pypi_package.type].version_class assert pypi_package_version == versions.PypiVersion + RANGE_CLASS_BY_SCHEMES["alpine"] = AlpineLinuxVersionRange alpine_version = RANGE_CLASS_BY_SCHEMES["alpine"].version_class assert alpine_version == versions.AlpineLinuxVersion