Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Look before you leap
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Nov 12, 2021
1 parent a132966 commit 7d697bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/rest/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,13 @@ def initiate_sso_login(

# hit the redirect url again with the right Host header, which should now issue
# a cookie and redirect to the SSO provider.
location = channel.headers.getRawHeaders("Location")[0]
def get_location() -> str:
location_values = channel.headers.getRawHeaders("Location")
# Keep mypy happy by asserting that location_values is nonempty
assert location_values
return location_values[0]

location = get_location()
parts = urllib.parse.urlsplit(location)
channel = make_request(
self.hs.get_reactor(),
Expand All @@ -672,7 +678,7 @@ def initiate_sso_login(

assert channel.code == 302
channel.extract_cookies(cookies)
return channel.headers.getRawHeaders("Location")[0]
return get_location()

def initiate_sso_ui_auth(
self, ui_auth_session_id: str, cookies: MutableMapping[str, str]
Expand Down

0 comments on commit 7d697bf

Please sign in to comment.