Skip to content

Commit 08ba113

Browse files
committed
Enable e2e tests in CI pipeline + fix interactive-test skip logic for ADO
- tests/test_e2e.py: - Add TF_BUILD to _SKIP_UNATTENDED_E2E_TESTS so acquire_token_interactive() and acquire_token_by_device_flow() tests skip on ADO (no browser/display), preventing hangs on headless agents. - Remove the class-level @unittest.skipIf(TF_BUILD) from PublicCloudScenariosTestCase; the class now uses lab config so can run on ADO when LAB_APP_CLIENT_ID is set. - Add a LAB_APP_CLIENT_ID guard in PublicCloudScenariosTestCase.setUpClass() so the class raises unittest.SkipTest (not EnvironmentError) when the env var is absent, giving the same clean-skip behaviour as LabBasedTestCase. - .Pipelines/template-pipeline-stages.yml: - Uncomment LAB_APP_CLIENT_ID env var in the Run tests step so integration tests run when the pipeline variable is configured.
1 parent d5ad7c0 commit 08ba113

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

.Pipelines/template-pipeline-stages.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,12 @@ stages:
183183
pytest -vv --junitxml=test-results/junit.xml 2>&1 | tee test-results/pytest.log
184184
displayName: 'Run tests'
185185
env:
186-
# LAB_APP_CLIENT_ID is intentionally omitted to match the PR gate build
187-
# behaviour (azure-pipelines.yml). Without it, _get_credential() in
188-
# lab_config.py raises EnvironmentError and all e2e tests skip or error
189-
# gracefully — identical to the PR build result.
190-
# Uncomment and set this variable to enable full e2e runs on a
191-
# lab-capable agent pool (requires CA-exempt network / internal agent).
192-
# LAB_APP_CLIENT_ID: $(LAB_APP_CLIENT_ID)
186+
# LAB_APP_CLIENT_ID enables e2e tests against the MSID Lab infrastructure.
187+
# Must be set as a pipeline variable to the lab app's client ID
188+
# (see https://docs.msidlab.com/accounts/confidentialclient.html).
189+
# The matching certificate is retrieved from Key Vault by the steps above.
190+
# When unset, all LabBasedTestCase tests skip gracefully.
191+
LAB_APP_CLIENT_ID: $(LAB_APP_CLIENT_ID)
193192
LAB_APP_CLIENT_CERT_PFX_PATH: $(LAB_APP_CLIENT_CERT_PFX_PATH)
194193
195194
- task: PublishTestResults@2

tests/test_e2e.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@
4444

4545
_PYMSALRUNTIME_INSTALLED = is_pymsalruntime_installed()
4646
_AZURE_CLI = "04b07795-8ddb-461a-bbee-02f9e1bf7b46"
47-
_SKIP_UNATTENDED_E2E_TESTS = os.getenv("TRAVIS") or not os.getenv("CI")
47+
# Skip interactive / browser-dependent tests when:
48+
# - on Travis CI (TRAVIS), or
49+
# - on Azure DevOps (TF_BUILD) where there is no display/browser on the agent, or
50+
# - not running in any CI environment at all (not CI).
51+
# Service-principal and ROPC tests are NOT gated on this flag; only tests that
52+
# call acquire_token_interactive() or acquire_token_by_device_flow() are.
53+
_SKIP_UNATTENDED_E2E_TESTS = (
54+
os.getenv("TRAVIS") or os.getenv("TF_BUILD") or not os.getenv("CI")
55+
)
4856

4957
def _get_app_and_auth_code(
5058
client_id,
@@ -329,13 +337,17 @@ def test_access_token_should_be_obtained_for_a_supported_scope(self):
329337
self.assertIsNotNone(result.get("access_token"))
330338

331339

332-
@unittest.skipIf(os.getenv("TF_BUILD"), "Skip PublicCloud scenarios on Azure DevOps")
333340
class PublicCloudScenariosTestCase(E2eTestCase):
334341
# Historically this class was driven by tests/config.json for semi-automated runs.
335-
# It now uses lab config + env vars so it can run automatically without local files.
342+
# It now uses lab config + env vars so it can run automatically on any CI
343+
# (including Azure DevOps) as long as LAB_APP_CLIENT_ID and
344+
# LAB_APP_CLIENT_CERT_PFX_PATH are set.
336345

337346
@classmethod
338347
def setUpClass(cls):
348+
if not os.getenv("LAB_APP_CLIENT_ID"):
349+
raise unittest.SkipTest(
350+
"LAB_APP_CLIENT_ID not set; skipping PublicCloud e2e tests")
339351
pca_app = get_app_config(AppSecrets.PCA_CLIENT)
340352
user = get_user_config(UserSecrets.PUBLIC_CLOUD)
341353
cls.config = {

0 commit comments

Comments
 (0)