Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ namespace Microsoft.Identity.Web.Test.Common.Mocks
/// </summary>
public class MockHttpClientFactory : IMsalHttpClientFactory, IDisposable
{
// MSAL will statically cache instance discovery, so we need to add
private static bool s_instanceDiscoveryAdded = false;
private static object s_instanceDiscoveryLock = new object();

public MockHttpClientFactory()
{
// Auto-add instance discovery call, but only once per process
if (!s_instanceDiscoveryAdded)
{
lock (s_instanceDiscoveryLock)
{
if (!s_instanceDiscoveryAdded)
{
_httpMessageHandlerQueue.Enqueue(MockHttpCreator.CreateInstanceDiscoveryMockHandler());
s_instanceDiscoveryAdded = true;
}
}
}
}

/// <inheritdoc />
public void Dispose()
{
Expand Down Expand Up @@ -66,8 +46,6 @@ public MockHttpMessageHandler AddMockHandler(MockHttpMessageHandler handler)

public HttpClient GetHttpClient()
{


HttpMessageHandler messageHandler;

Assert.NotEmpty(_httpMessageHandlerQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ public class MockHttpMessageHandler : HttpMessageHandler
{
public Func<MockHttpMessageHandler, MockHttpMessageHandler> ReplaceMockHttpMessageHandler;

private readonly bool _ignoreInstanceDiscovery;

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public MockHttpMessageHandler()
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
{
}

public HttpResponseMessage ResponseMessage { get; set; }

public string ExpectedUrl { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion tests/Microsoft.Identity.Web.Test/MsAuth10AtPopTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public async Task MsAuth10AtPop_WithAtPop_ShouldPopulateBuilderWithProofOfPosess
//mockHttpClientFactory.AddMockHandler(MockHttpCreator.CreateInstanceDiscoveryMockHandler());
mockHttpClientFactory.AddMockHandler(httpTokenRequest);

//Enables the mock handler to requeue requests that have been intercepted for instance discovery for example
httpTokenRequest.ReplaceMockHttpMessageHandler = mockHttpClientFactory.AddMockHandler;

var certificateDescription = CertificateDescription.FromBase64Encoded(
TestConstants.CertificateX5cWithPrivateKey,
TestConstants.CertificateX5cWithPrivateKeyPassword);
Expand All @@ -40,7 +43,6 @@ public async Task MsAuth10AtPop_WithAtPop_ShouldPopulateBuilderWithProofOfPosess
.WithHttpClientFactory(mockHttpClientFactory)
.Build();


var popPublicKey = "pop_key";
var jwkClaim = "jwk_claim";

Expand Down