diff --git a/src/sentry/integrations/jira_server/client.py b/src/sentry/integrations/jira_server/client.py index 951a020f51c1..0befa0a4b3a7 100644 --- a/src/sentry/integrations/jira_server/client.py +++ b/src/sentry/integrations/jira_server/client.py @@ -114,7 +114,10 @@ def search_issues(self, query): else: q = query.replace('"', '\\"') jql = f'text ~ "{q}"' - return self.get(self.SEARCH_URL, params={"jql": jql}) + return self.get( + self.SEARCH_URL, + params={"jql": jql, "startAt": 0, "maxResults": 20, "fields": "summary"}, + ) def create_comment(self, issue_key, comment): return self.post(self.COMMENTS_URL % issue_key, data={"body": comment}) diff --git a/tests/sentry/integrations/jira_server/test_client.py b/tests/sentry/integrations/jira_server/test_client.py index b240778b6ab2..80a92ae1add8 100644 --- a/tests/sentry/integrations/jira_server/test_client.py +++ b/tests/sentry/integrations/jira_server/test_client.py @@ -69,7 +69,16 @@ def test_search_issues_with_pasted_issue_url(self) -> None: responses.add( method=responses.GET, url="https://jira.example.com/rest/api/2/search/", - match=[query_param_matcher({"jql": 'id="ABC-123"'})], + match=[ + query_param_matcher( + { + "jql": 'id="ABC-123"', + "startAt": 0, + "maxResults": 20, + "fields": "summary", + } + ) + ], body=json.dumps(body), status=200, content_type="application/json", @@ -83,7 +92,16 @@ def test_search_issues_with_free_text(self) -> None: responses.add( method=responses.GET, url="https://jira.example.com/rest/api/2/search/", - match=[query_param_matcher({"jql": 'text ~ "login crash"'})], + match=[ + query_param_matcher( + { + "jql": 'text ~ "login crash"', + "startAt": 0, + "maxResults": 20, + "fields": "summary", + } + ) + ], body=json.dumps(body), status=200, content_type="application/json", diff --git a/tests/sentry/integrations/jira_server/test_search.py b/tests/sentry/integrations/jira_server/test_search.py index f5b13841f6b1..1febc6134af0 100644 --- a/tests/sentry/integrations/jira_server/test_search.py +++ b/tests/sentry/integrations/jira_server/test_search.py @@ -3,6 +3,7 @@ import responses from django.urls import reverse +from responses.matchers import query_param_matcher from sentry.testutils.cases import APITestCase from sentry.testutils.silo import control_silo_test @@ -22,7 +23,17 @@ def test_get_success_text_search(self) -> None: integration = self.integration responses.add( responses.GET, - 'https://jira.example.org/rest/api/2/search/?jql=text ~ "test"', + "https://jira.example.org/rest/api/2/search/", + match=[ + query_param_matcher( + { + "jql": 'text ~ "test"', + "startAt": 0, + "maxResults": 20, + "fields": "summary", + } + ) + ], body=EXAMPLE_ISSUE_SEARCH, content_type="json", ) @@ -40,7 +51,17 @@ def test_get_success_id_search(self) -> None: integration = self.integration responses.add( responses.GET, - 'https://jira.example.org/rest/api/2/search/?jql=id="HSP-1"', + "https://jira.example.org/rest/api/2/search/", + match=[ + query_param_matcher( + { + "jql": 'id="HSP-1"', + "startAt": 0, + "maxResults": 20, + "fields": "summary", + } + ) + ], body=EXAMPLE_ISSUE_SEARCH, content_type="json", ) @@ -58,7 +79,17 @@ def test_get_network_error(self) -> None: integration = self.integration responses.add( responses.GET, - 'https://jira.example.org/rest/api/2/search/?jql=id="HSP-1"', + "https://jira.example.org/rest/api/2/search/", + match=[ + query_param_matcher( + { + "jql": 'id="HSP-1"', + "startAt": 0, + "maxResults": 20, + "fields": "summary", + } + ) + ], status=502, body="

We are down

", )