Skip to content

Commit

Permalink
Upgrade Spring boot from 2.7 to 3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
torchr89 committed Nov 15, 2023
1 parent 35dea67 commit ad879b2
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/no/nav/syfo/api/auth/tokenX/TokenXUtil.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.syfo.api.auth.tokenX

import javax.ws.rs.ForbiddenException
import jakarta.ws.rs.ForbiddenException
import no.nav.security.token.support.core.context.TokenValidationContextHolder
import no.nav.security.token.support.core.jwt.JwtTokenClaims

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package no.nav.syfo.api.exception

import javax.ws.rs.WebApplicationException
import jakarta.ws.rs.WebApplicationException

class ConflictException : WebApplicationException(409)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.syfo.api.exception

import jakarta.ws.rs.ForbiddenException
import no.nav.security.token.support.spring.validation.interceptor.JwtTokenUnauthorizedException
import no.nav.syfo.consumer.brukertilgang.RequestUnauthorizedException
import no.nav.syfo.metric.Metric
Expand All @@ -13,7 +14,6 @@ import org.springframework.web.context.request.WebRequest
import org.springframework.web.util.WebUtils
import javax.inject.Inject
import javax.validation.ConstraintViolationException
import javax.ws.rs.ForbiddenException

@ControllerAdvice
class ControllerExceptionHandler @Inject constructor(
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/no/nav/syfo/config/ApplicationConfig.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.syfo.config

import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.context.annotation.*
import org.springframework.scheduling.TaskScheduler
import org.springframework.scheduling.annotation.EnableScheduling
Expand All @@ -8,7 +9,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement
import org.springframework.web.client.RestTemplate
import org.springframework.web.reactive.function.client.WebClient

@Configuration
@AutoConfiguration
@EnableTransactionManagement
@EnableScheduling
class ApplicationConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package no.nav.syfo.consumer.azuread

import org.apache.http.*
import org.apache.http.client.HttpClient
import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.impl.conn.DefaultProxyRoutePlanner
import org.apache.http.protocol.HttpContext
import org.apache.hc.client5.http.classic.HttpClient
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
import org.apache.hc.client5.http.impl.routing.DefaultProxyRoutePlanner
import org.apache.hc.core5.http.HttpException
import org.apache.hc.core5.http.HttpHost
import org.apache.hc.core5.http.protocol.HttpContext
import org.springframework.boot.web.client.RestTemplateCustomizer
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
import org.springframework.web.client.RestTemplate
Expand All @@ -18,11 +19,10 @@ class NaisProxyCustomizer : RestTemplateCustomizer {
@Throws(HttpException::class)
public override fun determineProxy(
target: HttpHost,
request: HttpRequest,
context: HttpContext
): HttpHost? {
return if (target.hostName.contains("microsoft")) {
super.determineProxy(target, request, context)
super.determineProxy(target, context)
} else null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import no.nav.syfo.util.createCallId
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatusCode
import org.springframework.http.MediaType
import org.springframework.stereotype.Service
import org.springframework.web.reactive.function.client.ClientResponse
Expand Down Expand Up @@ -41,15 +41,15 @@ class BrukertilgangConsumer(
.header(NAV_CONSUMER_ID_HEADER, APP_CONSUMER_ID)
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.onStatus({ obj: HttpStatus -> obj.value() == 401 }) { response ->
.onStatus({ obj: HttpStatusCode -> obj.value() == 401 }) { response ->
metric.countOutgoingReponses(METRIC_CALL_BRUKERTILGANG, response.rawStatusCode())
Mono.error(RequestUnauthorizedException("Unauthorized request to get access to Ansatt from Syfobrukertilgang"))
}
.onStatus({ obj: HttpStatus -> obj.is4xxClientError }) { response ->
.onStatus({ obj: HttpStatusCode -> obj.is4xxClientError }) { response ->
logError(response, callId)
Mono.error(RuntimeException("4xx"))
}
.onStatus({ obj: HttpStatus -> obj.is5xxServerError }) { response ->
.onStatus({ obj: HttpStatusCode -> obj.is5xxServerError }) { response ->
logError(response, callId)
Mono.error(RuntimeException("5xx"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package no.nav.syfo.consumer.brukertilgang

import jakarta.ws.rs.ForbiddenException
import no.nav.security.token.support.core.context.TokenValidationContextHolder
import no.nav.syfo.api.auth.tokenX.TokenXUtil
import no.nav.syfo.cache.CacheConfig
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Service
import javax.inject.Inject
import javax.ws.rs.ForbiddenException

@Service
class BrukertilgangService @Inject constructor(
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/syfo/consumer/sts/StsConsumer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class StsConsumer(
.uri(getStsTokenUrl())
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.onStatus({ obj: HttpStatus -> obj.is4xxClientError }) { response ->
.onStatus({ obj: HttpStatusCode -> obj.is4xxClientError }) { response ->
logError(response)
Mono.error(RuntimeException("4xx"))
}
.onStatus({ obj: HttpStatus -> obj.is5xxServerError }) { response ->
.onStatus({ obj: HttpStatusCode -> obj.is5xxServerError }) { response ->
logError(response)
Mono.error(RuntimeException("5xx"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package no.nav.syfo.motebehov.api.internad.v2

import jakarta.ws.rs.BadRequestException
import jakarta.ws.rs.ForbiddenException
import jakarta.ws.rs.NotFoundException
import no.nav.security.token.support.core.api.ProtectedWithClaims
import no.nav.security.token.support.core.context.TokenValidationContextHolder
import no.nav.syfo.api.auth.OIDCIssuer.INTERN_AZUREAD_V2
Expand All @@ -21,9 +24,6 @@ import org.springframework.web.bind.annotation.*
import javax.inject.Inject
import javax.validation.Valid
import javax.validation.constraints.Pattern
import javax.ws.rs.BadRequestException
import javax.ws.rs.ForbiddenException
import javax.ws.rs.NotFoundException

@RestController
@ProtectedWithClaims(issuer = INTERN_AZUREAD_V2)
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/no/nav/syfo/LocalApplicationConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import no.nav.security.token.support.test.spring.TokenGeneratorConfiguration
import no.nav.syfo.config.kafka.FunctionSerializer
import org.apache.kafka.common.serialization.StringSerializer
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.kafka.KafkaProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import
import org.springframework.kafka.core.DefaultKafkaProducerFactory
import org.springframework.kafka.core.KafkaTemplate
import org.springframework.kafka.core.ProducerFactory

@Configuration
@AutoConfiguration
@Import(TokenGeneratorConfiguration::class)
class LocalApplicationConfig {
@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.syfo.motebehov.api.internad.v2

import jakarta.ws.rs.ForbiddenException
import no.nav.security.token.support.core.context.TokenValidationContextHolder
import no.nav.syfo.LocalApplication
import no.nav.syfo.testhelper.OidcTestHelper.loggInnVeilederADV2
Expand All @@ -19,7 +20,6 @@ import org.springframework.test.web.client.MockRestServiceServer
import org.springframework.web.client.*
import java.text.ParseException
import javax.inject.Inject
import javax.ws.rs.ForbiddenException

@ExtendWith(SpringExtension::class)
@SpringBootTest(classes = [LocalApplication::class])
Expand Down
18 changes: 0 additions & 18 deletions src/test/resources/logback-test.xml

This file was deleted.

0 comments on commit ad879b2

Please sign in to comment.