11"""If the following ENV VAR were available, many end-to-end test cases would run.
2- LAB_APP_CLIENT_ID=...
32LAB_APP_CLIENT_CERT_PFX_PATH=...
43"""
54try :
2928from tests .broker_util import is_pymsalruntime_installed
3029from tests .lab_config import (
3130 get_user_config , get_app_config , get_user_password , get_secret ,
32- UserSecrets , AppSecrets ,
31+ UserSecrets , AppSecrets , LAB_APP_CLIENT_ID ,
3332)
3433
3534
@@ -348,14 +347,13 @@ def test_access_token_should_be_obtained_for_a_supported_scope(self):
348347class PublicCloudScenariosTestCase (E2eTestCase ):
349348 # Historically this class was driven by tests/config.json for semi-automated runs.
350349 # It now uses lab config + env vars so it can run automatically on any CI
351- # (including Azure DevOps) as long as LAB_APP_CLIENT_ID and
352- # LAB_APP_CLIENT_CERT_PFX_PATH are set.
350+ # (including Azure DevOps) as long as LAB_APP_CLIENT_CERT_PFX_PATH is set.
353351
354352 @classmethod
355353 def setUpClass (cls ):
356- if not _clean_env ("LAB_APP_CLIENT_ID " ):
354+ if not _clean_env ("LAB_APP_CLIENT_CERT_PFX_PATH " ):
357355 raise unittest .SkipTest (
358- "LAB_APP_CLIENT_ID not set; skipping PublicCloud e2e tests" )
356+ "LAB_APP_CLIENT_CERT_PFX_PATH not set; skipping PublicCloud e2e tests" )
359357 pca_app = get_app_config (AppSecrets .PCA_CLIENT )
360358 user = get_user_config (UserSecrets .PUBLIC_CLOUD )
361359 cls .config = {
@@ -436,13 +434,11 @@ def test_client_secret(self):
436434
437435 def test_subject_name_issuer_authentication (self ):
438436 from tests .lab_config import get_client_certificate
439-
440- client_id = os .getenv ("LAB_APP_CLIENT_ID" )
441- if not client_id :
442- self .skipTest ("LAB_APP_CLIENT_ID environment variable is required" )
437+ if not _clean_env ("LAB_APP_CLIENT_CERT_PFX_PATH" ):
438+ self .skipTest ("LAB_APP_CLIENT_CERT_PFX_PATH not set" )
443439
444440 self .app = msal .ConfidentialClientApplication (
445- client_id ,
441+ LAB_APP_CLIENT_ID ,
446442 authority = "https://login.microsoftonline.com/microsoft.onmicrosoft.com" ,
447443 client_credential = get_client_certificate (),
448444 http_client = MinimalHttpClient ())
@@ -467,23 +463,22 @@ def manual_test_device_flow(self):
467463
468464
469465def get_lab_app (
470- env_client_id = "LAB_APP_CLIENT_ID" ,
471466 env_client_cert_path = "LAB_APP_CLIENT_CERT_PFX_PATH" ,
472467 authority = "https://login.microsoftonline.com/"
473468 "72f988bf-86f1-41af-91ab-2d7cd011db47" , # Microsoft tenant ID
474469 timeout = None ,
475470 ** kwargs ):
476471 """Returns the lab app as an MSAL confidential client.
477472
478- Get it from environment variables if defined, otherwise fall back to use MSI.
473+ Uses the hardcoded lab app client ID (RequestMSIDLAB) and a certificate
474+ from the LAB_APP_CLIENT_CERT_PFX_PATH env var.
479475 """
480476 logger .info (
481- "Reading ENV variables %s and %s for lab app defined at "
477+ "Reading ENV variable %s for lab app defined at "
482478 "https://docs.msidlab.com/accounts/confidentialclient.html" ,
483- env_client_id , env_client_cert_path )
484- client_id = _clean_env (env_client_id )
479+ env_client_cert_path )
485480 cert_path = _clean_env (env_client_cert_path )
486- if client_id and cert_path :
481+ if cert_path :
487482 # id came from https://docs.msidlab.com/accounts/confidentialclient.html
488483 client_credential = {
489484 "private_key_pfx_path" :
@@ -496,7 +491,7 @@ def get_lab_app(
496491 # See also https://microsoft.sharepoint-df.com/teams/MSIDLABSExtended/SitePages/Programmatically-accessing-LAB-API's.aspx
497492 raise unittest .SkipTest ("MSI-based mechanism has not been implemented yet" )
498493 return msal .ConfidentialClientApplication (
499- client_id ,
494+ LAB_APP_CLIENT_ID ,
500495 client_credential = client_credential ,
501496 authority = authority ,
502497 http_client = MinimalHttpClient (timeout = timeout ),
@@ -1183,15 +1178,13 @@ def _test_acquire_token_for_client(self, configured_region, expected_region):
11831178 import os
11841179 from tests .lab_config import get_client_certificate
11851180
1186- # Get client ID from environment and certificate from lab_config
1187- client_id = os .getenv ("LAB_APP_CLIENT_ID" )
1188- if not client_id :
1189- self .skipTest ("LAB_APP_CLIENT_ID environment variable is required" )
1190-
1181+ # Get client ID from lab_config constant and certificate from lab_config
1182+ if not _clean_env ("LAB_APP_CLIENT_CERT_PFX_PATH" ):
1183+ self .skipTest ("LAB_APP_CLIENT_CERT_PFX_PATH is required" )
11911184 client_credential = get_client_certificate ()
11921185
11931186 self .app = msal .ConfidentialClientApplication (
1194- client_id ,
1187+ LAB_APP_CLIENT_ID ,
11951188 client_credential = client_credential ,
11961189 authority = "https://login.microsoftonline.com/microsoft.onmicrosoft.com" ,
11971190 azure_region = configured_region ,
0 commit comments