From 42134bb366081a6db0d31d685b28eb86f4fae715 Mon Sep 17 00:00:00 2001 From: Keith Cully Date: Tue, 15 Aug 2023 13:47:24 +0100 Subject: [PATCH] Use HttpClientHandler abstraction to specify CheckCertificateRevocationList --- .../Composables/HealthCheckTestHelpers.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/Diagnostics.HealthChecks.UnitTests/Composables/HealthCheckTestHelpers.cs b/tests/Diagnostics.HealthChecks.UnitTests/Composables/HealthCheckTestHelpers.cs index ec9e911b..35c24b93 100644 --- a/tests/Diagnostics.HealthChecks.UnitTests/Composables/HealthCheckTestHelpers.cs +++ b/tests/Diagnostics.HealthChecks.UnitTests/Composables/HealthCheckTestHelpers.cs @@ -92,13 +92,14 @@ internal static Mock 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); @@ -146,7 +147,7 @@ internal static void SetLocalServiceInfo() } } -internal class MockedHttpMessageHandler : HttpMessageHandler +internal class MockedHttpMessageHandler : HttpClientHandler { private readonly HttpResponseMessage m_response; @@ -163,7 +164,7 @@ protected override Task 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. /// -internal class MockedRepeatedErrorsHttpMessageHandler : HttpMessageHandler +internal class MockedRepeatedErrorsHttpMessageHandler : HttpClientHandler { private readonly HttpResponseMessage m_response; private readonly int m_failureTimes; @@ -189,7 +190,7 @@ protected override Task SendAsync(HttpRequestMessage reques } } -internal class MockedHttpExceptionMessageHandler : HttpMessageHandler +internal class MockedHttpExceptionMessageHandler : HttpClientHandler { private readonly HttpResponseMessage m_response;