From dd28f0e475b49e91294bc06f7e6c49bd94a4e5a3 Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:01:16 +0200 Subject: [PATCH 1/3] rename auditor -> reader wip --- backend/app_tests/test_vars.py | 8 ++++---- backend/core/apps.py | 4 ++-- backend/core/utils.py | 12 ++++++------ backend/core/views.py | 4 ++-- frontend/messages/en.json | 2 +- frontend/tests/utils/test-data.ts | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/backend/app_tests/test_vars.py b/backend/app_tests/test_vars.py index aa048b63a..bdda0ef8d 100644 --- a/backend/app_tests/test_vars.py +++ b/backend/app_tests/test_vars.py @@ -1,6 +1,6 @@ from typing import Any from core.apps import ( - AUDITOR_PERMISSIONS_LIST, + READER_PERMISSIONS_LIST, APPROVER_PERMISSIONS_LIST, ANALYST_PERMISSIONS_LIST, DOMAIN_MANAGER_PERMISSIONS_LIST, @@ -45,7 +45,7 @@ "BI-UG-GAD": { "folder": "Global", "name": "Global_auditor", - "perms": AUDITOR_PERMISSIONS_LIST, + "perms": READER_PERMISSIONS_LIST, }, "BI-UG-GAP": { "folder": "Global", @@ -54,8 +54,8 @@ }, "BI-UG-AUD": { "folder": "test", - "name": "Auditor", - "perms": AUDITOR_PERMISSIONS_LIST, + "name": "Reader", + "perms": READER_PERMISSIONS_LIST, }, "BI-UG-APP": { "folder": "test", diff --git a/backend/core/apps.py b/backend/core/apps.py index 4846d60cc..3541f25af 100644 --- a/backend/core/apps.py +++ b/backend/core/apps.py @@ -3,7 +3,7 @@ from ciso_assistant.settings import CISO_ASSISTANT_SUPERUSER_EMAIL import os -AUDITOR_PERMISSIONS_LIST = [ +READER_PERMISSIONS_LIST = [ "view_project", "view_riskassessment", "view_appliedcontrol", @@ -252,7 +252,7 @@ def startup(**kwargs): print("startup handler: initialize database") auditor_permissions = Permission.objects.filter( - codename__in=AUDITOR_PERMISSIONS_LIST + codename__in=READER_PERMISSIONS_LIST ) approver_permissions = Permission.objects.filter( diff --git a/backend/core/utils.py b/backend/core/utils.py index 7c6775169..8c65a4a77 100644 --- a/backend/core/utils.py +++ b/backend/core/utils.py @@ -14,7 +14,7 @@ class RoleCodename(Enum): DOMAIN_MANAGER = "BI-RL-DMA" ANALYST = "BI-RL-ANA" APPROVER = "BI-RL-APP" - AUDITOR = "BI-RL-AUD" + READER = "BI-RL-AUD" def __str__(self) -> str: return self.value @@ -22,12 +22,12 @@ def __str__(self) -> str: class UserGroupCodename(Enum): ADMINISTRATOR = "BI-UG-ADM" - GLOBAL_AUDITOR = "BI-UG-GAD" + GLOBAL_READER = "BI-UG-GAD" GLOBAL_APPROVER = "BI-UG-GAP" DOMAIN_MANAGER = "BI-UG-DMA" ANALYST = "BI-UG-ANA" APPROVER = "BI-UG-APP" - AUDITOR = "BI-UG-AUD" + READER = "BI-UG-AUD" def __str__(self) -> str: return self.value @@ -38,17 +38,17 @@ def __str__(self) -> str: str(RoleCodename.DOMAIN_MANAGER): _("Domain manager"), str(RoleCodename.ANALYST): _("Analyst"), str(RoleCodename.APPROVER): _("Approver"), - str(RoleCodename.AUDITOR): _("Auditor"), + str(RoleCodename.READER): _("Reader"), } BUILTIN_USERGROUP_CODENAMES = { str(UserGroupCodename.ADMINISTRATOR): _("Administrator"), - str(UserGroupCodename.GLOBAL_AUDITOR): _("Auditor"), + str(UserGroupCodename.GLOBAL_READER): _("Reader"), str(UserGroupCodename.GLOBAL_APPROVER): _("Approver"), str(UserGroupCodename.DOMAIN_MANAGER): _("Domain manager"), str(UserGroupCodename.ANALYST): _("Analyst"), str(UserGroupCodename.APPROVER): _("Approver"), - str(UserGroupCodename.AUDITOR): _("Auditor"), + str(UserGroupCodename.READER): _("Reader"), } COUNTRY_FLAGS = { diff --git a/backend/core/views.py b/backend/core/views.py index b53230040..ad31e0bb2 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -904,7 +904,7 @@ def perform_create(self, serializer): folder = Folder.objects.get(id=serializer.data["id"]) if folder.content_type == Folder.ContentType.DOMAIN: auditors = UserGroup.objects.create( - name=UserGroupCodename.AUDITOR, folder=folder, builtin=True + name=UserGroupCodename.READER, folder=folder, builtin=True ) approvers = UserGroup.objects.create( name=UserGroupCodename.APPROVER, folder=folder, builtin=True @@ -917,7 +917,7 @@ def perform_create(self, serializer): ) ra1 = RoleAssignment.objects.create( user_group=auditors, - role=Role.objects.get(name=RoleCodename.AUDITOR), + role=Role.objects.get(name=RoleCodename.READER), builtin=True, folder=Folder.get_root_folder(), is_recursive=True, diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 416d05a1c..3b6896058 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -367,7 +367,7 @@ "extraLarge": "Extra-large", "rid": "RID", "scope": "Scope", - "auditor": "Auditor", + "auditor": "Reader", "lastUpdate": "Last update", "riskScenarioAssetHelpText": "Assets impacted by this risk scenario", "riskScenarioMeasureHelpText": "The existing applied controls to manage this risk", diff --git a/frontend/tests/utils/test-data.ts b/frontend/tests/utils/test-data.ts index c0b948b06..abe634393 100644 --- a/frontend/tests/utils/test-data.ts +++ b/frontend/tests/utils/test-data.ts @@ -77,7 +77,7 @@ export default { ] }, auditor: { - name: 'Auditor', + name: 'Reader', perms: [ "view_project", "view_riskassessment", From e6f82d1ed94cd1cf4282972671819b0df934efa2 Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:09:52 +0200 Subject: [PATCH 2/3] finish replacing --- backend/app_tests/test_vars.py | 2 +- backend/core/apps.py | 14 +++++++------- backend/core/tests/test_helpers.py | 8 ++++---- backend/core/views.py | 4 ++-- frontend/messages/en.json | 2 +- frontend/messages/fr.json | 2 +- frontend/src/lib/utils/locales.ts | 2 +- frontend/tests/utils/test-data.ts | 2 +- frontend/tests/utils/test-utils.ts | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/backend/app_tests/test_vars.py b/backend/app_tests/test_vars.py index bdda0ef8d..fe9384a92 100644 --- a/backend/app_tests/test_vars.py +++ b/backend/app_tests/test_vars.py @@ -44,7 +44,7 @@ }, "BI-UG-GAD": { "folder": "Global", - "name": "Global_auditor", + "name": "Global_reader", "perms": READER_PERMISSIONS_LIST, }, "BI-UG-GAP": { diff --git a/backend/core/apps.py b/backend/core/apps.py index 3541f25af..9d49751c9 100644 --- a/backend/core/apps.py +++ b/backend/core/apps.py @@ -251,7 +251,7 @@ def startup(**kwargs): print("startup handler: initialize database") - auditor_permissions = Permission.objects.filter( + reader_permissions = Permission.objects.filter( codename__in=READER_PERMISSIONS_LIST ) @@ -277,8 +277,8 @@ def startup(**kwargs): name="Global", content_type=Folder.ContentType.ROOT, builtin=True ) # update builtin roles to facilitate migrations - auditor, created = Role.objects.get_or_create(name="BI-RL-AUD", builtin=True) - auditor.permissions.set(auditor_permissions) + reader, created = Role.objects.get_or_create(name="BI-RL-AUD", builtin=True) + reader.permissions.set(reader_permissions) approver, created = Role.objects.get_or_create(name="BI-RL-APP", builtin=True) approver.permissions.set(approver_permissions) analyst, created = Role.objects.get_or_create(name="BI-RL-ANA", builtin=True) @@ -302,23 +302,23 @@ def startup(**kwargs): folder=Folder.get_root_folder(), ) ra1.perimeter_folders.add(administrators.folder) - # if global auditors user group does not exist, then create it + # if global readers user group does not exist, then create it if not UserGroup.objects.filter( name="BI-UG-GAD", folder=Folder.get_root_folder() ).exists(): - global_auditors = UserGroup.objects.create( + global_readers = UserGroup.objects.create( name="BI-UG-GAD", folder=Folder.objects.get(content_type=Folder.ContentType.ROOT), builtin=True, ) ra2 = RoleAssignment.objects.create( - user_group=global_auditors, + user_group=global_readers, role=Role.objects.get(name="BI-RL-AUD"), is_recursive=True, builtin=True, folder=Folder.get_root_folder(), ) - ra2.perimeter_folders.add(global_auditors.folder) + ra2.perimeter_folders.add(global_readers.folder) # if global approvers user group does not exist, then create it if not UserGroup.objects.filter( name="BI-UG-GAP", folder=Folder.get_root_folder() diff --git a/backend/core/tests/test_helpers.py b/backend/core/tests/test_helpers.py index 8068e4db2..ef5abe66b 100644 --- a/backend/core/tests/test_helpers.py +++ b/backend/core/tests/test_helpers.py @@ -44,7 +44,7 @@ def test_get_rating_options_perm_to_view_matrix(): ) RiskScenario.objects.create(name="test", risk_assessment=risk_assessment) role = Role.objects.create(name="test") - auditor_permissions = Permission.objects.filter( + reader_permissions = Permission.objects.filter( codename__in=[ "view_project", "view_riskassessment", @@ -58,7 +58,7 @@ def test_get_rating_options_perm_to_view_matrix(): "view_usergroup", ] ) - role.permissions.set(auditor_permissions) + role.permissions.set(reader_permissions) role.save() role_assignment = RoleAssignment.objects.create( user=user, @@ -109,7 +109,7 @@ def test_get_rating_options_abbr_perm_to_view_matrix(): ) RiskScenario.objects.create(name="test", risk_assessment=risk_assessment) role = Role.objects.create(name="test") - auditor_permissions = Permission.objects.filter( + reader_permissions = Permission.objects.filter( codename__in=[ "view_project", "view_riskassessment", @@ -123,7 +123,7 @@ def test_get_rating_options_abbr_perm_to_view_matrix(): "view_usergroup", ] ) - role.permissions.set(auditor_permissions) + role.permissions.set(reader_permissions) role.save() role_assignment = RoleAssignment.objects.create( user=user, diff --git a/backend/core/views.py b/backend/core/views.py index ad31e0bb2..da1613d8b 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -903,7 +903,7 @@ def perform_create(self, serializer): serializer.save() folder = Folder.objects.get(id=serializer.data["id"]) if folder.content_type == Folder.ContentType.DOMAIN: - auditors = UserGroup.objects.create( + readers = UserGroup.objects.create( name=UserGroupCodename.READER, folder=folder, builtin=True ) approvers = UserGroup.objects.create( @@ -916,7 +916,7 @@ def perform_create(self, serializer): name=UserGroupCodename.DOMAIN_MANAGER, folder=folder, builtin=True ) ra1 = RoleAssignment.objects.create( - user_group=auditors, + user_group=readers, role=Role.objects.get(name=RoleCodename.READER), builtin=True, folder=Folder.get_root_folder(), diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 3b6896058..640a9ef50 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -367,7 +367,7 @@ "extraLarge": "Extra-large", "rid": "RID", "scope": "Scope", - "auditor": "Reader", + "reader": "Reader", "lastUpdate": "Last update", "riskScenarioAssetHelpText": "Assets impacted by this risk scenario", "riskScenarioMeasureHelpText": "The existing applied controls to manage this risk", diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 1d605e939..bbac559fe 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -367,7 +367,7 @@ "extraLarge": "Très grand", "rid": "RID", "scope": "Périmètre", - "auditor": "Auditeur", + "reader": "Auditeur", "lastUpdate": "Dernière mise à jour", "riskScenarioAssetHelpText": "Biens sensibles impactés par ce scénario de risque", "riskScenarioMeasureHelpText": "Les mesures appliquées existantes pour gérer ce risque", diff --git a/frontend/src/lib/utils/locales.ts b/frontend/src/lib/utils/locales.ts index 22b921956..9f31a74fc 100644 --- a/frontend/src/lib/utils/locales.ts +++ b/frontend/src/lib/utils/locales.ts @@ -300,7 +300,7 @@ export function localItems(languageTag: string): LocalItems { notApplicable: m.notApplicable({ languageTag: languageTag }), administrator: m.administrator({ languageTag: languageTag }), analyst: m.analyst({ languageTag: languageTag }), - auditor: m.auditor({ languageTag: languageTag }), + reader: m.reader({ languageTag: languageTag }), domainManager: m.domainManager({ languageTag: languageTag }), authors: m.authors({ languageTag: languageTag }), reviewers: m.reviewers({ languageTag: languageTag }), diff --git a/frontend/tests/utils/test-data.ts b/frontend/tests/utils/test-data.ts index abe634393..687ccd051 100644 --- a/frontend/tests/utils/test-data.ts +++ b/frontend/tests/utils/test-data.ts @@ -76,7 +76,7 @@ export default { "view_user", ] }, - auditor: { + reader: { name: 'Reader', perms: [ "view_project", diff --git a/frontend/tests/utils/test-utils.ts b/frontend/tests/utils/test-utils.ts index d33a189a5..b826b5721 100644 --- a/frontend/tests/utils/test-utils.ts +++ b/frontend/tests/utils/test-utils.ts @@ -359,7 +359,7 @@ export class TestContent { last_name: vars.user.lastName, user_groups: [ `${vars.folderName} - ${vars.usergroups.analyst.name}`, - `${vars.folderName} - ${vars.usergroups.auditor.name}`, + `${vars.folderName} - ${vars.usergroups.reader.name}`, `${vars.folderName} - ${vars.usergroups.domainManager.name}`, `${vars.folderName} - ${vars.usergroups.approver.name}` ], From 1c1f1c9ecc4a83b6d17e048f56ee66613d488ba9 Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Fri, 19 Apr 2024 05:40:42 +0200 Subject: [PATCH 3/3] Update fr.json add missing translation --- frontend/messages/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index bbac559fe..402a194a7 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -367,7 +367,7 @@ "extraLarge": "Très grand", "rid": "RID", "scope": "Périmètre", - "reader": "Auditeur", + "reader": "Lecteur", "lastUpdate": "Dernière mise à jour", "riskScenarioAssetHelpText": "Biens sensibles impactés par ce scénario de risque", "riskScenarioMeasureHelpText": "Les mesures appliquées existantes pour gérer ce risque",