Skip to content

Commit

Permalink
Adjust SerializeMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Jun 18, 2024
1 parent 4a2fb83 commit 07dd2bd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions unittests/dojo_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions unittests/test_apiv2_scan_import_options.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion unittests/test_importers_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions unittests/test_rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -130,7 +129,7 @@
UserContactInfo,
)

from .dojo_test_case import DojoAPITestCase
from .dojo_test_case import DojoAPITestCase, SerializeZapSample

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 07dd2bd

Please sign in to comment.