georchestra / georchestra-gateway

GNU General Public License v3.0
0 stars 5 forks source link

fix: Fix IT testsuite following PR#104 #105

Closed pmauduit closed 3 months ago

pmauduit commented 6 months ago

Following #104, the Host http header became mandatory, else throwing a NPE in Netty's code when reaching the NettyRoutingFilter class:

java.lang.NullPointerException: value
    at io.netty.util.internal.ObjectUtil.checkNotNull(ObjectUtil.java:39)
    Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below:
Error has been observed at the following site(s):
    *__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.authorization.AuthorizationWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.authorization.ExceptionTranslationWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.authentication.logout.LogoutWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.savedrequest.ServerRequestCacheWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.context.SecurityContextServerWebExchangeWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.authentication.AuthenticationWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.context.ReactorContextWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.header.HttpHeaderWriterWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.config.web.server.ServerHttpSecurity$ServerWebExchangeReactorContextWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.web.server.WebFilterChainProxy [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers$MutatorFilter [DefaultWebFilterChain]
    *__checkpoint ⇢ HTTP GET "/path/..." [ExceptionHandlingWebHandler]
Original Stack Trace:
        at io.netty.util.internal.ObjectUtil.checkNotNull(ObjectUtil.java:39)
        at io.netty.handler.codec.DefaultHeaders.fromObject(DefaultHeaders.java:1117)
        at io.netty.handler.codec.DefaultHeaders.addObject(DefaultHeaders.java:364)
        at io.netty.handler.codec.http.DefaultHttpHeaders.add(DefaultHttpHeaders.java:115)
        at org.springframework.cloud.gateway.filter.NettyRoutingFilter.lambda$filter$0(NettyRoutingFilter.java:139)
        at reactor.netty.http.client.HttpClient.headers(HttpClient.java:1038)
        at org.springframework.cloud.gateway.filter.NettyRoutingFilter.filter(NettyRoutingFilter.java:133)
        at org.springframework.cloud.gateway.handler.FilteringWebHandler$GatewayFilterAdapter.filter(FilteringWebHandler.java:137)
        at org.springframework.cloud.gateway.filter.OrderedGatewayFilter.filter(OrderedGatewayFilter.java:44)
        at org.springframework.cloud.gateway.handler.FilteringWebHandler$DefaultGatewayFilterChain.lambda$filter$0(FilteringWebHandler.java:117)

Tests: mvn clean verify on gateway subdir went fine 3 times in a row.

Notes:

pmauduit commented 6 months ago

Side-note: I'd have liked to find a way to define the host header as a default on the WebTestClient object, but could not find a way to do so.

pmauduit commented 6 months ago

forced-pushed because I commented out a header("host", "localhost"); in one of the tests in order to get the stacktrace put in the description, and forgot to uncomment afterwards before pushing.

edevosc2c commented 5 months ago

Maybe it's because we are mocking to an IP address instead of a hostname? Maybe we need to set the host header by default? I saw something related to withHost: https://wiremock.org/docs/multi-domain-mocking/

I think we should try to see which header are sent by wiremock using something like https://gist.github.com/phrawzty/62540f146ee5e74ea1ab

f-necas commented 3 months ago

Closed in favor of : https://github.com/georchestra/georchestra-gateway/pull/109