feat: read username if email is not available for oauth provider

Also add recipe for OAuth with GitHub setup
This commit is contained in:
2024-01-05 12:28:31 +02:00
parent 9e1cf3cde7
commit ed7ed5d5d9
7 changed files with 115 additions and 1 deletions

View File

@ -75,6 +75,17 @@ async def test_get_oauth_username(oauth: OAuth, mocker: MockerFixture) -> None:
assert email == "email"
async def test_get_oauth_username_empty_email(oauth: OAuth, mocker: MockerFixture) -> None:
"""
must read username if email is not available
"""
mocker.patch("aioauth_client.GoogleClient.get_access_token", return_value=("token", ""))
mocker.patch("aioauth_client.GoogleClient.user_info", return_value=(aioauth_client.User(username="username"), ""))
username = await oauth.get_oauth_username("code")
assert username == "username"
async def test_get_oauth_username_exception_1(oauth: OAuth, mocker: MockerFixture) -> None:
"""
must return None in case of OAuth request error (get_access_token)