Skip to content

Commit

Permalink
Use HttpClientHandler abstraction to specify CheckCertificateRevocati…
Browse files Browse the repository at this point in the history
…onList
  • Loading branch information
Keith Cully committed Aug 15, 2023
1 parent 5005f13 commit 42134bb
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ internal static Mock<IHttpClientFactory> GetHttpClientFactoryMock(
int? numberOfFailuresBeforeOk = null,
bool? shouldThrowException = false)
{
HttpMessageHandler messageHandler =
HttpClientHandler messageHandler =
(shouldThrowException, numberOfFailuresBeforeOk) switch
{
(true, _) => new MockedHttpExceptionMessageHandler(message),
(_, null) => new MockedHttpMessageHandler(message),
(_, int n) => new MockedRepeatedErrorsHttpMessageHandler(message, n)
};
messageHandler.CheckCertificateRevocationList = true;

HttpClient httpClientMock = new(messageHandler);

Expand Down Expand Up @@ -146,7 +147,7 @@ internal static void SetLocalServiceInfo()
}
}

internal class MockedHttpMessageHandler : HttpMessageHandler
internal class MockedHttpMessageHandler : HttpClientHandler
{
private readonly HttpResponseMessage m_response;

Expand All @@ -163,7 +164,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
/// Returns 500 for a given number of times before returning the given response.
/// The pattern is recursive, so after returning an OK response, it returns an originally given number of 500 responses.
/// </summary>
internal class MockedRepeatedErrorsHttpMessageHandler : HttpMessageHandler
internal class MockedRepeatedErrorsHttpMessageHandler : HttpClientHandler
{
private readonly HttpResponseMessage m_response;
private readonly int m_failureTimes;
Expand All @@ -189,7 +190,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
}
}

internal class MockedHttpExceptionMessageHandler : HttpMessageHandler
internal class MockedHttpExceptionMessageHandler : HttpClientHandler
{
private readonly HttpResponseMessage m_response;

Expand Down

0 comments on commit 42134bb

Please sign in to comment.