From 8d4301cfac1dd414cbe2b8ed2e7ecff454ab2c5a Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sun, 23 Jul 2023 09:32:23 +0300 Subject: [PATCH] Fail AzureKeyVaultHealthCheck if no keys, certificates or secrets configured --- .../AzureKeyVaultHealthCheck.cs | 4 ++ .../Functional/ArangoDbHealthCheckTests.cs | 6 +-- .../AzureKeyVaultHealthCheckTests.cs | 40 +++++++++++++++++++ .../HealthChecks.AzureKeyVault.Tests.csproj | 1 + .../Functional/ConsulHealthCheckTests.cs | 4 +- .../ElasticsearchAuthenticationTests.cs | 4 +- .../ElasticsearchHealthCheckTests.cs | 4 +- .../Functional/EventStoreHealthCheckTests.cs | 6 +-- .../Functional/EventStoreHealthCheckTests.cs | 2 +- .../Functional/GremlinHealthCheckTests.cs | 6 +-- .../Functional/SslHealthCheckTests.cs | 10 ++--- .../Functional/IdSvrHealthCheckTests.cs | 4 +- .../Functional/RabbitHealthCheckTests.cs | 16 ++++---- .../Functional/RavenDbHealthCheckTests.cs | 6 +-- ...bHealthCheckTestsSingleConnectionString.cs | 8 ++-- .../Functional/RedisHealthCheckTests.cs | 12 +++--- .../Functional/SignalRHealthCheckTests.cs | 4 +- .../Functional/SolrHealthCheckTests.cs | 6 +-- .../Functional/SqlServerHealthCheckTests.cs | 6 +-- .../Functional/FolderHealthCheckTests.cs | 6 +-- 20 files changed, 100 insertions(+), 55 deletions(-) create mode 100644 test/HealthChecks.AzureKeyVault.Tests/Functional/AzureKeyVaultHealthCheckTests.cs diff --git a/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs b/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs index 9e29e332e8..33739fb39c 100644 --- a/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs +++ b/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs @@ -29,6 +29,10 @@ public async Task CheckHealthAsync(HealthCheckContext context { try { + // https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/785 + if (_options._keys.Count == 0 && _options.Certificates.Count == 0 && _options._secrets.Count == 0) + return HealthCheckResult.Unhealthy("No keys, certificates or secrets configured."); + foreach (string secret in _options.Secrets) { var secretClient = CreateSecretClient(); diff --git a/test/HealthChecks.ArangoDb.Tests/Functional/ArangoDbHealthCheckTests.cs b/test/HealthChecks.ArangoDb.Tests/Functional/ArangoDbHealthCheckTests.cs index 9bd59af78d..c424c76428 100644 --- a/test/HealthChecks.ArangoDb.Tests/Functional/ArangoDbHealthCheckTests.cs +++ b/test/HealthChecks.ArangoDb.Tests/Functional/ArangoDbHealthCheckTests.cs @@ -29,7 +29,7 @@ public async Task be_healthy_if_arangodb_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -67,7 +67,7 @@ public async Task be_healthy_if_multiple_arango_are_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -97,7 +97,7 @@ public async Task be_unhealthy_if_arango_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } diff --git a/test/HealthChecks.AzureKeyVault.Tests/Functional/AzureKeyVaultHealthCheckTests.cs b/test/HealthChecks.AzureKeyVault.Tests/Functional/AzureKeyVaultHealthCheckTests.cs new file mode 100644 index 0000000000..f4964942c9 --- /dev/null +++ b/test/HealthChecks.AzureKeyVault.Tests/Functional/AzureKeyVaultHealthCheckTests.cs @@ -0,0 +1,40 @@ +using System.Net; +using Azure.Identity; + +namespace HealthChecks.AzureKeyVault.Tests.Functional; + +public class AzureKeyVaultHealthCheckTests +{ + // https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/785 + [Fact] + public async Task be_unhealthy_if_keyvalue_is_not_available() + { + var webHostBuilder = new WebHostBuilder() + .ConfigureServices(services => + { + services.AddHealthChecks() + .AddAzureKeyVault( + new Uri("https://www.thisisnotarealurl.com"), + new DefaultAzureCredential(), + setup => + { + //setup + // .UseKeyVaultUrl("https://www.thisisnotarealurl2.com") + // .UseAzureManagedServiceIdentity(); + }); + }) + .Configure(app => + { + app.UseHealthChecks("/health", new HealthCheckOptions + { + Predicate = _ => true, + }); + }); + + using var server = new TestServer(webHostBuilder); + + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); + + response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); + } +} diff --git a/test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj b/test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj index fbb1eec4d4..5f2760635d 100644 --- a/test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj +++ b/test/HealthChecks.AzureKeyVault.Tests/HealthChecks.AzureKeyVault.Tests.csproj @@ -5,6 +5,7 @@ + diff --git a/test/HealthChecks.Consul.Tests/Functional/ConsulHealthCheckTests.cs b/test/HealthChecks.Consul.Tests/Functional/ConsulHealthCheckTests.cs index ffdd29c3c6..dde9a9f2c3 100644 --- a/test/HealthChecks.Consul.Tests/Functional/ConsulHealthCheckTests.cs +++ b/test/HealthChecks.Consul.Tests/Functional/ConsulHealthCheckTests.cs @@ -28,7 +28,7 @@ public async Task be_healthy_if_consul_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -57,7 +57,7 @@ public async Task be_unhealthy_if_consul_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } diff --git a/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchAuthenticationTests.cs b/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchAuthenticationTests.cs index 5e94c25e28..f5210f5fe6 100644 --- a/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchAuthenticationTests.cs +++ b/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchAuthenticationTests.cs @@ -41,7 +41,7 @@ public async Task be_healthy_if_elasticsearch_is_using_valid_api_key() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health") + var response = await server.CreateRequest("/health") .GetAsync() .ConfigureAwait(false); @@ -77,7 +77,7 @@ public async Task be_healthy_if_elasticsearch_is_using_valid_user_and_password() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health") + var response = await server.CreateRequest("/health") .GetAsync() .ConfigureAwait(false); diff --git a/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchHealthCheckTests.cs b/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchHealthCheckTests.cs index 457ce19630..b2887f2785 100644 --- a/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchHealthCheckTests.cs +++ b/test/HealthChecks.Elasticsearch.Tests/Functional/ElasticsearchHealthCheckTests.cs @@ -25,7 +25,7 @@ public async Task be_healthy_if_elasticsearch_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -49,7 +49,7 @@ public async Task be_unhealthy_if_elasticsearch_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } diff --git a/test/HealthChecks.EventStore.Tests/Functional/EventStoreHealthCheckTests.cs b/test/HealthChecks.EventStore.Tests/Functional/EventStoreHealthCheckTests.cs index 8d2156be71..b6e975e882 100644 --- a/test/HealthChecks.EventStore.Tests/Functional/EventStoreHealthCheckTests.cs +++ b/test/HealthChecks.EventStore.Tests/Functional/EventStoreHealthCheckTests.cs @@ -25,7 +25,7 @@ public async Task be_healthy_if_eventstore_is_available_with_uri_format() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } @@ -50,7 +50,7 @@ public async Task be_healthy_if_eventstore_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } @@ -76,7 +76,7 @@ public async Task be_unhealthy_if_eventstore_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } diff --git a/test/HealthChecks.EventStore.gRPC.Tests/Functional/EventStoreHealthCheckTests.cs b/test/HealthChecks.EventStore.gRPC.Tests/Functional/EventStoreHealthCheckTests.cs index 3ac90fcbe9..256a9e2db2 100644 --- a/test/HealthChecks.EventStore.gRPC.Tests/Functional/EventStoreHealthCheckTests.cs +++ b/test/HealthChecks.EventStore.gRPC.Tests/Functional/EventStoreHealthCheckTests.cs @@ -23,7 +23,7 @@ public async Task be_healthy_if_eventstore_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } diff --git a/test/HealthChecks.Gremlin.Tests/Functional/GremlinHealthCheckTests.cs b/test/HealthChecks.Gremlin.Tests/Functional/GremlinHealthCheckTests.cs index e5d879766d..a320b30ffe 100644 --- a/test/HealthChecks.Gremlin.Tests/Functional/GremlinHealthCheckTests.cs +++ b/test/HealthChecks.Gremlin.Tests/Functional/GremlinHealthCheckTests.cs @@ -28,7 +28,7 @@ public async Task be_healthy_if_gremlin_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -63,7 +63,7 @@ public async Task be_healthy_if_multiple_gremlin_are_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -92,7 +92,7 @@ public async Task be_unhealthy_if_gremlin_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } diff --git a/test/HealthChecks.Network.Tests/Functional/SslHealthCheckTests.cs b/test/HealthChecks.Network.Tests/Functional/SslHealthCheckTests.cs index a74d1e896b..ad6514eb6a 100644 --- a/test/HealthChecks.Network.Tests/Functional/SslHealthCheckTests.cs +++ b/test/HealthChecks.Network.Tests/Functional/SslHealthCheckTests.cs @@ -36,7 +36,7 @@ public async Task be_healthy_if_ssl_is_valid() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -60,7 +60,7 @@ public async Task be_unhealthy_if_ssl_is_not_present() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -84,7 +84,7 @@ public async Task be_unhealthy_if_ssl_is_not_valid() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -108,7 +108,7 @@ public async Task be_unhealthy_if_ssl_is_expired() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -132,7 +132,7 @@ public async Task be_degraded_if_ssl_daysbefore() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); var resultAsString = await response.Content.ReadAsStringAsync().ConfigureAwait(false); diff --git a/test/HealthChecks.OpenIdConnectServer.Tests/Functional/IdSvrHealthCheckTests.cs b/test/HealthChecks.OpenIdConnectServer.Tests/Functional/IdSvrHealthCheckTests.cs index e534f2167f..5a6daa0a56 100644 --- a/test/HealthChecks.OpenIdConnectServer.Tests/Functional/IdSvrHealthCheckTests.cs +++ b/test/HealthChecks.OpenIdConnectServer.Tests/Functional/IdSvrHealthCheckTests.cs @@ -23,7 +23,7 @@ public async Task be_unhealthy_if_idsvr_is_unavailable() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -47,7 +47,7 @@ public async Task be_healthy_if_idsvr_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } diff --git a/test/HealthChecks.RabbitMQ.Tests/Functional/RabbitHealthCheckTests.cs b/test/HealthChecks.RabbitMQ.Tests/Functional/RabbitHealthCheckTests.cs index 6c33c26c69..1d53406c2a 100644 --- a/test/HealthChecks.RabbitMQ.Tests/Functional/RabbitHealthCheckTests.cs +++ b/test/HealthChecks.RabbitMQ.Tests/Functional/RabbitHealthCheckTests.cs @@ -26,7 +26,7 @@ public async Task be_healthy_if_rabbitmq_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -52,7 +52,7 @@ public async Task be_healthy_if_rabbitmq_is_available_using_ssloption() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -76,7 +76,7 @@ public async Task be_unhealthy_if_rabbitmq_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -110,7 +110,7 @@ public async Task be_healthy_if_rabbitmq_is_available_using_iconnectionfactory() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -147,7 +147,7 @@ public async Task be_healthy_if_rabbitmq_is_available_using_iconnection() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -173,7 +173,7 @@ public async Task be_healthy_if_rabbitmq_is_available_and_specify_default_sslopt using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -207,7 +207,7 @@ public async Task be_not_crash_on_startup_when_rabbitmq_is_down_at_startup() using var server = new TestServer(webHostBuilder); - var response1 = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response1 = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response1.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -234,7 +234,7 @@ public async Task be_healthy_if_rabbitmq_is_available_using_iServiceProvider() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } diff --git a/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTests.cs b/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTests.cs index 1f928a2991..49f5dbcc32 100644 --- a/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTests.cs +++ b/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTests.cs @@ -47,7 +47,7 @@ public async Task be_healthy_if_ravendb_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } @@ -77,7 +77,7 @@ public async Task be_healthy_if_ravendb_is_available_and_contains_specific_datab using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } @@ -136,7 +136,7 @@ public async Task be_unhealthy_if_ravendb_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } diff --git a/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTestsSingleConnectionString.cs b/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTestsSingleConnectionString.cs index 3749691039..4ac95da2f8 100644 --- a/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTestsSingleConnectionString.cs +++ b/test/HealthChecks.RavenDb.Tests/Functional/RavenDbHealthCheckTestsSingleConnectionString.cs @@ -45,7 +45,7 @@ public async Task be_healthy_if_ravendb_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -70,7 +70,7 @@ public async Task be_healthy_if_ravendb_is_available_and_contains_specific_datab using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -97,7 +97,7 @@ public async Task be_unhealthy_if_ravendb_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -126,7 +126,7 @@ public async Task be_unhealthy_if_ravendb_is_available_but_database_doesnot_exis using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } diff --git a/test/HealthChecks.Redis.Tests/Functional/RedisHealthCheckTests.cs b/test/HealthChecks.Redis.Tests/Functional/RedisHealthCheckTests.cs index 34da102f54..6723f91b87 100644 --- a/test/HealthChecks.Redis.Tests/Functional/RedisHealthCheckTests.cs +++ b/test/HealthChecks.Redis.Tests/Functional/RedisHealthCheckTests.cs @@ -26,7 +26,7 @@ public async Task be_healthy_if_redis_is_available_with_connection_string() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -53,7 +53,7 @@ public async Task be_healthy_if_multiple_redis_are_available_with_connection_str using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -80,7 +80,7 @@ public async Task be_healthy_if_redis_is_available_with_connection_multiplexer() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -110,7 +110,7 @@ public async Task be_healthy_if_multiple_redis_are_available_with_connection_mul using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -134,7 +134,7 @@ public async Task be_unhealthy_if_redis_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -159,7 +159,7 @@ public async Task be_unhealthy_if_redis_is_not_available_within_specified_timeou using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); (await response.Content.ReadAsStringAsync().ConfigureAwait(false)).ShouldContain("Healthcheck timed out"); diff --git a/test/HealthChecks.SignalR.Tests/Functional/SignalRHealthCheckTests.cs b/test/HealthChecks.SignalR.Tests/Functional/SignalRHealthCheckTests.cs index 25e81f0c1a..2f68ee68a9 100644 --- a/test/HealthChecks.SignalR.Tests/Functional/SignalRHealthCheckTests.cs +++ b/test/HealthChecks.SignalR.Tests/Functional/SignalRHealthCheckTests.cs @@ -37,7 +37,7 @@ public async Task be_healthy_if_signalr_hub_is_available() server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -72,7 +72,7 @@ public async Task be_unhealthy_if_signalr_hub_is_unavailable() server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } diff --git a/test/HealthChecks.Solr.Tests/Functional/SolrHealthCheckTests.cs b/test/HealthChecks.Solr.Tests/Functional/SolrHealthCheckTests.cs index f41e5f4f28..e359c86439 100644 --- a/test/HealthChecks.Solr.Tests/Functional/SolrHealthCheckTests.cs +++ b/test/HealthChecks.Solr.Tests/Functional/SolrHealthCheckTests.cs @@ -24,7 +24,7 @@ public async Task be_healthy_if_solr_is_available() }); using var server = new TestServer(webHostBuilder); - using var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + using var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } @@ -47,7 +47,7 @@ public async Task be_unhealthy_if_solr_ping_is_disabled() }); using var server = new TestServer(webHostBuilder); - using var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + using var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } @@ -70,7 +70,7 @@ public async Task be_unhealthy_if_solr_is_not_available() }); using var server = new TestServer(webHostBuilder); - using var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + using var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable, await response.Content.ReadAsStringAsync().ConfigureAwait(false)); } } diff --git a/test/HealthChecks.SqlServer.Tests/Functional/SqlServerHealthCheckTests.cs b/test/HealthChecks.SqlServer.Tests/Functional/SqlServerHealthCheckTests.cs index ef04d12982..91861c20c2 100644 --- a/test/HealthChecks.SqlServer.Tests/Functional/SqlServerHealthCheckTests.cs +++ b/test/HealthChecks.SqlServer.Tests/Functional/SqlServerHealthCheckTests.cs @@ -25,7 +25,7 @@ public async Task be_healthy_if_sqlServer_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -49,7 +49,7 @@ public async Task be_unhealthy_if_sqlServer_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } @@ -75,7 +75,7 @@ public async Task be_unhealthy_if_sqlquery_spec_is_not_valid() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); } diff --git a/test/HealthChecks.System.Tests/Functional/FolderHealthCheckTests.cs b/test/HealthChecks.System.Tests/Functional/FolderHealthCheckTests.cs index d2f589ee17..51171f7e0f 100644 --- a/test/HealthChecks.System.Tests/Functional/FolderHealthCheckTests.cs +++ b/test/HealthChecks.System.Tests/Functional/FolderHealthCheckTests.cs @@ -23,7 +23,7 @@ public async Task be_healthy_if_folder_is_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -49,7 +49,7 @@ public async Task be_healthy_if_no_folder_provided() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.OK); } @@ -73,7 +73,7 @@ public async Task be_unhealthy_if_folder_is_not_available() using var server = new TestServer(webHostBuilder); - var response = await server.CreateRequest($"/health").GetAsync().ConfigureAwait(false); + var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); }