From 7036e356b615faa1785948560b714b49101c0a8b Mon Sep 17 00:00:00 2001 From: Davlat Davydov Date: Sat, 8 Aug 2026 22:41:23 +0300 Subject: [PATCH 1/2] chore(application): replace rights checking from interactor to ACS --- src/conode/application/services/access_control.py | 4 ++++ src/conode/application/verify_company/verify_company.py | 6 +----- tests/e2e/company/test_verify_company.py | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/conode/application/services/access_control.py b/src/conode/application/services/access_control.py index 0d18862..956f8a1 100644 --- a/src/conode/application/services/access_control.py +++ b/src/conode/application/services/access_control.py @@ -290,6 +290,10 @@ async def ensure_user_can_manipulate_groups( "Not enough rights to perform operation", None ) + def ensure_user_can_verify_companies(self, user: User) -> None: + if user.system_role != UserSystemRole.ADMIN: + raise NotEnoughRightsError("Not enough rights to perform operation", None) + def ensure_user_can_manipulate_user_profiles(self, user: User) -> None: if user.system_role != UserSystemRole.ADMIN: raise NotEnoughRightsError("Not enough rights to perform operation", None) diff --git a/src/conode/application/verify_company/verify_company.py b/src/conode/application/verify_company/verify_company.py index 601bf9a..c9c3c75 100644 --- a/src/conode/application/verify_company/verify_company.py +++ b/src/conode/application/verify_company/verify_company.py @@ -20,11 +20,7 @@ async def execute(self, company_id: CompanyId) -> None: async with self.transaction_manager: user = await self.access_control_service.get_authorized_user() - if not user.is_admin(): - raise NotEnoughRightsError( - "Not enough rights to perform operation", - [{"key": "user_id", "value": user.id}], - ) + self.access_control_service.ensure_user_can_verify_companies(user) company = await self.company_repository.get_by_id(company_id) if company is None: diff --git a/tests/e2e/company/test_verify_company.py b/tests/e2e/company/test_verify_company.py index fb11883..1640074 100644 --- a/tests/e2e/company/test_verify_company.py +++ b/tests/e2e/company/test_verify_company.py @@ -1,6 +1,7 @@ from http import HTTPStatus import pytest +from dirty_equals import IsPartialDict from httpx import AsyncClient from conode.application.interfaces.repositories import CompanyRepository @@ -49,3 +50,7 @@ async def test_verify_company_user_not_admin( assert response.status_code == HTTPStatus.FORBIDDEN assert not company.verified + assert response.json() == IsPartialDict( + detail="Not enough rights to perform operation", + meta=None, + ) From f34bc457311b5bc6ec2c96a0534938bd2bb6e5bd Mon Sep 17 00:00:00 2001 From: Davlat Davydov Date: Sat, 8 Aug 2026 22:43:43 +0300 Subject: [PATCH 2/2] fix: lint --- src/conode/application/verify_company/verify_company.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/conode/application/verify_company/verify_company.py b/src/conode/application/verify_company/verify_company.py index c9c3c75..1f11aba 100644 --- a/src/conode/application/verify_company/verify_company.py +++ b/src/conode/application/verify_company/verify_company.py @@ -2,7 +2,6 @@ from conode.application.errors import ( CompanyNotFoundError, - NotEnoughRightsError, ) from conode.application.interfaces.repositories import CompanyRepository from conode.application.interfaces.transaction_manager import TransactionManager