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.
Browse files
Browse the repository at this point in the history
* PI-1911 Create initial project for oasys-and-delius * PI-1911 --------- Co-authored-by: Anthony Britton <[email protected]>
- Loading branch information
1 parent
cf8b0d3
commit 4c77522
Showing
35 changed files
with
652 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
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 @@ | ||
# oasys-and-delius | ||
|
||
// TODO Describe the 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,51 @@ | ||
{ | ||
"role": { | ||
"name": "oasys-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": "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:oauth-server")) | ||
|
||
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") | ||
implementation(libs.springdoc) | ||
|
||
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: oasys-and-delius | ||
version: 1.0.0 | ||
|
||
dependencies: | ||
- name: generic-service | ||
version: "2.8" | ||
repository: https://ministryofjustice.github.io/hmpps-helm-charts | ||
- name: generic-prometheus-alerts | ||
version: "1.3" | ||
repository: https://ministryofjustice.github.io/hmpps-helm-charts |
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: /oasys-and-delius/db-username | ||
password_key: /oasys-and-delius/db-password | ||
|
||
audit: | ||
username: OasysAndDelius | ||
forename: Oasys and Delius | ||
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,18 @@ | ||
enabled: false # TODO set this to true when you're ready to deploy your service | ||
|
||
generic-service: | ||
ingress: | ||
host: oasys-and-delius-dev.hmpps.service.justice.gov.uk | ||
|
||
scheduledDowntime: | ||
enabled: true | ||
|
||
env: | ||
SENTRY_ENVIRONMENT: dev | ||
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/.well-known/jwks.json | ||
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer | ||
|
||
LOGGING_LEVEL_UK_GOV_DIGITAL_JUSTICE_HMPPS: DEBUG | ||
|
||
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,16 @@ | ||
enabled: false # TODO set this to true when you're ready to deploy your service | ||
|
||
generic-service: | ||
ingress: | ||
host: oasys-and-delius-preprod.hmpps.service.justice.gov.uk | ||
|
||
scheduledDowntime: | ||
enabled: true | ||
|
||
env: | ||
SENTRY_ENVIRONMENT: preprod | ||
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/.well-known/jwks.json | ||
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/issuer | ||
|
||
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,10 @@ | ||
enabled: false # TODO set this to true when you're ready to deploy your service | ||
|
||
generic-service: | ||
ingress: | ||
host: oasys-and-delius.hmpps.service.justice.gov.uk | ||
|
||
env: | ||
SENTRY_ENVIRONMENT: prod | ||
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: https://sign-in.hmpps.service.justice.gov.uk/auth/.well-known/jwks.json | ||
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in.hmpps.service.justice.gov.uk/auth/issuer |
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,22 @@ | ||
# Common values | ||
generic-service: | ||
nameOverride: oasys-and-delius | ||
|
||
image: | ||
repository: ghcr.io/ministryofjustice/hmpps-probation-integration-services/oasys-and-delius | ||
|
||
ingress: | ||
tlsSecretName: oasys-and-delius-cert | ||
|
||
namespace_secrets: | ||
common: | ||
SPRING_DATASOURCE_URL: DB_URL | ||
oasys-and-delius-database: | ||
SPRING_DATASOURCE_USERNAME: DB_USERNAME | ||
SPRING_DATASOURCE_PASSWORD: DB_PASSWORD | ||
oasys-and-delius-sentry: | ||
SENTRY_DSN: SENTRY_DSN | ||
|
||
generic-prometheus-alerts: | ||
targetApplication: oasys-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 = "oasys-and-delius" |
25 changes: 25 additions & 0 deletions
25
projects/oasys-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... | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ys-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(), "OasysAndDelius") | ||
} |
30 changes: 30 additions & 0 deletions
30
...sys-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,30 @@ | ||
package uk.gov.justice.digital.hmpps | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.web.servlet.MockMvc | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status | ||
import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken | ||
import uk.gov.justice.digital.hmpps.telemetry.TelemetryService | ||
|
||
@AutoConfigureMockMvc | ||
@SpringBootTest(webEnvironment = RANDOM_PORT) | ||
internal class IntegrationTest { | ||
@Autowired | ||
lateinit var mockMvc: MockMvc | ||
|
||
@MockBean | ||
lateinit var telemetryService: TelemetryService | ||
|
||
@Test | ||
fun `API call retuns a success response`() { | ||
mockMvc | ||
.perform(get("/example/123").withToken()) | ||
.andExpect(status().is2xxSuccessful) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.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,11 @@ | ||
package uk.gov.justice.digital.hmpps | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
|
||
@SpringBootApplication | ||
class App | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<App>(*args) | ||
} |
17 changes: 17 additions & 0 deletions
17
...oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/ApiController.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,17 @@ | ||
package uk.gov.justice.digital.hmpps.controller | ||
|
||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
class ApiController { | ||
@PreAuthorize("hasRole('ROLE_EXAMPLE')") | ||
@GetMapping(value = ["/example/{inputId}"]) | ||
fun handle( | ||
@PathVariable("inputId") inputId: String | ||
) { | ||
// TODO Not yet implemented | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
projects/oasys-and-delius/src/main/resources/application.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,67 @@ | ||
# Default config | ||
server.shutdown: graceful | ||
spring: | ||
jackson: | ||
default-property-inclusion: non_null | ||
jpa: | ||
hibernate.ddl-auto: validate | ||
database-platform: org.hibernate.dialect.OracleDialect | ||
properties: | ||
hibernate: | ||
timezone.default_storage: NORMALIZE | ||
query.mutation_strategy: org.hibernate.query.sqm.mutation.internal.inline.InlineMutationStrategy | ||
query.mutation_strategy.persistent: | ||
create_tables: false | ||
drop_tables: false | ||
query.mutation_strategy.global_temporary: | ||
create_tables: false | ||
drop_tables: false | ||
threads.virtual.enabled: true | ||
|
||
springdoc.default-produces-media-type: application/json | ||
|
||
delius.db.username: OasysAndDelius # Should match value in [deploy/database/access.yml]. | ||
|
||
management: | ||
endpoints.web: | ||
base-path: / | ||
exposure.include: [ "health", "info" ] | ||
endpoint.health.show-details: always | ||
|
||
--- | ||
# Shared dev/test config | ||
spring.config.activate.on-profile: [ "dev", "integration-test" ] | ||
|
||
spring: | ||
datasource.url: jdbc:h2:file:./dev;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH;AUTO_SERVER=true;AUTO_SERVER_PORT=9092 | ||
jpa.hibernate.ddl-auto: create-drop | ||
|
||
seed.database: true | ||
context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser | ||
|
||
jwt.authorities: | ||
- ROLE_EXAMPLE | ||
|
||
logging.level: | ||
uk.gov.justice.digital.hmpps: DEBUG | ||
org.hibernate.tool.schema: ERROR | ||
org.apache.activemq: WARN | ||
|
||
--- | ||
spring.config.activate.on-profile: integration-test | ||
spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH | ||
|
||
--- | ||
spring.config.activate.on-profile: oracle | ||
spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1' | ||
|
||
--- | ||
spring.config.activate.on-profile: delius-db | ||
spring: | ||
datasource: | ||
url: 'jdbc:oracle:thin:@//localhost:1521/XEPDB1' | ||
username: delius_pool | ||
password: NDelius1 | ||
jpa.hibernate.ddl-auto: validate | ||
seed.database: false | ||
delius.db.username: NationalUser |
Oops, something went wrong.