File tree Expand file tree Collapse file tree 3 files changed +4
-25
lines changed
Microsoft.Identity.Web.Test.Common/Mocks
Microsoft.Identity.Web.Test Expand file tree Collapse file tree 3 files changed +4
-25
lines changed Original file line number Diff line number Diff line change @@ -17,26 +17,6 @@ namespace Microsoft.Identity.Web.Test.Common.Mocks
1717 /// </summary>
1818 public class MockHttpClientFactory : IMsalHttpClientFactory , IDisposable
1919 {
20- // MSAL will statically cache instance discovery, so we need to add
21- private static bool s_instanceDiscoveryAdded = false ;
22- private static object s_instanceDiscoveryLock = new object ( ) ;
23-
24- public MockHttpClientFactory ( )
25- {
26- // Auto-add instance discovery call, but only once per process
27- if ( ! s_instanceDiscoveryAdded )
28- {
29- lock ( s_instanceDiscoveryLock )
30- {
31- if ( ! s_instanceDiscoveryAdded )
32- {
33- _httpMessageHandlerQueue . Enqueue ( MockHttpCreator . CreateInstanceDiscoveryMockHandler ( ) ) ;
34- s_instanceDiscoveryAdded = true ;
35- }
36- }
37- }
38- }
39-
4020 /// <inheritdoc />
4121 public void Dispose ( )
4222 {
@@ -66,8 +46,6 @@ public MockHttpMessageHandler AddMockHandler(MockHttpMessageHandler handler)
6646
6747 public HttpClient GetHttpClient ( )
6848 {
69-
70-
7149 HttpMessageHandler messageHandler ;
7250
7351 Assert . NotEmpty ( _httpMessageHandlerQueue ) ;
Original file line number Diff line number Diff line change @@ -15,13 +15,12 @@ public class MockHttpMessageHandler : HttpMessageHandler
1515 {
1616 public Func < MockHttpMessageHandler , MockHttpMessageHandler > ReplaceMockHttpMessageHandler ;
1717
18- private readonly bool _ignoreInstanceDiscovery ;
19-
2018#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
2119 public MockHttpMessageHandler ( )
2220#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
2321 {
2422 }
23+
2524 public HttpResponseMessage ResponseMessage { get ; set ; }
2625
2726 public string ExpectedUrl { get ; set ; }
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ public async Task MsAuth10AtPop_WithAtPop_ShouldPopulateBuilderWithProofOfPosess
2626 //mockHttpClientFactory.AddMockHandler(MockHttpCreator.CreateInstanceDiscoveryMockHandler());
2727 mockHttpClientFactory . AddMockHandler ( httpTokenRequest ) ;
2828
29+ //Enables the mock handler to requeue requests that have been intercepted for instance discovery for example
30+ httpTokenRequest . ReplaceMockHttpMessageHandler = mockHttpClientFactory . AddMockHandler ;
31+
2932 var certificateDescription = CertificateDescription . FromBase64Encoded (
3033 TestConstants . CertificateX5cWithPrivateKey ,
3134 TestConstants . CertificateX5cWithPrivateKeyPassword ) ;
@@ -40,7 +43,6 @@ public async Task MsAuth10AtPop_WithAtPop_ShouldPopulateBuilderWithProofOfPosess
4043 . WithHttpClientFactory ( mockHttpClientFactory )
4144 . Build ( ) ;
4245
43-
4446 var popPublicKey = "pop_key" ;
4547 var jwkClaim = "jwk_claim" ;
4648
You can’t perform that action at this time.
0 commit comments