From f67ef24de6c17ab436e0886509dc892d166a331c Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Thu, 28 Aug 2025 22:34:48 +0100 Subject: [PATCH 1/2] Add health check services and endpoints Updated MiddlewareRegistry to include health check services and added ApiEndpointHttpHandler for custom certificate validation. Modified EstateManagementUI.csproj to include new health check packages and adjusted package references. Implemented health check endpoints in Startup for improved application monitoring. --- .../Bootstrapper/MiddlewareRegistry.cs | 20 +++++++++++++++++++ EstateManagementUI/EstateManagementUI.csproj | 7 ++++++- EstateManagementUI/Startup.cs | 14 +++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/EstateManagementUI/Bootstrapper/MiddlewareRegistry.cs b/EstateManagementUI/Bootstrapper/MiddlewareRegistry.cs index 81cbb58e..99c59485 100644 --- a/EstateManagementUI/Bootstrapper/MiddlewareRegistry.cs +++ b/EstateManagementUI/Bootstrapper/MiddlewareRegistry.cs @@ -1,4 +1,5 @@ using Lamar; +using Shared.Extensions; using Shared.Middleware; using System.Diagnostics.CodeAnalysis; @@ -11,6 +12,25 @@ public MiddlewareRegistry() { new RequestResponseMiddlewareLoggingConfig(LogLevel.Information, true, true); this.AddSingleton(config); + + this.AddHealthChecks().AddSecurityService(this.ApiEndpointHttpHandler).AddTransactionProcessorService(this.ApiEndpointHttpHandler) + .AddFileProcessorService(this.ApiEndpointHttpHandler); + } + + private HttpClientHandler ApiEndpointHttpHandler(IServiceProvider serviceProvider) + { + return new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (message, + cert, + chain, + errors) => + { + return true; + } + }; } } + + } diff --git a/EstateManagementUI/EstateManagementUI.csproj b/EstateManagementUI/EstateManagementUI.csproj index f6352145..c14bb7c2 100644 --- a/EstateManagementUI/EstateManagementUI.csproj +++ b/EstateManagementUI/EstateManagementUI.csproj @@ -34,7 +34,12 @@ - + + + + + + diff --git a/EstateManagementUI/Startup.cs b/EstateManagementUI/Startup.cs index f035380f..bf9f23de 100644 --- a/EstateManagementUI/Startup.cs +++ b/EstateManagementUI/Startup.cs @@ -7,6 +7,8 @@ using Shared.Middleware; using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens.Jwt; +using HealthChecks.UI.Client; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; [ExcludeFromCodeCoverage] public class Startup { @@ -118,6 +120,18 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, { endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); + endpoints.MapHealthChecks("health", + new HealthCheckOptions + { + Predicate = _ => true, + ResponseWriter = Shared.HealthChecks.HealthCheckMiddleware.WriteResponse + }); + endpoints.MapHealthChecks("healthui", + new HealthCheckOptions + { + Predicate = _ => true, + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + }); }); app.PreWarm().Wait(); From a03eb800223eadaeeacd95f90d93bff7a2980a68 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Fri, 29 Aug 2025 13:35:53 +0100 Subject: [PATCH 2/2] fix broken unit test --- EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs b/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs index 655b97e1..004c52c0 100644 --- a/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs +++ b/EstateManagementUI.BusinessLogic.Tests/MediatorTests.cs @@ -117,6 +117,7 @@ private IConfigurationRoot SetupMemoryConfiguration() configuration.Add("AppSettings:SecurityService", "http://127.0.0.1"); configuration.Add("AppSettings:MessagingServiceApi", "http://127.0.0.1"); configuration.Add("AppSettings:TransactionProcessorApi", "http://127.0.0.1"); + configuration.Add("AppSettings:FileProcessorApi", "http://127.0.0.1"); configuration.Add("AppSettings:DatabaseEngine", "SqlServer"); configuration.Add("AppSettings:EstateReportingApi", "http://127.0.0.1");