Skip to content

Commit

Permalink
R&R bundler ikke lenger naisful-app - Tilpasser til nytt R&R versjon.
Browse files Browse the repository at this point in the history
  • Loading branch information
geiralund committed Dec 16, 2024
1 parent 09392e4 commit f90b781
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
2 changes: 2 additions & 0 deletions mediator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ dependencies {
implementation(libs.bundles.postgres)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.9.0")

implementation("com.github.navikt.tbd-libs:naisful-app:2024.11.29-15.07-105481e3")

implementation(libs.bundles.jackson)

implementation(libs.bundles.ktor.server)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package no.nav.dagpenger.mottak

import com.github.navikt.tbd_libs.naisful.naisApp
import com.github.navikt.tbd_libs.rapids_and_rivers_api.RapidsConnection
import io.micrometer.core.instrument.Clock
import io.micrometer.prometheusmetrics.PrometheusConfig
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import io.prometheus.metrics.model.registry.PrometheusRegistry
import mu.KotlinLogging
import no.nav.dagpenger.mottak.Config.dokarkivTokenProvider
import no.nav.dagpenger.mottak.Config.objectMapper
Expand Down Expand Up @@ -41,12 +46,30 @@ internal class ApplicationBuilder(

private val rapidsConnection =
RapidApplication
.create(env = env, objectMapper = objectMapper) { engine, _ ->
engine.application.innsendingApi(
innsendingRepository = innsendingRepository,
observer = ferdigstiltInnsendingObserver,
)
}.apply {
.create(env = env, builder = {
withKtor { preStopHook, rapid ->
naisApp(
meterRegistry =
PrometheusMeterRegistry(
PrometheusConfig.DEFAULT,
PrometheusRegistry.defaultRegistry,
Clock.SYSTEM,
),
objectMapper = objectMapper,
applicationLogger = KotlinLogging.logger("ApplicationLogger"),
callLogger = KotlinLogging.logger("CallLogger"),
aliveCheck = rapid::isReady,
readyCheck = rapid::isReady,
preStopHook = preStopHook::handlePreStopRequest,
) {
innsendingApi(
innsendingRepository = innsendingRepository,
observer = ferdigstiltInnsendingObserver,
)
}
}
})
.apply {
val mediator =
InnsendingMediator(
innsendingRepository = innsendingRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import com.github.navikt.tbd_libs.naisful.test.TestContext
import com.github.navikt.tbd_libs.naisful.test.naisfulTestApp
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.header
import io.ktor.client.request.request
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import io.ktor.http.content.TextContent
import io.ktor.server.application.Application
import io.micrometer.prometheusmetrics.PrometheusConfig
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
Expand Down Expand Up @@ -58,18 +52,4 @@ internal object TestApplication {
internal fun HttpRequestBuilder.autentisert(token: String = azureAd) {
this.header(HttpHeaders.Authorization, "Bearer $token")
}

internal suspend fun TestContext.autentisert(
endepunkt: String,
token: String = azureAd,
httpMethod: HttpMethod = HttpMethod.Get,
body: String? = null,
): HttpResponse =
client.request(endepunkt) {
this.method = httpMethod
body?.let { this.setBody(TextContent(it, ContentType.Application.Json)) }
this.header(HttpHeaders.Authorization, "Bearer $token")
this.header(HttpHeaders.Accept, ContentType.Application.Json.toString())
this.header(HttpHeaders.ContentType, ContentType.Application.Json.toString())
}
}

0 comments on commit f90b781

Please sign in to comment.