Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve/rename auditor #291

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions backend/app_tests/test_vars.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -44,8 +44,8 @@
},
"BI-UG-GAD": {
"folder": "Global",
"name": "Global_auditor",
"perms": AUDITOR_PERMISSIONS_LIST,
"name": "Global_reader",
"perms": READER_PERMISSIONS_LIST,
},
"BI-UG-GAP": {
"folder": "Global",
Expand All @@ -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",
Expand Down
18 changes: 9 additions & 9 deletions backend/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -251,8 +251,8 @@ def startup(**kwargs):

print("startup handler: initialize database")

auditor_permissions = Permission.objects.filter(
codename__in=AUDITOR_PERMISSIONS_LIST
reader_permissions = Permission.objects.filter(
codename__in=READER_PERMISSIONS_LIST
)

approver_permissions = Permission.objects.filter(
Expand All @@ -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)
Expand All @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions backend/core/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions backend/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ 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


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
Expand All @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ 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(
name=UserGroupCodename.AUDITOR, folder=folder, builtin=True
readers = UserGroup.objects.create(
name=UserGroupCodename.READER, folder=folder, builtin=True
)
approvers = UserGroup.objects.create(
name=UserGroupCodename.APPROVER, folder=folder, builtin=True
Expand All @@ -916,8 +916,8 @@ def perform_create(self, serializer):
name=UserGroupCodename.DOMAIN_MANAGER, folder=folder, builtin=True
)
ra1 = RoleAssignment.objects.create(
user_group=auditors,
role=Role.objects.get(name=RoleCodename.AUDITOR),
user_group=readers,
role=Role.objects.get(name=RoleCodename.READER),
builtin=True,
folder=Folder.get_root_folder(),
is_recursive=True,
Expand Down
2 changes: 1 addition & 1 deletion frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"extraLarge": "Extra-large",
"rid": "RID",
"scope": "Scope",
"auditor": "Auditor",
"reader": "Reader",
"lastUpdate": "Last update",
"riskScenarioAssetHelpText": "Assets impacted by this risk scenario",
"riskScenarioMeasureHelpText": "The existing applied controls to manage this risk",
Expand Down
2 changes: 1 addition & 1 deletion frontend/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"extraLarge": "Très grand",
"rid": "RID",
"scope": "Périmètre",
"auditor": "Auditeur",
"reader": "Auditeur",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translation in french stays the same @eric-intuitem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Solved.

"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",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
4 changes: 2 additions & 2 deletions frontend/tests/utils/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export default {
"view_user",
]
},
auditor: {
name: 'Auditor',
reader: {
name: 'Reader',
perms: [
"view_project",
"view_riskassessment",
Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
],
Expand Down
Loading