diff --git a/unittests/dojo_test_case.py b/unittests/dojo_test_case.py index 1a4468c6f0..61c1c5a808 100644 --- a/unittests/dojo_test_case.py +++ b/unittests/dojo_test_case.py @@ -6,6 +6,7 @@ from itertools import chain from django.test import TestCase +from django.test.testcases import SerializeMixin from django.urls import reverse from django.utils import timezone from django.utils.http import urlencode @@ -41,6 +42,10 @@ def get_unit_tests_path(): return os.path.dirname(os.path.realpath(__file__)) +class SerializeZapSample(SerializeMixin): + lockfile = 'tests_zap_sample_xml' + + class DojoTestUtilsMixin: def get_test_admin(self, *args, **kwargs): diff --git a/unittests/test_apiv2_scan_import_options.py b/unittests/test_apiv2_scan_import_options.py index c3101b64f5..29951eca5a 100644 --- a/unittests/test_apiv2_scan_import_options.py +++ b/unittests/test_apiv2_scan_import_options.py @@ -1,13 +1,14 @@ from django.core.files.uploadedfile import SimpleUploadedFile -from django.test.testcases import SerializeMixin from django.urls import reverse from rest_framework.authtoken.models import Token from rest_framework.test import APIClient, APITestCase from dojo.models import Finding, Test, Test_Type +from .dojo_test_case import SerializeZapSample -class ScanImportOptionsTest(SerializeMixin, APITestCase): + +class ScanImportOptionsTest(SerializeZapSample, APITestCase): """ Test the options `skip_duplicates` and `close_old_findings` for the scan import APIv2 endpoint with ZAP diff --git a/unittests/test_importers_importer.py b/unittests/test_importers_importer.py index fe676ca757..f29ed482d9 100644 --- a/unittests/test_importers_importer.py +++ b/unittests/test_importers_importer.py @@ -517,7 +517,11 @@ def test_reimport_with_invalid_parameters(self): self.assertEqual(import0, ['product_name parameter missing']) -class TestImporterUtils(SerializeMixin, DojoAPITestCase): +class SerializedTestImporterUtils(SerializeMixin): + lockfile = __file__ + + +class TestImporterUtils(SerializedTestImporterUtils, DojoAPITestCase): def setUp(self): self.testuser, _ = User.objects.get_or_create(username="admin", is_superuser=True) token, _ = Token.objects.get_or_create(user=self.testuser) diff --git a/unittests/test_rest_framework.py b/unittests/test_rest_framework.py index 4d32c6ebe5..59c235ea95 100644 --- a/unittests/test_rest_framework.py +++ b/unittests/test_rest_framework.py @@ -9,7 +9,6 @@ from unittest.mock import ANY, MagicMock, call, patch from django.contrib.auth.models import Permission -from django.test.testcases import SerializeMixin from django.urls import reverse from drf_spectacular.drainage import GENERATOR_STATS from drf_spectacular.settings import spectacular_settings @@ -130,7 +129,7 @@ UserContactInfo, ) -from .dojo_test_case import DojoAPITestCase +from .dojo_test_case import DojoAPITestCase, SerializeZapSample logger = logging.getLogger(__name__) @@ -1764,7 +1763,7 @@ def test_user_should_not_have_access_to_product_3_in_detail(self): self.assertEqual(response.status_code, 404) -class ImportScanTest(SerializeMixin, BaseClass.BaseClassTest): +class ImportScanTest(SerializeZapSample, BaseClass.BaseClassTest): fixtures = ['dojo_testdata.json'] def __init__(self, *args, **kwargs): @@ -2018,7 +2017,7 @@ def test_create_authorized_product_name_engagement_name_auto_create_product_type reimporter_mock.assert_not_called() -class ReimportScanTest(SerializeMixin, DojoAPITestCase): +class ReimportScanTest(SerializeZapSample, DojoAPITestCase): fixtures = ['dojo_testdata.json'] def setUp(self): @@ -2696,7 +2695,7 @@ def __init__(self, *args, **kwargs): BaseClass.RESTEndpointTest.__init__(self, *args, **kwargs) -class ImportLanguagesTest(SerializeMixin, BaseClass.BaseClassTest): +class ImportLanguagesTest(BaseClass.BaseClassTest): fixtures = ['dojo_testdata.json'] def __init__(self, *args, **kwargs):