diff --git a/http-client/main/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClient.kt b/http-client/main/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClient.kt index fe8f426..2ec2047 100644 --- a/http-client/main/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClient.kt +++ b/http-client/main/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClient.kt @@ -3,6 +3,7 @@ package no.nav.tilleggsstonader.libs.http.client import no.nav.security.token.support.client.core.http.OAuth2HttpRequest import no.nav.security.token.support.client.core.oauth2.OAuth2AccessTokenResponse import no.nav.security.token.support.client.spring.oauth2.DefaultOAuth2HttpClient +import org.apache.hc.core5.http.NoHttpResponseException import org.slf4j.LoggerFactory import org.springframework.core.NestedExceptionUtils import org.springframework.web.client.HttpServerErrorException @@ -23,6 +24,7 @@ class RetryOAuth2HttpClient( SocketException::class, SocketTimeoutException::class, HttpServerErrorException.GatewayTimeout::class, + NoHttpResponseException::class, ) override fun post(req: OAuth2HttpRequest): OAuth2AccessTokenResponse { diff --git a/http-client/test/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClientTest.kt b/http-client/test/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClientTest.kt index 96e170c..6800433 100644 --- a/http-client/test/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClientTest.kt +++ b/http-client/test/no/nav/tilleggsstonader/libs/http/client/RetryOAuth2HttpClientTest.kt @@ -71,6 +71,13 @@ internal class RetryOAuth2HttpClientTest { wireMockServer.verify(3, RequestPatternBuilder.allRequests()) } + @Test + internal fun `fault - skal prøve på nytt hvis servern feiler med å svare`() { + stub(WireMock.aResponse().withBody("{}").withFault(Fault.EMPTY_RESPONSE)) + post() + wireMockServer.verify(3, RequestPatternBuilder.allRequests()) + } + private fun stub(responseDefinitionBuilder: ResponseDefinitionBuilder?) { wireMockServer.stubFor( WireMock.post(WireMock.anyUrl())