Skip to content

Commit

Permalink
Update dependencies (#413)
Browse files Browse the repository at this point in the history
* Update all non-major dependencies
* Keep kotlin plugins <2.1
* Replace deprecated mockito annotation
* Specify the same postgres version for testcontainer as others
* Fix openapi licence identifier
* Simplify OpenAPI tests
* Add gradle tasks to dump open-api schema
there appears to be a lingering issue with how swagger uses jackson (swagger-core#4755)
  • Loading branch information
renovate[bot] authored Jan 9, 2025
1 parent ea8ce63 commit 6bba7ee
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 78 deletions.
9 changes: 7 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
kotlin("plugin.jpa") version "2.0.21"
kotlin("plugin.spring") version "2.0.21"
idea
id("org.springdoc.openapi-gradle-plugin") version "1.9.0"
}

configurations {
Expand All @@ -22,15 +23,15 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-validation")

implementation("uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:5.2.2")
implementation("uk.gov.justice.service.hmpps:hmpps-digital-prison-reporting-lib:7.3.13")
implementation("uk.gov.justice.service.hmpps:hmpps-digital-prison-reporting-lib:7.3.15")

implementation("io.opentelemetry:opentelemetry-api:1.45.0")
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:2.11.0")

implementation("com.vladmihalcea:hibernate-types-60:2.21.1")
implementation("org.hibernate.orm:hibernate-community-dialects:6.6.4.Final")

implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.1")

implementation("com.zaxxer:HikariCP:6.2.1")
runtimeOnly("org.flywaydb:flyway-database-postgresql")
Expand Down Expand Up @@ -72,3 +73,7 @@ tasks {
compilerOptions.jvmTarget = JvmTarget.JVM_21
}
}

openApi {
customBootRun.args.set(listOf("--spring.profiles.active=dev,localstack"))
}
100 changes: 50 additions & 50 deletions clients/node/package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class OpenApiConfiguration(
.version(version)
.description("API for viewing and managing non-associations for prisoners")
.contact(Contact().name("HMPPS Digital Studio").email("feedback@digital.justice.gov.uk"))
.license(License().name("MIT")),
.license(License().name("MIT").identifier("MIT")),
)
.components(
Components()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object PostgresContainer {
return null
}
log.info("Creating a Postgres database")
return PostgreSQLContainer<Nothing>("postgres").apply {
return PostgreSQLContainer<Nothing>("postgres:15").apply {
withEnv("HOSTNAME_EXTERNAL", "localhost")
withDatabaseName("non_associations")
withUsername("non_associations")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import org.junit.jupiter.api.BeforeEach
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
import org.springframework.boot.test.mock.mockito.SpyBean
import org.springframework.http.HttpHeaders
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean
import org.springframework.test.web.reactive.server.WebTestClient
import uk.gov.justice.digital.hmpps.hmppsnonassociationsapi.SYSTEM_USERNAME
import uk.gov.justice.digital.hmpps.hmppsnonassociationsapi.helper.TestBase
Expand All @@ -32,7 +32,7 @@ abstract class IntegrationTestBase : TestBase() {
@Autowired
protected lateinit var jwtAuthorisationHelper: JwtAuthorisationHelper

@SpyBean
@MockitoSpyBean
protected lateinit var telemetryClient: TelemetryClient

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package uk.gov.justice.digital.hmpps.hmppsnonassociationsapi.integration

import io.swagger.v3.parser.OpenAPIV3Parser
import net.minidev.json.JSONArray
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.server.LocalServerPort
import org.springframework.http.MediaType
import java.time.LocalDate
import java.time.format.DateTimeFormatter

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DisplayName("OpenApi docs")
class OpenApiDocsTest : SqsIntegrationTestBase() {
@LocalServerPort
private var port: Int = 0

@Test
fun `open api docs are available`() {
webTestClient.get()
Expand All @@ -31,7 +26,9 @@ class OpenApiDocsTest : SqsIntegrationTestBase() {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().is3xxRedirection
.expectHeader().value("Location") { it.contains("/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config") }
.expectHeader().value("Location") {
it.contains("/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config")
}
}

@Test
Expand All @@ -41,14 +38,12 @@ class OpenApiDocsTest : SqsIntegrationTestBase() {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk
.expectBody().jsonPath("messages").doesNotExist()
}

@Test
fun `the open api json is valid and contains documentation`() {
val result = OpenAPIV3Parser().readLocation("http://localhost:$port/v3/api-docs", null, null)
assertThat(result.messages).isEmpty()
assertThat(result.openAPI.paths).isNotEmpty
.expectBody().consumeWith {
val contents = it.responseBody!!.decodeToString()
val result = OpenAPIV3Parser().readContents(contents)
assertThat(result.messages).isEmpty()
assertThat(result.openAPI.paths).isNotEmpty
}
}

@Test
Expand All @@ -63,8 +58,6 @@ class OpenApiDocsTest : SqsIntegrationTestBase() {

@Test
fun `the security scheme is setup for bearer tokens`() {
val bearerJwts = JSONArray()
bearerJwts.addAll(listOf("read", "write"))
webTestClient.get()
.uri("/v3/api-docs")
.accept(MediaType.APPLICATION_JSON)
Expand All @@ -74,8 +67,7 @@ class OpenApiDocsTest : SqsIntegrationTestBase() {
.jsonPath("$.components.securitySchemes.bearer-jwt.type").isEqualTo("http")
.jsonPath("$.components.securitySchemes.bearer-jwt.scheme").isEqualTo("bearer")
.jsonPath("$.components.securitySchemes.bearer-jwt.bearerFormat").isEqualTo("JWT")
.jsonPath("$.security[0].bearer-jwt")
.isEqualTo(bearerJwts)
.jsonPath("$.security[0].bearer-jwt").isEqualTo(listOf("read", "write"))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package uk.gov.justice.digital.hmpps.hmppsnonassociationsapi.integration
import org.junit.jupiter.api.BeforeEach
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.SpyBean
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.DynamicPropertyRegistry
import org.springframework.test.context.DynamicPropertySource
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean
import software.amazon.awssdk.services.sqs.model.PurgeQueueRequest
import uk.gov.justice.digital.hmpps.hmppsnonassociationsapi.config.LocalStackContainer
import uk.gov.justice.digital.hmpps.hmppsnonassociationsapi.config.LocalStackContainer.setLocalStackProperties
Expand All @@ -24,7 +24,7 @@ class SqsIntegrationTestBase : IntegrationTestBase() {
@Autowired
private lateinit var hmppsQueueService: HmppsQueueService

@SpyBean
@MockitoSpyBean
protected lateinit var hmppsSqsPropertiesSpy: HmppsSqsProperties

protected val domainEventsTopic by lazy {
Expand Down

0 comments on commit 6bba7ee

Please sign in to comment.