|
@@ -2,6 +2,7 @@ from unittest.mock import MagicMock, patch
|
|
|
|
|
|
import pytest
|
|
|
from django.test import RequestFactory
|
|
|
+from django.urls import reverse
|
|
|
|
|
|
from sentry.integrations.slack.requests.command import SlackCommandRequest
|
|
|
from sentry.middleware.integrations.integration_control import IntegrationControlMiddleware
|
|
@@ -19,7 +20,6 @@ class SlackRequestParserTest(TestCase):
|
|
|
get_response = MagicMock()
|
|
|
middleware = IntegrationControlMiddleware(get_response)
|
|
|
factory = RequestFactory()
|
|
|
- path_base = f"{IntegrationControlMiddleware.webhook_prefix}slack"
|
|
|
region = Region("na", 1, "https://na.testserver", RegionCategory.MULTI_TENANT)
|
|
|
|
|
|
def setUp(self):
|
|
@@ -29,8 +29,8 @@ class SlackRequestParserTest(TestCase):
|
|
|
organization=self.organization, external_id="TXXXXXXX1", provider="slack"
|
|
|
)
|
|
|
|
|
|
- def get_parser(self, path):
|
|
|
- self.request = self.factory.post(f"{self.path_base}{path}")
|
|
|
+ def get_parser(self, path: str):
|
|
|
+ self.request = self.factory.post(path)
|
|
|
parser = SlackRequestParser(self.request, self.get_response)
|
|
|
parser.get_regions_from_organizations = MagicMock(return_value=[self.region])
|
|
|
return parser
|
|
@@ -45,7 +45,7 @@ class SlackRequestParserTest(TestCase):
|
|
|
def test_webhook(self, mock_authorize, mock_validate_integration, mock_integration):
|
|
|
# Retrieve the correct integration
|
|
|
mock_integration.id = self.integration.id
|
|
|
- parser = self.get_parser("/commands/")
|
|
|
+ parser = self.get_parser(reverse("sentry-integration-slack-commands"))
|
|
|
integration = parser.get_integration_from_request()
|
|
|
assert mock_authorize.called
|
|
|
assert mock_validate_integration.called
|
|
@@ -72,7 +72,12 @@ class SlackRequestParserTest(TestCase):
|
|
|
|
|
|
def test_django_view(self):
|
|
|
# Retrieve the correct integration
|
|
|
- parser = self.get_parser(f"/link-identity/{sign(integration_id=self.integration.id)}/")
|
|
|
+ parser = self.get_parser(
|
|
|
+ reverse(
|
|
|
+ "sentry-integration-slack-link-identity",
|
|
|
+ kwargs={"signed_params": sign(integration_id=self.integration.id)},
|
|
|
+ )
|
|
|
+ )
|
|
|
parser_integration = parser.get_integration_from_request()
|
|
|
assert parser_integration.id == self.integration.id
|
|
|
|