Merge branch '2.1.x'

This commit is contained in:
Andy Wilkinson
2018-12-20 15:30:51 +00:00
22 changed files with 166 additions and 109 deletions

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
import java.time.Duration;
import org.junit.Test;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
@@ -63,7 +65,8 @@ public class CloudFoundryReactiveHealthEndpointWebExtensionTests {
this.contextRunner.run((context) -> {
CloudFoundryReactiveHealthEndpointWebExtension extension = context
.getBean(CloudFoundryReactiveHealthEndpointWebExtension.class);
assertThat(extension.health().block().getBody().getDetails()).isNotEmpty();
assertThat(extension.health().block(Duration.ofSeconds(30)).getBody()
.getDetails()).isNotEmpty();
});
}

View File

@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -198,16 +199,17 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
Boolean cfRequestMatches = filters.get(0)
.matches(MockServerWebExchange.from(MockServerHttpRequest
.get("/cloudfoundryapplication/my-path").build()))
.block();
.block(Duration.ofSeconds(30));
Boolean otherRequestMatches = filters.get(0)
.matches(MockServerWebExchange.from(MockServerHttpRequest
.get("/some-other-path").build()))
.block();
.block(Duration.ofSeconds(30));
assertThat(cfRequestMatches).isTrue();
assertThat(otherRequestMatches).isFalse();
otherRequestMatches = filters.get(1).matches(MockServerWebExchange
.from(MockServerHttpRequest.get("/some-other-path").build()))
.block();
otherRequestMatches = filters.get(1)
.matches(MockServerWebExchange.from(MockServerHttpRequest
.get("/some-other-path").build()))
.block(Duration.ofSeconds(30));
assertThat(otherRequestMatches).isTrue();
});
@@ -312,7 +314,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
WebClient webClient = (WebClient) ReflectionTestUtils
.getField(interceptorSecurityService, "webClient");
webClient.get().uri("https://self-signed.badssl.com/").exchange()
.block();
.block(Duration.ofSeconds(30));
});
}
@@ -334,9 +336,9 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
WebClient webClient = (WebClient) ReflectionTestUtils
.getField(interceptorSecurityService, "webClient");
assertThatExceptionOfType(RuntimeException.class)
.isThrownBy(
webClient.get().uri("https://self-signed.badssl.com/")
.exchange()::block)
.isThrownBy(() -> webClient.get()
.uri("https://self-signed.badssl.com/").exchange()
.block(Duration.ofSeconds(30)))
.withCauseInstanceOf(SSLException.class);
});
}

View File

@@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure.health;
import java.security.Principal;
import java.time.Duration;
import org.junit.Test;
import reactor.core.publisher.Mono;
@@ -98,8 +99,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal())
.willReturn(mock(Principal.class));
Health extensionHealth = extension.health(securityContext).block()
.getBody();
Health extensionHealth = extension.health(securityContext)
.block(Duration.ofSeconds(30)).getBody();
assertThat(endpointHealth.getDetails())
.containsOnlyKeys("application", "first", "second");
assertThat(extensionHealth.getDetails())
@@ -112,8 +113,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
this.contextRunner.run((context) -> {
ReactiveHealthEndpointWebExtension extension = context
.getBean(ReactiveHealthEndpointWebExtension.class);
assertThat(extension.health(mock(SecurityContext.class)).block().getBody()
.getDetails()).isEmpty();
assertThat(extension.health(mock(SecurityContext.class))
.block(Duration.ofSeconds(30)).getBody().getDetails()).isEmpty();
});
}
@@ -124,8 +125,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
.getBean(ReactiveHealthEndpointWebExtension.class);
SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()).willReturn(mock(Principal.class));
assertThat(extension.health(securityContext).block().getBody().getDetails())
.isEmpty();
assertThat(extension.health(securityContext).block(Duration.ofSeconds(30))
.getBody().getDetails()).isEmpty();
});
}
@@ -140,8 +141,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal())
.willReturn(mock(Principal.class));
assertThat(extension.health(securityContext).block().getBody()
.getDetails()).isNotEmpty();
assertThat(extension.health(securityContext)
.block(Duration.ofSeconds(30)).getBody().getDetails())
.isNotEmpty();
});
}
@@ -152,8 +154,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
.run((context) -> {
ReactiveHealthEndpointWebExtension extension = context
.getBean(ReactiveHealthEndpointWebExtension.class);
assertThat(extension.health(null).block().getBody().getDetails())
.isNotEmpty();
assertThat(extension.health(null).block(Duration.ofSeconds(30))
.getBody().getDetails()).isNotEmpty();
});
}
@@ -165,8 +167,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
ReactiveHealthEndpointWebExtension extension = context
.getBean(ReactiveHealthEndpointWebExtension.class);
SecurityContext securityContext = mock(SecurityContext.class);
assertThat(extension.health(securityContext).block().getBody()
.getDetails()).isEmpty();
assertThat(extension.health(securityContext)
.block(Duration.ofSeconds(30)).getBody().getDetails())
.isEmpty();
});
}
@@ -181,8 +184,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
given(securityContext.getPrincipal())
.willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(false);
assertThat(extension.health(securityContext).block().getBody()
.getDetails()).isEmpty();
assertThat(extension.health(securityContext)
.block(Duration.ofSeconds(30)).getBody().getDetails())
.isEmpty();
});
}
@@ -197,8 +201,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
given(securityContext.getPrincipal())
.willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(true);
assertThat(extension.health(securityContext).block().getBody()
.getDetails()).isNotEmpty();
assertThat(extension.health(securityContext)
.block(Duration.ofSeconds(30)).getBody().getDetails())
.isNotEmpty();
});
}
@@ -213,8 +218,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
given(securityContext.getPrincipal())
.willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ADMIN")).willReturn(true);
assertThat(extension.health(securityContext).block().getBody()
.getDetails()).isNotEmpty();
assertThat(extension.health(securityContext)
.block(Duration.ofSeconds(30)).getBody().getDetails())
.isNotEmpty();
});
}
@@ -227,11 +233,12 @@ public class ReactiveHealthEndpointWebExtensionTests {
.getBean(ReactiveHealthIndicatorRegistry.class);
ReactiveHealthEndpointWebExtension extension = context
.getBean(ReactiveHealthEndpointWebExtension.class);
assertThat(extension.health(null).block().getBody().getDetails())
.containsOnlyKeys("application", "first", "second");
assertThat(extension.health(null).block(Duration.ofSeconds(30))
.getBody().getDetails()).containsOnlyKeys("application",
"first", "second");
assertThat(registry.unregister("second")).isNotNull();
assertThat(extension.health(null).block().getBody().getDetails())
.containsKeys("application", "first");
assertThat(extension.health(null).block(Duration.ofSeconds(30))
.getBody().getDetails()).containsKeys("application", "first");
});
}

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.metrics.web.client;
import java.time.Duration;
import io.micrometer.core.instrument.MeterRegistry;
import org.junit.Rule;
import org.junit.Test;
@@ -106,7 +108,8 @@ public class WebClientMetricsConfigurationTests {
WebClient webClient = mockWebClient(context.getBean(WebClient.Builder.class));
MeterRegistry registry = context.getBean(MeterRegistry.class);
for (int i = 0; i < 3; i++) {
webClient.get().uri("http://example.org/projects/" + i).exchange().block();
webClient.get().uri("http://example.org/projects/" + i).exchange()
.block(Duration.ofSeconds(30));
}
return registry;
}
@@ -115,7 +118,7 @@ public class WebClientMetricsConfigurationTests {
WebClient webClient = mockWebClient(builder);
assertThat(registry.find("http.client.requests").meter()).isNull();
webClient.get().uri("http://example.org/projects/{project}", "spring-boot")
.exchange().block();
.exchange().block(Duration.ofSeconds(30));
assertThat(registry.find("http.client.requests")
.tags("uri", "/projects/{project}").meter()).isNotNull();
}

View File

@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.security.reactive;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -250,8 +251,8 @@ public class EndpointRequestTests {
}
private void matches(ServerWebExchange exchange) {
assertThat(this.matcher.matches(exchange).block().isMatch())
.as("Matches " + getRequestPath(exchange)).isTrue();
assertThat(this.matcher.matches(exchange).block(Duration.ofSeconds(30))
.isMatch()).as("Matches " + getRequestPath(exchange)).isTrue();
}
void doesNotMatch(String path) {
@@ -262,8 +263,9 @@ public class EndpointRequestTests {
}
private void doesNotMatch(ServerWebExchange exchange) {
assertThat(this.matcher.matches(exchange).block().isMatch())
.as("Does not match " + getRequestPath(exchange)).isFalse();
assertThat(this.matcher.matches(exchange).block(Duration.ofSeconds(30))
.isMatch()).as("Does not match " + getRequestPath(exchange))
.isFalse();
}
private TestHttpWebHandlerAdapter webHandler() {

View File

@@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure.security.reactive;
import java.net.URI;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
@@ -139,7 +140,8 @@ public class ReactiveManagementWebSecurityAutoConfigurationTests {
ServerWebExchange exchange = webHandler(context).createExchange(
MockServerHttpRequest.get(path).build(), new MockServerHttpResponse());
WebFilterChainProxy proxy = context.getBean(WebFilterChainProxy.class);
proxy.filter(exchange, (serverWebExchange) -> Mono.empty()).block();
proxy.filter(exchange, (serverWebExchange) -> Mono.empty())
.block(Duration.ofSeconds(30));
return exchange;
}