Skip to content

Commit

Permalink
chore(github): remove all reinstall_id logic (#67782)
Browse files Browse the repository at this point in the history
  • Loading branch information
oioki committed Mar 28, 2024
1 parent fed05aa commit 7727e3b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 56 deletions.
6 changes: 0 additions & 6 deletions src/sentry/integrations/github/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ def build_integration(self, state: Mapping[str, str]) -> Mapping[str, Any]:
if state.get("sender"):
integration["metadata"]["sender"] = state["sender"]

if state.get("reinstall_id"):
integration["reinstall_id"] = state["reinstall_id"]

return integration

def setup(self) -> None:
Expand All @@ -361,9 +358,6 @@ def get_app_url(self) -> str:
return f"https://github.com/apps/{slugify(name)}"

def dispatch(self, request: Request, pipeline: Pipeline) -> HttpResponse:
if "reinstall_id" in request.GET:
pipeline.bind_state("reinstall_id", request.GET["reinstall_id"])

if "installation_id" not in request.GET:
return self.redirect(self.get_app_url())

Expand Down
5 changes: 0 additions & 5 deletions src/sentry/integrations/github_enterprise/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,6 @@ def build_integration(self, state):
"idp_config": state["oauth_config_information"],
}

if state.get("reinstall_id"):
integration["reinstall_id"] = state["reinstall_id"]

return integration

def setup(self):
Expand All @@ -442,8 +439,6 @@ def get_app_url(self, installation_data):

def dispatch(self, request: Request, pipeline) -> HttpResponse:
installation_data = pipeline.fetch_state(key="installation_data")
if "reinstall_id" in request.GET:
pipeline.bind_state("reinstall_id", request.GET["reinstall_id"])

if "installation_id" in request.GET:
pipeline.bind_state("installation_id", request.GET["installation_id"])
Expand Down
8 changes: 1 addition & 7 deletions src/sentry/integrations/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,7 @@ def finish_pipeline(self):
return response

def _finish_pipeline(self, data):
if "reinstall_id" in data:
self.integration = Integration.objects.get(
provider=self.provider.integration_key, id=data["reinstall_id"]
)
self.integration.update(external_id=data["external_id"], status=ObjectStatus.ACTIVE)
self.integration.get_installation(self.organization.id).reinstall()
elif "expect_exists" in data:
if "expect_exists" in data:
self.integration = Integration.objects.get(
provider=self.provider.integration_key, external_id=data["external_id"]
)
Expand Down
38 changes: 0 additions & 38 deletions tests/sentry/integrations/github/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,44 +349,6 @@ def test_installation_not_found(self):
)
assert b"The GitHub installation could not be found." in resp.content

@responses.activate
def test_reinstall_flow(self):
self._stub_github()
self.assert_setup_flow()

integration = Integration.objects.get(provider=self.provider.key)
integration.update(status=ObjectStatus.DISABLED)
assert integration.status == ObjectStatus.DISABLED
assert integration.external_id == self.installation_id

resp = self.client.get(
"{}?{}".format(self.init_path, urlencode({"reinstall_id": integration.id}))
)

assert resp.status_code == 302
redirect = urlparse(resp["Location"])
assert redirect.scheme == "https"
assert redirect.netloc == "github.com"
assert redirect.path == "/apps/sentry-test-app"

# New Installation
self.installation_id = "install_2"

self._stub_github()

resp = self.client.get(
"{}?{}".format(self.setup_path, urlencode({"installation_id": self.installation_id}))
)

assert resp.status_code == 200

auth_header = responses.calls[0].request.headers["Authorization"]
assert auth_header == "Bearer jwt_token_1"

integration = Integration.objects.get(provider=self.provider.key)
assert integration.status == ObjectStatus.ACTIVE
assert integration.external_id == self.installation_id

@responses.activate
def test_disable_plugin_when_fully_migrated(self):
self._stub_github()
Expand Down

0 comments on commit 7727e3b

Please sign in to comment.