-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYNPY-1436] avoid duplicate user profile call during login (#1124)
* add diaplayname to SynapseAuthTokenCredentials * simplify display_name creation
- Loading branch information
Showing
6 changed files
with
64 additions
and
24 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
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 |
---|---|---|
|
@@ -62,6 +62,7 @@ def test_get_credentials__multiple_providers(self) -> None: | |
cred_provider2.get_synapse_credentials.return_value = ( | ||
SynapseAuthTokenCredentials( | ||
username="asdf", | ||
displayname="aaaa", | ||
token="ghjk", | ||
) | ||
) | ||
|
@@ -174,13 +175,14 @@ def test_create_synapse_credential_username_not_None_auth_token_is_not_None( | |
assert creds is mock_creds | ||
|
||
@pytest.mark.parametrize( | ||
"login_username,profile_username,profile_emails", | ||
"login_username,profile_username,profile_emails,profile_displayname", | ||
( | ||
("foo", "foo", ["[email protected]"]), # username matches | ||
("foo", "foo", ["[email protected]"], "foo"), # username matches | ||
( | ||
"[email protected]", | ||
"foo", | ||
["[email protected]", "[email protected]", "[email protected]"], | ||
"foo", | ||
), # email matches | ||
), | ||
) | ||
|
@@ -190,6 +192,7 @@ def test_create_synapse_credential__username_auth_token_match( | |
login_username, | ||
profile_username, | ||
profile_emails, | ||
profile_displayname, | ||
) -> None: | ||
"""Verify that if both a username/email and a auth token are provided, the login is successful | ||
if the token matches either the username or a profile email address.""" | ||
|
@@ -198,13 +201,15 @@ def test_create_synapse_credential__username_auth_token_match( | |
mock_rest_get.return_value = { | ||
"userName": profile_username, | ||
"emails": profile_emails, | ||
"displayName": profile_displayname, | ||
} | ||
|
||
cred = self.provider._create_synapse_credential( | ||
syn=self.syn, username=login_username, auth_token=self.auth_token | ||
) | ||
assert cred.secret == self.auth_token | ||
assert cred.username == profile_username | ||
assert cred.displayname == profile_displayname | ||
|
||
def test_create_synapse_credential__username_auth_token_mismatch( | ||
self, mocker | ||
|
@@ -217,6 +222,7 @@ def test_create_synapse_credential__username_auth_token_mismatch( | |
mock_rest_get.return_value = { | ||
"userName": "foo", | ||
"emails": ["[email protected]", "[email protected]"], | ||
"displayName": "foo", | ||
} | ||
|
||
with pytest.raises(SynapseAuthenticationError) as ex: | ||
|
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