Skip to content

Commit 93c2a55

Browse files
authored
CDPS-1054: Added template API for iteration 1 (#3)
* Updated environment name for dev from "dev" to "development" to match infrastructure. * Removed rename-project workflow * Set security scans to send alerts to the connect DPS dev channel. * CDPS-1054: Added Prison API url and client credentials to helm values. * CDPS-1054: Setup docker compose for running locally. * CDPS-1054: Added prison API details to application properties. * CDPS-1054: Updated the template references in banner and log config. * CDP-1054: Template Iteration 1 API added to Core Person Record and Protected Characteristics domains. * CDPS-1054: Template tests added for iteration 1 API. * CDPS-1054: Corrected typo in app name. * CDPS-1054: Set SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI to the local hmpps auth container url * CDPS-1054: Lint issues fixed. * CDPS-1054: Switch helm lint environment name from development to dev. * CDPS-1054: Updated resource and service tests for core person record. * CDPS-1054: Added basic tests for prototype functionality and applied auto-formating. * CDPS-1054: Updated roles to be read or read/write and allowed access to reference data to either role. * CDPS-1054: Updated app name on open api spec. * CDPS-1054: Updated the docker-compose file to use container names instead of localhost. * CDPS-1054: Remove wildcard import. * CDPS-1054: Added service specific timeouts to web clients. * CDPS-1054: Switched PUT and PATCH endpoints to return No Content on success. * CDPS-1054: Fixed description for field value property. * CDPS-1054: Updated image update test to expect a no content response. * CDPS-1054: Corrected prison api port number in docker compose.
1 parent 3a77b7d commit 93c2a55

File tree

61 files changed

+1633
-613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1633
-613
lines changed

.github/workflows/pipeline.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ jobs:
7878
docker_multiplatform: ${{ inputs.docker_multiplatform || true }}
7979
deploy_dev:
8080
name: Deploy to dev environment
81-
needs:
81+
needs:
8282
- build
8383
- helm_lint
8484
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
8585
secrets: inherit
8686
with:
87-
environment: 'dev'
87+
environment: 'development'
8888
app_version: '${{ needs.build.outputs.app_version }}'
8989

9090
# deploy_preprod:
9191
# name: Deploy to pre-production environment
92-
# needs:
92+
# needs:
9393
# - build
9494
# - deploy_dev
9595
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
@@ -99,7 +99,7 @@ jobs:
9999
# app_version: '${{ needs.build.outputs.app_version }}'
100100
# deploy_prod:
101101
# name: Deploy to production environment
102-
# needs:
102+
# needs:
103103
# - build
104104
# - deploy_preprod
105105
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION

.github/workflows/rename_template_project_pr.yml

-43
This file was deleted.

.github/workflows/security_owasp.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
name: Kotlin security OWASP dependency check
99
uses: ministryofjustice/hmpps-github-actions/.github/workflows/security_owasp.yml@v0.7 # WORKFLOW_VERSION
1010
with:
11-
channel_id: C05J915DX0Q
11+
channel_id: C04JFG3QJE6
1212
secrets: inherit

.github/workflows/security_trivy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
name: Project security trivy dependency check
99
uses: ministryofjustice/hmpps-github-actions/.github/workflows/security_trivy.yml@v0.7 # WORKFLOW_VERSION
1010
with:
11-
channel_id: C05J915DX0Q
11+
channel_id: C04JFG3QJE6
1212
secrets: inherit

.github/workflows/security_veracode_pipeline_scan.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
name: Project security veracode pipeline scan
99
uses: ministryofjustice/hmpps-github-actions/.github/workflows/security_veracode_pipeline_scan.yml@v0.7 # WORKFLOW_VERSION
1010
with:
11-
channel_id: C05J915DX0Q
11+
channel_id: C04JFG3QJE6
1212
secrets: inherit

.github/workflows/security_veracode_policy_scan.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
name: Project security veracode policy scan
99
uses: ministryofjustice/hmpps-github-actions/.github/workflows/security_veracode_policy_scan.yml@v0.7 # WORKFLOW_VERSION
1010
with:
11-
channel_id: C05J915DX0Q
11+
channel_id: C04JFG3QJE6
1212
secrets: inherit

docker-compose.yml

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
version: "3"
21
services:
32
hmpps-person-integration-api:
43
build:
54
context: .
5+
depends_on:
6+
- hmpps-auth
7+
- prison-api
68
networks:
79
- hmpps
810
container_name: hmpps-person-integration-api
@@ -13,8 +15,7 @@ services:
1315
environment:
1416
- SERVER_PORT=8080
1517
- HMPPS_AUTH_URL=http://hmpps-auth:8080/auth
16-
# TODO: Remove this URL and replace with outgoing service URLs
17-
- EXAMPLE_URL=http://hmpps-person-integration-api:8080
18+
- PRISON_API_BASE_URL=http://prison-api:8080
1819
- SPRING_PROFILES_ACTIVE=dev
1920

2021
hmpps-auth:
@@ -31,5 +32,19 @@ services:
3132
- SPRING_PROFILES_ACTIVE=dev
3233
- APPLICATION_AUTHENTICATION_UI_ALLOWLIST=0.0.0.0/0
3334

35+
prison-api:
36+
image: quay.io/hmpps/prison-api:latest
37+
container_name: prison-api
38+
networks:
39+
- hmpps
40+
ports:
41+
- '8082:8080'
42+
healthcheck:
43+
test: [ 'CMD', 'curl', '-f', 'http://localhost:8080/health' ]
44+
environment:
45+
- SERVER_PORT=8080
46+
- SPRING_PROFILES_ACTIVE=nomis-hsqldb
47+
- SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI=http://hmpps-auth:8080/auth/.well-known/jwks.json
48+
3449
networks:
3550
hmpps:

helm_deploy/hmpps-person-integration-api/values.yaml

+4-8
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,18 @@ generic-service:
2121
APPLICATIONINSIGHTS_CONNECTION_STRING: "InstrumentationKey=$(APPINSIGHTS_INSTRUMENTATIONKEY)"
2222
APPLICATIONINSIGHTS_CONFIGURATION_FILE: applicationinsights.json
2323

24-
# Pre-existing kubernetes secrets to load as environment variables in the deployment.
25-
# namespace_secrets:
26-
# [name of kubernetes secret]:
27-
# [name of environment variable as seen by app]: [key of kubernetes secret to load]
28-
2924
namespace_secrets:
3025
hmpps-person-integration-api:
31-
# Example client registration secrets
32-
EXAMPLE_API_CLIENT_ID: "TEMPLATE_KOTLIN_API_CLIENT_ID"
33-
EXAMPLE_API_CLIENT_SECRET: "TEMPLATE_KOTLIN_API_CLIENT_SECRET"
26+
SYSTEM_CLIENT_ID: "SYSTEM_CLIENT_ID"
27+
SYSTEM_CLIENT_SECRET: "SYSTEM_CLIENT_SECRET"
3428
application-insights:
3529
APPINSIGHTS_INSTRUMENTATIONKEY: "APPINSIGHTS_INSTRUMENTATIONKEY"
3630

3731
allowlist:
3832
groups:
3933
- internal
4034

35+
modsecurity_enabled: true
36+
4137
generic-prometheus-alerts:
4238
targetApplication: hmpps-person-integration-api

helm_deploy/values-dev.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ generic-service:
1010
env:
1111
APPLICATIONINSIGHTS_CONFIGURATION_FILE: "applicationinsights.dev.json"
1212
HMPPS_AUTH_URL: "https://sign-in-dev.hmpps.service.justice.gov.uk/auth"
13-
# Template kotlin calls out to itself to provide an example of a service call
14-
# TODO: This should be replaced by a call to a different service, or removed
15-
EXAMPLE_API_URL: "https://person-integration-api-dev.hmpps.service.justice.gov.uk"
13+
PRISON_API_BASE_URL: "https://prison-api-dev.prison.service.justice.gov.uk"
1614

1715
# CloudPlatform AlertManager receiver to route prometheus alerts to slack
1816
# See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts

helm_deploy/values-preprod.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ generic-service:
1010
env:
1111
APPLICATIONINSIGHTS_CONFIGURATION_FILE: "applicationinsights.dev.json"
1212
HMPPS_AUTH_URL: "https://sign-in-preprod.hmpps.service.justice.gov.uk/auth"
13-
# Template kotlin calls out to itself to provide an example of a service call
14-
# TODO: This should be replaced by a call to a different service, or removed
15-
EXAMPLE_API_URL: "https://person-integration-api-preprod.hmpps.service.justice.gov.uk"
13+
PRISON_API_BASE_URL: "https://prison-api-preprod.prison.service.justice.gov.uk"
1614

1715
# CloudPlatform AlertManager receiver to route prometheus alerts to slack
1816
# See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts

helm_deploy/values-prod.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ generic-service:
77

88
env:
99
HMPPS_AUTH_URL: "https://sign-in.hmpps.service.justice.gov.uk/auth"
10-
# Template kotlin calls out to itself to provide an example of a service call
11-
# TODO: This should be replaced by a call to a different service, or removed
12-
EXAMPLE_API_URL: "https://person-integration-api.hmpps.service.justice.gov.uk"
10+
PRISON_API_BASE_URL: "https://prison-api.prison.service.justice.gov.uk"
1311

1412
# CloudPlatform AlertManager receiver to route prometheus alerts to slack
1513
# See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package uk.gov.justice.digital.hmpps.templatepackagename
1+
package uk.gov.justice.digital.hmpps.personintegrationapi
22

33
import org.springframework.boot.autoconfigure.SpringBootApplication
44
import org.springframework.boot.runApplication
55

66
@SpringBootApplication
7-
class HmppsTemplateKotlin
7+
class HmppsPersonIntegrationApi
88

99
fun main(args: Array<String>) {
10-
runApplication<HmppsTemplateKotlin>(*args)
10+
runApplication<HmppsPersonIntegrationApi>(*args)
1111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package uk.gov.justice.digital.hmpps.personintegrationapi.common
2+
3+
object Constants {
4+
const val PRISONER_NUMBER_REGEX = "^[A-Za-z0-9]{1,10}\$"
5+
const val PRISONER_NUMBER_VALIDATION_MESSAGE =
6+
"The prisoner number must be a alphanumeric string upto 10 characters in length."
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package uk.gov.justice.digital.hmpps.personintegrationapi.common.annotation
2+
3+
import io.swagger.v3.oas.annotations.media.Schema
4+
import jakarta.validation.constraints.Pattern
5+
import uk.gov.justice.digital.hmpps.personintegrationapi.common.Constants
6+
7+
@Schema(
8+
description = Constants.PRISONER_NUMBER_VALIDATION_MESSAGE,
9+
example = "A12345",
10+
pattern = Constants.PRISONER_NUMBER_REGEX,
11+
)
12+
@Pattern(
13+
regexp = Constants.PRISONER_NUMBER_REGEX,
14+
message = Constants.PRISONER_NUMBER_VALIDATION_MESSAGE,
15+
)
16+
@Target(
17+
AnnotationTarget.FIELD,
18+
AnnotationTarget.VALUE_PARAMETER,
19+
)
20+
@Retention(
21+
AnnotationRetention.RUNTIME,
22+
)
23+
annotation class ValidPrisonerNumber
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package uk.gov.justice.digital.hmpps.personintegrationapi.common.client
2+
3+
import org.springframework.http.ResponseEntity
4+
import org.springframework.web.bind.annotation.PathVariable
5+
import org.springframework.web.bind.annotation.RequestBody
6+
import org.springframework.web.service.annotation.HttpExchange
7+
import org.springframework.web.service.annotation.PutExchange
8+
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.dto.UpdateBirthPlace
9+
10+
@HttpExchange("/api/offenders")
11+
interface PrisonApiClient {
12+
@PutExchange("/{offenderNo}/birth-place")
13+
fun updateBirthPlaceForWorkingName(
14+
@PathVariable offenderNo: String,
15+
@RequestBody updateBirthPlace: UpdateBirthPlace,
16+
): ResponseEntity<Void>
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package uk.gov.justice.digital.hmpps.personintegrationapi.common.client.dto
2+
3+
import io.swagger.v3.oas.annotations.media.Schema
4+
5+
@Schema(description = "Update to prisoner birth place (city or town of birth)")
6+
data class UpdateBirthPlace(
7+
@Schema(description = "Birth place (city or town of birth)", example = "SHEFFIELD")
8+
val birthPlace: String,
9+
)

0 commit comments

Comments
 (0)