diff --git a/zerver/lib/user_groups.py b/zerver/lib/user_groups.py index 556c27e678..cea86ca868 100644 --- a/zerver/lib/user_groups.py +++ b/zerver/lib/user_groups.py @@ -11,9 +11,8 @@ def access_user_group_by_id(user_group_id: int, user_profile: UserProfile) -> Us try: user_group = UserGroup.objects.get(id=user_group_id, realm=user_profile.realm) group_member_ids = get_user_group_members(user_group) - msg = _("Only group members and organization administrators can administer this group.") if not user_profile.is_realm_admin and user_profile.id not in group_member_ids: - raise JsonableError(msg) + raise JsonableError(_("Insufficient permission")) except UserGroup.DoesNotExist: raise JsonableError(_("Invalid user group")) return user_group diff --git a/zerver/tests/test_user_groups.py b/zerver/tests/test_user_groups.py index dafb195094..490ef8899c 100644 --- a/zerver/tests/test_user_groups.py +++ b/zerver/tests/test_user_groups.py @@ -178,9 +178,7 @@ class UserGroupAPITestCase(ZulipTestCase): "description": "Troubleshooting", } result = self.client_patch(f"/json/user_groups/{user_group.id}", info=params) - self.assert_json_error( - result, "Only group members and organization administrators can administer this group." - ) + self.assert_json_error(result, "Insufficient permission") self.logout() # Test when organization admin tries to modify group @@ -264,9 +262,7 @@ class UserGroupAPITestCase(ZulipTestCase): self.login_user(cordelia) result = self.client_delete(f"/json/user_groups/{user_group.id}") - self.assert_json_error( - result, "Only group members and organization administrators can administer this group." - ) + self.assert_json_error(result, "Insufficient permission") self.assertEqual(UserGroup.objects.count(), 2) self.logout() @@ -333,9 +329,7 @@ class UserGroupAPITestCase(ZulipTestCase): add = [cordelia.id] params = {"add": orjson.dumps(add).decode()} result = self.client_post(f"/json/user_groups/{user_group.id}/members", info=params) - self.assert_json_error( - result, "Only group members and organization administrators can administer this group." - ) + self.assert_json_error(result, "Insufficient permission") self.assertEqual(UserGroupMembership.objects.count(), 4) self.logout() @@ -380,9 +374,7 @@ class UserGroupAPITestCase(ZulipTestCase): self.login_user(cordelia) params = {"delete": orjson.dumps([hamlet.id]).decode()} result = self.client_post(f"/json/user_groups/{user_group.id}/members", info=params) - self.assert_json_error( - result, "Only group members and organization administrators can administer this group." - ) + self.assert_json_error(result, "Insufficient permission") self.assertEqual(UserGroupMembership.objects.count(), 4) self.logout()