Skip to content

Commit 48553d0

Browse files
authored
Merge pull request #32: Support AAD in MSA
Support AAD in MSA
2 parents 3ad6ec1 + 2ed3790 commit 48553d0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/shared/Microsoft.AzureRepos.Tests/AzureDevOpsApiTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class AzureDevOpsApiTests
1818
{
1919
private const string ExpectedLocationServicePath = "_apis/ServiceDefinitions/LocationService2/951917AC-A960-4999-8464-E3F0AA25B381?api-version=1.0";
2020
private const string ExpectedIdentityServicePath = "_apis/token/sessiontokens?api-version=1.0&tokentype=compact";
21+
private const string CommonAuthority = "https://login.microsoftonline.com/common";
2122

2223
[Fact]
2324
public async Task AzureDevOpsRestApi_GetAuthorityAsync_NullUri_ThrowsException()
@@ -47,7 +48,7 @@ public async Task AzureDevOpsRestApi_GetAuthorityAsync_NoHeaders_ReturnsCommonAu
4748
var context = new TestCommandContext();
4849
var uri = new Uri("https://example.com");
4950

50-
const string expectedAuthority = "https://login.microsoftonline.com/common";
51+
const string expectedAuthority = CommonAuthority;
5152

5253
var httpResponse = new HttpResponseMessage(HttpStatusCode.Unauthorized);
5354

@@ -166,13 +167,13 @@ public async Task AzureDevOpsRestApi_GetAuthorityAsync_VssResourceTenantMultiple
166167
}
167168

168169
[Fact]
169-
public async Task AzureDevOpsRestApi_GetAuthorityAsync_VssResourceTenantMsa_ReturnsMsaAuthority()
170+
public async Task AzureDevOpsRestApi_GetAuthorityAsync_VssResourceTenantMsa_ReturnsCommonAuthority()
170171
{
171172
var context = new TestCommandContext();
172173
var uri = new Uri("https://example.com");
173174
var msaTenantId = Guid.Empty;
174175

175-
const string expectedAuthority = "https://login.microsoftonline.com/live.com";
176+
const string expectedAuthority = CommonAuthority;
176177

177178
var httpResponse = new HttpResponseMessage(HttpStatusCode.Unauthorized)
178179
{

src/shared/Microsoft.AzureRepos/AzureDevOpsRestApi.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public async Task<string> GetAuthorityAsync(Uri organizationUri)
4141

4242
const string authorityBase = "https://login.microsoftonline.com/";
4343
const string commonAuthority = authorityBase + "common";
44-
const string msaAuthority = authorityBase + "live.com";
4544

4645
_context.Trace.WriteLine($"HTTP: HEAD {organizationUri}");
4746
using (HttpResponseMessage response = await HttpClient.HeadAsync(organizationUri))
@@ -80,7 +79,7 @@ public async Task<string> GetAuthorityAsync(Uri organizationUri)
8079
if (tenantIds.Length == 1 && Guid.TryParse(tenantIds[0], out guid) && guid == Guid.Empty)
8180
{
8281
_context.Trace.WriteLine($"Found {AzureDevOpsConstants.VssResourceTenantHeader} header with MSA tenant ID (empty GUID).");
83-
return msaAuthority;
82+
return commonAuthority;
8483
}
8584
}
8685
}

0 commit comments

Comments
 (0)