Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bgavrilMS committed Oct 9, 2019
1 parent 588b49a commit e4fe4a9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void ClassInitialize(TestContext context)
}

[TestMethod]
[Ignore] // https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/1427
public async Task ROPC_B2C_Async()
{
var labResponse = await LabUserHelper.GetB2CLocalAccountAsync().ConfigureAwait(false);
Expand All @@ -39,7 +40,10 @@ private async Task RunB2CHappyPathTestAsync(LabResponse labResponse)

SecureString securePassword = new NetworkCredential("", user.GetOrFetchPassword()).SecurePassword;

var msalPublicClient = PublicClientApplicationBuilder.Create("e3b9ad76-9763-4827-b088-80c7a7888f79").WithB2CAuthority(_b2CROPCAuthority).Build();
var msalPublicClient = PublicClientApplicationBuilder
.Create(labResponse.App.AppId)
.WithB2CAuthority(_b2CROPCAuthority)
.Build();

AuthenticationResult authResult = await msalPublicClient
.AcquireTokenByUsernamePassword(s_b2cScopes, user.Upn, securePassword)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Microsoft.Identity.Client;
using Microsoft.Identity.Test.Common;
using Microsoft.Identity.Test.Common.Core.Helpers;
using Microsoft.Identity.Test.LabInfrastructure;
using Microsoft.Identity.Test.Unit;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -111,7 +112,7 @@ public async Task AcquireTokenWithManagedUsernameIncorrectPasswordAsync()
[TestMethod]
public async Task AcquireTokenWithFederatedUsernameIncorrectPasswordAsync()
{
var labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.AdfsV4, false).ConfigureAwait(false);
var labResponse = await LabUserHelper.GetDefaultUserAsync().ConfigureAwait(false);
var user = labResponse.User;

SecureString incorrectSecurePassword = new SecureString();
Expand All @@ -120,10 +121,14 @@ public async Task AcquireTokenWithFederatedUsernameIncorrectPasswordAsync()

var msalPublicClient = PublicClientApplicationBuilder.Create(labResponse.App.AppId).WithAuthority(_authority).Build();

var result = Assert.ThrowsExceptionAsync<MsalException>(async () => await msalPublicClient
.AcquireTokenByUsernamePassword(s_scopes, user.Upn, incorrectSecurePassword)
.ExecuteAsync(CancellationToken.None)
.ConfigureAwait(false));
var result = await AssertException.TaskThrowsAsync<MsalUiRequiredException>(() =>
msalPublicClient
.AcquireTokenByUsernamePassword(s_scopes, user.Upn, incorrectSecurePassword)
.ExecuteAsync(CancellationToken.None)
)
.ConfigureAwait(false);

Assert.AreEqual(result.ErrorCode, "invalid_grant");
}

private async Task RunHappyPathTestAsync(LabResponse labResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ public class LabApp
public string AppId { get; set; }

// TODO: this is a list, but lab sends a string. Not used today, discuss with lab to return a list
//[JsonProperty("redirecturi")]
//public string RedirectUri { get; set; }
[JsonProperty("redirecturi")]
public string RedirectUri { get; set; }

[JsonProperty("signinaudience")]
public string Audience { get; set; }

// TODO: this is a list, but lab sends a string. Not used today, discuss with lab to return a list
[JsonProperty("authority")]
public string Authority { get; set; }
}

public class Lab
Expand Down

0 comments on commit e4fe4a9

Please sign in to comment.