diff --git a/rbac/management/group/view.py b/rbac/management/group/view.py index 8e2fe130..a1581ae8 100644 --- a/rbac/management/group/view.py +++ b/rbac/management/group/view.py @@ -48,7 +48,7 @@ from management.principal.it_service import ITService from management.principal.model import Principal from management.principal.proxy import PrincipalProxy -from management.principal.serializer import PrincipalSerializer, ServiceAccountSerializer +from management.principal.serializer import ServiceAccountSerializer from management.principal.view import ADMIN_ONLY_KEY, USERNAME_ONLY_KEY, VALID_BOOLEAN_VALUE from management.querysets import get_group_queryset, get_role_queryset from management.role.view import RoleViewSet @@ -807,25 +807,21 @@ def principals(self, request: Request, uuid: Optional[UUID] = None): return self.get_paginated_response(serializer.data) principals_from_params = self.filtered_principals(group, request) - page = self.paginate_queryset(principals_from_params) - serializer = PrincipalSerializer(page, many=True) - principal_data = serializer.data - if principal_data: - username_list = [principal["username"] for principal in principal_data] - else: - username_list = [] - proxy = PrincipalProxy() + username_list = [principal.username for principal in principals_from_params] admin_only = validate_and_get_key(request.query_params, ADMIN_ONLY_KEY, VALID_BOOLEAN_VALUE, False, False) if admin_only == "true": options[ADMIN_ONLY_KEY] = True + proxy = PrincipalProxy() if settings.AUTHENTICATE_WITH_ORG_ID: resp = proxy.request_filtered_principals(username_list, org_id=org_id, options=options) else: resp = proxy.request_filtered_principals(username_list, account=account, options=options) if isinstance(resp, dict) and "errors" in resp: return Response(status=resp.get("status_code"), data=resp.get("errors")) + + self.paginate_queryset(resp.get("data")) response = self.get_paginated_response(resp.get("data")) else: self.protect_system_groups("remove principals") diff --git a/tests/internal/integration/test_integration_views.py b/tests/internal/integration/test_integration_views.py index 9997cb04..d0b3b6c0 100644 --- a/tests/internal/integration/test_integration_views.py +++ b/tests/internal/integration/test_integration_views.py @@ -290,7 +290,16 @@ def test_roles_from_group_invalid_account(self): "username": "user_a", "account_number": "1111111", "is_active": True, - } + }, + { + "org_id": "100001", + "is_org_admin": False, + "is_internal": False, + "id": 52567474, + "username": "user_admin", + "account_number": "1111111", + "is_active": True, + }, ], }, )