-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for OpenSRP v2 user details
OpenSRP v2 returns the username as "username" instead of the olf "userName". This commit adds support for OpenSRP v2, while keeping support for the old version. Finally, this PR adds additional settings for isort, flake8 and pycodestyle.
- Loading branch information
1 parent
becbdda
commit 292d569
Showing
3 changed files
with
29 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,21 @@ def test_oauth_user_info_opensrp_provider(self): | |
request_mock.assert_called_once_with("user-details") | ||
assert user_info2 == result_info2 | ||
|
||
# Sample data returned OpenSRP v2 | ||
data3 = {"username": "mosh", "roles": ["Privilege Level: Full"]} | ||
|
||
# Expected result | ||
result_info3 = {"email": "[email protected]", "username": "mosh"} | ||
|
||
appbuilder3 = MagicMock() | ||
user_mock3 = MagicMock() | ||
user_mock3.data = data3 | ||
appbuilder3.sm.oauth_remotes["OpenSRP"].get = MagicMock( | ||
side_effect=[user_mock3]) | ||
csm3 = CustomSecurityManager(appbuilder=appbuilder3) | ||
user_info3 = csm3.oauth_user_info(provider="OpenSRP") | ||
assert user_info3 == result_info3 | ||
|
||
def test_oauth_user_info_no_provider(self): | ||
""" | ||
Test that when no provider is provided | ||
|