Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CallbackHandler.BusinessLogic.Tests/Mediator/MediatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public async Task Mediator_Send_RequestHandled()

ServiceRegistry services = new();
IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build();
//ConfigurationReader.Initialise(configurationRoot);


this.AddTestRegistrations(services, hostingEnvironment.Instance(), configurationRoot);
services.AddCallbackHandlerRegistries(configurationRoot);
Container container = new(services);
Expand All @@ -55,7 +54,7 @@ public async Task Mediator_Send_RequestHandled()
{
try
{
await mediator.Send(baseRequest);
await mediator.Send(baseRequest, TestContext.Current.CancellationToken);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,23 @@ public static async Task<Result<TokenResponse>> GetToken(TokenResponse currentTo
// Get a token to talk to the estate service
String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId");
String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret");
Logger.LogDebug($"Client Id is {clientId}");
Logger.LogDebug($"Client Secret is {clientSecret}");


if (currentToken == null)
{
Result<TokenResponse> tokenResult = await securityServiceClient.GetToken(clientId, clientSecret, cancellationToken);
if (tokenResult.IsFailed)
return ResultHelpers.CreateFailure(tokenResult);
TokenResponse token = tokenResult.Data;
Logger.LogDebug($"Token is {token.AccessToken}");
return Result.Success(token);
}

if (currentToken.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2))
{
Logger.LogDebug($"Token is about to expire at {currentToken.Expires.DateTime:O}");
Logger.LogDebug("Token is about to expire at {tokenExpiry}", currentToken.Expires.DateTime);
Result<TokenResponse> tokenResult = await securityServiceClient.GetToken(clientId, clientSecret, cancellationToken);
if (tokenResult.IsFailed)
return ResultHelpers.CreateFailure(tokenResult);
TokenResponse token = tokenResult.Data;
Logger.LogDebug($"Token is {token.AccessToken}");
return Result.Success(token);
}

Expand Down
5 changes: 1 addition & 4 deletions CallbackHandler.IntegrationTests/Common/DockerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public DockerHelper() {

public ISecurityServiceClient SecurityServiceClient;
public ITransactionProcessorClient TransactionProcessorClient;

public EventStoreProjectionManagementClient LegacyProjectionManagementClient;


public KurrentDBProjectionManagementClient ProjectionManagementClient;

public String AccessToken;
Expand Down Expand Up @@ -87,7 +85,6 @@ public override async Task StartContainersForScenarioRun(String scenarioName,
this.SecurityServiceClient = new SecurityServiceClient(SecurityServiceBaseAddressResolver, httpClient, Serialise, Deserialise);
this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient, Serialise, Deserialise);
this.ProjectionManagementClient = new KurrentDBProjectionManagementClient(this.ConfigureKurrentDbSettings());
this.LegacyProjectionManagementClient = new EventStoreProjectionManagementClient(this.ConfigureLegacyEventstoreDbSettings());
this.TestHostHttpClient = new HttpClient(clientHandler);
this.TestHostHttpClient.BaseAddress = new Uri($"http://127.0.0.1:{this.TestHostServicePort}");
this.AgencyBankingClient = new AgencyBankingClient(TestHostServiceBaseAddressResolver, httpClient, Serialise_CamelCase, this.Deserialise_CamelCase);
Expand Down
3 changes: 2 additions & 1 deletion CallbackHandler.IntegrationTests/Common/GenericSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public async Task StartSystem()
String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");
NlogLogger logger = new();
logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName);
LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);
LogManager.Setup().SetupLogFactory(setup =>
setup.AddCallSiteHiddenAssembly(typeof(NlogLogger).Assembly));

DockerServices dockerServices = DockerServices.SecurityService | DockerServices.TransactionProcessor |
DockerServices.CallbackHandler | DockerServices.KurrentDb |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CallbackHandler.IntegrationTests/Shared/SharedSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SharedSteps(ScenarioContext scenarioContext,

this.SecurityServiceSteps = new SecurityServiceSteps(testingContext.DockerHelper.SecurityServiceClient, testingContext.DockerHelper.AccessToken);
this.TransactionProcessorSteps = new TransactionProcessorSteps(testingContext.DockerHelper.TransactionProcessorClient, testingContext.DockerHelper.TestHostHttpClient,
testingContext.DockerHelper.LegacyProjectionManagementClient, testingContext.DockerHelper.AgencyBankingClient);
testingContext.DockerHelper.ProjectionManagementClient, testingContext.DockerHelper.AgencyBankingClient);

}

Expand Down
3 changes: 1 addition & 2 deletions CallbackHandler/Common/JsonSerializerConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Shared.Serialisation;
using System.Text.Json;
using Shared.Serialisation;

namespace CallbackHandler.Common;

Expand Down
7 changes: 5 additions & 2 deletions CallbackHandler/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CallbackHandler.Endpoints;
using CallbackHandler.Bootstrapper;
using CallbackHandler.Common;
using HealthChecks.UI.Client;
using JasperFx.CommandLine.Descriptions;
using Lamar;
Expand Down Expand Up @@ -78,8 +79,9 @@

WebApplication app = builder.Build();

Microsoft.Extensions.Logging.ILogger logger = app.Services.GetRequiredService<ILoggerFactory>().CreateLogger("CallbackHandler");
Shared.Logger.Logger.Initialise(logger);
LogManager.Setup().LoadConfigurationFromFile("NLog.config");
NLog.Logger logger = LogManager.GetLogger("CallbackHandler");
Shared.Logger.Logger.Initialise(logger, "callbackhandler");
IConfigurationRoot appConfiguration = (IConfigurationRoot)app.Configuration;
appConfiguration.LogConfiguration(Shared.Logger.Logger.LogWarning);
ConfigurationReader.Initialise(appConfiguration);
Expand All @@ -91,6 +93,7 @@

app.UseMiddleware<TenantMiddleware>();
app.AddRequestResponseLogging();
//app.UseMiddleware<RequestResponseLoggingMiddlewareX>();

Check notice on line 96 in CallbackHandler/Program.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

CallbackHandler/Program.cs#L96

Remove this commented out code.
app.AddExceptionHandler();
app.UseRouting();

Expand Down
41 changes: 28 additions & 13 deletions CallbackHandler/nlog.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,37 @@
<targets>
<target name="asyncFile" xsi:type="AsyncWrapper">
<target name="logfile" xsi:type="File"
fileName="/home/txnproc/trace/callbackhandler.log"
layout="${date:format=dd/MM/yyyy HH\:mm\:ss.ffff} | ${level} |${mdlc:CorrelationId:fallback=NO-ID} | ${callsite:className=true} | ${message} | ${exception:format=type,method:maxInnerExceptionLevel=5:innerFormat=shortType,message,method:InnerExceptionSeparator= | }"
archiveFileName="/home/txnproc/trace/callbackhandler.{#####}.log"
fileName="/home/txnproc/trace/callbackhandler.json"
archiveFileName="/home/txnproc/trace/callbackhandler.{#####}.json"
archiveAboveSize="104857600"
archiveNumbering="Sequence"
concurrentWrites="true"
maxArchiveFiles="2"/>
<target name="healthlogfile" xsi:type="File"
fileName="/home/txnproc/trace/callbackhandler_health.log"
layout="${date:format=dd/MM/yyyy HH\:mm\:ss} | ${date:format=dd/MM/yyyy HH\:mm\:ss.ffff} | ${level} | ${callsite:className=true} | ${message} | ${exception:format=type,method:maxInnerExceptionLevel=5:innerFormat=shortType,message,method:InnerExceptionSeparator= | }"
archiveFileName="/home/txnproc/trace/callbackhandler_health.{#####}.log"
archiveAboveSize="104857600"
archiveNumbering="Sequence"
concurrentWrites="true"
maxArchiveFiles="2"/>

maxArchiveFiles="2">
<layout xsi:type="JsonLayout"
includeEventProperties="true"
excludeProperties="timestampUtc">
<attribute name="timestampUtc" layout="${date:universalTime=true:format=o}" />
<attribute name="level" layout="${level:uppercase=true}" />
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=type,method:maxInnerExceptionLevel=5:innerFormat=shortType,message,method:InnerExceptionSeparator= | }" />
</layout>
</target>
<target name="healthlogfile" xsi:type="File"
fileName="/home/txnproc/trace/callbackhandler_health.json"
archiveFileName="/home/txnproc/trace/callbackhandler_health.{#####}.json"
archiveAboveSize="104857600"
archiveNumbering="Sequence"
concurrentWrites="true"
maxArchiveFiles="2">
<layout xsi:type="JsonLayout"
includeEventProperties="true"
excludeProperties="timestampUtc">
<attribute name="timestampUtc" layout="${date:universalTime=true:format=o}" />
<attribute name="level" layout="${level:uppercase=true}" />
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=type,method:maxInnerExceptionLevel=5:innerFormat=shortType,message,method:InnerExceptionSeparator= | }" />
</layout>
</target>
</target>
</targets>

Expand Down
24 changes: 12 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="EventStore.Client.Grpc.ProjectionManagement" Version="23.3.9" />
<PackageVersion Include="HealthMonitoring.Client" Version="2026.10.1" />
<PackageVersion Include="HealthMonitoring.Client" Version="2026.10.2.55" />
<PackageVersion Include="Lamar" Version="16.0.0" />
<PackageVersion Include="Lamar.Microsoft.DependencyInjection" Version="16.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.13" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.13" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageVersion Include="Imposter" Version="1.0.3" />
<PackageVersion Include="Imposter" Version="1.0.4" />
<PackageVersion Include="SharpCompress" Version="0.50.7" />
<PackageVersion Include="SSH.NET" Version="2026.0.0" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="10.0.13" />
<PackageVersion Include="TransactionProcessing.ApiDefaults" Version="2026.10.4" />
<PackageVersion Include="TransactionProcessing.ApiDefaults" Version="2026.11.2" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="4.0.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1" />
<PackageVersion Include="coverlet.collector" Version="10.1.0" />
Expand All @@ -25,20 +25,20 @@
<PackageVersion Include="Reqnroll.NUnit" Version="3.3.4" />
<PackageVersion Include="NUnit" Version="5.0.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.3.1" />
<PackageVersion Include="SecurityService.Client" Version="2026.10.1" />
<PackageVersion Include="SecurityService.IntegrationTesting.Helpers" Version="2026.10.1" />
<PackageVersion Include="Shared" Version="2026.10.4" />
<PackageVersion Include="Shared.IntegrationTesting" Version="2026.10.4" />
<PackageVersion Include="TransactionProcessor.Client" Version="2026.10.1" />
<PackageVersion Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2026.10.1" />
<PackageVersion Include="SecurityService.Client" Version="2026.10.3.203" />
<PackageVersion Include="SecurityService.IntegrationTesting.Helpers" Version="2026.10.3.203" />
<PackageVersion Include="Shared" Version="2026.11.2" />
<PackageVersion Include="Shared.IntegrationTesting" Version="2026.11.2" />
<PackageVersion Include="TransactionProcessor.Client" Version="2026.10.2.411" />
<PackageVersion Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2026.10.2.411" />
<PackageVersion Include="Grpc.Net.Client" Version="2.84.0" />
<PackageVersion Include="Shared.DomainDrivenDesign" Version="2026.10.4" />
<PackageVersion Include="Shared.EventStore" Version="2026.10.4" />
<PackageVersion Include="Shared.DomainDrivenDesign" Version="2026.11.2" />
<PackageVersion Include="Shared.EventStore" Version="2026.11.2" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageVersion Include="MediatR" Version="14.2.0" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageVersion Include="Sentry.AspNetCore" Version="6.12.1" />
<PackageVersion Include="Shared.Results.Web" Version="2026.10.4" />
<PackageVersion Include="Shared.Results.Web" Version="2026.11.2" />
<PackageVersion Include="SimpleResults.AspNetCore" Version="4.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.13" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
Expand Down
Loading