Skip to content

Commit a32ec08

Browse files
authored
Merge pull request #2775 from bcgov/DEP-238-super-admin-engagement-listing
DEP-238: Fix admin permission check when listing engagements
2 parents 9faacfc + c4a95b1 commit a32ec08

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

CHANGELOG.MD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
## March 12, 2026
2+
3+
- **Bugfix** Always let users with SUPER_ADMIN role list engagements, even if they don't have the VIEW_ENGAGEMENT permission. [🎟️ DEP-238](https://citz-gdx.atlassian.net/browse/DEP-238)
4+
- Updated the API endpoint for listing engagements to check for the SUPER_ADMIN role in addition to the VIEW_ENGAGEMENT permission and direct membership in the engagement. The role bypasses all other checks.
5+
- This ensures that users with the SUPER_ADMIN role can always list engagements, regardless of their specific permissions.
6+
17
## March 11, 2026
28

39
- Implemented Subscribe section of engagement authoring area [🎟️ DEP-227](https://citz-gdx.atlassian.net/browse/DEP-227)
410
- Added new fields to the API and database to support subscribe section data
511
- Populated form components in AuthoringSubscribe.tsx to allow users to input data for the subscribe section
612
- Modified AuthoringContext to include subscribe section data and actions for updating it
713

14+
815
## March 8, 2026
916

1017
- Added delete functionality to engagement section [🎟️ DEP-175](https://citz-gdx.atlassian.net/browse/DEP-175)

met-api/src/met_api/services/engagement_service.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,15 @@ def _attach_banner_url(self, engagements: list):
116116

117117
@staticmethod
118118
def _get_scope_options(user_roles, has_team_access):
119-
if Role.VIEW_PRIVATE_ENGAGEMENTS.value in user_roles:
119+
if Role.SUPER_ADMIN.value in user_roles or Role.VIEW_PRIVATE_ENGAGEMENTS.value in user_roles:
120+
# Super admins should always see all engagements within the current tenant.
120121
# If user has VIEW_PRIVATE_ENGAGEMENTS, e.g. Administrator role, return unrestricted scope options
121122
return EngagementScopeOptions(restricted=False)
122123
if has_team_access:
123124
# return those engagements where user has access for edit members..
124125
# either they have edit_member role or check if they are a team member
125-
has_edit_role = Role.EDIT_MEMBERS.value in user_roles
126-
if has_edit_role:
126+
if Role.EDIT_MEMBERS.value in user_roles:
127127
return EngagementScopeOptions(restricted=False)
128-
129128
# check if user
130129
return EngagementScopeOptions(include_assigned=True)
131130
if Role.VIEW_ENGAGEMENT.value in user_roles:

met-api/tests/unit/services/test_engagement.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from met_api.models import db
2626
from met_api.models.engagement import Engagement
27+
from met_api.utils.roles import Role
2728
from met_api.services import authorization
2829
from met_api.services.engagement_service import EngagementService
2930
from tests.utilities.factory_scenarios import TestEngagementInfo, TestJwtClaims
@@ -142,3 +143,18 @@ def test_delete_failure_production_environment(db, monkeypatch, mocker):
142143
'It is either read-protected or not readable by the server.')
143144

144145
assert expected in desc
146+
147+
148+
def test_get_scope_options_super_admin_unrestricted():
149+
"""Assert that super admin can list all tenant engagements."""
150+
scope_options = EngagementService._get_scope_options({Role.SUPER_ADMIN.value}, has_team_access=False)
151+
152+
assert scope_options.restricted is False
153+
assert scope_options.include_assigned is False
154+
155+
156+
def test_get_scope_options_super_admin_overrides_team_access():
157+
"""Assert super admin remains unrestricted even when team access filter is requested."""
158+
scope_options = EngagementService._get_scope_options({Role.SUPER_ADMIN.value}, has_team_access=True)
159+
160+
assert scope_options.restricted is False

0 commit comments

Comments
 (0)