-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Update azure-identity history and version #9437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| import pytest | ||
|
|
||
| from helpers import build_aad_response, mock_response, Request | ||
| from helpers_async import async_validating_transport, wrap_in_future | ||
| from helpers_async import async_validating_transport, AsyncMockTransport, wrap_in_future | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
|
|
@@ -32,6 +32,32 @@ async def send(*_, **__): | |
| assert policy.on_request.called | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_close(): | ||
| transport = AsyncMockTransport() | ||
| credential = AuthorizationCodeCredential( | ||
| "tenant-id", "client-id", "auth-code", "http://localhost", transport=transport | ||
| ) | ||
|
|
||
| await credential.close() | ||
|
|
||
| assert transport.__aexit__.call_count == 1 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_context_manager(): | ||
| transport = AsyncMockTransport() | ||
| credential = AuthorizationCodeCredential( | ||
| "tenant-id", "client-id", "auth-code", "http://localhost", transport=transport | ||
| ) | ||
|
|
||
| async with credential: | ||
| assert transport.__aenter__.call_count == 1 | ||
|
|
||
| assert transport.__aenter__.call_count == 1 | ||
| assert transport.__aexit__.call_count == 1 | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add credential.close() after the context manager to make sure double close does not cause problems?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could, but the credential just wraps the transport's methods, which these tests already verify. It seems like what you really want is to ensure double closing the transport is okay. I want that too, but I think it's a test for the real transport implementations. |
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_user_agent(): | ||
| transport = async_validating_transport( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the private field is optional but the parameter is not. The authorization code is a string, so the private field is initially a string. Authorization codes are single use. After successfully redeeming the code for a token,
get_tokensets the private field toNoneto indicate the credential no longer has an authorization code and can only return a cached token. So,Optional[str].