Formatting
This commit is contained in:
@@ -236,7 +236,8 @@ public class GatewayAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.forwarded.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.forwarded.enabled",
|
||||
matchIfMissing = true)
|
||||
public ForwardedHeadersFilter forwardedHeadersFilter() {
|
||||
return new ForwardedHeadersFilter();
|
||||
}
|
||||
@@ -249,7 +250,8 @@ public class GatewayAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.x-forwarded.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.x-forwarded.enabled",
|
||||
matchIfMissing = true)
|
||||
public XForwardedHeadersFilter xForwardedHeadersFilter() {
|
||||
return new XForwardedHeadersFilter();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ public class GatewayMetricsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(MeterRegistry.class)
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.metrics.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.metrics.enabled",
|
||||
matchIfMissing = true)
|
||||
public GatewayMetricsFilter gatewayMetricFilter(MeterRegistry meterRegistry) {
|
||||
return new GatewayMetricsFilter(meterRegistry);
|
||||
}
|
||||
|
||||
@@ -360,7 +360,8 @@ public class HttpClientProperties {
|
||||
this.closeNotifyReadTimeout = closeNotifyReadTimeout;
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.cloud.gateway.httpclient.ssl.handshake-timeout")
|
||||
@DeprecatedConfigurationProperty(
|
||||
replacement = "spring.cloud.gateway.httpclient.ssl.handshake-timeout")
|
||||
@Deprecated
|
||||
public long getHandshakeTimeoutMillis() {
|
||||
return getHandshakeTimeout().toMillis();
|
||||
@@ -371,7 +372,8 @@ public class HttpClientProperties {
|
||||
setHandshakeTimeout(Duration.ofMillis(handshakeTimeoutMillis));
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.cloud.gateway.httpclient.ssl.close-notify-flush-timeout")
|
||||
@DeprecatedConfigurationProperty(
|
||||
replacement = "spring.cloud.gateway.httpclient.ssl.close-notify-flush-timeout")
|
||||
@Deprecated
|
||||
public long getCloseNotifyFlushTimeoutMillis() {
|
||||
return getCloseNotifyFlushTimeout().toMillis();
|
||||
@@ -382,7 +384,8 @@ public class HttpClientProperties {
|
||||
setCloseNotifyFlushTimeout(Duration.ofMillis(closeNotifyFlushTimeoutMillis));
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(replacement = "spring.cloud.gateway.httpclient.ssl.close-notify-read-timeout")
|
||||
@DeprecatedConfigurationProperty(
|
||||
replacement = "spring.cloud.gateway.httpclient.ssl.close-notify-read-timeout")
|
||||
@Deprecated
|
||||
public long getCloseNotifyReadTimeoutMillis() {
|
||||
return getCloseNotifyReadTimeout().toMillis();
|
||||
|
||||
@@ -20,7 +20,8 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import static org.springframework.http.HttpStatus.GATEWAY_TIMEOUT;
|
||||
|
||||
@ResponseStatus(value = GATEWAY_TIMEOUT, reason = "Response took longer than configured timeout")
|
||||
@ResponseStatus(value = GATEWAY_TIMEOUT,
|
||||
reason = "Response took longer than configured timeout")
|
||||
public class TimeoutException extends Exception {
|
||||
|
||||
public TimeoutException() {
|
||||
|
||||
@@ -36,7 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = "management.endpoints.web.exposure.include=*", webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(properties = "management.endpoints.web.exposure.include=*",
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class GatewayControllerEndpointTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -41,9 +41,10 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = DiscoveryClientRouteDefinitionLocatorIntegrationTests.Config.class, properties = {
|
||||
"spring.cloud.gateway.discovery.locator.enabled=true",
|
||||
"spring.cloud.gateway.discovery.locator.route-id-prefix=test__" })
|
||||
@SpringBootTest(
|
||||
classes = DiscoveryClientRouteDefinitionLocatorIntegrationTests.Config.class,
|
||||
properties = { "spring.cloud.gateway.discovery.locator.enabled=true",
|
||||
"spring.cloud.gateway.discovery.locator.route-id-prefix=test__" })
|
||||
public class DiscoveryClientRouteDefinitionLocatorIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -44,11 +44,11 @@ import static org.springframework.cloud.gateway.filter.factory.RewritePathGatewa
|
||||
import static org.springframework.cloud.gateway.handler.predicate.RoutePredicateFactory.PATTERN_KEY;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = DiscoveryClientRouteDefinitionLocatorTests.Config.class, properties = {
|
||||
"spring.cloud.gateway.discovery.locator.enabled=true",
|
||||
"spring.cloud.gateway.discovery.locator.route-id-prefix=testedge_",
|
||||
"spring.cloud.gateway.discovery.locator.include-expression=metadata['edge'] == 'true'",
|
||||
"spring.cloud.gateway.discovery.locator.lower-case-service-id=true"
|
||||
@SpringBootTest(classes = DiscoveryClientRouteDefinitionLocatorTests.Config.class,
|
||||
properties = { "spring.cloud.gateway.discovery.locator.enabled=true",
|
||||
"spring.cloud.gateway.discovery.locator.route-id-prefix=testedge_",
|
||||
"spring.cloud.gateway.discovery.locator.include-expression=metadata['edge'] == 'true'",
|
||||
"spring.cloud.gateway.discovery.locator.lower-case-service-id=true"
|
||||
/*
|
||||
* "spring.cloud.gateway.discovery.locator.predicates[0].name=Path",
|
||||
* "spring.cloud.gateway.discovery.locator.predicates[0].args[pattern]='/'+serviceId.toLowerCase()+'/**'",
|
||||
@@ -57,7 +57,7 @@ import static org.springframework.cloud.gateway.handler.predicate.RoutePredicate
|
||||
* ,
|
||||
* "spring.cloud.gateway.discovery.locator.filters[0].args[replacement]='/$\\\\{remaining}'",
|
||||
*/
|
||||
})
|
||||
})
|
||||
public class DiscoveryClientRouteDefinitionLocatorTests {
|
||||
|
||||
@Autowired(required = false)
|
||||
|
||||
@@ -36,9 +36,9 @@ import static org.mockito.Mockito.mock;
|
||||
public class GatewayDiscoveryClientAutoConfigurationTests {
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Config.class, properties = {
|
||||
"spring.cloud.gateway.discovery.locator.enabled=true",
|
||||
"spring.cloud.gateway.loadbalancer.use404=true" })
|
||||
@SpringBootTest(classes = Config.class,
|
||||
properties = { "spring.cloud.gateway.discovery.locator.enabled=true",
|
||||
"spring.cloud.gateway.loadbalancer.use404=true" })
|
||||
public static class EnabledByProperty {
|
||||
|
||||
@Autowired(required = false)
|
||||
|
||||
@@ -31,7 +31,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = "spring.cloud.gateway.httpclient.response-timeout=3s", webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(properties = "spring.cloud.gateway.httpclient.response-timeout=3s",
|
||||
webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
@SuppressWarnings("unchecked")
|
||||
public class NettyRoutingFilterIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
@@ -33,7 +33,8 @@ import org.springframework.util.SocketUtils;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = "management.server.port=${test.port}")
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = "management.server.port=${test.port}")
|
||||
@DirtiesContext
|
||||
public class RoutePredicateHandlerMappingIntegrationTests extends BaseWebClientTests {
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ public class ReadBodyPredicateFactoryTest {
|
||||
@SpringBootConfiguration
|
||||
@RibbonClients({
|
||||
@RibbonClient(name = "message", configuration = TestRibbonConfig.class),
|
||||
@RibbonClient(name = "messageChannel", configuration = TestRibbonConfig.class) })
|
||||
@RibbonClient(name = "messageChannel",
|
||||
configuration = TestRibbonConfig.class) })
|
||||
@Import(PermitAllSecurityConfiguration.class)
|
||||
@RestController
|
||||
public static class TestConfig {
|
||||
@@ -103,12 +104,14 @@ public class ReadBodyPredicateFactoryTest {
|
||||
return r -> r.getFoo().equals(type);
|
||||
}
|
||||
|
||||
@PostMapping(path = "message/events", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@PostMapping(path = "message/events",
|
||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public String messageEvents(@RequestBody Event e) {
|
||||
return "{\"headers\":{\"Hello\":\"World\"}}";
|
||||
}
|
||||
|
||||
@PostMapping(path = "messageChannel/events", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@PostMapping(path = "messageChannel/events",
|
||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public String messageChannelEvents(@RequestBody Event e) {
|
||||
return "{\"headers\":{\"World\":\"Hello\"}}";
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public class HttpBinCompatibleController {
|
||||
return "httpbin compatible home";
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/headers", method = { RequestMethod.GET,
|
||||
RequestMethod.POST }, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(path = "/headers", method = { RequestMethod.GET, RequestMethod.POST },
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Map<String, Object> headers(ServerWebExchange exchange) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("headers", getHeaders(exchange));
|
||||
@@ -66,7 +66,8 @@ public class HttpBinCompatibleController {
|
||||
return Mono.just(get(exchange)).delayElement(Duration.ofSeconds(delay));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/anything/{anything}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(path = "/anything/{anything}",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Map<String, Object> anything(ServerWebExchange exchange,
|
||||
@PathVariable(required = false) String anything) {
|
||||
return get(exchange);
|
||||
@@ -87,7 +88,8 @@ public class HttpBinCompatibleController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/post", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Mono<Map<String, Object>> postFormData(
|
||||
@RequestBody Mono<MultiValueMap<String, Part>> parts) {
|
||||
// StringDecoder decoder = StringDecoder.allMimeTypes(true);
|
||||
@@ -105,13 +107,16 @@ public class HttpBinCompatibleController {
|
||||
}).map(files -> Collections.singletonMap("files", files));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/post", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(path = "/post",
|
||||
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Mono<Map<String, Object>> postUrlEncoded(ServerWebExchange exchange)
|
||||
throws IOException {
|
||||
return post(exchange, null);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(path = "/post", method = RequestMethod.POST,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Mono<Map<String, Object>> post(ServerWebExchange exchange,
|
||||
@RequestBody(required = false) String body) throws IOException {
|
||||
HashMap<String, Object> ret = new HashMap<>();
|
||||
|
||||
@@ -31,8 +31,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
@RunWith(SpringRunner.class)
|
||||
// this test works because it assumes TLS hand shake cannot be done in 1ms. It takes
|
||||
// closer to 80ms
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = {
|
||||
"spring.cloud.gateway.httpclient.ssl.handshake-timeout-millis=1" })
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = { "spring.cloud.gateway.httpclient.ssl.handshake-timeout-millis=1" })
|
||||
@DirtiesContext
|
||||
@ActiveProfiles("ssl")
|
||||
// this is testing that the deprecated handshake-timeout-millis property still works
|
||||
|
||||
@@ -31,8 +31,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
@RunWith(SpringRunner.class)
|
||||
// this test works because it assumes TLS hand shake cannot be done in 1ms. It takes
|
||||
// closer to 80ms
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = {
|
||||
"spring.cloud.gateway.httpclient.ssl.handshake-timeout=1ms" })
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = { "spring.cloud.gateway.httpclient.ssl.handshake-timeout=1ms" })
|
||||
@DirtiesContext
|
||||
@ActiveProfiles("ssl")
|
||||
public class SSLHandshakeTimeoutTests extends SingleCertSSLTests {
|
||||
|
||||
@@ -358,7 +358,8 @@ public class WebSocketIntegrationTests {
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@Import(PermitAllSecurityConfiguration.class)
|
||||
@RibbonClient(name = "wsservice", configuration = LocalRibbonClientConfiguration.class)
|
||||
@RibbonClient(name = "wsservice",
|
||||
configuration = LocalRibbonClientConfiguration.class)
|
||||
protected static class GatewayConfig {
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user