Skip to content

Commit eddfc53

Browse files
committed
Address review comments: rename _clean_env to clean_env, fix __all__, fix doc diagram, drop redundant import os
1 parent 3fe050b commit eddfc53

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

.Pipelines/CI-AND-RELEASE-PIPELINES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ with both parameters filled in.
6262
### Stage Flow
6363

6464
```
65-
PreBuildCheck ─► Validate ─► CI ─► Build ─┬─► PublishMSALPython (publishTarget == test.pypi.org)
66-
└─► PublishPyPI (publishTarget == pypi.org)
65+
PreBuildCheck ─► Validate ─► CI ─► Build ─┬─► PublishMSALPython (publishTarget == 'test.pypi.org (Preview / RC)')
66+
└─► PublishPyPI (publishTarget == 'pypi.org (ESRP Production)')
6767
```
6868

6969
| Stage | What it does | Condition |

tests/lab_config.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@
3636

3737
__all__ = [
3838
# Constants
39+
"LAB_APP_CLIENT_ID",
3940
"UserSecrets",
4041
"AppSecrets",
4142
# Data classes
4243
"UserConfig",
4344
"AppConfig",
4445
# Functions
45-
"LAB_APP_CLIENT_ID",
4646
"get_secret",
4747
"get_user_config",
4848
"get_app_config",
4949
"get_user_password",
5050
"get_client_certificate",
51+
"clean_env",
5152
]
5253

5354
# =============================================================================
@@ -170,7 +171,7 @@ class AppConfig:
170171
_msal_team_client: Optional[SecretClient] = None
171172

172173

173-
def _clean_env(name: str) -> Optional[str]:
174+
def clean_env(name: str) -> Optional[str]:
174175
"""Return the env var value, or None if unset or it contains an unexpanded
175176
ADO pipeline variable literal such as ``$(VAR_NAME)``.
176177
@@ -198,7 +199,7 @@ def _get_credential():
198199
Raises:
199200
EnvironmentError: If required environment variables are not set.
200201
"""
201-
cert_path = _clean_env("LAB_APP_CLIENT_CERT_PFX_PATH")
202+
cert_path = clean_env("LAB_APP_CLIENT_CERT_PFX_PATH")
202203
tenant_id = "72f988bf-86f1-41af-91ab-2d7cd011db47" # Microsoft tenant
203204

204205
if cert_path:
@@ -412,7 +413,7 @@ def get_client_certificate() -> Dict[str, object]:
412413
Raises:
413414
EnvironmentError: If LAB_APP_CLIENT_CERT_PFX_PATH is not set.
414415
"""
415-
cert_path = _clean_env("LAB_APP_CLIENT_CERT_PFX_PATH")
416+
cert_path = clean_env("LAB_APP_CLIENT_CERT_PFX_PATH")
416417
if not cert_path:
417418
raise EnvironmentError(
418419
"LAB_APP_CLIENT_CERT_PFX_PATH environment variable is required "
@@ -423,4 +424,4 @@ def get_client_certificate() -> Dict[str, object]:
423424
return {
424425
"private_key_pfx_path": cert_path,
425426
"public_certificate": True, # Enable SNI (send certificate chain)
426-
}
427+
}

tests/test_e2e.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from tests.broker_util import is_pymsalruntime_installed
2929
from tests.lab_config import (
3030
get_user_config, get_app_config, get_user_password, get_secret,
31-
UserSecrets, AppSecrets, LAB_APP_CLIENT_ID, _clean_env,
31+
UserSecrets, AppSecrets, LAB_APP_CLIENT_ID, clean_env,
3232
)
3333

3434

@@ -345,7 +345,7 @@ class PublicCloudScenariosTestCase(E2eTestCase):
345345

346346
@classmethod
347347
def setUpClass(cls):
348-
if not _clean_env("LAB_APP_CLIENT_CERT_PFX_PATH"):
348+
if not clean_env("LAB_APP_CLIENT_CERT_PFX_PATH"):
349349
raise unittest.SkipTest(
350350
"LAB_APP_CLIENT_CERT_PFX_PATH not set; skipping PublicCloud e2e tests")
351351
pca_app = get_app_config(AppSecrets.PCA_CLIENT)
@@ -428,7 +428,7 @@ def test_client_secret(self):
428428

429429
def test_subject_name_issuer_authentication(self):
430430
from tests.lab_config import get_client_certificate
431-
if not _clean_env("LAB_APP_CLIENT_CERT_PFX_PATH"):
431+
if not clean_env("LAB_APP_CLIENT_CERT_PFX_PATH"):
432432
self.skipTest("LAB_APP_CLIENT_CERT_PFX_PATH not set")
433433

434434
self.app = msal.ConfidentialClientApplication(
@@ -471,7 +471,7 @@ def get_lab_app(
471471
"Reading ENV variable %s for lab app defined at "
472472
"https://docs.msidlab.com/accounts/confidentialclient.html",
473473
env_client_cert_path)
474-
cert_path = _clean_env(env_client_cert_path)
474+
cert_path = clean_env(env_client_cert_path)
475475
if cert_path:
476476
# id came from https://docs.msidlab.com/accounts/confidentialclient.html
477477
client_credential = {
@@ -1167,11 +1167,10 @@ def _test_acquire_token_for_client(self, configured_region, expected_region):
11671167
11681168
Uses the lab app certificate for authentication.
11691169
"""
1170-
import os
11711170
from tests.lab_config import get_client_certificate
11721171

11731172
# Get client ID from lab_config constant and certificate from lab_config
1174-
if not _clean_env("LAB_APP_CLIENT_CERT_PFX_PATH"):
1173+
if not clean_env("LAB_APP_CLIENT_CERT_PFX_PATH"):
11751174
self.skipTest("LAB_APP_CLIENT_CERT_PFX_PATH is required")
11761175
client_credential = get_client_certificate()
11771176

0 commit comments

Comments
 (0)