Skip to content

Commit

Permalink
PI-2584 Create initial project for justice-email-and-delius (#4376)
Browse files Browse the repository at this point in the history
* PI-2584 Create initial project for justice-email-and-delius

* Update access.yml

---------

Co-authored-by: probation-integration-bot[bot] <177347787+probation-integration-bot[bot]@users.noreply.github.com>
Co-authored-by: Marcus Aspin <[email protected]>
  • Loading branch information
1 parent f5c5c34 commit c723756
Show file tree
Hide file tree
Showing 36 changed files with 670 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/access.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ on:
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
- '["justice-email-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
- common-platform-and-delius
- ims-and-delius
- appointment-reminders-and-delius
- justice-email-and-delius
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ on:
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
- '["justice-email-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/service-catalogue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ on:
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
- '["justice-email-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
Expand Down
12 changes: 12 additions & 0 deletions .idea/runConfigurations/justice_email_and_delius.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions doc/tech-docs/source/services.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ weight: 20
* [Common Platform And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/common-platform-and-delius)
* [Ims And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/ims-and-delius)
* [Appointment Reminders And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/appointment-reminders-and-delius)
* [Justice Email And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/justice-email-and-delius)
<li style="display: none">^ add new projects here</li>
Empty file.
3 changes: 3 additions & 0 deletions projects/justice-email-and-delius/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# justice-email-and-delius

// TODO Describe the service
62 changes: 62 additions & 0 deletions projects/justice-email-and-delius/applicationinsights.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"role": {
"name": "justice-email-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
}
]
}
}
}
36 changes: 36 additions & 0 deletions projects/justice-email-and-delius/build.gradle.kts
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"
)
}
13 changes: 13 additions & 0 deletions projects/justice-email-and-delius/deploy/Chart.yaml
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: justice-email-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 projects/justice-email-and-delius/deploy/database/access.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
database:
access:
username_key: /justice-email-and-delius/db-username
password_key: /justice-email-and-delius/db-password

audit:
username: JusticeEmailAndDelius
forename: Justice Email Integration
surname: Service
17 changes: 17 additions & 0 deletions projects/justice-email-and-delius/deploy/values-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
enabled: false # TODO set this to true when you're ready to deploy your service

generic-service:
ingress:
host: justice-email-and-delius-dev.hmpps.service.justice.gov.uk

scheduledDowntime:
enabled: true

env:
SENTRY_ENVIRONMENT: dev
LOGGING_LEVEL_UK_GOV_DIGITAL_JUSTICE_HMPPS: DEBUG
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

generic-prometheus-alerts:
businessHoursOnly: true
16 changes: 16 additions & 0 deletions projects/justice-email-and-delius/deploy/values-preprod.yml
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: justice-email-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
10 changes: 10 additions & 0 deletions projects/justice-email-and-delius/deploy/values-prod.yml
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: justice-email-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
23 changes: 23 additions & 0 deletions projects/justice-email-and-delius/deploy/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Common values
generic-service:
productId: HMPPS518
nameOverride: justice-email-and-delius

image:
repository: ghcr.io/ministryofjustice/hmpps-probation-integration-services/justice-email-and-delius

ingress:
tlsSecretName: justice-email-and-delius-cert

namespace_secrets:
common:
SPRING_DATASOURCE_URL: DB_URL
justice-email-and-delius-database:
SPRING_DATASOURCE_USERNAME: DB_USERNAME
SPRING_DATASOURCE_PASSWORD: DB_PASSWORD
justice-email-and-delius-sentry:
SENTRY_DSN: SENTRY_DSN

generic-prometheus-alerts:
targetApplication: justice-email-and-delius

1 change: 1 addition & 0 deletions projects/justice-email-and-delius/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "justice-email-and-delius"
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...
}
}
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(), "JusticeEmailAndDelius")
}
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)
}
}
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)
}
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('EXAMPLE')")
@GetMapping(value = ["/example/{inputId}"])
fun handle(
@PathVariable("inputId") inputId: String
) {
// TODO Not yet implemented
}
}
Loading

0 comments on commit c723756

Please sign in to comment.