From 8a51f7470fd47e0b8f750100bf8f1f4082f63acf Mon Sep 17 00:00:00 2001 From: Alberto Leal Date: Fri, 21 Jul 2023 20:05:32 -0400 Subject: [PATCH] chore(hybrid-cloud): Mark Bitbucket webhook endpoint as region silo (#53380) --- src/sentry/integrations/bitbucket/webhook.py | 6 ++++-- tests/sentry/integrations/bitbucket/test_webhook.py | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sentry/integrations/bitbucket/webhook.py b/src/sentry/integrations/bitbucket/webhook.py index 68e63f812e40c..e4f5c493c5ce6 100644 --- a/src/sentry/integrations/bitbucket/webhook.py +++ b/src/sentry/integrations/bitbucket/webhook.py @@ -7,9 +7,9 @@ from django.utils import timezone from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt -from django.views.generic import View from rest_framework.request import Request +from sentry.api.base import Endpoint, region_silo_endpoint from sentry.integrations.bitbucket.constants import BITBUCKET_IP_RANGES, BITBUCKET_IPS from sentry.models import Commit, CommitAuthor, Organization, Repository from sentry.plugins.providers import IntegrationRepositoryProvider @@ -105,7 +105,9 @@ def __call__(self, organization, event): pass -class BitbucketWebhookEndpoint(View): +@region_silo_endpoint +class BitbucketWebhookEndpoint(Endpoint): + permission_classes = () _handlers = {"repo:push": PushEventWebhook} def get_handler(self, event_type): diff --git a/tests/sentry/integrations/bitbucket/test_webhook.py b/tests/sentry/integrations/bitbucket/test_webhook.py index 55b3e22301885..d903bc3f4b7b2 100644 --- a/tests/sentry/integrations/bitbucket/test_webhook.py +++ b/tests/sentry/integrations/bitbucket/test_webhook.py @@ -16,6 +16,7 @@ BITBUCKET_IP = "34.198.178.64" +@region_silo_test(stable=True) class WebhookBaseTest(APITestCase): endpoint = "sentry-extensions-bitbucket-webhook" @@ -67,11 +68,13 @@ def create_repository(self, **kwargs: Any) -> Repository: ) +@region_silo_test(stable=True) class WebhookGetTest(WebhookBaseTest): def test_get_request_fails(self): self.get_error_response(self.organization_id, status_code=405) +@region_silo_test(stable=True) class WebhookTest(WebhookBaseTest): method = "post" @@ -107,7 +110,7 @@ def test_invalid_signature_ip(self): ) -@region_silo_test +@region_silo_test(stable=True) class PushEventWebhookTest(WebhookBaseTest): method = "post"