Skip to content

Commit

Permalink
minor fixes w/variable names & xml doc updates (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyf19 authored Sep 3, 2020
1 parent 90eeda7 commit 56a8ee3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.Resource;
using Microsoft.Identity.Web.Test.Common;

namespace IntegrationTestService.Controllers
{
Expand All @@ -33,7 +34,7 @@ public async Task<string> GetAsync()
{
HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);
return await _tokenAcquisition.GetAccessTokenForUserAsync(
new string[] { "User.Read" }).ConfigureAwait(false);
TestConstants.s_userReadScope).ConfigureAwait(false);
}
}
}
3 changes: 2 additions & 1 deletion tests/Microsoft.Identity.Web.Test.Common/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static class TestConstants

public static readonly string s_scopeForApp = "https://graph.microsoft.com/.default";

public static readonly IEnumerable<string> s_scopesForUser = new[]
public static readonly IEnumerable<string> s_userReadScope = new[]
{
"user.read",
};
Expand All @@ -101,6 +101,7 @@ public static class TestConstants
public const string ConfidentialClientLabTenant = "72f988bf-86f1-41af-91ab-2d7cd011db47";
public const string OBOUser = "[email protected]";
public const string OBOClientSideClientId = "c0485386-1e9a-4663-bc96-7ab30656de7f";
public static string[] OBOApiScope = new string[] { "api://f4aa5217-e87c-42b2-82af-5624dd14ee72/.default" };

// This value is only for testing purposes. It is for a certificate that is not used for anything other than running tests
public const string CertificateX5c = @"MIIDHzCCAgegAwIBAgIQM6NFYNBJ9rdOiK+C91ZzFDANBgkqhkiG9w0BAQsFADAgMR4wHAYDVQQDExVBQ1MyQ2xpZW50Q2VydGlmaWNhdGUwHhcNMTIwNTIyMj
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public async Task GetAccessTokenForApp_WithUserScope_MsalServiceExceptionThrownA

// Act & Assert
async Task result() =>
await _tokenAcquisition.GetAccessTokenForAppAsync(TestConstants.s_scopesForUser.FirstOrDefault()).ConfigureAwait(false);
await _tokenAcquisition.GetAccessTokenForAppAsync(TestConstants.s_userReadScope.FirstOrDefault()).ConfigureAwait(false);

ArgumentException ex = await Assert.ThrowsAsync<ArgumentException>(result).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ namespace Microsoft.Identity.Web.Test.Integration
#if !FROM_GITHUB_ACTION
public class AcquireTokenForUserIntegrationTests : IClassFixture<WebApplicationFactory<IntegrationTestService.Startup>>
{
private readonly WebApplicationFactory<IntegrationTestService.Startup> _factory;

public AcquireTokenForUserIntegrationTests(WebApplicationFactory<IntegrationTestService.Startup> factory)
{
_factory = factory;
}

private readonly WebApplicationFactory<IntegrationTestService.Startup> _factory;

[Fact]
public async Task GetTokenForUserAsync()
{
Expand Down Expand Up @@ -75,7 +75,7 @@ private static async Task<AuthenticationResult> AcquireTokenForLabUserAsync()

AuthenticationResult authResult = await msalPublicClient
.AcquireTokenByUsernamePassword(
new string[] { "api://f4aa5217-e87c-42b2-82af-5624dd14ee72/.default" },
TestConstants.OBOApiScope,
TestConstants.OBOUser,
new NetworkCredential(
TestConstants.OBOUser,
Expand Down

0 comments on commit 56a8ee3

Please sign in to comment.