Skip to content

Commit

Permalink
Updated checks to new PAT format (#20436)
Browse files Browse the repository at this point in the history
* Update AzureTestPlanV0

Co-authored-by: Jan Kolarik jankolarik@microsoft.com

* Update AppCenterTestV1
  • Loading branch information
max-zaytsev authored Sep 20, 2024
1 parent 4ab3b20 commit e37b9a7
Show file tree
Hide file tree
Showing 22 changed files with 128 additions and 119 deletions.
3 changes: 2 additions & 1 deletion Tasks/AppCenterTestV1/appcentertest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ToolRunner } from 'azure-pipelines-task-lib/toolrunner';
var utils = require('./utils.js');

const testRunIdLineRegexp = /Test run id: "([^"]+)"/;
const personalAccessTokenRegexp = /^.{76}AZDO.{4}$/;

function getEndpointAPIToken(endpointInputFieldName) {
var errorMessage = tl.loc("CannotDecodeEndpoint");
Expand Down Expand Up @@ -206,7 +207,7 @@ async function setTestRunIdBuildPropertyAsync(testRunId: string) {
let token = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);
let projectId = tl.getVariable('System.TeamProjectId');
let buildId = tl.getVariable('Build.BuildId');
let auth = token.length == 52 ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let auth = token.length == (52 || personalAccessTokenRegexp.test(token)) ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let vsts: apim.WebApi = new apim.WebApi(url, auth);
let conn: lim.ConnectionData = await vsts.connect();
let buildApi = await vsts.getBuildApi();
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AppCenterTestV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 246,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.206.1",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AppCenterTestV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 246,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.206.1",
"groups": [
Expand Down
78 changes: 39 additions & 39 deletions Tasks/AzureTestPlanV0/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tasks/AzureTestPlanV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 246,
"Patch": 0
},
"preview": true,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureTestPlanV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 245,
"Minor": 246,
"Patch": 0
},
"preview": true,
Expand Down
6 changes: 4 additions & 2 deletions Tasks/AzureTestPlanV0/testPlanData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import VSSInterfaces = require('azure-devops-node-api/interfaces/common/VSSInter
import constants = require('./constants');
import { ITestResultsApi } from "azure-devops-node-api/TestResultsApi";

const personalAccessTokenRegexp = /^.{76}AZDO.{4}$/;

export interface TestPlanData {
listOfFQNOfTestCases: string[];
testPlanId: number;
Expand Down Expand Up @@ -186,7 +188,7 @@ export async function getTestCaseListAsync(testPlanId: number, testSuiteId: numb
let url = tl.getEndpointUrl('SYSTEMVSSCONNECTION', false);
let token = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);
let projectId = tl.getVariable('System.TeamProjectId');
let auth = token.length == 52 ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let auth = (token.length == 52 || personalAccessTokenRegexp.test(token)) ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let vsts: apim.WebApi = new apim.WebApi(url, auth);
let testPlanApi = await vsts.getTestPlanApi();

Expand Down Expand Up @@ -278,7 +280,7 @@ export async function getTestResultApiClient(){
let url = tl.getEndpointUrl('SYSTEMVSSCONNECTION', false);
let token = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);

let auth = token.length == 52 ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let auth = (token.length == 52 || personalAccessTokenRegexp.test(token)) ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let vsts: apim.WebApi = new apim.WebApi(url, auth);
let testResultsApi = await vsts.getTestResultsApi();

Expand Down
4 changes: 2 additions & 2 deletions _generated/AppCenterTestV1.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|1.246.0
Node20_229_7|1.246.1
Default|1.246.2
Node20_229_7|1.246.3
3 changes: 2 additions & 1 deletion _generated/AppCenterTestV1/appcentertest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ToolRunner } from 'azure-pipelines-task-lib/toolrunner';
var utils = require('./utils.js');

const testRunIdLineRegexp = /Test run id: "([^"]+)"/;
const personalAccessTokenRegexp = /^.{76}AZDO.{4}$/;

function getEndpointAPIToken(endpointInputFieldName) {
var errorMessage = tl.loc("CannotDecodeEndpoint");
Expand Down Expand Up @@ -206,7 +207,7 @@ async function setTestRunIdBuildPropertyAsync(testRunId: string) {
let token = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);
let projectId = tl.getVariable('System.TeamProjectId');
let buildId = tl.getVariable('Build.BuildId');
let auth = token.length == 52 ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let auth = token.length == (52 || personalAccessTokenRegexp.test(token)) ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let vsts: apim.WebApi = new apim.WebApi(url, auth);
let conn: lim.ConnectionData = await vsts.connect();
let buildApi = await vsts.getBuildApi();
Expand Down
6 changes: 3 additions & 3 deletions _generated/AppCenterTestV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 246,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.206.1",
"groups": [
Expand Down Expand Up @@ -499,7 +499,7 @@
"FoundMultipleFiles": "Found multiple files matching %s."
},
"_buildConfigMapping": {
"Default": "1.246.0",
"Node20_229_7": "1.246.1"
"Default": "1.246.2",
"Node20_229_7": "1.246.3"
}
}
6 changes: 3 additions & 3 deletions _generated/AppCenterTestV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 246,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.206.1",
"groups": [
Expand Down Expand Up @@ -499,7 +499,7 @@
"FoundMultipleFiles": "ms-resource:loc.messages.FoundMultipleFiles"
},
"_buildConfigMapping": {
"Default": "1.246.0",
"Node20_229_7": "1.246.1"
"Default": "1.246.2",
"Node20_229_7": "1.246.3"
}
}
3 changes: 2 additions & 1 deletion _generated/AppCenterTestV1_Node20/appcentertest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ToolRunner } from 'azure-pipelines-task-lib/toolrunner';
var utils = require('./utils.js');

const testRunIdLineRegexp = /Test run id: "([^"]+)"/;
const personalAccessTokenRegexp = /^.{76}AZDO.{4}$/;

function getEndpointAPIToken(endpointInputFieldName) {
var errorMessage = tl.loc("CannotDecodeEndpoint");
Expand Down Expand Up @@ -206,7 +207,7 @@ async function setTestRunIdBuildPropertyAsync(testRunId: string) {
let token = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);
let projectId = tl.getVariable('System.TeamProjectId');
let buildId = tl.getVariable('Build.BuildId');
let auth = token.length == 52 ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let auth = token.length == (52 || personalAccessTokenRegexp.test(token)) ? apim.getPersonalAccessTokenHandler(token) : apim.getBearerHandler(token);
let vsts: apim.WebApi = new apim.WebApi(url, auth);
let conn: lim.ConnectionData = await vsts.connect();
let buildApi = await vsts.getBuildApi();
Expand Down
6 changes: 3 additions & 3 deletions _generated/AppCenterTestV1_Node20/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 246,
"Patch": 1
"Patch": 3
},
"minimumAgentVersion": "2.206.1",
"groups": [
Expand Down Expand Up @@ -503,7 +503,7 @@
"FoundMultipleFiles": "Found multiple files matching %s."
},
"_buildConfigMapping": {
"Default": "1.246.0",
"Node20_229_7": "1.246.1"
"Default": "1.246.2",
"Node20_229_7": "1.246.3"
}
}
6 changes: 3 additions & 3 deletions _generated/AppCenterTestV1_Node20/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 246,
"Patch": 1
"Patch": 3
},
"minimumAgentVersion": "2.206.1",
"groups": [
Expand Down Expand Up @@ -503,7 +503,7 @@
"FoundMultipleFiles": "ms-resource:loc.messages.FoundMultipleFiles"
},
"_buildConfigMapping": {
"Default": "1.246.0",
"Node20_229_7": "1.246.1"
"Default": "1.246.2",
"Node20_229_7": "1.246.3"
}
}
4 changes: 2 additions & 2 deletions _generated/AzureTestPlanV0.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|0.245.0
Node20-225|0.245.1
Default|0.246.0
Node20-225|0.246.1
78 changes: 39 additions & 39 deletions _generated/AzureTestPlanV0/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e37b9a7

Please sign in to comment.