Skip to content

Commit c2ac0a7

Browse files
authored
[Identity] Re-enable client secret live tests (#40859)
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
1 parent e9bf60e commit c2ac0a7

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def record_imds_test(request):
6363
@pytest.fixture()
6464
def live_service_principal():
6565
"""Fixture for live Identity tests. Skips them when environment configuration is incomplete."""
66-
pytest.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/35957")
6766
missing_variables = [
6867
v
6968
for v in (
@@ -118,6 +117,7 @@ def get_certificate_with_password_parameters(password_protected_content: bytes,
118117

119118
@pytest.fixture()
120119
def live_pem_certificate(live_service_principal):
120+
pytest.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/35957")
121121
content = os.environ.get("PEM_CONTENT")
122122
password_protected_content = os.environ.get("PEM_CONTENT_PASSWORD_PROTECTED")
123123
password = os.environ.get("CERTIFICATE_PASSWORD")
@@ -143,6 +143,7 @@ def live_pem_certificate(live_service_principal):
143143
@pytest.fixture()
144144
def live_pfx_certificate(live_service_principal):
145145
# PFX bytes arrive base64 encoded because Key Vault secrets have string values
146+
pytest.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/35957")
146147
encoded_content = os.environ.get("PFX_CONTENTS")
147148
encoded_password_protected_content = os.environ.get("PFX_CONTENT_PASSWORD_PROTECTED")
148149
password = os.environ.get("CERTIFICATE_PASSWORD")

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,11 @@ def test_live_multitenant_authentication(live_service_principal, get_token_metho
334334
live_service_principal["client_secret"],
335335
additionally_allowed_tenants=["*"],
336336
)
337+
kwargs = {"tenant_id": live_service_principal["tenant_id"]}
338+
if get_token_method == "get_token_info":
339+
kwargs = {"options": kwargs}
337340
# then get a valid token for an actual tenant
338-
token = getattr(credential, get_token_method)(
339-
"https://vault.azure.net/.default", tenant_id=live_service_principal["tenant_id"]
340-
)
341+
token = getattr(credential, get_token_method)("https://vault.azure.net/.default", **kwargs)
341342
assert token.token
342343
assert token.expires_on
343344

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
from helpers import get_token_payload_contents, GET_TOKEN_METHODS
2121

22-
ARM_SCOPE = "https://management.azure.com/.default"
22+
GRAPH_SCOPE = "https://graph.microsoft.com/.default"
2323

2424

2525
def get_token(credential, method, **kwargs):
26-
token = getattr(credential, method)(ARM_SCOPE, **kwargs)
26+
token = getattr(credential, method)(GRAPH_SCOPE, **kwargs)
2727
assert token
2828
assert token.token
2929
assert token.expires_on
@@ -66,7 +66,10 @@ def test_client_secret_credential(live_service_principal, get_token_method):
6666
live_service_principal["client_id"],
6767
live_service_principal["client_secret"],
6868
)
69-
token = get_token(credential, get_token_method, enable_cae=True)
69+
kwargs = {"enable_cae": True}
70+
if get_token_method == "get_token_info":
71+
kwargs = {"options": kwargs}
72+
token = get_token(credential, get_token_method, **kwargs)
7073
parsed_payload = get_token_payload_contents(token.token)
7174
assert "xms_cc" in parsed_payload and "CP1" in parsed_payload["xms_cc"]
7275

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
from helpers import get_token_payload_contents, GET_TOKEN_METHODS
1818

19-
ARM_SCOPE = "https://management.azure.com/.default"
19+
GRAPH_SCOPE = "https://graph.microsoft.com/.default"
2020

2121

2222
async def get_token(credential, get_token_method, **kwargs):
23-
token = await getattr(credential, get_token_method)(ARM_SCOPE, **kwargs)
23+
token = await getattr(credential, get_token_method)(GRAPH_SCOPE, **kwargs)
2424
assert token
2525
assert token.token
2626
assert token.expires_on
@@ -65,7 +65,10 @@ async def test_client_secret_credential(live_service_principal, get_token_method
6565
live_service_principal["client_id"],
6666
live_service_principal["client_secret"],
6767
)
68-
token = await get_token(credential, get_token_method, enable_cae=True)
68+
kwargs = {"enable_cae": True}
69+
if get_token_method == "get_token_info":
70+
kwargs = {"options": kwargs}
71+
token = await get_token(credential, get_token_method, **kwargs)
6972
parsed_payload = get_token_payload_contents(token.token)
7073
assert "xms_cc" in parsed_payload and "CP1" in parsed_payload["xms_cc"]
7174

0 commit comments

Comments
 (0)