Skip to content

Commit

Permalink
[Identity] Fix device code tests (#35846)
Browse files Browse the repository at this point in the history
A recent change in MSAL made it so it is required that
"device_authorization_endpoint" is set in the discovery response.

This populates the value in the mock discovery response.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
  • Loading branch information
pvaneck committed Jun 10, 2024
1 parent e16a704 commit 6a07fc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion sdk/identity/azure-identity/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ def get_discovery_response(endpoint="https://a/b"):
sufficient. MSAL will send token requests to "{endpoint}/oauth2/v2.0/token_endpoint" after receiving a tenant
discovery response created by this method.
"""
aad_metadata_endpoint_names = ("authorization_endpoint", "token_endpoint", "tenant_discovery_endpoint")
aad_metadata_endpoint_names = (
"authorization_endpoint",
"token_endpoint",
"tenant_discovery_endpoint",
"device_authorization_endpoint",
)
payload = {name: endpoint + "/oauth2/v2.0/" + name for name in aad_metadata_endpoint_names}
payload["metadata"] = ""
return mock_response(json_payload=payload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_device_code_credential():
requests=[Request()] * 3, # not validating requests because they're formed by MSAL
responses=[
# expected requests: discover tenant, start device code flow, poll for completion
mock_response(json_payload={"authorization_endpoint": "https://a/b", "token_endpoint": "https://a/b"}),
get_discovery_response(),
mock_response(
json_payload={
"device_code": "_",
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_tenant_id():
requests=[Request()] * 3, # not validating requests because they're formed by MSAL
responses=[
# expected requests: discover tenant, start device code flow, poll for completion
mock_response(json_payload={"authorization_endpoint": "https://a/b", "token_endpoint": "https://a/b"}),
get_discovery_response(),
mock_response(
json_payload={
"device_code": "_",
Expand Down

0 comments on commit 6a07fc9

Please sign in to comment.