Skip to content

Commit 5dad69a

Browse files
authored
Make get_cred method not fallback to use dac (#36528)
* Not fallback to DAC by default if running in CI * update * update
1 parent 0f6a13a commit 5dad69a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,15 @@ def get_credential(**kwargs):
271271
**kwargs
272272
)
273273
# This is for testing purposes only, to ensure that the AzurePipelinesCredential is used when available
274-
# else:
275-
# raise ValueError(
276-
# "Environment variables not set for service principal authentication. "
277-
# f"service_connection_id: {service_connection_id}, client_id: {client_id}, tenant_id: {tenant_id}, system_access_token: {system_access_token}"
278-
# )
274+
else:
275+
force_fallback_dac = os.environ.get("AZURE_TEST_FORCE_FALLBACK_DAC", "false")
276+
if service_connection_id and not(force_fallback_dac):
277+
# if service_connection_id is set, we believe it is running in CI
278+
system_access_token = SANITIZED if system_access_token else None
279+
raise ValueError(
280+
"Running in Azure Pipelines. Environment variables not set for service principal authentication. "
281+
f"service_connection_id: {service_connection_id}, client_id: {client_id}, tenant_id: {tenant_id}, system_access_token: {system_access_token}"
282+
)
279283
# Fall back to DefaultAzureCredential
280284
from azure.identity import DefaultAzureCredential
281285
if is_async:

0 commit comments

Comments
 (0)