Skip to content

Commit 961dd07

Browse files
committed
postpone rpc_user param until next change
1 parent 1fb026e commit 961dd07

File tree

6 files changed

+7
-118
lines changed

6 files changed

+7
-118
lines changed

src/sentry/sentry_apps/api/endpoints/installation_external_issue_details.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
)
99
from sentry.sentry_apps.services.cell import sentry_app_cell_service
1010
from sentry.sentry_apps.utils.errors import SentryAppError
11-
from sentry.users.services.user.serial import serialize_generic_user
1211

1312

1413
@control_silo_endpoint
@@ -26,15 +25,14 @@ def delete(self, request: Request, installation, external_issue_id) -> Response:
2625
status_code=400,
2726
)
2827

29-
rpc_user = serialize_generic_user(request.user)
30-
if rpc_user is None:
28+
if not request.user.is_authenticated:
3129
return Response({"detail": "Authentication credentials were not provided."}, status=401)
3230

31+
# Do not pass `user` until cells accept the new RPC arg everywhere (deploy phase 2).
3332
result = sentry_app_cell_service.delete_external_issue(
3433
organization_id=installation.organization_id,
3534
installation=installation,
3635
external_issue_id=external_issue_id,
37-
user=rpc_user,
3836
)
3937

4038
if result.error:

src/sentry/sentry_apps/api/endpoints/installation_external_issues.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
PlatformExternalIssueSerializer as ResponsePlatformExternalIssueSerializer,
1515
)
1616
from sentry.sentry_apps.services.cell import sentry_app_cell_service
17-
from sentry.users.services.user.serial import serialize_generic_user
1817

1918

2019
class PlatformExternalIssueSerializer(serializers.Serializer):
@@ -42,18 +41,17 @@ def post(self, request: Request, installation) -> Response:
4241
except Exception:
4342
return Response({"detail": "issueId is required, and must be an integer"}, status=400)
4443

45-
rpc_user = serialize_generic_user(request.user)
46-
if rpc_user is None:
44+
if not request.user.is_authenticated:
4745
return Response({"detail": "Authentication credentials were not provided."}, status=401)
4846

47+
# Do not pass `user` until cells accept the new RPC arg everywhere (deploy phase 2).
4948
result = sentry_app_cell_service.create_external_issue(
5049
organization_id=installation.organization_id,
5150
installation=installation,
5251
group_id=group_id,
5352
web_url=data["webUrl"],
5453
project=data["project"],
5554
identifier=data["identifier"],
56-
user=rpc_user,
5755
)
5856

5957
if result.error:

src/sentry/sentry_apps/api/endpoints/installation_external_requests.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from sentry.sentry_apps.api.bases.sentryapps import SentryAppInstallationBaseEndpoint
1111
from sentry.sentry_apps.services.app.model import RpcSentryAppInstallation
1212
from sentry.sentry_apps.services.cell import sentry_app_cell_service
13-
from sentry.users.services.user.serial import serialize_generic_user
1413

1514
logger = logging.getLogger("sentry.sentry-apps")
1615

@@ -27,8 +26,7 @@ def get(self, request: Request, installation: RpcSentryAppInstallation) -> Respo
2726
if not uri:
2827
return Response({"detail": "uri query parameter is required"}, status=400)
2928

30-
rpc_user = serialize_generic_user(request.user)
31-
if rpc_user is None:
29+
if not request.user.is_authenticated:
3230
return Response({"detail": "Authentication credentials were not provided."}, status=401)
3331

3432
project_id: int | None = None
@@ -39,11 +37,11 @@ def get(self, request: Request, installation: RpcSentryAppInstallation) -> Respo
3937
except (TypeError, ValueError):
4038
return Response({"detail": "projectId must be an integer"}, status=400)
4139

40+
# Do not pass `user` until cells accept the new RPC arg everywhere (deploy phase 2).
4241
result = sentry_app_cell_service.get_select_options(
4342
organization_id=installation.organization_id,
4443
installation=installation,
4544
uri=request.GET.get("uri"),
46-
user=rpc_user,
4745
project_id=project_id,
4846
query=request.GET.get("query"),
4947
dependent_data=request.GET.get("dependentData"),

tests/sentry/sentry_apps/api/endpoints/test_sentry_app_installation_external_issue_details.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from sentry.models.organization import Organization
21
from sentry.sentry_apps.models.platformexternalissue import PlatformExternalIssue
32
from sentry.testutils.cases import APITestCase
43
from sentry.testutils.silo import assume_test_silo_mode_of, control_silo_test
@@ -72,43 +71,3 @@ def test_handles_invalid_external_issue_id_format(self) -> None:
7271
# Ensure the external issue still exists after failed attempts
7372
with assume_test_silo_mode_of(PlatformExternalIssue):
7473
assert PlatformExternalIssue.objects.filter(id=self.external_issue.id).exists()
75-
76-
def test_rejects_delete_without_project_access(self) -> None:
77-
with assume_test_silo_mode_of(Organization):
78-
self.org.flags.allow_joinleave = False
79-
self.org.save()
80-
81-
user_team = self.create_team(organization=self.org, name="sed-user-team")
82-
other_team = self.create_team(organization=self.org, name="sed-other-team")
83-
self.create_project(organization=self.org, teams=[user_team], name="sed-user-proj")
84-
other_project = self.create_project(
85-
organization=self.org, teams=[other_team], name="sed-other-proj"
86-
)
87-
other_group = self.create_group(project=other_project)
88-
89-
limited_user = self.create_user()
90-
self.create_member(
91-
organization=self.org,
92-
user=limited_user,
93-
role="member",
94-
teams=[user_team],
95-
teamRole="admin",
96-
)
97-
98-
with assume_test_silo_mode_of(PlatformExternalIssue):
99-
other_external_issue = PlatformExternalIssue.objects.create(
100-
group_id=other_group.id,
101-
project_id=other_project.id,
102-
service_type=self.sentry_app.slug,
103-
display_name="Other#1",
104-
web_url="https://example.com/o/1",
105-
)
106-
107-
self.login_as(user=limited_user)
108-
self.get_error_response(
109-
self.install.uuid,
110-
other_external_issue.id,
111-
status_code=403,
112-
)
113-
with assume_test_silo_mode_of(PlatformExternalIssue):
114-
assert PlatformExternalIssue.objects.filter(id=other_external_issue.id).exists()

tests/sentry/sentry_apps/api/endpoints/test_sentry_app_installation_external_issues.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from django.urls import reverse
44

5-
from sentry.models.organization import Organization
65
from sentry.sentry_apps.models.platformexternalissue import PlatformExternalIssue
76
from sentry.testutils.cases import APITestCase
87
from sentry.testutils.silo import assume_test_silo_mode_of, control_silo_test
@@ -77,40 +76,6 @@ def test_invalid_group_id(self) -> None:
7776

7877
assert response.status_code == 404
7978

80-
def test_rejects_issue_from_inaccessible_project(self) -> None:
81-
self._set_up_sentry_app("Testin", ["event:write"])
82-
with assume_test_silo_mode_of(Organization):
83-
self.org.flags.allow_joinleave = False
84-
self.org.save()
85-
86-
user_team = self.create_team(organization=self.org, name="sei-user-team")
87-
other_team = self.create_team(organization=self.org, name="sei-other-team")
88-
self.create_project(organization=self.org, teams=[user_team], name="sei-user-proj")
89-
other_project = self.create_project(
90-
organization=self.org, teams=[other_team], name="sei-other-proj"
91-
)
92-
other_group = self.create_group(project=other_project)
93-
94-
limited_user = self.create_user()
95-
self.create_member(
96-
organization=self.org,
97-
user=limited_user,
98-
role="member",
99-
teams=[user_team],
100-
teamRole="admin",
101-
)
102-
103-
data = self._post_data()
104-
data["issueId"] = other_group.id
105-
106-
self.login_as(user=limited_user)
107-
response = self.client.post(self.url, data=data)
108-
109-
assert response.status_code == 403
110-
assert response.data["detail"] == (
111-
"You do not have permission to create an external issue for this issue."
112-
)
113-
11479
def test_invalid_scopes(self) -> None:
11580
self._set_up_sentry_app("Testin", ["project:read"])
11681
data = self._post_data()

tests/sentry/sentry_apps/api/endpoints/test_sentry_app_installation_external_requests.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
from django.utils.http import urlencode
55
from responses.matchers import query_string_matcher
66

7-
from sentry.models.organization import Organization
87
from sentry.testutils.cases import APITestCase
9-
from sentry.testutils.silo import assume_test_silo_mode_of, control_silo_test
8+
from sentry.testutils.silo import control_silo_test
109

1110

1211
@control_silo_test
@@ -95,34 +94,6 @@ def test_external_request_fails(self) -> None:
9594
response = self.client.get(url, format="json")
9695
assert response.status_code == 500
9796

98-
def test_rejects_project_id_without_access(self) -> None:
99-
with assume_test_silo_mode_of(Organization):
100-
self.org.flags.allow_joinleave = False
101-
self.org.save()
102-
103-
user_team = self.create_team(organization=self.org, name="ser-user-team")
104-
other_team = self.create_team(organization=self.org, name="ser-other-team")
105-
self.create_project(organization=self.org, teams=[user_team], name="ser-user-proj")
106-
other_project = self.create_project(
107-
organization=self.org, teams=[other_team], name="ser-other-proj"
108-
)
109-
110-
limited_user = self.create_user()
111-
self.create_member(
112-
organization=self.org,
113-
user=limited_user,
114-
role="member",
115-
teams=[user_team],
116-
teamRole="admin",
117-
)
118-
119-
self.login_as(user=limited_user)
120-
url = self.url + f"?projectId={other_project.id}&uri=/get-projects&query=proj"
121-
response = self.client.get(url, format="json")
122-
123-
assert response.status_code == 403
124-
assert response.data["detail"] == "You do not have permission to access this project."
125-
12697
def test_invalid_project_id_returns_400(self) -> None:
12798
self.login_as(user=self.user)
12899
url = self.url + "?projectId=not-an-int&uri=/get-projects&query=proj"

0 commit comments

Comments
 (0)