-
Notifications
You must be signed in to change notification settings - Fork 61
[Python] pass auth flows into credential policy #3062
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
786abba
Update dependencies (2025-03-26 05:20:22)
c74b5c5
Regenerate for typespec-python (2025-03-26 05:24:34)
33b3833
merge
msyyc 78ca9c0
Update dependencies (2025-03-27 06:37:28)
ed06e2e
Regenerate for typespec-python (2025-03-27 06:41:52)
5b558d8
Update dependencies (2025-03-31 05:41:59)
779bb04
udpate
msyyc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
.chronus/changes/auto-microsoft-python-auth-flow-2025-2-31-14-16-3.md
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@autorest/python" | ||
| - "@azure-tools/typespec-python" | ||
| --- | ||
|
|
||
| Pass authentication flows info into credential policy for unbranded |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
27 changes: 27 additions & 0 deletions
27
...ages/typespec-python/test/generic_mock_api_tests/asynctests/test_streaming_jsonl_async.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
|
|
||
| from streaming.jsonl.aio import JsonlClient | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def client(): | ||
| async with JsonlClient(endpoint="http://localhost:3000") as client: | ||
| yield client | ||
|
|
||
|
|
||
| JSONL = b'{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}' | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_basic_send(client: JsonlClient): | ||
| await client.basic.send(JSONL) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_basic_recv(client: JsonlClient): | ||
| assert b"".join([d async for d in (await client.basic.receive())]) == JSONL |
This file contains hidden or 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
25 changes: 25 additions & 0 deletions
25
packages/typespec-python/test/generic_mock_api_tests/test_streaming_jsonl.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
|
|
||
| from streaming.jsonl import JsonlClient | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def client(): | ||
| with JsonlClient(endpoint="http://localhost:3000") as client: | ||
| yield client | ||
|
|
||
|
|
||
| JSONL = b'{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}' | ||
|
|
||
|
|
||
| def test_basic_send(client: JsonlClient): | ||
| client.basic.send(JSONL) | ||
|
|
||
|
|
||
| def test_basic_recv(client: JsonlClient): | ||
| assert b"".join(client.basic.receive()) == JSONL |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
19 changes: 19 additions & 0 deletions
19
packages/typespec-python/test/unbranded/mock_api_tests/asynctests/test_auth_flow_async.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from authentication.oauth2.aio import OAuth2Client | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_oauth2_auth_flows(): | ||
| oauth2_client = OAuth2Client("fake_credential") | ||
| assert oauth2_client._config.authentication_policy._auth_flows == [ | ||
| { | ||
| "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", | ||
| "scopes": [{"value": "https://security.microsoft.com/.default"}], | ||
| "type": "implicit", | ||
| } | ||
| ] |
17 changes: 17 additions & 0 deletions
17
packages/typespec-python/test/unbranded/mock_api_tests/test_auth_flow.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| from authentication.oauth2 import OAuth2Client | ||
|
|
||
|
|
||
| def test_oauth2_auth_flows(): | ||
| oauth2_client = OAuth2Client("fake_credential") | ||
| assert oauth2_client._config.authentication_policy._auth_flows == [ | ||
| { | ||
| "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", | ||
| "scopes": [{"value": "https://security.microsoft.com/.default"}], | ||
| "type": "implicit", | ||
| } | ||
| ] |
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.