-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor, google: rename _google_groups_for_user to _fetch_user_groups
- Loading branch information
1 parent
3c62101
commit fd06b47
Showing
2 changed files
with
32 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,8 +37,8 @@ async def test_google(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakeadmingroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakeadmingroup'}, | ||
): | ||
user_info = await authenticator.get_authenticated_user(handler, None) | ||
assert sorted(user_info) == ['admin', 'auth_state', 'name'] | ||
|
@@ -56,8 +56,8 @@ async def test_google_username_claim(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakeadmingroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakeadmingroup'}, | ||
): | ||
user_info = await authenticator.get_authenticated_user(handler, None) | ||
assert sorted(user_info) == ['admin', 'auth_state', 'name'] | ||
|
@@ -70,8 +70,8 @@ async def test_hosted_domain(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakeadmingroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakeadmingroup'}, | ||
): | ||
user_info = await authenticator.get_authenticated_user(handler, None) | ||
name = user_info['name'] | ||
|
@@ -88,8 +88,8 @@ async def test_multiple_hosted_domain(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakeadmingroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakeadmingroup'}, | ||
): | ||
user_info = await authenticator.get_authenticated_user(handler, None) | ||
name = user_info['name'] | ||
|
@@ -115,8 +115,8 @@ async def test_admin_google_groups(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakeadmingroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakeadmingroup'}, | ||
): | ||
admin_user_info = await authenticator.get_authenticated_user(handler, None) | ||
# Make sure the user authenticated successfully | ||
|
@@ -126,8 +126,8 @@ async def test_admin_google_groups(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakegroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakegroup'}, | ||
): | ||
allowed_user_info = await authenticator.get_authenticated_user(handler, None) | ||
allowed_user_groups = allowed_user_info['auth_state']['google_user'][ | ||
|
@@ -139,8 +139,8 @@ async def test_admin_google_groups(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakenonallowedgroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakenonallowedgroup'}, | ||
): | ||
allowed_user_groups = await authenticator.get_authenticated_user(handler, None) | ||
assert allowed_user_groups is None | ||
|
@@ -155,8 +155,8 @@ async def test_admin_user_but_no_admin_google_groups(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakegroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakegroup'}, | ||
): | ||
admin_user_info = await authenticator.get_authenticated_user(handler, data=None) | ||
# Make sure the user authenticated successfully | ||
|
@@ -173,16 +173,16 @@ async def test_allowed_google_groups(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakeadmingroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakeadmingroup'}, | ||
): | ||
admin_user_info = await authenticator.get_authenticated_user(handler, None) | ||
assert admin_user_info is None | ||
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakegroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakegroup'}, | ||
): | ||
allowed_user_info = await authenticator.get_authenticated_user(handler, None) | ||
allowed_user_groups = allowed_user_info['auth_state']['google_user'][ | ||
|
@@ -194,14 +194,14 @@ async def test_allowed_google_groups(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakenonallowedgroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakenonallowedgroup'}, | ||
): | ||
allowed_user_groups = await authenticator.get_authenticated_user(handler, None) | ||
assert allowed_user_groups is None | ||
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, '_google_groups_for_user', lambda *args: ['fakegroup'] | ||
authenticator, '_fetch_user_groups', lambda *args: {'fakegroup'} | ||
): | ||
allowed_user_groups = await authenticator.get_authenticated_user(handler, None) | ||
assert allowed_user_groups is None | ||
|
@@ -215,8 +215,8 @@ async def test_admin_only_google_groups(google_client): | |
handler = google_client.handler_for_user(user_model('[email protected]')) | ||
with mock.patch.object( | ||
authenticator, | ||
'_google_groups_for_user', | ||
lambda *args: ['anotherone', 'fakeadmingroup'], | ||
'_fetch_user_groups', | ||
lambda *args: {'anotherone', 'fakeadmingroup'}, | ||
): | ||
admin_user_info = await authenticator.get_authenticated_user(handler, None) | ||
admin_user = admin_user_info['admin'] | ||
|