From a4e094489bfbb396f71f64886131a55c0d77fa0a Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene <90701924+Mohamed-Hacene@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:06:33 +0200 Subject: [PATCH 1/3] Update and rename unit-test-asfrm.yml to unit-test-ciso-assistant.yml --- .../{unit-test-asfrm.yml => unit-test-ciso-assistant.yml} | 1 + 1 file changed, 1 insertion(+) rename .github/workflows/{unit-test-asfrm.yml => unit-test-ciso-assistant.yml} (97%) diff --git a/.github/workflows/unit-test-asfrm.yml b/.github/workflows/unit-test-ciso-assistant.yml similarity index 97% rename from .github/workflows/unit-test-asfrm.yml rename to .github/workflows/unit-test-ciso-assistant.yml index dce6ec981..b347d617b 100644 --- a/.github/workflows/unit-test-asfrm.yml +++ b/.github/workflows/unit-test-ciso-assistant.yml @@ -49,6 +49,7 @@ jobs: echo EMAIL_PORT=1025 >> .env echo EMAIL_HOST_USER='' >> .env echo EMAIL_HOST_PASSWORD='' >> .env + echo DJANGO_SETTINGS_MODULE=ciso_assistant.settings >> .env #echo EMAIL_USE_TLS=False >> .env echo CISO_URL=http://127.0.0.1:8000 >> .env echo DEFAULT_FROM_EMAIL='ciso-assistant@alsigo.net' >> .env From cdbc07a0ee330a9ec1fa513887b26668a2bb6c23 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene <90701924+Mohamed-Hacene@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:12:10 +0200 Subject: [PATCH 2/3] Update test_utils.py --- cal/tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cal/tests/test_utils.py b/cal/tests/test_utils.py index 6f4ca72ce..a380fd61b 100644 --- a/cal/tests/test_utils.py +++ b/cal/tests/test_utils.py @@ -1,7 +1,7 @@ from cal.models import * from cal.utils import * from calendar import LocaleHTMLCalendar -from core.models import SecurityMeasure, RiskAcceptance +from core.models import SecurityMeasure import pytest """ From fe3b2f51cf35ae7031350f7e311b73bb34e609c7 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Mon, 2 Oct 2023 14:00:44 +0200 Subject: [PATCH 3/3] fix: unit test folder name used checking --- core/base_models.py | 11 ++++++++++- core/migrations/0018_alter_evidence_options.py | 17 +++++++++++++++++ iam/models.py | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 core/migrations/0018_alter_evidence_options.py diff --git a/core/base_models.py b/core/base_models.py index 17e342352..b0e37e0af 100644 --- a/core/base_models.py +++ b/core/base_models.py @@ -17,7 +17,16 @@ class Meta: def __str__(self) -> str: return self.name - + + def clean(self) -> None: + scope = self.get_scope() + field_errors = {} + _fields_to_check = self.fields_to_check if hasattr(self, 'fields_to_check') else ['name'] + if not self.is_unique_in_scope(scope=scope, fields_to_check=_fields_to_check): + field_errors['name'] = _('This name is already in use.') + super().clean() + if field_errors: + raise ValidationError(field_errors) class AbstractBaseModel(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) diff --git a/core/migrations/0018_alter_evidence_options.py b/core/migrations/0018_alter_evidence_options.py new file mode 100644 index 000000000..fb0fa012a --- /dev/null +++ b/core/migrations/0018_alter_evidence_options.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.5 on 2023-10-02 11:51 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0017_remove_evidence_ref_url'), + ] + + operations = [ + migrations.AlterModelOptions( + name='evidence', + options={'verbose_name': 'Evidence', 'verbose_name_plural': 'Evidences'}, + ), + ] diff --git a/iam/models.py b/iam/models.py index 178c4213f..3491b6697 100644 --- a/iam/models.py +++ b/iam/models.py @@ -82,7 +82,7 @@ def _get_root_folder(): return None -class Folder(AbstractBaseModel, I18nMixin, NameDescriptionMixin): +class Folder(I18nMixin, NameDescriptionMixin, AbstractBaseModel): """ A folder is a container for other folders or any object Folders are organized in a tree structure, with a single root folder Folders are the base perimeter for role assignments