File tree Expand file tree Collapse file tree 3 files changed +4
-25
lines changed
Microsoft.Identity.Web.Test
Microsoft.Identity.Web.Test.Common/Mocks 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
17
17
/// </summary>
18
18
public class MockHttpClientFactory : IMsalHttpClientFactory , IDisposable
19
19
{
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
-
40
20
/// <inheritdoc />
41
21
public void Dispose ( )
42
22
{
@@ -66,8 +46,6 @@ public MockHttpMessageHandler AddMockHandler(MockHttpMessageHandler handler)
66
46
67
47
public HttpClient GetHttpClient ( )
68
48
{
69
-
70
-
71
49
HttpMessageHandler messageHandler ;
72
50
73
51
Assert . NotEmpty ( _httpMessageHandlerQueue ) ;
Original file line number Diff line number Diff line change @@ -15,13 +15,12 @@ public class MockHttpMessageHandler : HttpMessageHandler
15
15
{
16
16
public Func < MockHttpMessageHandler , MockHttpMessageHandler > ReplaceMockHttpMessageHandler ;
17
17
18
- private readonly bool _ignoreInstanceDiscovery ;
19
-
20
18
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
21
19
public MockHttpMessageHandler ( )
22
20
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
23
21
{
24
22
}
23
+
25
24
public HttpResponseMessage ResponseMessage { get ; set ; }
26
25
27
26
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
26
26
//mockHttpClientFactory.AddMockHandler(MockHttpCreator.CreateInstanceDiscoveryMockHandler());
27
27
mockHttpClientFactory . AddMockHandler ( httpTokenRequest ) ;
28
28
29
+ //Enables the mock handler to requeue requests that have been intercepted for instance discovery for example
30
+ httpTokenRequest . ReplaceMockHttpMessageHandler = mockHttpClientFactory . AddMockHandler ;
31
+
29
32
var certificateDescription = CertificateDescription . FromBase64Encoded (
30
33
TestConstants . CertificateX5cWithPrivateKey ,
31
34
TestConstants . CertificateX5cWithPrivateKeyPassword ) ;
@@ -40,7 +43,6 @@ public async Task MsAuth10AtPop_WithAtPop_ShouldPopulateBuilderWithProofOfPosess
40
43
. WithHttpClientFactory ( mockHttpClientFactory )
41
44
. Build ( ) ;
42
45
43
-
44
46
var popPublicKey = "pop_key" ;
45
47
var jwkClaim = "jwk_claim" ;
46
48
You can’t perform that action at this time.
0 commit comments