Skip to content

Commit 640a407

Browse files
anshika-gupta21Anshika Gupta
andauthored
Adding AzureRM service connection to ATP task in Playwright (#21131)
* Add Connected Service input for Azure Resource Manager in Playwright Azure Test Plan task --------- Co-authored-by: Anshika Gupta <[email protected]>
1 parent 004044c commit 640a407

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

Tasks/AzureTestPlanV0/Automated Flow/TestExecutors/PlaywrightTestExecutor.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ export class PlaywrightTestExecutor implements ITestExecutor {
4949
}
5050
}
5151

52+
const connectedService = tl.getInput('ConnectedServiceName', false);
53+
if (connectedService) {
54+
var authScheme: string = tl.getEndpointAuthorizationScheme(connectedService, false);
55+
if (authScheme && authScheme.toLowerCase() == "workloadidentityfederation") {
56+
process.env.AZURESUBSCRIPTION_SERVICE_CONNECTION_ID = connectedService;
57+
process.env.AZURESUBSCRIPTION_CLIENT_ID = tl.getEndpointAuthorizationParameter(connectedService, "serviceprincipalid", false);
58+
process.env.AZURESUBSCRIPTION_TENANT_ID = tl.getEndpointAuthorizationParameter(connectedService, "tenantid", false);
59+
tl.debug('Environment variables AZURESUBSCRIPTION_SERVICE_CONNECTION_ID, AZURESUBSCRIPTION_CLIENT_ID and AZURESUBSCRIPTION_TENANT_ID are set');
60+
}
61+
else {
62+
tl.debug('Connected service is not of type Workload Identity Federation');
63+
}
64+
}
65+
else {
66+
tl.debug('No connected service set');
67+
}
68+
5269
} catch (error) {
5370
operationResult.returnCode = 1;
5471
operationResult.errorMessage = error.message || String(error);
@@ -96,7 +113,7 @@ export class PlaywrightTestExecutor implements ITestExecutor {
96113
grepArg = grepPattern;
97114

98115
tl.debug(`Grep Argument: ${grepArg}`);
99-
116+
100117
executionTimer.start();
101118

102119
const commandPreview = `npx cross-env PLAYWRIGHT_JUNIT_OUTPUT_NAME=${junitOutput} playwright test --reporter=junit -g "${grepArg}"`;

Tasks/AzureTestPlanV0/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?LinkID=613742)",
44
"loc.description": "Run manual and automated tests points of test plan for different testing frameworks like Maven and Gradle for Java, PyTest for Python and Jest for JavaScript",
55
"loc.instanceNameFormat": "Azure Test Plan - $(testSelector)",
6+
"loc.input.label.ConnectedServiceName": "Azure Resource Manager connection",
7+
"loc.input.help.ConnectedServiceName": "Select an Azure Resource Manager service connection",
68
"loc.input.label.testSelector": "Test cases to be executed",
79
"loc.input.help.testSelector": "<ul><li><b>Manual tests: </b>Use this option to trigger manual tests from your test plan.</li><li><b>Automated tests: </b>Use this option to run tests from your test plan that have automated test method associated with it.</li>",
810
"loc.input.label.testPlanOrRunSelector": "Select tests using",

Tasks/AzureTestPlanV0/task.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@
1414
"version": {
1515
"Major": 0,
1616
"Minor": 259,
17-
"Patch": 4
17+
"Patch": 5
1818
},
1919
"preview": true,
2020
"demands": [],
2121
"minimumAgentVersion": "2.144.0",
2222
"inputs": [
23+
{
24+
"name": "ConnectedServiceName",
25+
"aliases": [
26+
"azureSubscription"
27+
],
28+
"type": "connectedService:AzureRM",
29+
"label": "Azure Resource Manager connection",
30+
"defaultValue": "",
31+
"helpMarkDown": "Select an Azure Resource Manager service connection"
32+
},
2333
{
2434
"name": "testSelector",
2535
"type": "pickList",

Tasks/AzureTestPlanV0/task.loc.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@
1414
"version": {
1515
"Major": 0,
1616
"Minor": 259,
17-
"Patch": 4
17+
"Patch": 5
1818
},
1919
"preview": true,
2020
"demands": [],
2121
"minimumAgentVersion": "2.144.0",
2222
"inputs": [
23+
{
24+
"name": "ConnectedServiceName",
25+
"aliases": [
26+
"azureSubscription"
27+
],
28+
"type": "connectedService:AzureRM",
29+
"label": "ms-resource:loc.input.label.ConnectedServiceName",
30+
"defaultValue": "",
31+
"helpMarkDown": "ms-resource:loc.input.help.ConnectedServiceName"
32+
},
2333
{
2434
"name": "testSelector",
2535
"type": "pickList",

0 commit comments

Comments
 (0)