mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-19 14:10:23 -04:00
Improve UsernamePickerTestCase (#9112)
* make the OIDC bits of the test work at a higher level - via the REST api instead of poking the OIDCHandler directly. * Move it to test_login.py, where I think it fits better.
This commit is contained in:
parent
4575ad0b1e
commit
0dd2649c12
5 changed files with 114 additions and 125 deletions
|
@ -363,10 +363,10 @@ class RestHelper:
|
|||
the normal places.
|
||||
"""
|
||||
client_redirect_url = "https://x"
|
||||
channel = self.auth_via_oidc(remote_user_id, client_redirect_url)
|
||||
channel = self.auth_via_oidc({"sub": remote_user_id}, client_redirect_url)
|
||||
|
||||
# expect a confirmation page
|
||||
assert channel.code == 200
|
||||
assert channel.code == 200, channel.result
|
||||
|
||||
# fish the matrix login token out of the body of the confirmation page
|
||||
m = re.search(
|
||||
|
@ -390,7 +390,7 @@ class RestHelper:
|
|||
|
||||
def auth_via_oidc(
|
||||
self,
|
||||
remote_user_id: str,
|
||||
user_info_dict: JsonDict,
|
||||
client_redirect_url: Optional[str] = None,
|
||||
ui_auth_session_id: Optional[str] = None,
|
||||
) -> FakeChannel:
|
||||
|
@ -411,7 +411,8 @@ class RestHelper:
|
|||
the normal places.
|
||||
|
||||
Args:
|
||||
remote_user_id: the remote id that the OIDC provider should present
|
||||
user_info_dict: the remote userinfo that the OIDC provider should present.
|
||||
Typically this should be '{"sub": "<remote user id>"}'.
|
||||
client_redirect_url: for a login flow, the client redirect URL to pass to
|
||||
the login redirect endpoint
|
||||
ui_auth_session_id: if set, we will perform a UI Auth flow. The session id
|
||||
|
@ -457,7 +458,7 @@ class RestHelper:
|
|||
# a dummy OIDC access token
|
||||
("https://issuer.test/token", {"access_token": "TEST"}),
|
||||
# and then one to the user_info endpoint, which returns our remote user id.
|
||||
("https://issuer.test/userinfo", {"sub": remote_user_id}),
|
||||
("https://issuer.test/userinfo", user_info_dict),
|
||||
]
|
||||
|
||||
async def mock_req(method: str, uri: str, data=None, headers=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue