Merge pull request #23175 from Phiph/bug/ado-scopes

Fix Microsoft Auth Provider when getting ADO Scopes
This commit is contained in:
Ben Lambert
2024-02-26 16:38:31 +01:00
committed by GitHub
3 changed files with 21 additions and 10 deletions
@@ -112,7 +112,8 @@ describe('ScmAuth', () => {
await expect(
azureAuth.getCredentials({ url: 'http://example.com' }),
).resolves.toMatchObject({
token: 'vso.build vso.code vso.graph vso.project vso.profile',
token:
'499b84ac-1321-427f-aa17-267ca6975798/vso.build 499b84ac-1321-427f-aa17-267ca6975798/vso.code 499b84ac-1321-427f-aa17-267ca6975798/vso.graph 499b84ac-1321-427f-aa17-267ca6975798/vso.project 499b84ac-1321-427f-aa17-267ca6975798/vso.profile',
});
await expect(
azureAuth.getCredentials({
@@ -121,7 +122,7 @@ describe('ScmAuth', () => {
}),
).resolves.toMatchObject({
token:
'vso.build vso.code vso.graph vso.project vso.profile vso.code_manage',
'499b84ac-1321-427f-aa17-267ca6975798/vso.build 499b84ac-1321-427f-aa17-267ca6975798/vso.code 499b84ac-1321-427f-aa17-267ca6975798/vso.graph 499b84ac-1321-427f-aa17-267ca6975798/vso.project 499b84ac-1321-427f-aa17-267ca6975798/vso.profile 499b84ac-1321-427f-aa17-267ca6975798/vso.code_manage',
});
const bitbucketAuth = ScmAuth.forBitbucket(mockAuthApi);
@@ -174,10 +175,15 @@ describe('ScmAuth', () => {
await expect(
azureAuth.getCredentials({
url: 'http://example.com',
additionalScope: { customScopes: { azure: ['vso.org'] } },
additionalScope: {
customScopes: {
azure: ['499b84ac-1321-427f-aa17-267ca6975798/vso.org'],
},
},
}),
).resolves.toMatchObject({
token: 'vso.build vso.code vso.graph vso.project vso.profile vso.org',
token:
'499b84ac-1321-427f-aa17-267ca6975798/vso.build 499b84ac-1321-427f-aa17-267ca6975798/vso.code 499b84ac-1321-427f-aa17-267ca6975798/vso.graph 499b84ac-1321-427f-aa17-267ca6975798/vso.project 499b84ac-1321-427f-aa17-267ca6975798/vso.profile 499b84ac-1321-427f-aa17-267ca6975798/vso.org',
});
const bitbucketAuth = ScmAuth.forBitbucket(mockAuthApi);
@@ -199,13 +199,13 @@ export class ScmAuth implements ScmAuthApi {
const host = options?.host ?? 'dev.azure.com';
return new ScmAuth('azure', microsoftAuthApi, host, {
default: [
'vso.build',
'vso.code',
'vso.graph',
'vso.project',
'vso.profile',
'499b84ac-1321-427f-aa17-267ca6975798/vso.build',
'499b84ac-1321-427f-aa17-267ca6975798/vso.code',
'499b84ac-1321-427f-aa17-267ca6975798/vso.graph',
'499b84ac-1321-427f-aa17-267ca6975798/vso.project',
'499b84ac-1321-427f-aa17-267ca6975798/vso.profile',
],
repoWrite: ['vso.code_manage'],
repoWrite: ['499b84ac-1321-427f-aa17-267ca6975798/vso.code_manage'],
});
}