generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PI-2575 Create initial project for common-platform-and-delius
- Loading branch information
1 parent
dcc66c9
commit 6b48689
Showing
44 changed files
with
868 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# common-platform-and-delius | ||
|
||
// TODO Describe the service |
62 changes: 62 additions & 0 deletions
62
projects/common-platform-and-delius/applicationinsights.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"role": { | ||
"name": "common-platform-and-delius" | ||
}, | ||
"customDimensions": { | ||
"service.version": "${VERSION}", | ||
"service.team": "probation-integration" | ||
}, | ||
"instrumentation": { | ||
"logging": { | ||
"level": "DEBUG" | ||
}, | ||
"springScheduling": { | ||
"enabled": false | ||
} | ||
}, | ||
"selfDiagnostics": { | ||
"destination": "console" | ||
}, | ||
"sampling": { | ||
"percentage": 100 | ||
}, | ||
"preview": { | ||
"sampling": { | ||
"overrides": [ | ||
{ | ||
"telemetryType": "request", | ||
"attributes": [ | ||
{ | ||
"key": "http.url", | ||
"value": "https?://[^/]+/health/?.*", | ||
"matchType": "regexp" | ||
} | ||
], | ||
"percentage": 0 | ||
}, | ||
{ | ||
"telemetryType": "request", | ||
"attributes": [ | ||
{ | ||
"key": "http.url", | ||
"value": "https?://[^/]+/info/?.*", | ||
"matchType": "regexp" | ||
} | ||
], | ||
"percentage": 0 | ||
}, | ||
{ | ||
"telemetryType": "dependency", | ||
"attributes": [ | ||
{ | ||
"key": "db.operation", | ||
"value": "SELECT", | ||
"matchType": "strict" | ||
} | ||
], | ||
"percentage": 10 | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import uk.gov.justice.digital.hmpps.extensions.ClassPathExtension | ||
|
||
apply(plugin = "com.google.cloud.tools.jib") | ||
|
||
dependencies { | ||
implementation(project(":libs:audit")) | ||
implementation(project(":libs:commons")) | ||
implementation(project(":libs:messaging")) | ||
implementation(project(":libs:oauth-client")) | ||
|
||
implementation("org.springframework.boot:spring-boot-starter-actuator") | ||
implementation("org.springframework.boot:spring-boot-starter-data-jpa") | ||
implementation("org.springframework.boot:spring-boot-starter-security") | ||
implementation("org.springframework.boot:spring-boot-starter-validation") | ||
implementation("org.springframework.boot:spring-boot-starter-web") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
|
||
dev(project(":libs:dev-tools")) | ||
dev("com.h2database:h2") | ||
dev("org.testcontainers:oracle-xe") | ||
|
||
runtimeOnly("com.oracle.database.jdbc:ojdbc11") | ||
|
||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation(libs.bundles.mockito) | ||
} | ||
|
||
configure<ClassPathExtension> { | ||
jacocoExclusions = listOf( | ||
"**/config/**", | ||
"**/entity/**", | ||
"**/AppKt.class" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v2 | ||
appVersion: '1.0' | ||
description: A Helm chart for Kubernetes | ||
name: common-platform-and-delius | ||
version: 1.0.0 | ||
|
||
dependencies: | ||
- name: generic-service | ||
version: "3.2" | ||
repository: https://ministryofjustice.github.io/hmpps-helm-charts | ||
- name: generic-prometheus-alerts | ||
version: "1.4" | ||
repository: https://ministryofjustice.github.io/hmpps-helm-charts |
9 changes: 9 additions & 0 deletions
9
projects/common-platform-and-delius/deploy/database/access.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
database: | ||
access: | ||
username_key: /common-platform-and-delius/db-username | ||
password_key: /common-platform-and-delius/db-password | ||
|
||
audit: | ||
username: CommonPlatformAndDelius | ||
forename: Probation Integration # TODO change this to something meaningful for your service | ||
surname: Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
enabled: false # TODO set this to true when you're ready to deploy your service | ||
|
||
generic-service: | ||
ingress: | ||
host: common-platform-and-delius-dev.hmpps.service.justice.gov.uk | ||
|
||
scheduledDowntime: | ||
enabled: true | ||
|
||
env: | ||
SENTRY_ENVIRONMENT: dev | ||
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/oauth/token | ||
|
||
SPRING_DATASOURCE_HIKARI_MAXIMUMPOOLSIZE: 5 | ||
SPRING_DATASOURCE_HIKARI_MINIMUMIDLE: 0 | ||
|
||
LOGGING_LEVEL_UK_GOV_DIGITAL_JUSTICE_HMPPS: DEBUG | ||
|
||
generic-prometheus-alerts: | ||
businessHoursOnly: true |
15 changes: 15 additions & 0 deletions
15
projects/common-platform-and-delius/deploy/values-preprod.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
enabled: false # TODO set this to true when you're ready to deploy your service | ||
|
||
generic-service: | ||
ingress: | ||
host: common-platform-and-delius-preprod.hmpps.service.justice.gov.uk | ||
|
||
scheduledDowntime: | ||
enabled: true | ||
|
||
env: | ||
SENTRY_ENVIRONMENT: preprod | ||
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/oauth/token | ||
|
||
generic-prometheus-alerts: | ||
businessHoursOnly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
enabled: false # TODO set this to true when you're ready to deploy your service | ||
|
||
generic-service: | ||
ingress: | ||
host: common-platform-and-delius.hmpps.service.justice.gov.uk | ||
|
||
env: | ||
SENTRY_ENVIRONMENT: prod | ||
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in.hmpps.service.justice.gov.uk/auth/oauth/token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Common values | ||
generic-service: | ||
productId: HMPPS518 | ||
nameOverride: common-platform-and-delius | ||
serviceAccountName: common-platform-and-delius | ||
|
||
image: | ||
repository: ghcr.io/ministryofjustice/hmpps-probation-integration-services/common-platform-and-delius | ||
|
||
ingress: | ||
tlsSecretName: common-platform-and-delius-cert | ||
|
||
namespace_secrets: | ||
common: | ||
SPRING_DATASOURCE_URL: DB_URL | ||
common-platform-and-delius-client-credentials: | ||
OAUTH2_CLIENT-ID: CLIENT_ID | ||
OAUTH2_CLIENT-SECRET: CLIENT_SECRET | ||
common-platform-and-delius-database: | ||
SPRING_DATASOURCE_USERNAME: DB_USERNAME | ||
SPRING_DATASOURCE_PASSWORD: DB_PASSWORD | ||
common-platform-and-delius-sentry: | ||
SENTRY_DSN: SENTRY_DSN | ||
common-platform-and-delius-queue: | ||
MESSAGING_CONSUMER_QUEUE: QUEUE_NAME | ||
|
||
generic-prometheus-alerts: | ||
targetApplication: common-platform-and-delius | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "common-platform-and-delius" |
25 changes: 25 additions & 0 deletions
25
...common-platform-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package uk.gov.justice.digital.hmpps.data | ||
|
||
import jakarta.annotation.PostConstruct | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.boot.context.event.ApplicationReadyEvent | ||
import org.springframework.context.ApplicationListener | ||
import org.springframework.stereotype.Component | ||
import uk.gov.justice.digital.hmpps.data.generator.UserGenerator | ||
import uk.gov.justice.digital.hmpps.user.AuditUserRepository | ||
|
||
@Component | ||
@ConditionalOnProperty("seed.database") | ||
class DataLoader( | ||
private val auditUserRepository: AuditUserRepository | ||
) : ApplicationListener<ApplicationReadyEvent> { | ||
|
||
@PostConstruct | ||
fun saveAuditUser() { | ||
auditUserRepository.save(UserGenerator.AUDIT_USER) | ||
} | ||
|
||
override fun onApplicationEvent(are: ApplicationReadyEvent) { | ||
// Perform dev/test database setup here, using JPA repositories and generator classes... | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/MessageGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent | ||
import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader | ||
|
||
object MessageGenerator { | ||
val EXAMPLE = ResourceLoader.message<HmppsDomainEvent>("example-message") | ||
} |
7 changes: 7 additions & 0 deletions
7
...rm-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/UserGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.user.AuditUser | ||
|
||
object UserGenerator { | ||
val AUDIT_USER = AuditUser(IdGenerator.getAndIncrement(), "CommonPlatformAndDelius") | ||
} |
17 changes: 17 additions & 0 deletions
17
projects/common-platform-and-delius/src/dev/resources/messages/example-message.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"Type": "Notification", | ||
"MessageId": "aa2c2828-167f-529b-8e19-73735a2fb85c", | ||
"TopicArn": "arn:aws:sns:eu-west-2:000000000000:example", | ||
"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\"}]}}", | ||
"Timestamp": "2022-07-27T14:22:08.509Z", | ||
"SignatureVersion": "1", | ||
"Signature": "EXAMPLE", | ||
"SigningCertURL": "https://sns.eu-west-2.amazonaws.com/EXAMPLE.pem", | ||
"UnsubscribeURL": "https://sns.eu-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=EXAMPLE", | ||
"MessageAttributes": { | ||
"eventType": { | ||
"Type": "String", | ||
"Value": "example" | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
projects/common-platform-and-delius/src/dev/resources/simulations/mappings/hmpps-auth.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"request": { | ||
"method": "POST", | ||
"urlPath": "/auth/oauth/token" | ||
}, | ||
"response": { | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"status": 200, | ||
"jsonBody": { | ||
"access_token": "token", | ||
"token_type": "bearer", | ||
"expires_in": 9999999999, | ||
"scope": "read write", | ||
"sub": "probation-integration-dev", | ||
"auth_source": "none", | ||
"iss": "https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer" | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...orm-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package uk.gov.justice.digital.hmpps | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.mockito.Mockito.atLeastOnce | ||
import org.mockito.kotlin.verify | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator | ||
import uk.gov.justice.digital.hmpps.message.Notification | ||
import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager | ||
import uk.gov.justice.digital.hmpps.telemetry.TelemetryService | ||
import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived | ||
import java.util.concurrent.TimeoutException | ||
|
||
@SpringBootTest | ||
internal class IntegrationTest { | ||
@Value("\${messaging.consumer.queue}") | ||
lateinit var queueName: String | ||
|
||
@Autowired | ||
lateinit var channelManager: HmppsChannelManager | ||
|
||
@MockBean | ||
lateinit var telemetryService: TelemetryService | ||
|
||
@Test | ||
fun `message is logged to telemetry`() { | ||
// Given a message | ||
val notification = Notification(message = MessageGenerator.EXAMPLE) | ||
|
||
// When it is received | ||
try { | ||
channelManager.getChannel(queueName).publishAndWait(notification) | ||
} catch (_: TimeoutException) { | ||
// Note: Remove this try/catch when the MessageListener logic has been implemented | ||
} | ||
|
||
// Then it is logged to telemetry | ||
verify(telemetryService, atLeastOnce()).notificationReceived(notification) | ||
} | ||
} |
Oops, something went wrong.