Skip to content

Commit 6a07fc9

Browse files
committed
[Identity] Fix device code tests (#35846)
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 <[email protected]>
1 parent e16a704 commit 6a07fc9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

sdk/identity/azure-identity/tests/helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ def get_discovery_response(endpoint="https://a/b"):
162162
sufficient. MSAL will send token requests to "{endpoint}/oauth2/v2.0/token_endpoint" after receiving a tenant
163163
discovery response created by this method.
164164
"""
165-
aad_metadata_endpoint_names = ("authorization_endpoint", "token_endpoint", "tenant_discovery_endpoint")
165+
aad_metadata_endpoint_names = (
166+
"authorization_endpoint",
167+
"token_endpoint",
168+
"tenant_discovery_endpoint",
169+
"device_authorization_endpoint",
170+
)
166171
payload = {name: endpoint + "/oauth2/v2.0/" + name for name in aad_metadata_endpoint_names}
167172
payload["metadata"] = ""
168173
return mock_response(json_payload=payload)

sdk/identity/azure-identity/tests/test_device_code_credential.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_device_code_credential():
178178
requests=[Request()] * 3, # not validating requests because they're formed by MSAL
179179
responses=[
180180
# expected requests: discover tenant, start device code flow, poll for completion
181-
mock_response(json_payload={"authorization_endpoint": "https://a/b", "token_endpoint": "https://a/b"}),
181+
get_discovery_response(),
182182
mock_response(
183183
json_payload={
184184
"device_code": "_",
@@ -237,7 +237,7 @@ def test_tenant_id():
237237
requests=[Request()] * 3, # not validating requests because they're formed by MSAL
238238
responses=[
239239
# expected requests: discover tenant, start device code flow, poll for completion
240-
mock_response(json_payload={"authorization_endpoint": "https://a/b", "token_endpoint": "https://a/b"}),
240+
get_discovery_response(),
241241
mock_response(
242242
json_payload={
243243
"device_code": "_",

0 commit comments

Comments
 (0)