-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(integrations) Fix jira sync always failing (#61936)
Getting an installation requires an organization_id. Provide one if we have an organization linked to the integration. I've also fixed the integration icon being saved as a tuple. The JS types and API serializer imply that this value should be a string. Fixes SENTRY-1680
- Loading branch information
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import responses | ||
|
||
from sentry.tasks.integrations.sync_metadata import sync_metadata | ||
from sentry.testutils.cases import TestCase | ||
from sentry.testutils.silo import control_silo_test | ||
|
||
|
||
@control_silo_test | ||
class SyncMetadataTest(TestCase): | ||
@responses.activate | ||
def test_no_sync_with_no_org(self): | ||
integration = self.create_integration( | ||
organization=self.organization, | ||
provider="jira", | ||
external_id="abc123", | ||
metadata={ | ||
"base_url": "https://acme.atlassian.net", | ||
"shared_secret": "super-sekret", | ||
}, | ||
) | ||
org_integration = integration.organizationintegration_set.first() | ||
if org_integration: | ||
org_integration.delete() | ||
sync_metadata(integration.id) | ||
assert len(responses.calls) == 0 | ||
|
||
@responses.activate | ||
def test_success(self): | ||
responses.add( | ||
responses.GET, | ||
"https://acme.atlassian.net/rest/api/2/serverInfo", | ||
json={ | ||
"serverTitle": "Acme Jira", | ||
}, | ||
) | ||
responses.add( | ||
responses.GET, | ||
"https://acme.atlassian.net/rest/api/2/project", | ||
json=[ | ||
{"avatarUrls": {"48x48": "https://example.com/avatar.jpg"}}, | ||
], | ||
) | ||
integration = self.create_integration( | ||
organization=self.organization, | ||
provider="jira", | ||
external_id="abc123", | ||
metadata={ | ||
"base_url": "https://acme.atlassian.net", | ||
"shared_secret": "super-sekret", | ||
}, | ||
) | ||
sync_metadata(integration.id) | ||
|
||
integration.refresh_from_db() | ||
assert integration.name == "Acme Jira" | ||
assert integration.metadata["icon"] == "https://example.com/avatar.jpg" |