This is the API service for Managing Offences.
This service requires a postgresql database.
Tools required:
- JDK v21+
- Kotlin
- docker
- docker-compose
Unit tests mock all external dependencies and can be run with no dependent containers.
Integration tests use Wiremock to stub any API calls required, and use a local H2 database
that is seeded with data specific to each test suite.
$ ./gradlew test
$ ./gradlew ktlintcheck
$ ./gradlew dependencyCheckAnalyze
This will run the service locally. It starts the database and auth using docker compose then runs manage-offences-api via a bash script. Run the following commands from the root directory of the project:
docker compose -f docker-compose-test.yml pull
docker compose -f docker-compose-test.yml up --no-start
docker compose -f docker-compose-test.yml start hmpps-auth manage-offences-db
./run-local.sh
Use the keytool command. if modifying cacerts pass in the option -cacerts
, otherwise the following can modify any truststore -keystore /etc/ssl/certs/java/cacerts
The SDRS Staging api is publicly open api with root URL at
https://sdrs.staging.apps.hmcts.net/
However, in order for it to work with java you have to add it to the truststore, locally this can be achieved by doing the following (using the default password of changeit):
- Download the cert from https://sdrs.staging.apps.hmcts.net/ using a browser or the following command:
openssl s_client -servername sdrs.staging.apps.hmcts.net -connect crime-reference-data-api.staging.service.justice.gov.uk:443 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >sdrs-staging.pem
- Then add it to the tuststore using the following command:
keytool -noprompt -storepass changeit -importcert -trustcacerts -cacerts -file sdrs-staging.pem -alias sdrs_staging_cert
The SDRS staging API is only used by the DEV environment.
The SDRS Production API (used in preprod and prod) is not affected by this issue as the production certificate is trusted by the java trust store
keytool -noprompt -storepass changeit -list -v -cacerts
keytool -noprompt -storepass changeit -delete -alias sdrs_staging_cert -cacerts