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