Skip to content

Commit 0608be7

Browse files
PI-2575 Create initial project for common-platform-and-delius (#4289)
* PI-2575 Create initial project for common-platform-and-delius * Update access.yml * Update values-dev.yml * Update values-preprod.yml --------- Co-authored-by: probation-integration-bot[bot] <177347787+probation-integration-bot[bot]@users.noreply.github.com> Co-authored-by: joseph-bcl <[email protected]>
1 parent dcc66c9 commit 0608be7

File tree

44 files changed

+864
-0
lines changed

Some content is hidden

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

44 files changed

+864
-0
lines changed

.github/workflows/access.yml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ on:
5454
- '["unpaid-work-and-delius"]'
5555
- '["workforce-allocations-to-delius"]'
5656
- '["subject-access-requests-and-delius"]'
57+
- '["common-platform-and-delius"]'
5758
# ^ add new projects here
5859
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
5960
# See https://github.com/community/community/discussions/11795

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
- unpaid-work-and-delius
7878
- workforce-allocations-to-delius
7979
- subject-access-requests-and-delius
80+
- common-platform-and-delius
8081
# ^ add new projects here
8182
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
8283
# See https://github.com/community/community/discussions/11795

.github/workflows/deploy.yml

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ on:
6969
- '["unpaid-work-and-delius"]'
7070
- '["workforce-allocations-to-delius"]'
7171
- '["subject-access-requests-and-delius"]'
72+
- '["common-platform-and-delius"]'
7273
# ^ add new projects here
7374
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
7475
# See https://github.com/community/community/discussions/11795

.github/workflows/messaging.yml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ on:
3737
- prison-identifier-and-delius-queue
3838
- assessment-summary-and-delius-queue
3939
- cas2-and-delius-queue
40+
- common-platform-and-delius-queue
4041
# ^ add new queues here
4142

4243
jobs:

.github/workflows/service-catalogue.yml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ on:
5454
- '["unpaid-work-and-delius"]'
5555
- '["workforce-allocations-to-delius"]'
5656
- '["subject-access-requests-and-delius"]'
57+
- '["common-platform-and-delius"]'
5758
# ^ add new projects here
5859
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
5960
# See https://github.com/community/community/discussions/11795

.idea/runConfigurations/common_platform_and_delius.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/tech-docs/source/services.html.md.erb

+1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ weight: 20
8181
* [Probation Search And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/probation-search-and-delius)
8282
* [Core Person Record And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/core-person-record-and-delius)
8383
* [Subject Access Requests And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/subject-access-requests-and-delius)
84+
* [Common Platform And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/common-platform-and-delius)
8485
<li style="display: none">^ add new projects here</li>

projects/common-platform-and-delius/.trivyignore

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# common-platform-and-delius
2+
3+
// TODO Describe the service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"role": {
3+
"name": "common-platform-and-delius"
4+
},
5+
"customDimensions": {
6+
"service.version": "${VERSION}",
7+
"service.team": "probation-integration"
8+
},
9+
"instrumentation": {
10+
"logging": {
11+
"level": "DEBUG"
12+
},
13+
"springScheduling": {
14+
"enabled": false
15+
}
16+
},
17+
"selfDiagnostics": {
18+
"destination": "console"
19+
},
20+
"sampling": {
21+
"percentage": 100
22+
},
23+
"preview": {
24+
"sampling": {
25+
"overrides": [
26+
{
27+
"telemetryType": "request",
28+
"attributes": [
29+
{
30+
"key": "http.url",
31+
"value": "https?://[^/]+/health/?.*",
32+
"matchType": "regexp"
33+
}
34+
],
35+
"percentage": 0
36+
},
37+
{
38+
"telemetryType": "request",
39+
"attributes": [
40+
{
41+
"key": "http.url",
42+
"value": "https?://[^/]+/info/?.*",
43+
"matchType": "regexp"
44+
}
45+
],
46+
"percentage": 0
47+
},
48+
{
49+
"telemetryType": "dependency",
50+
"attributes": [
51+
{
52+
"key": "db.operation",
53+
"value": "SELECT",
54+
"matchType": "strict"
55+
}
56+
],
57+
"percentage": 10
58+
}
59+
]
60+
}
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import uk.gov.justice.digital.hmpps.extensions.ClassPathExtension
2+
3+
apply(plugin = "com.google.cloud.tools.jib")
4+
5+
dependencies {
6+
implementation(project(":libs:audit"))
7+
implementation(project(":libs:commons"))
8+
implementation(project(":libs:messaging"))
9+
implementation(project(":libs:oauth-client"))
10+
11+
implementation("org.springframework.boot:spring-boot-starter-actuator")
12+
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
13+
implementation("org.springframework.boot:spring-boot-starter-security")
14+
implementation("org.springframework.boot:spring-boot-starter-validation")
15+
implementation("org.springframework.boot:spring-boot-starter-web")
16+
implementation("org.jetbrains.kotlin:kotlin-reflect")
17+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
18+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
19+
20+
dev(project(":libs:dev-tools"))
21+
dev("com.h2database:h2")
22+
dev("org.testcontainers:oracle-xe")
23+
24+
runtimeOnly("com.oracle.database.jdbc:ojdbc11")
25+
26+
testImplementation("org.springframework.boot:spring-boot-starter-test")
27+
testImplementation(libs.bundles.mockito)
28+
}
29+
30+
configure<ClassPathExtension> {
31+
jacocoExclusions = listOf(
32+
"**/config/**",
33+
"**/entity/**",
34+
"**/AppKt.class"
35+
)
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v2
2+
appVersion: '1.0'
3+
description: A Helm chart for Kubernetes
4+
name: common-platform-and-delius
5+
version: 1.0.0
6+
7+
dependencies:
8+
- name: generic-service
9+
version: "3.2"
10+
repository: https://ministryofjustice.github.io/hmpps-helm-charts
11+
- name: generic-prometheus-alerts
12+
version: "1.4"
13+
repository: https://ministryofjustice.github.io/hmpps-helm-charts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
database:
2+
access:
3+
username_key: /common-platform-and-delius/db-username
4+
password_key: /common-platform-and-delius/db-password
5+
6+
audit:
7+
username: CommonPlatformAndDelius
8+
forename: Common Platform
9+
surname: Service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
generic-service:
2+
ingress:
3+
host: common-platform-and-delius-dev.hmpps.service.justice.gov.uk
4+
5+
scheduledDowntime:
6+
enabled: true
7+
8+
env:
9+
SENTRY_ENVIRONMENT: dev
10+
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/oauth/token
11+
12+
SPRING_DATASOURCE_HIKARI_MAXIMUMPOOLSIZE: 5
13+
SPRING_DATASOURCE_HIKARI_MINIMUMIDLE: 0
14+
15+
LOGGING_LEVEL_UK_GOV_DIGITAL_JUSTICE_HMPPS: DEBUG
16+
17+
generic-prometheus-alerts:
18+
businessHoursOnly: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
generic-service:
2+
ingress:
3+
host: common-platform-and-delius-preprod.hmpps.service.justice.gov.uk
4+
5+
scheduledDowntime:
6+
enabled: true
7+
8+
env:
9+
SENTRY_ENVIRONMENT: preprod
10+
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/oauth/token
11+
12+
generic-prometheus-alerts:
13+
businessHoursOnly: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
enabled: false # TODO set this to true when you're ready to deploy your service
2+
3+
generic-service:
4+
ingress:
5+
host: common-platform-and-delius.hmpps.service.justice.gov.uk
6+
7+
env:
8+
SENTRY_ENVIRONMENT: prod
9+
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in.hmpps.service.justice.gov.uk/auth/oauth/token
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Common values
2+
generic-service:
3+
productId: HMPPS518
4+
nameOverride: common-platform-and-delius
5+
serviceAccountName: common-platform-and-delius
6+
7+
image:
8+
repository: ghcr.io/ministryofjustice/hmpps-probation-integration-services/common-platform-and-delius
9+
10+
ingress:
11+
tlsSecretName: common-platform-and-delius-cert
12+
13+
namespace_secrets:
14+
common:
15+
SPRING_DATASOURCE_URL: DB_URL
16+
common-platform-and-delius-client-credentials:
17+
OAUTH2_CLIENT-ID: CLIENT_ID
18+
OAUTH2_CLIENT-SECRET: CLIENT_SECRET
19+
common-platform-and-delius-database:
20+
SPRING_DATASOURCE_USERNAME: DB_USERNAME
21+
SPRING_DATASOURCE_PASSWORD: DB_PASSWORD
22+
common-platform-and-delius-sentry:
23+
SENTRY_DSN: SENTRY_DSN
24+
common-platform-and-delius-queue:
25+
MESSAGING_CONSUMER_QUEUE: QUEUE_NAME
26+
27+
generic-prometheus-alerts:
28+
targetApplication: common-platform-and-delius
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "common-platform-and-delius"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package uk.gov.justice.digital.hmpps.data
2+
3+
import jakarta.annotation.PostConstruct
4+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
5+
import org.springframework.boot.context.event.ApplicationReadyEvent
6+
import org.springframework.context.ApplicationListener
7+
import org.springframework.stereotype.Component
8+
import uk.gov.justice.digital.hmpps.data.generator.UserGenerator
9+
import uk.gov.justice.digital.hmpps.user.AuditUserRepository
10+
11+
@Component
12+
@ConditionalOnProperty("seed.database")
13+
class DataLoader(
14+
private val auditUserRepository: AuditUserRepository
15+
) : ApplicationListener<ApplicationReadyEvent> {
16+
17+
@PostConstruct
18+
fun saveAuditUser() {
19+
auditUserRepository.save(UserGenerator.AUDIT_USER)
20+
}
21+
22+
override fun onApplicationEvent(are: ApplicationReadyEvent) {
23+
// Perform dev/test database setup here, using JPA repositories and generator classes...
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package uk.gov.justice.digital.hmpps.data.generator
2+
3+
import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent
4+
import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader
5+
6+
object MessageGenerator {
7+
val EXAMPLE = ResourceLoader.message<HmppsDomainEvent>("example-message")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package uk.gov.justice.digital.hmpps.data.generator
2+
3+
import uk.gov.justice.digital.hmpps.user.AuditUser
4+
5+
object UserGenerator {
6+
val AUDIT_USER = AuditUser(IdGenerator.getAndIncrement(), "CommonPlatformAndDelius")
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"Type": "Notification",
3+
"MessageId": "aa2c2828-167f-529b-8e19-73735a2fb85c",
4+
"TopicArn": "arn:aws:sns:eu-west-2:000000000000:example",
5+
"Message": "{\"eventType\":\"example\",\"version\":1,\"description\":\"Example event\",\"detailUrl\":\"http://localhost:{wiremock.port}/example/123\",\"occurredAt\":\"2022-07-27T15:22:08.452612281+01:00\",\"additionalInformation\":{\"exampleId\":\"123\"},\"personReference\":{\"identifiers\":[{\"type\":\"CRN\",\"value\":\"A000001\"}]}}",
6+
"Timestamp": "2022-07-27T14:22:08.509Z",
7+
"SignatureVersion": "1",
8+
"Signature": "EXAMPLE",
9+
"SigningCertURL": "https://sns.eu-west-2.amazonaws.com/EXAMPLE.pem",
10+
"UnsubscribeURL": "https://sns.eu-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=EXAMPLE",
11+
"MessageAttributes": {
12+
"eventType": {
13+
"Type": "String",
14+
"Value": "example"
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"request": {
3+
"method": "POST",
4+
"urlPath": "/auth/oauth/token"
5+
},
6+
"response": {
7+
"headers": {
8+
"Content-Type": "application/json"
9+
},
10+
"status": 200,
11+
"jsonBody": {
12+
"access_token": "token",
13+
"token_type": "bearer",
14+
"expires_in": 9999999999,
15+
"scope": "read write",
16+
"sub": "probation-integration-dev",
17+
"auth_source": "none",
18+
"iss": "https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer"
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package uk.gov.justice.digital.hmpps
2+
3+
import org.junit.jupiter.api.Test
4+
import org.mockito.Mockito.atLeastOnce
5+
import org.mockito.kotlin.verify
6+
import org.springframework.beans.factory.annotation.Autowired
7+
import org.springframework.beans.factory.annotation.Value
8+
import org.springframework.boot.test.context.SpringBootTest
9+
import org.springframework.boot.test.mock.mockito.MockBean
10+
import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator
11+
import uk.gov.justice.digital.hmpps.message.Notification
12+
import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager
13+
import uk.gov.justice.digital.hmpps.telemetry.TelemetryService
14+
import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived
15+
import java.util.concurrent.TimeoutException
16+
17+
@SpringBootTest
18+
internal class IntegrationTest {
19+
@Value("\${messaging.consumer.queue}")
20+
lateinit var queueName: String
21+
22+
@Autowired
23+
lateinit var channelManager: HmppsChannelManager
24+
25+
@MockBean
26+
lateinit var telemetryService: TelemetryService
27+
28+
@Test
29+
fun `message is logged to telemetry`() {
30+
// Given a message
31+
val notification = Notification(message = MessageGenerator.EXAMPLE)
32+
33+
// When it is received
34+
try {
35+
channelManager.getChannel(queueName).publishAndWait(notification)
36+
} catch (_: TimeoutException) {
37+
// Note: Remove this try/catch when the MessageListener logic has been implemented
38+
}
39+
40+
// Then it is logged to telemetry
41+
verify(telemetryService, atLeastOnce()).notificationReceived(notification)
42+
}
43+
}

0 commit comments

Comments
 (0)