File tree 2 files changed +9
-0
lines changed
main/no/nav/tilleggsstonader/libs/http/client
test/no/nav/tilleggsstonader/libs/http/client
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package no.nav.tilleggsstonader.libs.http.client
3
3
import no.nav.security.token.support.client.core.http.OAuth2HttpRequest
4
4
import no.nav.security.token.support.client.core.oauth2.OAuth2AccessTokenResponse
5
5
import no.nav.security.token.support.client.spring.oauth2.DefaultOAuth2HttpClient
6
+ import org.apache.hc.core5.http.NoHttpResponseException
6
7
import org.slf4j.LoggerFactory
7
8
import org.springframework.core.NestedExceptionUtils
8
9
import org.springframework.web.client.HttpServerErrorException
@@ -23,6 +24,7 @@ class RetryOAuth2HttpClient(
23
24
SocketException ::class ,
24
25
SocketTimeoutException ::class ,
25
26
HttpServerErrorException .GatewayTimeout ::class ,
27
+ NoHttpResponseException ::class ,
26
28
)
27
29
28
30
override fun post (req : OAuth2HttpRequest ): OAuth2AccessTokenResponse {
Original file line number Diff line number Diff line change @@ -71,6 +71,13 @@ internal class RetryOAuth2HttpClientTest {
71
71
wireMockServer.verify(3 , RequestPatternBuilder .allRequests())
72
72
}
73
73
74
+ @Test
75
+ internal fun `fault - skal prøve på nytt hvis servern feiler med å svare` () {
76
+ stub(WireMock .aResponse().withBody(" {}" ).withFault(Fault .EMPTY_RESPONSE ))
77
+ post()
78
+ wireMockServer.verify(3 , RequestPatternBuilder .allRequests())
79
+ }
80
+
74
81
private fun stub (responseDefinitionBuilder : ResponseDefinitionBuilder ? ) {
75
82
wireMockServer.stubFor(
76
83
WireMock .post(WireMock .anyUrl())
You can’t perform that action at this time.
0 commit comments