|
23 | 23 | IntegrationConfigurationError, |
24 | 24 | IntegrationError, |
25 | 25 | IntegrationFormError, |
| 26 | + IntegrationProviderError, |
26 | 27 | ) |
27 | 28 | from sentry.silo.base import SiloMode |
28 | 29 | from sentry.testutils.cases import APITestCase, IntegrationTestCase |
@@ -778,6 +779,64 @@ def test_create_issue_with_configuration_error(self) -> None: |
778 | 779 | } |
779 | 780 | ) |
780 | 781 |
|
| 782 | + @responses.activate |
| 783 | + def test_create_issue_product_unavailable_error(self) -> None: |
| 784 | + responses.add( |
| 785 | + responses.GET, |
| 786 | + "https://example.atlassian.net/rest/api/2/issue/createmeta", |
| 787 | + body=StubService.get_stub_json("jira", "createmeta_response.json"), |
| 788 | + content_type="json", |
| 789 | + ) |
| 790 | + # Simulate Jira returning an HTML "Product Unavailable" error page |
| 791 | + responses.add( |
| 792 | + responses.POST, |
| 793 | + "https://example.atlassian.net/rest/api/2/issue", |
| 794 | + status=503, |
| 795 | + body='<!DOCTYPE html>\n<html lang="en">\n <head>\n <title>Atlassian Cloud Notifications - Product Unavailable</title>\n </head>\n <body>\n <h1>Jira has been deactivated</h1>\n </body>\n</html>', |
| 796 | + content_type="text/html", |
| 797 | + ) |
| 798 | + installation = self.integration.get_installation(self.organization.id) |
| 799 | + with pytest.raises( |
| 800 | + IntegrationProviderError, match="Something went wrong while communicating with Jira" |
| 801 | + ): |
| 802 | + installation.create_issue( |
| 803 | + { |
| 804 | + "title": "example summary", |
| 805 | + "description": "example bug report", |
| 806 | + "issuetype": "1", |
| 807 | + "project": "10000", |
| 808 | + } |
| 809 | + ) |
| 810 | + |
| 811 | + @responses.activate |
| 812 | + def test_create_issue_page_unavailable_error(self) -> None: |
| 813 | + responses.add( |
| 814 | + responses.GET, |
| 815 | + "https://example.atlassian.net/rest/api/2/issue/createmeta", |
| 816 | + body=StubService.get_stub_json("jira", "createmeta_response.json"), |
| 817 | + content_type="json", |
| 818 | + ) |
| 819 | + # Simulate Jira returning an HTML "Page Unavailable" error |
| 820 | + responses.add( |
| 821 | + responses.POST, |
| 822 | + "https://example.atlassian.net/rest/api/2/issue", |
| 823 | + status=503, |
| 824 | + body='<!DOCTYPE html>\n<html lang="en">\n <head>\n <title>Page Unavailable</title>\n </head>\n <body>\n <h1>Page Unavailable</h1>\n </body>\n</html>', |
| 825 | + content_type="text/html", |
| 826 | + ) |
| 827 | + installation = self.integration.get_installation(self.organization.id) |
| 828 | + with pytest.raises( |
| 829 | + IntegrationProviderError, match="Something went wrong while communicating with Jira" |
| 830 | + ): |
| 831 | + installation.create_issue( |
| 832 | + { |
| 833 | + "title": "example summary", |
| 834 | + "description": "example bug report", |
| 835 | + "issuetype": "1", |
| 836 | + "project": "10000", |
| 837 | + } |
| 838 | + ) |
| 839 | + |
781 | 840 | @responses.activate |
782 | 841 | def test_create_issue_labels_and_option(self) -> None: |
783 | 842 | installation = self.integration.get_installation(self.organization.id) |
|
0 commit comments