@camunda/e2e-test-suite 0.0.1756 → 0.0.1758

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/pages/SM-8.10/EntraUtils.d.ts +5 -0
  2. package/dist/pages/SM-8.10/EntraUtils.js +36 -0
  3. package/dist/pages/SM-8.10/LoginPage.d.ts +7 -0
  4. package/dist/pages/SM-8.10/LoginPage.js +28 -2
  5. package/dist/pages/SM-8.10/NavigationPage.d.ts +1 -0
  6. package/dist/pages/SM-8.10/NavigationPage.js +46 -0
  7. package/dist/pages/SM-8.10/OCIdentityRolesPage.d.ts +1 -0
  8. package/dist/pages/SM-8.10/OCIdentityRolesPage.js +2 -0
  9. package/dist/pages/SM-8.11/EntraUtils.d.ts +5 -0
  10. package/dist/pages/SM-8.11/EntraUtils.js +36 -0
  11. package/dist/pages/SM-8.11/LoginPage.d.ts +7 -0
  12. package/dist/pages/SM-8.11/LoginPage.js +28 -2
  13. package/dist/pages/SM-8.11/NavigationPage.d.ts +1 -0
  14. package/dist/pages/SM-8.11/NavigationPage.js +46 -0
  15. package/dist/pages/SM-8.11/OCIdentityRolesPage.d.ts +1 -0
  16. package/dist/pages/SM-8.11/OCIdentityRolesPage.js +2 -0
  17. package/dist/pages/SM-8.8/ModelerCreatePage.js +9 -3
  18. package/dist/tests/SM-8.10/entra-login.spec.d.ts +1 -0
  19. package/dist/tests/SM-8.10/entra-login.spec.js +41 -0
  20. package/dist/tests/SM-8.10/identity-user-flows.spec.js +52 -6
  21. package/dist/tests/SM-8.10/smoke-tests.spec.js +27 -1
  22. package/dist/tests/SM-8.11/entra-login.spec.d.ts +1 -0
  23. package/dist/tests/SM-8.11/entra-login.spec.js +41 -0
  24. package/dist/tests/SM-8.11/identity-user-flows.spec.js +52 -6
  25. package/dist/tests/SM-8.11/smoke-tests.spec.js +28 -1
  26. package/dist/utils/apiHelpers.js +70 -14
  27. package/dist/utils/entraLogin.d.ts +48 -0
  28. package/dist/utils/entraLogin.js +122 -0
  29. package/dist/utils/totp.d.ts +2 -0
  30. package/dist/utils/totp.js +43 -0
  31. package/dist/utils/users.d.ts +7 -0
  32. package/dist/utils/users.js +34 -1
  33. package/package.json +1 -1
  34. package/playwright.config.ts +20 -6
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const findLocatorWithPagination_1 = require("../../utils/assertionHelpers/findLocatorWithPagination");
6
7
  const test_1 = require("@playwright/test");
7
8
  const SM_8_10_1 = require("../../fixtures/SM-8.10");
8
9
  const _setup_1 = require("../../test-setup.js");
@@ -12,6 +13,10 @@ const node_process_1 = __importDefault(require("node:process"));
12
13
  const KeycloakUtils_1 = require("../../pages/SM-8.10/KeycloakUtils");
13
14
  const expectLocatorWithPagination_1 = require("../../utils/assertionHelpers/expectLocatorWithPagination");
14
15
  const expectTextWithPagination_1 = require("../../utils/assertionHelpers/expectTextWithPagination");
16
+ const entraLogin_1 = require("../../utils/entraLogin");
17
+ const users_1 = require("../../utils/users");
18
+ // The pool account this spec signs in as; see the slot comment in the test.
19
+ const ENTRA_SLOT = 5;
15
20
  SM_8_10_1.test.describe('Identity User Flow Tests', () => {
16
21
  SM_8_10_1.test.afterEach(async ({ page }, testInfo) => {
17
22
  await (0, _setup_1.captureScreenshot)(page, testInfo);
@@ -23,6 +28,19 @@ SM_8_10_1.test.describe('Identity User Flow Tests', () => {
23
28
  node_process_1.default.env.IS_LICENSE_KEY === 'true') {
24
29
  SM_8_10_1.test.skip(true, 'Skipping test because test not required in this test environment');
25
30
  }
31
+ // The flow under test is Management Identity's Users -> Assigned roles
32
+ // tab, which an OIDC cluster does not have: there is no local user store
33
+ // to create the account in, and component access comes from mapping rules
34
+ // on token claims rather than from a per-user grant. Not applicable rather
35
+ // than broken.
36
+ //
37
+ // The Orchestration Cluster test below is NOT a substitute -- it covers
38
+ // OC-level access, not Management Identity's Hub/Optimize roles -- so
39
+ // enforcement of those roles is genuinely unverified on Entra. #4730
40
+ // tracks closing that gap, which needs a chart change: the QA OIDC values
41
+ // grant them on the tenant claim, so every pool account holds them and
42
+ // none can assert their absence.
43
+ SM_8_10_1.test.skip((0, entraLogin_1.isEntraRun)(), 'Management Identity assigns roles per user only on a Keycloak cluster');
26
44
  SM_8_10_1.test.slow();
27
45
  const testUser = (await (0, _setup_1.generateRandomStringAsync)(6)).toLowerCase();
28
46
  const password = node_process_1.default.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
@@ -120,24 +138,52 @@ SM_8_10_1.test.describe('Identity User Flow Tests', () => {
120
138
  SM_8_10_1.test.skip(true, 'Skipping test because test not required in this test environment');
121
139
  }
122
140
  SM_8_10_1.test.slow();
123
- const testUser = (await (0, _setup_1.generateRandomStringAsync)(6)).toLowerCase();
124
- const password = node_process_1.default.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
141
+ // Slot 5 is reserved for this spec: it is the one SM-8.10 pool account the
142
+ // smoke tests never put in the admin role, which this test needs because
143
+ // it asserts the user has no access before the mapping rule exists.
144
+ const entra = (0, entraLogin_1.isEntraRun)() ? (0, users_1.requireEntraPoolUser)(ENTRA_SLOT) : undefined;
145
+ const randomSuffix = (await (0, _setup_1.generateRandomStringAsync)(6)).toLowerCase();
146
+ // On an Entra cluster usernameClaim is `oid`, so the Camunda username is
147
+ // the account's object id and that is what the mapping rule has to match.
148
+ const testUser = entra ? entra.oid : randomSuffix;
149
+ const password = entra
150
+ ? entra.password
151
+ : node_process_1.default.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
125
152
  const credentials = {
126
- username: testUser,
153
+ username: entra ? entra.username : testUser,
127
154
  password: password,
128
155
  };
129
- const mappingRuleId = `${testUser}-user-mapping`;
130
- const claimName = 'preferred_username';
156
+ // A pool account outlives the attempt, so an Entra run uses a fixed id
157
+ // that the next attempt can find and remove before its no-access checks.
158
+ const mappingRuleId = entra
159
+ ? `e2e-entra-pool-${ENTRA_SLOT}-mapping`
160
+ : `${randomSuffix}-user-mapping`;
161
+ const claimName = entra ? 'oid' : 'preferred_username';
162
+ const adminUser = entra ? node_process_1.default.env.ENTRA_USER_OBJECT_ID : 'demo';
131
163
  await SM_8_10_1.test.step('Navigate to Keycloak and Create New User', async () => {
164
+ if (entra) {
165
+ return;
166
+ }
132
167
  await (0, KeycloakUtils_1.createUser)(navigationPage, managementIdentityPage, keycloakLoginPage, keycloakAdminPage, testUser, password);
133
168
  });
134
169
  await SM_8_10_1.test.step('Navigate to OC Identity', async () => {
135
170
  await navigationPage.goToOCAdmin();
136
171
  });
172
+ await SM_8_10_1.test.step('Remove a Mapping Rule Left by an Earlier Attempt', async () => {
173
+ if (!entra) {
174
+ return;
175
+ }
176
+ await ocIdentityHomePage.clickMappingRulesTab();
177
+ await ocIdentityMappingRulesPage.filterTable(mappingRuleId);
178
+ const leftOver = await (0, findLocatorWithPagination_1.findLocatorWithPagination)(page, ocIdentityMappingRulesPage.mappingRuleCell(mappingRuleId).first(), { timeout: 30000 });
179
+ if (leftOver) {
180
+ await ocIdentityMappingRulesPage.deleteMappingRule(mappingRuleId);
181
+ }
182
+ });
137
183
  await SM_8_10_1.test.step('Assert Admin Mapping and No Mapping Defined for Test User', async () => {
138
184
  await ocIdentityHomePage.clickRolesTab();
139
185
  await ocIdentityRolesPage.clickRole('admin');
140
- await (0, test_1.expect)(ocIdentityRolesPage.roleCell('demo')).toBeVisible();
186
+ await (0, test_1.expect)(ocIdentityRolesPage.roleCell(adminUser)).toBeVisible();
141
187
  await ocIdentityHomePage.clickMappingRulesTab();
142
188
  await (0, sleep_1.sleep)(1000);
143
189
  await (0, expectTextWithPagination_1.expectTextWithPagination)(page, testUser, { shouldBeVisible: false });
@@ -8,7 +8,18 @@ const optimizeReportUtils_1 = require("../../pages/SM-8.10/optimizeReportUtils")
8
8
  const loggingUtils_1 = require("../../utils/loggingUtils");
9
9
  const resetSession_1 = require("../../utils/resetSession");
10
10
  const KeycloakUtils_1 = require("../../pages/SM-8.10/KeycloakUtils");
11
+ const EntraUtils_1 = require("../../pages/SM-8.10/EntraUtils");
12
+ const entraLogin_1 = require("../../utils/entraLogin");
11
13
  const constants_1 = require("../../utils/constants");
14
+ // Entra pool slots 1..5 belong to SM-8.10; one per test so the four run in
15
+ // parallel without sharing an identity. Slot 5 is left to identity-user-flows,
16
+ // which needs an account that starts with no Orchestration Cluster access.
17
+ const ENTRA_SLOTS = {
18
+ 'Basic Login': 1,
19
+ 'Basic Navigation': 2,
20
+ 'Most Common Flow User Flow With All Apps': 3,
21
+ 'Most Common REST Connector User Flow @tasklistV2': 4,
22
+ };
12
23
  SM_8_10_1.test.describe.parallel('Smoke Tests', () => {
13
24
  SM_8_10_1.test.beforeEach(async ({ navigationPage, managementIdentityPage, managementIdentityTenantPage, keycloakLoginPage, keycloakAdminPage, page, browser, ocIdentityHomePage, ocIdentityRolesPage, }, testInfo) => {
14
25
  if (process.env.IS_MIGRATION === 'true') {
@@ -22,7 +33,22 @@ SM_8_10_1.test.describe.parallel('Smoke Tests', () => {
22
33
  else {
23
34
  console.log(`BeforeEach start: timeout = ${testInfo.timeout}`);
24
35
  (0, loggingUtils_1.setupTestLogging)(testInfo);
25
- const { testUsername, testPassword } = await (0, KeycloakUtils_1.setupKeycloakUser)(navigationPage, managementIdentityPage, keycloakLoginPage, keycloakAdminPage, ocIdentityHomePage, ocIdentityRolesPage, process.env.IS_MT === 'true', managementIdentityTenantPage);
36
+ let testUsername;
37
+ let testPassword;
38
+ if ((0, entraLogin_1.isEntraRun)()) {
39
+ const slot = ENTRA_SLOTS[testInfo.title];
40
+ if (slot === undefined) {
41
+ throw new Error(`No Entra pool slot is assigned to "${testInfo.title}". Add it ` +
42
+ 'to ENTRA_SLOTS -- two tests sharing a slot race on the same ' +
43
+ 'identity.');
44
+ }
45
+ const poolUser = await (0, EntraUtils_1.setupEntraPoolUser)(navigationPage, ocIdentityHomePage, ocIdentityRolesPage, slot);
46
+ testUsername = poolUser.username;
47
+ testPassword = poolUser.password;
48
+ }
49
+ else {
50
+ ({ testUsername, testPassword } = await (0, KeycloakUtils_1.setupKeycloakUser)(navigationPage, managementIdentityPage, keycloakLoginPage, keycloakAdminPage, ocIdentityHomePage, ocIdentityRolesPage, process.env.IS_MT === 'true', managementIdentityTenantPage));
51
+ }
26
52
  console.log(`BeforeEach end: timeout = ${testInfo.timeout}`);
27
53
  await (0, resetSession_1.resetSession)(browser, page);
28
54
  // Not loginPage.login() on the page resetSession leaves us on: where
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_1 = require("@playwright/test");
4
+ const SM_8_11_1 = require("../../fixtures/SM-8.11");
5
+ const _setup_1 = require("../../test-setup.js");
6
+ const loggingUtils_1 = require("../../utils/loggingUtils");
7
+ SM_8_11_1.test.describe('Entra ID Sign-In', () => {
8
+ SM_8_11_1.test.beforeEach(async ({ page }, testInfo) => {
9
+ (0, loggingUtils_1.setupTestLogging)(testInfo);
10
+ await page.context().clearCookies();
11
+ });
12
+ SM_8_11_1.test.afterEach(async ({ page }, testInfo) => {
13
+ await (0, _setup_1.captureScreenshot)(page, testInfo);
14
+ await (0, _setup_1.captureFailureVideo)(page, testInfo);
15
+ (0, loggingUtils_1.cleanupTestLogging)();
16
+ });
17
+ (0, SM_8_11_1.test)('signs in to Web Modeler through Entra ID', async ({ page, loginPage, }) => {
18
+ await SM_8_11_1.test.step('Open Web Modeler and follow the IdP redirect', async () => {
19
+ // C8_USERNAME/C8_PASSWORD are the SaaS slots and are never exported by
20
+ // the SM flow: it passes sm_username/sm_password -- the Entra address and
21
+ // password on an oidc run -- which run-tests-reusable maps to these two.
22
+ // Reading the SaaS names filled both Entra fields with the empty string,
23
+ // so the IdP answered "Enter a valid email address" and the test failed
24
+ // 120s later on waitForURL rather than on the missing credential.
25
+ const username = process.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_USERNAME;
26
+ const password = process.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
27
+ (0, test_1.expect)(username, 'DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_USERNAME is unset').toBeTruthy();
28
+ (0, test_1.expect)(password, 'DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD is unset').toBeTruthy();
29
+ await page.goto('/modeler');
30
+ await page.waitForURL((url) => url.hostname.endsWith('login.microsoftonline.com'), { timeout: 60000 });
31
+ const submitted = await loginPage.login(username, password);
32
+ (0, test_1.expect)(submitted).toBe(true);
33
+ });
34
+ await SM_8_11_1.test.step('Land back on Web Modeler as a signed-in user', async () => {
35
+ await page.waitForURL((url) => url.pathname.startsWith('/modeler'), {
36
+ timeout: 120000,
37
+ });
38
+ await (0, test_1.expect)(page.getByRole('link', { name: /workspaces/i }).first()).toBeVisible({ timeout: 60000 });
39
+ });
40
+ });
41
+ });
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const findLocatorWithPagination_1 = require("../../utils/assertionHelpers/findLocatorWithPagination");
6
7
  const test_1 = require("@playwright/test");
7
8
  const SM_8_11_1 = require("../../fixtures/SM-8.11");
8
9
  const _setup_1 = require("../../test-setup.js");
@@ -12,6 +13,10 @@ const node_process_1 = __importDefault(require("node:process"));
12
13
  const KeycloakUtils_1 = require("../../pages/SM-8.11/KeycloakUtils");
13
14
  const expectLocatorWithPagination_1 = require("../../utils/assertionHelpers/expectLocatorWithPagination");
14
15
  const expectTextWithPagination_1 = require("../../utils/assertionHelpers/expectTextWithPagination");
16
+ const entraLogin_1 = require("../../utils/entraLogin");
17
+ const users_1 = require("../../utils/users");
18
+ // The pool account this spec signs in as; see the slot comment in the test.
19
+ const ENTRA_SLOT = 10;
15
20
  SM_8_11_1.test.describe('Identity User Flow Tests', () => {
16
21
  SM_8_11_1.test.afterEach(async ({ page }, testInfo) => {
17
22
  await (0, _setup_1.captureScreenshot)(page, testInfo);
@@ -23,6 +28,19 @@ SM_8_11_1.test.describe('Identity User Flow Tests', () => {
23
28
  node_process_1.default.env.IS_LICENSE_KEY === 'true') {
24
29
  SM_8_11_1.test.skip(true, 'Skipping test because test not required in this test environment');
25
30
  }
31
+ // The flow under test is Management Identity's Users -> Assigned roles
32
+ // tab, which an OIDC cluster does not have: there is no local user store
33
+ // to create the account in, and component access comes from mapping rules
34
+ // on token claims rather than from a per-user grant. Not applicable rather
35
+ // than broken.
36
+ //
37
+ // The Orchestration Cluster test below is NOT a substitute -- it covers
38
+ // OC-level access, not Management Identity's Hub/Optimize roles -- so
39
+ // enforcement of those roles is genuinely unverified on Entra. #4730
40
+ // tracks closing that gap, which needs a chart change: the QA OIDC values
41
+ // grant them on the tenant claim, so every pool account holds them and
42
+ // none can assert their absence.
43
+ SM_8_11_1.test.skip((0, entraLogin_1.isEntraRun)(), 'Management Identity assigns roles per user only on a Keycloak cluster');
26
44
  SM_8_11_1.test.slow();
27
45
  const testUser = (await (0, _setup_1.generateRandomStringAsync)(6)).toLowerCase();
28
46
  const password = node_process_1.default.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
@@ -124,24 +142,52 @@ SM_8_11_1.test.describe('Identity User Flow Tests', () => {
124
142
  SM_8_11_1.test.skip(true, 'Skipping test because test not required in this test environment');
125
143
  }
126
144
  SM_8_11_1.test.slow();
127
- const testUser = (await (0, _setup_1.generateRandomStringAsync)(6)).toLowerCase();
128
- const password = node_process_1.default.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
145
+ // Slot 10 is reserved for this spec: it is the one pool account the SM-8.11
146
+ // smoke tests never put in the admin role, which this test needs because
147
+ // it asserts the user has no access before the mapping rule exists.
148
+ const entra = (0, entraLogin_1.isEntraRun)() ? (0, users_1.requireEntraPoolUser)(ENTRA_SLOT) : undefined;
149
+ const randomSuffix = (await (0, _setup_1.generateRandomStringAsync)(6)).toLowerCase();
150
+ // On an Entra cluster usernameClaim is `oid`, so the Camunda username is
151
+ // the account's object id and that is what the mapping rule has to match.
152
+ const testUser = entra ? entra.oid : randomSuffix;
153
+ const password = entra
154
+ ? entra.password
155
+ : node_process_1.default.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
129
156
  const credentials = {
130
- username: testUser,
157
+ username: entra ? entra.username : testUser,
131
158
  password: password,
132
159
  };
133
- const mappingRuleId = `${testUser}-user-mapping`;
134
- const claimName = 'preferred_username';
160
+ // A pool account outlives the attempt, so an Entra run uses a fixed id
161
+ // that the next attempt can find and remove before its no-access checks.
162
+ const mappingRuleId = entra
163
+ ? `e2e-entra-pool-${ENTRA_SLOT}-mapping`
164
+ : `${randomSuffix}-user-mapping`;
165
+ const claimName = entra ? 'oid' : 'preferred_username';
166
+ const adminUser = entra ? node_process_1.default.env.ENTRA_USER_OBJECT_ID : 'demo';
135
167
  await SM_8_11_1.test.step('Navigate to Keycloak and Create New User', async () => {
168
+ if (entra) {
169
+ return;
170
+ }
136
171
  await (0, KeycloakUtils_1.createUser)(navigationPage, managementIdentityPage, keycloakLoginPage, keycloakAdminPage, testUser, password);
137
172
  });
138
173
  await SM_8_11_1.test.step('Navigate to OC Identity', async () => {
139
174
  await navigationPage.goToOCAdmin();
140
175
  });
176
+ await SM_8_11_1.test.step('Remove a Mapping Rule Left by an Earlier Attempt', async () => {
177
+ if (!entra) {
178
+ return;
179
+ }
180
+ await ocIdentityHomePage.clickMappingRulesTab();
181
+ await ocIdentityMappingRulesPage.filterTable(mappingRuleId);
182
+ const leftOver = await (0, findLocatorWithPagination_1.findLocatorWithPagination)(page, ocIdentityMappingRulesPage.mappingRuleCell(mappingRuleId).first(), { timeout: 30000 });
183
+ if (leftOver) {
184
+ await ocIdentityMappingRulesPage.deleteMappingRule(mappingRuleId);
185
+ }
186
+ });
141
187
  await SM_8_11_1.test.step('Assert Admin Mapping and No Mapping Defined for Test User', async () => {
142
188
  await ocIdentityHomePage.clickRolesTab();
143
189
  await ocIdentityRolesPage.clickRole('admin');
144
- await (0, test_1.expect)(ocIdentityRolesPage.roleCell('demo')).toBeVisible();
190
+ await (0, test_1.expect)(ocIdentityRolesPage.roleCell(adminUser)).toBeVisible();
145
191
  await ocIdentityHomePage.clickMappingRulesTab();
146
192
  await (0, sleep_1.sleep)(1000);
147
193
  await (0, expectTextWithPagination_1.expectTextWithPagination)(page, testUser, { shouldBeVisible: false });
@@ -8,7 +8,19 @@ const optimizeReportUtils_1 = require("../../pages/SM-8.11/optimizeReportUtils")
8
8
  const loggingUtils_1 = require("../../utils/loggingUtils");
9
9
  const resetSession_1 = require("../../utils/resetSession");
10
10
  const KeycloakUtils_1 = require("../../pages/SM-8.11/KeycloakUtils");
11
+ const EntraUtils_1 = require("../../pages/SM-8.11/EntraUtils");
12
+ const entraLogin_1 = require("../../utils/entraLogin");
11
13
  const constants_1 = require("../../utils/constants");
14
+ // Entra pool slots 6..10 belong to SM-8.11 (1..5 to SM-8.10, so the two
15
+ // nightlies can overlap); one per test so the four run in parallel without
16
+ // sharing an identity. Slot 10 is left to identity-user-flows, which needs an
17
+ // account that starts with no Orchestration Cluster access.
18
+ const ENTRA_SLOTS = {
19
+ 'Basic Login': 6,
20
+ 'Basic Navigation': 7,
21
+ 'Most Common Flow User Flow With All Apps': 8,
22
+ 'Most Common REST Connector User Flow @tasklistV2': 9,
23
+ };
12
24
  SM_8_11_1.test.describe.parallel('Smoke Tests', () => {
13
25
  SM_8_11_1.test.beforeEach(async ({ navigationPage, managementIdentityPage, managementIdentityTenantPage, keycloakLoginPage, keycloakAdminPage, page, browser, ocIdentityHomePage, ocIdentityRolesPage, }, testInfo) => {
14
26
  if (process.env.IS_MIGRATION === 'true') {
@@ -17,7 +29,22 @@ SM_8_11_1.test.describe.parallel('Smoke Tests', () => {
17
29
  else {
18
30
  console.log(`BeforeEach start: timeout = ${testInfo.timeout}`);
19
31
  (0, loggingUtils_1.setupTestLogging)(testInfo);
20
- const { testUsername, testPassword } = await (0, KeycloakUtils_1.setupKeycloakUser)(navigationPage, managementIdentityPage, keycloakLoginPage, keycloakAdminPage, ocIdentityHomePage, ocIdentityRolesPage, process.env.IS_MT === 'true', managementIdentityTenantPage);
32
+ let testUsername;
33
+ let testPassword;
34
+ if ((0, entraLogin_1.isEntraRun)()) {
35
+ const slot = ENTRA_SLOTS[testInfo.title];
36
+ if (slot === undefined) {
37
+ throw new Error(`No Entra pool slot is assigned to "${testInfo.title}". Add it ` +
38
+ 'to ENTRA_SLOTS -- two tests sharing a slot race on the same ' +
39
+ 'identity.');
40
+ }
41
+ const poolUser = await (0, EntraUtils_1.setupEntraPoolUser)(navigationPage, ocIdentityHomePage, ocIdentityRolesPage, slot);
42
+ testUsername = poolUser.username;
43
+ testPassword = poolUser.password;
44
+ }
45
+ else {
46
+ ({ testUsername, testPassword } = await (0, KeycloakUtils_1.setupKeycloakUser)(navigationPage, managementIdentityPage, keycloakLoginPage, keycloakAdminPage, ocIdentityHomePage, ocIdentityRolesPage, process.env.IS_MT === 'true', managementIdentityTenantPage));
47
+ }
21
48
  console.log(`BeforeEach end: timeout = ${testInfo.timeout}`);
22
49
  await (0, resetSession_1.resetSession)(browser, page);
23
50
  // Not loginPage.login() on the page resetSession leaves us on: where
@@ -11,6 +11,7 @@ const fs_1 = __importDefault(require("fs"));
11
11
  const path_1 = __importDefault(require("path"));
12
12
  const os_1 = __importDefault(require("os"));
13
13
  const utils_1 = require("./utils");
14
+ const entraLogin_1 = require("./entraLogin");
14
15
  let apiRequestContext;
15
16
  // ---- Internal: API request context ----
16
17
  async function getApiRequestContext() {
@@ -218,6 +219,31 @@ function buildZeebeApiUrl(resourcePath, environmentOverride, clusterType) {
218
219
  return `${baseUrl}${pathWithPrefix}`;
219
220
  }
220
221
  exports.buildZeebeApiUrl = buildZeebeApiUrl;
222
+ // ---- Auth ----
223
+ const entraAudienceByOrigin = new Map();
224
+ // Each deployment signs in against an app registration of its own, so the
225
+ // audience the components validate is that app's id -- not the shared app the
226
+ // job authenticates as. The login page embeds it, which keeps this independent
227
+ // of the namespace-to-app-name convention.
228
+ async function resolveEntraAudience(origin) {
229
+ const configured = process.env.ENTRA_API_AUDIENCE?.trim();
230
+ if (configured) {
231
+ return configured;
232
+ }
233
+ const cached = entraAudienceByOrigin.get(origin);
234
+ if (cached) {
235
+ return cached;
236
+ }
237
+ const loginUrl = `${origin}/modeler/login`;
238
+ const response = await apiRequestContext.get(loginUrl);
239
+ const clientId = (await response.text()).match(/"clientId"\s*:\s*"([0-9a-fA-F-]{36})"/)?.[1];
240
+ if (!clientId) {
241
+ throw new Error(`Could not resolve the Entra audience from ${loginUrl} ` +
242
+ `(HTTP ${response.status()}): the page embedded no clientId.`);
243
+ }
244
+ entraAudienceByOrigin.set(origin, clientId);
245
+ return clientId;
246
+ }
221
247
  async function authAPI(environment, audience = process.env.ZEEBE_API_TOKEN_AUDIENCE) {
222
248
  apiRequestContext = await getApiRequestContext();
223
249
  if (environment === 'saas') {
@@ -245,20 +271,43 @@ async function authAPI(environment, audience = process.env.ZEEBE_API_TOKEN_AUDIE
245
271
  throw new Error('Missing BASE_URL (required for SM auth).');
246
272
  }
247
273
  const origin = normalizeOrigin(baseUrlRaw, 'https');
248
- const tokenUrl = `${origin}/auth/realms/camunda-platform/protocol/openid-connect/token`;
249
- const tokenResponse = await apiRequestContext.post(tokenUrl, {
274
+ // An OIDC cluster has no Keycloak, so the realm token endpoint is not served
275
+ // at all: the request 404s with an empty body, which is why the failure read
276
+ // `Failed to fetch SM access token. Response: ` with nothing after it. Mint
277
+ // the token at the IdP instead, with the resource scope the chart already
278
+ // gives connectors and console (tokenScope: $ENTRA_APP_CLIENT_ID/.default) --
279
+ // without it Entra issues a Microsoft Graph token the cluster cannot
280
+ // validate against its own issuer.
281
+ const entraTenant = process.env.ENTRA_APP_DIRECTORY_ID?.trim();
282
+ const entraClientId = process.env.ENTRA_APP_CLIENT_ID?.trim();
283
+ const tokenRequest = (0, entraLogin_1.isEntraRun)() && entraTenant && entraClientId
284
+ ? {
285
+ url: `https://login.microsoftonline.com/${entraTenant}/oauth2/v2.0/token`,
286
+ form: {
287
+ client_id: entraClientId,
288
+ client_secret: process.env.ENTRA_APP_CLIENT_SECRET,
289
+ grant_type: 'client_credentials',
290
+ scope: `${await resolveEntraAudience(origin)}/.default`,
291
+ },
292
+ }
293
+ : {
294
+ url: `${origin}/auth/realms/camunda-platform/protocol/openid-connect/token`,
295
+ form: {
296
+ client_id: process.env.DISTRO_QA_E2E_TESTS_KEYCLOAK_CLIENT_ID ?? 'venom',
297
+ client_secret: process.env.DISTRO_QA_E2E_TESTS_KEYCLOAK_ADMIN_SECRET,
298
+ grant_type: 'client_credentials',
299
+ },
300
+ };
301
+ const tokenResponse = await apiRequestContext.post(tokenRequest.url, {
250
302
  headers: {
251
303
  'Content-Type': 'application/x-www-form-urlencoded',
252
304
  },
253
- form: {
254
- client_id: process.env.DISTRO_QA_E2E_TESTS_KEYCLOAK_CLIENT_ID ?? 'venom',
255
- client_secret: process.env.DISTRO_QA_E2E_TESTS_KEYCLOAK_ADMIN_SECRET,
256
- grant_type: 'client_credentials',
257
- },
305
+ form: tokenRequest.form,
258
306
  });
259
307
  if (tokenResponse.status() !== 200) {
260
308
  const errorBody = await tokenResponse.text();
261
- throw new Error(`Failed to fetch SM access token. Response: ${errorBody}`);
309
+ throw new Error(`Failed to fetch SM access token from ${tokenRequest.url} ` +
310
+ `(HTTP ${tokenResponse.status()}). Response: ${errorBody}`);
262
311
  }
263
312
  const tokenJson = await tokenResponse.json();
264
313
  const bearerToken = `Bearer ${tokenJson.access_token}`;
@@ -961,7 +1010,9 @@ async function getOptimizeCoockie(page) {
961
1010
  exports.getOptimizeCoockie = getOptimizeCoockie;
962
1011
  async function performOptimizeKeycloakLogin(page, callerLabel, verifySession) {
963
1012
  const optimizeUrl = process.env.CAMUNDA_OPTIMIZE_BASE_URL;
964
- const username = 'demo';
1013
+ // Keycloak clusters seed a local `demo` user; an OIDC cluster has none, and
1014
+ // the identity that can sign in is the IdP user the workflow exports here.
1015
+ const username = process.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_USERNAME || 'demo';
965
1016
  const password = process.env.DISTRO_QA_E2E_TESTS_IDENTITY_FIRSTUSER_PASSWORD;
966
1017
  const maxLoginAttempts = 6;
967
1018
  // Upgrade scenarios trigger rolling restarts of Optimize; page.goto can
@@ -977,11 +1028,16 @@ async function performOptimizeKeycloakLogin(page, callerLabel, verifySession) {
977
1028
  if (response && response.status() >= 500) {
978
1029
  throw new Error(`${callerLabel}: Optimize returned ${response.status()} on load (service not ready yet)`);
979
1030
  }
980
- await page.waitForSelector('#username', { timeout: 30000 });
981
- await page.fill('#username', username);
982
- await page.fill('#password', password);
983
- await page.click('button[type="submit"]');
984
- await page.waitForURL(`${optimizeUrl}/**`, { timeout: 30000 });
1031
+ const form = await (0, entraLogin_1.waitForLoginForm)(page, 30000);
1032
+ if (form === 'entra') {
1033
+ await (0, entraLogin_1.signInWithEntra)(page, username, password);
1034
+ }
1035
+ else {
1036
+ await page.fill('#username', username);
1037
+ await page.fill('#password', password);
1038
+ await page.click('button[type="submit"]');
1039
+ }
1040
+ await page.waitForURL(`${optimizeUrl}/**`, { timeout: 60000 });
985
1041
  if (verifySession && !(await verifySession(page))) {
986
1042
  await redoOptimizeSsoHandshake(page);
987
1043
  if (!(await verifySession(page))) {
@@ -0,0 +1,48 @@
1
+ import { Page } from '@playwright/test';
2
+ export declare const entraLocators: (page: Page) => {
3
+ email: import("playwright-core").Locator;
4
+ password: import("playwright-core").Locator;
5
+ code: import("playwright-core").Locator;
6
+ submit: import("playwright-core").Locator;
7
+ staySignedInDecline: import("playwright-core").Locator;
8
+ consentAccept: import("playwright-core").Locator;
9
+ };
10
+ export declare function isEntraRun(): boolean;
11
+ /**
12
+ * The authenticator seed registered for one Entra account.
13
+ *
14
+ * Every pool slot has its own seed, so a single ENTRA_TOTP_SECRET is only
15
+ * right for the admin identity the workflow signs in with by default. Looking
16
+ * the seed up from the address being typed keeps every existing caller --
17
+ * which passes credentials and nothing else -- working for a pool user too.
18
+ */
19
+ export declare function totpSecretForUser(username: string): string | undefined;
20
+ /**
21
+ * Drive the Entra ID sign-in pages.
22
+ *
23
+ * Entra splits sign-in across sequential pages -- email, then password, then
24
+ * the authenticator code -- each submitted with the same #idSIButton9. The
25
+ * code page only appears when the tenant's Conditional Access asks for it, and
26
+ * the "stay signed in" page only on some sign-ins, so both are probed rather
27
+ * than awaited unconditionally.
28
+ *
29
+ * A consent page can sit between them the first time an account signs in to
30
+ * an app it has not used before, so it is raced against "stay signed in"
31
+ * rather than probed separately: only one of the two is ever shown, and
32
+ * waiting for each in turn would spend the missing one's timeout on every
33
+ * sign-in. Leaving a consent page unanswered is read as a refusal and the
34
+ * callback returns AADSTS65004.
35
+ *
36
+ * The tenant only lets an admin consent, so this clears the page for an
37
+ * account that may consent for itself; for the pool accounts the grant has to
38
+ * exist before they arrive.
39
+ */
40
+ export declare function signInWithEntra(page: Page, username: string, password: string): Promise<void>;
41
+ /**
42
+ * Wait for whichever sign-in form the cluster serves and say which it was.
43
+ *
44
+ * An OIDC cluster redirects to Entra on a different origin, so the Keycloak
45
+ * `#username` field never renders there and waiting for it burns the whole
46
+ * timeout -- which is how the Optimize API specs failed on the Entra nightly.
47
+ */
48
+ export declare function waitForLoginForm(page: Page, timeout?: number): Promise<'entra' | 'keycloak'>;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.waitForLoginForm = exports.signInWithEntra = exports.totpSecretForUser = exports.isEntraRun = exports.entraLocators = void 0;
4
+ const totp_1 = require("./totp");
5
+ const ENTRA_HOST = 'login.microsoftonline.com';
6
+ const entraLocators = (page) => ({
7
+ email: page.locator('input[name="loginfmt"]'),
8
+ password: page.locator('input[name="passwd"]'),
9
+ code: page.locator('input[name="otc"]'),
10
+ submit: page.locator('#idSIButton9'),
11
+ staySignedInDecline: page.locator('#idBtn_Back'),
12
+ consentAccept: page.getByRole('button', { name: 'Accept' }),
13
+ });
14
+ exports.entraLocators = entraLocators;
15
+ function isEntraRun() {
16
+ return Boolean(process.env.ENTRA_TOTP_SECRET);
17
+ }
18
+ exports.isEntraRun = isEntraRun;
19
+ /**
20
+ * The authenticator seed registered for one Entra account.
21
+ *
22
+ * Every pool slot has its own seed, so a single ENTRA_TOTP_SECRET is only
23
+ * right for the admin identity the workflow signs in with by default. Looking
24
+ * the seed up from the address being typed keeps every existing caller --
25
+ * which passes credentials and nothing else -- working for a pool user too.
26
+ */
27
+ function totpSecretForUser(username) {
28
+ const wanted = username.trim().toLowerCase();
29
+ for (const [name, value] of Object.entries(process.env)) {
30
+ const slot = /^ENTRA_USER_EMAIL(?:_(\d+))?$/.exec(name);
31
+ if (!slot || value?.trim().toLowerCase() !== wanted) {
32
+ continue;
33
+ }
34
+ const secret = process.env[slot[1] ? `ENTRA_USER_TOTP_SECRET_${slot[1]}` : 'ENTRA_USER_TOTP_SECRET'];
35
+ if (secret) {
36
+ return secret;
37
+ }
38
+ }
39
+ return process.env.ENTRA_TOTP_SECRET;
40
+ }
41
+ exports.totpSecretForUser = totpSecretForUser;
42
+ /**
43
+ * Drive the Entra ID sign-in pages.
44
+ *
45
+ * Entra splits sign-in across sequential pages -- email, then password, then
46
+ * the authenticator code -- each submitted with the same #idSIButton9. The
47
+ * code page only appears when the tenant's Conditional Access asks for it, and
48
+ * the "stay signed in" page only on some sign-ins, so both are probed rather
49
+ * than awaited unconditionally.
50
+ *
51
+ * A consent page can sit between them the first time an account signs in to
52
+ * an app it has not used before, so it is raced against "stay signed in"
53
+ * rather than probed separately: only one of the two is ever shown, and
54
+ * waiting for each in turn would spend the missing one's timeout on every
55
+ * sign-in. Leaving a consent page unanswered is read as a refusal and the
56
+ * callback returns AADSTS65004.
57
+ *
58
+ * The tenant only lets an admin consent, so this clears the page for an
59
+ * account that may consent for itself; for the pool accounts the grant has to
60
+ * exist before they arrive.
61
+ */
62
+ async function signInWithEntra(page, username, password) {
63
+ const entra = (0, exports.entraLocators)(page);
64
+ await entra.email.waitFor({ state: 'visible', timeout: 60000 });
65
+ await entra.email.fill(username);
66
+ await entra.submit.click({ timeout: 60000 });
67
+ await entra.password.waitFor({ state: 'visible', timeout: 60000 });
68
+ await entra.password.fill(password);
69
+ await entra.submit.click({ timeout: 60000 });
70
+ const codeRequested = await entra.code
71
+ .waitFor({ state: 'visible', timeout: 30000 })
72
+ .then(() => true)
73
+ .catch(() => false);
74
+ if (codeRequested) {
75
+ const secret = totpSecretForUser(username);
76
+ if (!secret) {
77
+ throw new Error(`Entra requested a verification code for ${username} but no ` +
78
+ 'authenticator seed is set for it (ENTRA_USER_TOTP_SECRET_<slot>, ' +
79
+ 'or ENTRA_TOTP_SECRET for the default identity).');
80
+ }
81
+ await entra.code.fill((0, totp_1.generateTotp)(secret));
82
+ await entra.submit.click({ timeout: 60000 });
83
+ }
84
+ const prompted = await entra.consentAccept
85
+ .or(entra.staySignedInDecline)
86
+ .first()
87
+ .waitFor({ state: 'visible', timeout: 30000 })
88
+ .then(() => true)
89
+ .catch(() => false);
90
+ if (prompted && (await entra.consentAccept.isVisible())) {
91
+ await entra.consentAccept.click({ timeout: 60000 });
92
+ const staysAfterConsent = await entra.staySignedInDecline
93
+ .waitFor({ state: 'visible', timeout: 30000 })
94
+ .then(() => true)
95
+ .catch(() => false);
96
+ if (staysAfterConsent) {
97
+ await entra.staySignedInDecline.click({ timeout: 60000 });
98
+ }
99
+ return;
100
+ }
101
+ if (prompted) {
102
+ await entra.staySignedInDecline.click({ timeout: 60000 });
103
+ }
104
+ }
105
+ exports.signInWithEntra = signInWithEntra;
106
+ /**
107
+ * Wait for whichever sign-in form the cluster serves and say which it was.
108
+ *
109
+ * An OIDC cluster redirects to Entra on a different origin, so the Keycloak
110
+ * `#username` field never renders there and waiting for it burns the whole
111
+ * timeout -- which is how the Optimize API specs failed on the Entra nightly.
112
+ */
113
+ async function waitForLoginForm(page, timeout = 30000) {
114
+ const entra = (0, exports.entraLocators)(page);
115
+ const keycloakUsername = page.locator('#username');
116
+ await keycloakUsername
117
+ .or(entra.email)
118
+ .first()
119
+ .waitFor({ state: 'visible', timeout });
120
+ return page.url().includes(ENTRA_HOST) ? 'entra' : 'keycloak';
121
+ }
122
+ exports.waitForLoginForm = waitForLoginForm;
@@ -0,0 +1,2 @@
1
+ declare function generateTotp(secret: string, atMs?: number): string;
2
+ export { generateTotp };