Skip to content

Commit 9e9f6ef

Browse files
committed
EY-3389 Lagt til nytt endepunkt i proxy for simulering mot Oppdrag
1 parent c8c5108 commit 9e9f6ef

File tree

10 files changed

+91
-3
lines changed

10 files changed

+91
-3
lines changed

apps/etterlatte-proxy/.nais/dev.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ spec:
4444
value: https://sts-q1.preprod.local/SecurityTokenServiceProvider/
4545
- name: TILBAKEKREVING_URL
4646
value: https://cics-q1.adeo.no/oppdrag/K231CW80
47+
- name: SIMULERING_OPPDRAG_URL
48+
value: https://cics-q1.adeo.no/oppdrag/simulerFpServiceWSBinding
4749
prometheus:
4850
enabled: true
4951
path: /internal/prometheus

apps/etterlatte-proxy/.nais/prod.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ spec:
4545
value: https://sts.adeo.no/SecurityTokenServiceProvider/
4646
- name: TILBAKEKREVING_URL
4747
value: https://cics.adeo.no/oppdrag/K231CW80
48+
- name: SIMULERING_OPPDRAG_URL
49+
value: https://wasapp.adeo.no/cics/services/simulerFpServiceWSBinding
4850
prometheus:
4951
enabled: true
5052
path: /internal/prometheus

apps/etterlatte-proxy/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies {
2424
implementation(libs.ktor.okHttp)
2525
implementation(libs.navFellesTokenClientCore)
2626
implementation(libs.tjenestespesifikasjonerTilbakekreving)
27+
implementation(libs.tjenestespesifikasjonerOppdragSimulering)
2728
implementation(libs.cxf.logging)
2829
implementation(libs.cxf.jax.ws)
2930
implementation(libs.cxf.transports.http)

apps/etterlatte-proxy/src/main/kotlin/Application.kt

+3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import io.ktor.server.routing.route
1414
import io.ktor.server.routing.routing
1515
import kotlinx.coroutines.runBlocking
1616
import no.nav.etterlatte.auth.installAuthentication
17+
import no.nav.etterlatte.config.SimuleringOppdragConfig
1718
import no.nav.etterlatte.config.TilbakekrevingConfig
1819
import no.nav.etterlatte.config.load
1920
import no.nav.etterlatte.routes.internalRoute
21+
import no.nav.etterlatte.routes.simuleringOppdragRoute
2022
import no.nav.etterlatte.routes.tilbakekrevingRoute
2123
import org.slf4j.event.Level
2224
import java.util.*
@@ -46,6 +48,7 @@ fun Application.module() {
4648
authenticate("aad") {
4749
route("/aad") {
4850
tilbakekrevingRoute(TilbakekrevingConfig(config, false).createTilbakekrevingService())
51+
simuleringOppdragRoute(SimuleringOppdragConfig(config, true).createSimuleringOppdragService())
4952
}
5053
}
5154
}

apps/etterlatte-proxy/src/main/kotlin/config/Config.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import no.nav.etterlatte.routes.httpClientWithProxy
99
data class Config(
1010
val sts: Sts,
1111
val aad: AAD,
12-
val tilbakekrevingUrl: String
12+
val tilbakekrevingUrl: String,
13+
val simuleringOppdragUrl: String,
1314
) {
1415

1516
data class Sts(
@@ -39,6 +40,7 @@ data class Config(
3940

4041
suspend fun ApplicationConfig.load() = Config(
4142
tilbakekrevingUrl = property("tilbakekreving.url").getString(),
43+
simuleringOppdragUrl = property("simuleringOppdrag.url").getString(),
4244
sts = Config.Sts(
4345
soapUrl = property("sts.soapUrl").getString(),
4446
serviceuser = Config.Sts.ServiceUser(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package no.nav.etterlatte.config
2+
3+
import no.nav.etterlatte.auth.sts.ServiceUserConfig
4+
import no.nav.etterlatte.auth.sts.wrapInStsClient
5+
import no.nav.system.os.eksponering.simulerfpservicewsbinding.SimulerFpService
6+
import org.apache.cxf.ext.logging.LoggingFeature
7+
import org.apache.cxf.feature.Feature
8+
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean
9+
import org.apache.cxf.ws.addressing.WSAddressingFeature
10+
import org.slf4j.LoggerFactory
11+
import javax.xml.namespace.QName
12+
13+
class SimuleringOppdragConfig(config: Config, private val enableLogging: Boolean = false) {
14+
15+
private val simuleringOppdragUrl = config.simuleringOppdragUrl
16+
private val sts = config.sts
17+
private val logger = LoggerFactory.getLogger(javaClass)
18+
19+
fun createSimuleringOppdragService(): SimulerFpService {
20+
logger.info("Bruker simuleringOppdrag url $simuleringOppdragUrl")
21+
22+
val enabledFeatures = mutableListOf<Feature>().apply {
23+
add(WSAddressingFeature())
24+
if (enableLogging) add(LoggingFeature().apply {
25+
setVerbose(true)
26+
setPrettyLogging(true)
27+
})
28+
}
29+
30+
return JaxWsProxyFactoryBean().apply {
31+
address = simuleringOppdragUrl
32+
wsdlURL = WSDL
33+
serviceName = SERVICE
34+
endpointName = PORT
35+
serviceClass = SimulerFpService::class.java
36+
features = enabledFeatures
37+
}.wrapInStsClient(sts.soapUrl, ServiceUserConfig(sts.serviceuser.name, sts.serviceuser.password), true)
38+
}
39+
40+
private companion object {
41+
private const val WSDL = "wsdl/no/nav/system/os/eksponering/simulerfpservicewsbinding.wsdl"
42+
private const val NAMESPACE = "http://nav.no/system/os/eksponering/simulerFpServiceWSBinding"
43+
private val SERVICE = QName(NAMESPACE, "simulerFpService")
44+
private val PORT = QName(NAMESPACE, "simulerFpServicePort")
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package no.nav.etterlatte.routes
2+
3+
import io.ktor.server.application.call
4+
import io.ktor.server.application.log
5+
import io.ktor.server.request.receive
6+
import io.ktor.server.response.respond
7+
import io.ktor.server.routing.Route
8+
import io.ktor.server.routing.application
9+
import io.ktor.server.routing.post
10+
import no.nav.system.os.eksponering.simulerfpservicewsbinding.SimulerFpService
11+
import no.nav.system.os.tjenester.simulerfpservice.simulerfpservicegrensesnitt.SimulerBeregningRequest
12+
13+
/**
14+
* Endepunkter for å integrere med simuleringstjenesten i OS fra gcp til fss
15+
*/
16+
fun Route.simuleringOppdragRoute(simulerFpService: SimulerFpService) {
17+
val logger = application.log
18+
19+
post("/simuleringoppdrag/simulerberegning") {
20+
val request = call.receive<SimulerBeregningRequest>()
21+
22+
logger.info("Videresender simuleringsberegning for vedtakId=${request.request.oppdrag.oppdragslinje.first().vedtakId} fra proxy")
23+
val response = simulerFpService.simulerBeregning(request)
24+
call.respond(response)
25+
}
26+
}

apps/etterlatte-proxy/src/main/resources/application.conf

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ tilbakekreving {
1717
url = ${?TILBAKEKREVING_URL}
1818
}
1919

20+
simuleringOppdrag {
21+
url = "http://localhost:8089/simuleringoppdrag"
22+
url = ${?SIMULERING_OPPDRAG_URL}
23+
}
24+
2025
serviceuser {
2126
name = "srvbarnepensjon"
2227
password = "srv-password"

apps/etterlatte-proxy/src/test/kotlin/ApplicationTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import org.junit.jupiter.api.TestInstance
1818
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
1919
internal class ApplicationTest {
2020

21-
val mockOAuth2 = MockOAuth2Server()
21+
private val mockOAuth2 = MockOAuth2Server()
2222
private lateinit var hoconApplicationConfig: HoconApplicationConfig
2323

2424
@BeforeAll

gradle/libs.versions.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ rapidAndRivers = { module = "com.github.navikt:rapids-and-rivers", version = "20
1717
brukernotifikasjonSchemas = { module = "com.github.navikt:brukernotifikasjon-schemas", version = "2.5.2"}
1818
mockOauth2Server = { module = "no.nav.security:mock-oauth2-server", version = "2.1.2"}
1919
navFellesTokenClientCore = { module = "no.nav.security:token-client-core", version.ref = "navfelles-token-version"}
20-
tjenestespesifikasjonerTilbakekreving = { module = "com.github.navikt.pensjon-etterlatte-tjenestespesifikasjoner:tilbakekreving-v1-tjenestespesifikasjon", version = "1.78ffd1e"}
20+
tjenestespesifikasjonerTilbakekreving = { module = "com.github.navikt.pensjon-etterlatte-tjenestespesifikasjoner:tilbakekreving-v1-tjenestespesifikasjon", version = "1.d27898d"}
21+
tjenestespesifikasjonerOppdragSimulering = { module = "com.github.navikt.pensjon-etterlatte-tjenestespesifikasjoner:nav-system-os-simuler-fp-service-tjenestespesifikasjon", version = "1.d27898d"}
2122

2223
#Ktor
2324
ktor-callLogging = { module = "io.ktor:ktor-server-call-logging", version.ref = "ktor-version"}

0 commit comments

Comments
 (0)