-
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.
- Loading branch information
1 parent
96723da
commit 2d91638
Showing
1 changed file
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import logging | ||
import re | ||
from unittest import mock | ||
from unittest.mock import AsyncMock | ||
|
||
from pytest import fixture, mark, raises | ||
from traitlets.config import Config | ||
|
@@ -380,3 +381,33 @@ async def test_deprecated_config( | |
|
||
expected_log_tuple = (test_logger.name, expect_loglevel, expect_message) | ||
assert expected_log_tuple in captured_log_tuples | ||
|
||
|
||
@mark.asyncio | ||
async def test_nested_group_memberships(): | ||
mock_fetch_member_groups = AsyncMock( | ||
return_value={'group1', 'nested_group1', 'nested_group2'} | ||
) | ||
|
||
authenticator = GoogleOAuthenticator() | ||
authenticator._fetch_member_groups = mock_fetch_member_groups | ||
|
||
user_info = {'name': 'testuser', 'email': '[email protected]'} | ||
|
||
result = await authenticator._fetch_member_groups(user_info['email'], 'example.com') | ||
assert 'nested_group1' in result | ||
assert 'nested_group2' in result | ||
|
||
|
||
@mark.asyncio | ||
async def test_user_not_in_nested_group(): | ||
mock_fetch_member_groups = AsyncMock(return_value={'group1', 'group2'}) | ||
|
||
authenticator = GoogleOAuthenticator() | ||
authenticator._fetch_member_groups = mock_fetch_member_groups | ||
|
||
user_info = {'name': 'testuser', 'email': '[email protected]'} | ||
|
||
result = await authenticator._fetch_member_groups(user_info['email'], 'example.com') | ||
assert 'nested_group1' not in result | ||
assert 'nested_group2' not in result |