|
|
|
@ -33,9 +33,7 @@ import org.springframework.boot.actuate.trace.http.Include; |
|
|
|
import org.springframework.boot.actuate.web.trace.reactive.HttpTraceWebFilter; |
|
|
|
import org.springframework.boot.actuate.web.trace.reactive.HttpTraceWebFilter; |
|
|
|
import org.springframework.mock.http.server.reactive.MockServerHttpRequest; |
|
|
|
import org.springframework.mock.http.server.reactive.MockServerHttpRequest; |
|
|
|
import org.springframework.mock.web.server.MockServerWebExchange; |
|
|
|
import org.springframework.mock.web.server.MockServerWebExchange; |
|
|
|
import org.springframework.web.server.ServerWebExchange; |
|
|
|
|
|
|
|
import org.springframework.web.server.ServerWebExchangeDecorator; |
|
|
|
import org.springframework.web.server.ServerWebExchangeDecorator; |
|
|
|
import org.springframework.web.server.WebFilterChain; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.junit.Assert.fail; |
|
|
|
import static org.junit.Assert.fail; |
|
|
|
@ -62,14 +60,7 @@ public class HttpTraceWebFilterTests { |
|
|
|
this.filter.filter( |
|
|
|
this.filter.filter( |
|
|
|
MockServerWebExchange |
|
|
|
MockServerWebExchange |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
new WebFilterChain() { |
|
|
|
(exchange) -> Mono.empty()).block(Duration.ofSeconds(30)); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Mono<Void> filter(ServerWebExchange exchange) { |
|
|
|
|
|
|
|
return Mono.empty(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
|
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -79,15 +70,10 @@ public class HttpTraceWebFilterTests { |
|
|
|
this.filter.filter( |
|
|
|
this.filter.filter( |
|
|
|
MockServerWebExchange |
|
|
|
MockServerWebExchange |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
new WebFilterChain() { |
|
|
|
(exchange) -> { |
|
|
|
|
|
|
|
exchange.getSession().block(Duration.ofSeconds(30)).getAttributes() |
|
|
|
@Override |
|
|
|
.put("a", "alpha"); |
|
|
|
public Mono<Void> filter(ServerWebExchange exchange) { |
|
|
|
return Mono.empty(); |
|
|
|
exchange.getSession().block(Duration.ofSeconds(30)) |
|
|
|
|
|
|
|
.getAttributes().put("a", "alpha"); |
|
|
|
|
|
|
|
return Mono.empty(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
Session session = this.repository.findAll().get(0).getSession(); |
|
|
|
Session session = this.repository.findAll().get(0).getSession(); |
|
|
|
@ -101,14 +87,9 @@ public class HttpTraceWebFilterTests { |
|
|
|
this.filter.filter( |
|
|
|
this.filter.filter( |
|
|
|
MockServerWebExchange |
|
|
|
MockServerWebExchange |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
new WebFilterChain() { |
|
|
|
(exchange) -> { |
|
|
|
|
|
|
|
exchange.getSession().block(Duration.ofSeconds(30)); |
|
|
|
@Override |
|
|
|
return Mono.empty(); |
|
|
|
public Mono<Void> filter(ServerWebExchange exchange) { |
|
|
|
|
|
|
|
exchange.getSession().block(Duration.ofSeconds(30)); |
|
|
|
|
|
|
|
return Mono.empty(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
Session session = this.repository.findAll().get(0).getSession(); |
|
|
|
Session session = this.repository.findAll().get(0).getSession(); |
|
|
|
@ -127,15 +108,10 @@ public class HttpTraceWebFilterTests { |
|
|
|
return Mono.just(principal); |
|
|
|
return Mono.just(principal); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, new WebFilterChain() { |
|
|
|
}, (exchange) -> { |
|
|
|
|
|
|
|
exchange.getSession().block(Duration.ofSeconds(30)).getAttributes().put("a", |
|
|
|
@Override |
|
|
|
"alpha"); |
|
|
|
public Mono<Void> filter(ServerWebExchange exchange) { |
|
|
|
return Mono.empty(); |
|
|
|
exchange.getSession().block(Duration.ofSeconds(30)).getAttributes() |
|
|
|
|
|
|
|
.put("a", "alpha"); |
|
|
|
|
|
|
|
return Mono.empty(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
assertThat(this.repository.findAll()).hasSize(1); |
|
|
|
org.springframework.boot.actuate.trace.http.HttpTrace.Principal tracedPrincipal = this.repository |
|
|
|
org.springframework.boot.actuate.trace.http.HttpTrace.Principal tracedPrincipal = this.repository |
|
|
|
@ -148,17 +124,11 @@ public class HttpTraceWebFilterTests { |
|
|
|
public void statusIsAssumedToBe500WhenChainFails() |
|
|
|
public void statusIsAssumedToBe500WhenChainFails() |
|
|
|
throws ServletException, IOException { |
|
|
|
throws ServletException, IOException { |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.filter.filter( |
|
|
|
this.filter |
|
|
|
MockServerWebExchange |
|
|
|
.filter(MockServerWebExchange |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
.from(MockServerHttpRequest.get("https://api.example.com")), |
|
|
|
new WebFilterChain() { |
|
|
|
(exchange) -> Mono.error(new RuntimeException())) |
|
|
|
|
|
|
|
.block(Duration.ofSeconds(30)); |
|
|
|
@Override |
|
|
|
|
|
|
|
public Mono<Void> filter(ServerWebExchange exchange) { |
|
|
|
|
|
|
|
return Mono.error(new RuntimeException()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).block(Duration.ofSeconds(30)); |
|
|
|
|
|
|
|
fail(); |
|
|
|
fail(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) { |
|
|
|
catch (Exception ex) { |
|
|
|
|