Skip to content

Commit 634efdc

Browse files
tobias-wilfertarmenzg
authored andcommitted
feat(relay): Managed Relay for all (back-end) (#98696)
Back-end changes to make managed relay available for all. Front-end here: #98688 Ref: https://linear.app/getsentry/issue/INGEST-544/update-sentry
1 parent def9c98 commit 634efdc

File tree

4 files changed

+10
-47
lines changed

4 files changed

+10
-47
lines changed

src/sentry/api/endpoints/organization_relay_usage.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from rest_framework.request import Request
33
from rest_framework.response import Response
44

5-
from sentry import features
65
from sentry.api.api_owners import ApiOwner
76
from sentry.api.api_publish_status import ApiPublishStatus
87
from sentry.api.base import region_silo_endpoint
@@ -41,12 +40,7 @@ class OrganizationRelayUsage(OrganizationEndpoint):
4140
def get(self, request: Request, organization: Organization) -> Response:
4241
"""
4342
Return a list of trusted relays bound to an organization.
44-
45-
If the organization doesn't have Relay usage enabled it returns a 404.
4643
"""
47-
has_relays = features.has("organizations:relay", organization, actor=request.user)
48-
if not has_relays:
49-
return Response(status=404)
5044

5145
option_key = "sentry:trusted-relays"
5246
trusted_relays = organization.get_option(option_key)

src/sentry/core/endpoints/organization_details.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,6 @@ def validate_require2FA(self, value):
418418
return value
419419

420420
def validate_trustedRelays(self, value):
421-
from sentry import features
422-
423-
organization = self.context["organization"]
424-
request = self.context["request"]
425-
has_relays = features.has("organizations:relay", organization, actor=request.user)
426-
if not has_relays:
427-
raise serializers.ValidationError(
428-
"Organization does not have the relay feature enabled"
429-
)
430-
431421
# make sure we don't have multiple instances of one public key
432422
public_keys = set()
433423
if value is not None:

tests/sentry/api/endpoints/test_organization_relay_usage.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from sentry.models.relay import RelayUsage
77
from sentry.testutils.cases import APITestCase
8-
from sentry.testutils.helpers import with_feature
98

109

1110
class OrganizationRelayHistoryTest(APITestCase):
@@ -59,7 +58,6 @@ def setUp(self) -> None:
5958
for relay_data in self._history_fixture():
6059
RelayUsage.objects.create(**relay_data)
6160

62-
@with_feature("organizations:relay")
6361
def _set_org_public_keys(self, public_keys):
6462
self.login_as(user=self.user)
6563

@@ -73,7 +71,6 @@ def _set_org_public_keys(self, public_keys):
7371
resp = self.client.put(url, data=data)
7472
assert resp.status_code == 200
7573

76-
@with_feature("organizations:relay")
7774
def test_no_valid_public_keys(self) -> None:
7875
"""
7976
An organization with no valid public keys should return an
@@ -84,13 +81,11 @@ def test_no_valid_public_keys(self) -> None:
8481
response = self.get_success_response(self.organization.slug)
8582
assert response.data == []
8683

87-
@with_feature({"organizations:relay": False})
8884
def test_endpoint_checks_feature_present(self) -> None:
8985
self.login_as(user=self.user)
9086
resp = self.get_response(self.organization.slug)
91-
assert resp.status_code == 404
87+
assert resp.status_code == 200
9288

93-
@with_feature("organizations:relay")
9489
def test_only_records_for_known_public_keys_are_returned(self) -> None:
9590
"""
9691
Only the relay history for relays belonging to the origanization are

tests/sentry/core/endpoints/test_organization_details.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,10 @@ def test_trusted_relays_info(self) -> None:
259259

260260
data = {"trustedRelays": trusted_relays}
261261

262-
with self.feature("organizations:relay"):
263-
start_time = timezone.now()
264-
self.get_success_response(self.organization.slug, method="put", **data)
265-
end_time = timezone.now()
266-
response = self.get_success_response(self.organization.slug)
262+
start_time = timezone.now()
263+
self.get_success_response(self.organization.slug, method="put", **data)
264+
end_time = timezone.now()
265+
response = self.get_success_response(self.organization.slug)
267266

268267
response_data = response.data.get("trustedRelays")
269268

@@ -886,19 +885,6 @@ def test_setting_codecov_without_paid_plan_forbidden(self) -> None:
886885
data = {"codecovAccess": True}
887886
self.get_error_response(self.organization.slug, status_code=403, **data)
888887

889-
def test_setting_trusted_relays_forbidden(self) -> None:
890-
data = {
891-
"trustedRelays": [
892-
{"publicKey": _VALID_RELAY_KEYS[0], "name": "name1"},
893-
{"publicKey": _VALID_RELAY_KEYS[1], "name": "name2"},
894-
]
895-
}
896-
897-
with self.feature({"organizations:relay": False}):
898-
response = self.get_error_response(self.organization.slug, status_code=400, **data)
899-
900-
assert b"feature" in response.content
901-
902888
def test_setting_duplicate_trusted_keys(self) -> None:
903889
"""
904890
Test that you cannot set duplicated keys
@@ -928,8 +914,7 @@ def test_setting_duplicate_trusted_keys(self) -> None:
928914

929915
data = {"trustedRelays": trusted_relays}
930916

931-
with self.feature("organizations:relay"):
932-
response = self.get_error_response(self.organization.slug, status_code=400, **data)
917+
response = self.get_error_response(self.organization.slug, status_code=400, **data)
933918

934919
response_data = response.data.get("trustedRelays")
935920
assert response_data is not None
@@ -956,7 +941,7 @@ def test_creating_trusted_relays(self) -> None:
956941

957942
data = {"trustedRelays": trusted_relays}
958943

959-
with self.feature("organizations:relay"), outbox_runner():
944+
with outbox_runner():
960945
start_time = timezone.now()
961946
response = self.get_success_response(self.organization.slug, **data)
962947
end_time = timezone.now()
@@ -1040,7 +1025,7 @@ def test_modifying_trusted_relays(self) -> None:
10401025
initial_settings = {"trustedRelays": initial_trusted_relays}
10411026
changed_settings = {"trustedRelays": modified_trusted_relays}
10421027

1043-
with self.feature("organizations:relay"), outbox_runner():
1028+
with outbox_runner():
10441029
start_time = timezone.now()
10451030
self.get_success_response(self.organization.slug, **initial_settings)
10461031
after_initial = timezone.now()
@@ -1108,9 +1093,8 @@ def test_deleting_trusted_relays(self) -> None:
11081093
initial_settings = {"trustedRelays": initial_trusted_relays}
11091094
changed_settings: dict[str, Any] = {"trustedRelays": []}
11101095

1111-
with self.feature("organizations:relay"):
1112-
self.get_success_response(self.organization.slug, **initial_settings)
1113-
response = self.get_success_response(self.organization.slug, **changed_settings)
1096+
self.get_success_response(self.organization.slug, **initial_settings)
1097+
response = self.get_success_response(self.organization.slug, **changed_settings)
11141098

11151099
response_data = response.data.get("trustedRelays")
11161100

0 commit comments

Comments
 (0)