From a9e9d0505ce4ed4fb98fa3c0f1f292b58e9bd92d Mon Sep 17 00:00:00 2001 From: Anton Fofanov Date: Thu, 24 Oct 2024 14:21:40 +0200 Subject: [PATCH] PEK-607 upgrade Spring Boot to 3.3.4. Upgrade Logback access to 2.0.4 --- build.gradle.kts | 25 ++++++++++++------- .../simulering/config/ConsumerIdProvider.kt | 2 +- .../config/CorrelationIdProvider.kt | 2 +- .../simulering/config/SecurityConfig.kt | 4 +-- .../config/TomcatAccessLogCustomizer.kt | 2 +- src/main/resources/logback-access.xml | 2 +- .../simulering/config/WebClientConfigTest.kt | 2 ++ .../simulering/service/TpClientTest.kt | 16 +++++++++--- 8 files changed, 36 insertions(+), 19 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 56106d64..73a47abb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ description = "tjenestepensjon-simulering" plugins { kotlin("jvm") version "1.9.23" kotlin("plugin.spring") version "1.9.23" - id("org.springframework.boot") version "3.1.12" + id("org.springframework.boot") version "3.3.4" id("io.spring.dependency-management") version "1.1.6" } @@ -21,8 +21,13 @@ dependencies { implementation("io.micrometer", "micrometer-registry-prometheus") implementation("jakarta.annotation", "jakarta.annotation-api", "2.1.1") implementation("javax.xml.soap", "javax.xml.soap-api", "1.4.0") - implementation("net.logstash.logback", "logstash-logback-encoder", "7.2") - implementation("ch.qos.logback", "logback-access", "1.4.14") + implementation("net.logstash.logback", "logstash-logback-encoder", "8.0") + implementation("ch.qos.logback.access:logback-access-common:2.0.4") + implementation("ch.qos.logback:logback-core:1.5.11") + implementation("ch.qos.logback.access:logback-access-tomcat:2.0.4"){ + exclude("org.apache.tomcat","tomcat-catalina") //classes supplied by spring-boot (tomcat-embed-core) use a newer version (10.1.26 vs 10.0.27 supplied here) + exclude("org.apache.tomcat","tomcat-coyote") //classes supplied by spring-boot (tomcat-embed-core) use a newer version (10.1.26 vs 10.0.27 supplied here) + } implementation("org.yaml","snakeyaml","2.3") implementation("org.codehaus.janino:janino:3.1.12") implementation("org.codehaus.janino:commons-compiler:3.1.12") @@ -30,19 +35,21 @@ dependencies { implementation("org.slf4j","slf4j-api", "2.0.12" ) implementation("org.glassfish.jaxb", "jaxb-runtime", "4.0.1") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2") + implementation("org.springframework.boot:spring-boot-starter-tomcat") // Spring Boot manages Tomcat + + // Exclude older versions of Tomcat + implementation("org.apache.tomcat.embed:tomcat-embed-core:10.1.30") implementation("org.springframework.boot", "spring-boot-starter-actuator") implementation("org.springframework.boot", "spring-boot-starter-cache") - implementation("org.springframework.boot", "spring-boot-starter-web") - implementation("org.springframework.boot", "spring-boot-starter-webflux") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("org.springframework.boot", "spring-boot-starter-oauth2-resource-server") - implementation("org.springframework.ws", "spring-ws-core", "4.0.3") + implementation("org.springframework.ws", "spring-ws-core", "4.0.11") testImplementation(kotlin("test-junit5")) - testImplementation("com.github.tomakehurst:wiremock:3.0.1") + testImplementation("org.wiremock:wiremock-standalone:3.9.2") testImplementation("org.mockito.kotlin", "mockito-kotlin", "5.2.1") testImplementation("org.springframework.boot", "spring-boot-starter-test") testImplementation("org.springframework.security", "spring-security-test") - implementation("org.springframework.boot:spring-boot-properties-migrator:3.1.2") - } tasks { diff --git a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/ConsumerIdProvider.kt b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/ConsumerIdProvider.kt index 0ca2235b..e244d4f1 100644 --- a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/ConsumerIdProvider.kt +++ b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/ConsumerIdProvider.kt @@ -1,6 +1,6 @@ package no.nav.tjenestepensjon.simulering.config -import ch.qos.logback.access.spi.IAccessEvent +import ch.qos.logback.access.common.spi.IAccessEvent import com.fasterxml.jackson.core.JsonGenerator import net.logstash.logback.composite.AbstractFieldJsonProvider import net.logstash.logback.composite.JsonWritingUtils diff --git a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/CorrelationIdProvider.kt b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/CorrelationIdProvider.kt index bf3e604d..ced4b0e5 100644 --- a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/CorrelationIdProvider.kt +++ b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/CorrelationIdProvider.kt @@ -1,6 +1,6 @@ package no.nav.tjenestepensjon.simulering.config -import ch.qos.logback.access.spi.IAccessEvent +import ch.qos.logback.access.common.spi.IAccessEvent import com.fasterxml.jackson.core.JsonGenerator import net.logstash.logback.composite.AbstractFieldJsonProvider import net.logstash.logback.composite.JsonWritingUtils diff --git a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/SecurityConfig.kt b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/SecurityConfig.kt index a4c6973b..9911342e 100644 --- a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/SecurityConfig.kt +++ b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/SecurityConfig.kt @@ -5,7 +5,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity -import org.springframework.security.oauth2.server.resource.authentication.JwtIssuerAuthenticationManagerResolver +import org.springframework.security.oauth2.server.resource.authentication.JwtIssuerAuthenticationManagerResolver.fromTrustedIssuers import org.springframework.security.web.DefaultSecurityFilterChain import org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher @@ -15,7 +15,7 @@ class SecurityConfig( @Value("\${simulering.security.issuers}") issuers: String ) { - private val issuerResolver = JwtIssuerAuthenticationManagerResolver(issuers.split(',')) + private val issuerResolver = fromTrustedIssuers(issuers.split(',')) @Bean fun configure(http: HttpSecurity): DefaultSecurityFilterChain = http.run { diff --git a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/TomcatAccessLogCustomizer.kt b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/TomcatAccessLogCustomizer.kt index 4b7fa7d2..8fb74dbe 100644 --- a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/TomcatAccessLogCustomizer.kt +++ b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/TomcatAccessLogCustomizer.kt @@ -11,6 +11,6 @@ class TomcatAccessLogCustomizer : WebServerFactoryCustomizer - + return (event.getRequestURI().contains("/actuator/")); DENY diff --git a/src/test/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfigTest.kt b/src/test/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfigTest.kt index 32a3cdbd..818ba86f 100644 --- a/src/test/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfigTest.kt +++ b/src/test/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfigTest.kt @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import kotlin.test.AfterTest + @SpringBootTest internal class WebClientConfigTest { @@ -33,6 +34,7 @@ internal class WebClientConfigTest { @Test fun `Should throw exception if read timeout exceeded`() { + assertThrows { val findTpLeverandorName = tpClient.findTpLeverandorName(TPOrdningIdDto(defaultTssid, defaultTpid)) print(findTpLeverandorName) diff --git a/src/test/kotlin/no/nav/tjenestepensjon/simulering/service/TpClientTest.kt b/src/test/kotlin/no/nav/tjenestepensjon/simulering/service/TpClientTest.kt index 11f4da9e..2aa30fca 100644 --- a/src/test/kotlin/no/nav/tjenestepensjon/simulering/service/TpClientTest.kt +++ b/src/test/kotlin/no/nav/tjenestepensjon/simulering/service/TpClientTest.kt @@ -55,41 +55,49 @@ class TpClientTest { @Test fun `findForhold med ett forhold`() { - wireMockServer.stubFor( + val stub = wireMockServer.stubFor( defaultTjenestepensjonRequest.willReturn(okJson(defaultForhold)) ) val response = tpClient.findForhold(defaultFNR) assertEquals(defaultTpid, response.first().ordning) + + wireMockServer.removeStub(stub.uuid) } @Test fun `findForhold uten forhold`() { - wireMockServer.stubFor( + val stub = wireMockServer.stubFor( defaultTjenestepensjonRequest.willReturn(okJson("""{"_embedded":{"forholdModelList":[]}}""")) ) assertThrows { tpClient.findForhold(defaultFNR) } + + wireMockServer.removeStub(stub.uuid) } @Test fun `findForhold person ikke funnet`() { - wireMockServer.stubFor( + val stub = wireMockServer.stubFor( defaultTjenestepensjonRequest.willReturn(notFound()) ) assertThrows { tpClient.findForhold(defaultFNR) } + + wireMockServer.removeStub(stub.uuid) } @Test fun `findForhold unauthorized`() { - wireMockServer.stubFor( + val stub = wireMockServer.stubFor( defaultTjenestepensjonRequest.willReturn(unauthorized()) ) assertThrows { tpClient.findForhold(defaultFNR) } + wireMockServer.removeStub(stub.uuid) + } } \ No newline at end of file