The Trade Imports Reporting API is a .NET application which subscribes to Data API resource events and exposes reporting information.
- Prerequisites
- Setup Process
- How to run in development
- How to run Tests
- Running
- Deploying
- SonarCloud
- Dependabot
- Message Consumption
- Tracing
- Licence Information
- About the Licence
- .NET 9 SDK
- Docker
- localstack - used for local queuing
- wiremock - used for mocking out http requests
- Install the .NET 9 SDK
- Install Docker
- Run the following Docker Compose to set up locally running queues for testing
docker compose -f compose.yml up -d
Run the application with the command:
dotnet run --project src/Api/Api.csproj
Run the unit tests with:
dotnet test --filter "Category!=IntegrationTest"
Run the integration tests with:
dotnet test --filter "Category=IntegrationTest"
Run all tests with:
dotnet test
Some unit tests may run an in memory instance service.
Integration tests run against the built docker image.
Because these use the built docker image, the appsettings.json
will be used, should any values need to be overridden, then they can be injected as an environment variable via the compose.yml
Before deploying via CDP set any config needed in the appropriate cdp
app settings JSON in the Api project root, otherwise add as a secret in the CDP portal.
See the configured project in SonarCloud.
We are using dependabot.
Connection to the private Defra nuget packages is provided by a user generated PAT stored in this repo's settings - /settings/secrets/dependabot - see DEPENDABOT_PAT
secret.
The PAT is a classic token and needs permissions of read:packages
.
At time of writing, using PAT is the only way to make Dependabot work with private nuget feeds.
Should the user who owns the PAT leave Defra then another user on the team should create a new PAT and update the settings in this repo.
This service is using a framework called Slim Message Bus, which maps queues/types to consumer classes.
The out of the box CDP template doesn't provide any example of how to handle tracing for non Http communication.
This service expects the trace.id
to be a header on the message.
Getting the trace.id
header is achieved via a SMB TraceContextInterceptor
.
Making sure that trace.id
is then used in log messages is achieved via TraceContextEnricher
.
Setting the trace.id
header on a HTTP request is achieved via Header Propagation.
THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3
The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.