Skip to content

Commit 2dbcac9

Browse files
authored
nit: Update fly build config (#52301)
cleans up the build_config method
1 parent 56ad71a commit 2dbcac9

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

Diff for: src/sentry/auth/providers/fly/provider.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,13 @@ def get_refresh_token_url(self):
4545
return ACCESS_TOKEN_URL
4646

4747
@classmethod
48-
def build_config(self, state: Any, organization: Optional[Any] = None):
48+
def build_config(self, resource: Optional[Any] = None):
4949
"""
5050
On configuration, we determine which provider organization to configure sentry SSO for.
5151
This configuration is then stored and passed into the pipeline instances during SSO
5252
to determine whether the Auth'd user has the appropriate access to the provider org
5353
"""
54-
org = organization
55-
if not organization:
56-
data = state["data"]
57-
# TODO: determine which org to configure SSO for
58-
org = data["user"]["organizations"][0]
59-
60-
return {"org": {"id": cast(Dict, org).get("id")}}
54+
return {"org": {"id": cast(Dict, resource).get("id")}}
6155

6256
def build_identity(self, state):
6357
"""

Diff for: tests/sentry/auth/providers/fly/test_provider.py

+2-26
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,8 @@ def test_refresh_identity_without_refresh_token(self):
2727

2828
def test_build_config(self):
2929
provider = self.auth_provider.get_provider()
30-
state = {
31-
"state": "9da4041848844e8088864eaea3c3a705",
32-
"data": {
33-
"access_token": "fo1_6xgeCrB8ew8vFQ86vdaakBSFTVDGCzOUvebUbvgPGhI",
34-
"token_type": "Bearer",
35-
"expires_in": 7200,
36-
"refresh_token": "PmUkAB75UPLKGZplERMq8WwOHnsTllZ5HveY4RvNUTk",
37-
"scope": "read",
38-
"created_at": 1686786353,
39-
"user": {
40-
"resource_owner_id": "k9d01lp82rky6vo2",
41-
"scope": ["read"],
42-
"expires_in": 7200,
43-
"application": {"uid": "elMJpuhA5bXbR59ZaKdXrxXGFVKTypGHuJ4h6Rfw1Qk"},
44-
"created_at": 1686786353,
45-
"user_id": "k9d01lp82rky6vo2",
46-
"user_name": "Nathan",
47-
"email": "[email protected]",
48-
"organizations": [
49-
{"id": "nathans-org", "role": "member"},
50-
{"id": "0vogzmzoj1k5xp29", "role": "admin"},
51-
],
52-
},
53-
},
54-
}
55-
result = provider.build_config(state)
30+
resource = {"id": "nathans-org", "role": "member"}
31+
result = provider.build_config(resource=resource)
5632
assert result == {"org": {"id": "nathans-org"}}
5733

5834
def test_build_identity(self):

0 commit comments

Comments
 (0)