Use a two-space indent when continuing a line
This commit is contained in:
parent
b25323afb2
commit
44485bcc48
@ -8,8 +8,8 @@ public class WebFilterGatewayApplication {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SpringApplicationBuilder(WebFilterGatewayApplication.class)
|
new SpringApplicationBuilder(WebFilterGatewayApplication.class)
|
||||||
.profiles("webfilters")
|
.profiles("webfilters")
|
||||||
.run(args);
|
.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -14,19 +14,19 @@ public class ModifyBodyRouteConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public RouteLocator routes(RouteLocatorBuilder builder) {
|
public RouteLocator routes(RouteLocatorBuilder builder) {
|
||||||
return builder.routes()
|
return builder.routes()
|
||||||
.route("modify_request_body", r -> r.path("/post")
|
.route("modify_request_body", r -> r.path("/post")
|
||||||
.filters(f -> f.modifyRequestBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE,
|
.filters(f -> f.modifyRequestBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE,
|
||||||
(exchange, s) -> Mono.just(new Hello(s.toUpperCase())))).uri("https://httpbin.org"))
|
(exchange, s) -> Mono.just(new Hello(s.toUpperCase())))).uri("https://httpbin.org"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RouteLocator responseRoutes(RouteLocatorBuilder builder) {
|
public RouteLocator responseRoutes(RouteLocatorBuilder builder) {
|
||||||
return builder.routes()
|
return builder.routes()
|
||||||
.route("modify_response_body", r -> r.path("/put/**")
|
.route("modify_response_body", r -> r.path("/put/**")
|
||||||
.filters(f -> f.modifyResponseBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE,
|
.filters(f -> f.modifyResponseBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE,
|
||||||
(exchange, s) -> Mono.just(new Hello("New Body")))).uri("https://httpbin.org"))
|
(exchange, s) -> Mono.just(new Hello("New Body")))).uri("https://httpbin.org"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Hello {
|
static class Hello {
|
||||||
|
@ -40,8 +40,8 @@ public class WebFilterFactoriesLiveTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void configureClient() {
|
public void configureClient() {
|
||||||
client = WebTestClient.bindToServer()
|
client = WebTestClient.bindToServer()
|
||||||
.baseUrl("http://localhost:" + port)
|
.baseUrl("http://localhost:" + port)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -63,19 +63,19 @@ public class WebFilterFactoriesLiveTest {
|
|||||||
@Test
|
@Test
|
||||||
public void whenCallHeaderPostThroughGateway_thenAllHTTPResponseHeadersAreSet() {
|
public void whenCallHeaderPostThroughGateway_thenAllHTTPResponseHeadersAreSet() {
|
||||||
ResponseSpec response = client.post()
|
ResponseSpec response = client.post()
|
||||||
.uri("/header/post")
|
.uri("/header/post")
|
||||||
.exchange();
|
.exchange();
|
||||||
|
|
||||||
response.expectStatus()
|
response.expectStatus()
|
||||||
.isOk()
|
.isOk()
|
||||||
.expectHeader()
|
.expectHeader()
|
||||||
.valueEquals("My-Header-Rewrite", "password=***")
|
.valueEquals("My-Header-Rewrite", "password=***")
|
||||||
.expectHeader()
|
.expectHeader()
|
||||||
.valueEquals("My-Header-Set", "Set")
|
.valueEquals("My-Header-Set", "Set")
|
||||||
.expectHeader()
|
.expectHeader()
|
||||||
.valueEquals("My-Header-Good", "Good")
|
.valueEquals("My-Header-Good", "Good")
|
||||||
.expectHeader()
|
.expectHeader()
|
||||||
.doesNotExist("My-Header-Remove");
|
.doesNotExist("My-Header-Remove");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -84,8 +84,7 @@ public class WebFilterFactoriesLiveTest {
|
|||||||
|
|
||||||
HttpEntity<String> entity = new HttpEntity<>("content", new HttpHeaders());
|
HttpEntity<String> entity = new HttpEntity<>("content", new HttpHeaders());
|
||||||
|
|
||||||
ResponseEntity<String> response = restTemplate.exchange(url,
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||||
HttpMethod.POST, entity, String.class);
|
|
||||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
|
|
||||||
JSONObject json = new JSONObject(response.getBody());
|
JSONObject json = new JSONObject(response.getBody());
|
||||||
@ -93,15 +92,13 @@ public class WebFilterFactoriesLiveTest {
|
|||||||
assertThat(data.getString("message")).isEqualTo("CONTENT");
|
assertThat(data.getString("message")).isEqualTo("CONTENT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCallPutThroughGateway_thenBodyIsRetrieved() throws JSONException {
|
public void whenCallPutThroughGateway_thenBodyIsRetrieved() throws JSONException {
|
||||||
String url = "http://localhost:" + port + "/put";
|
String url = "http://localhost:" + port + "/put";
|
||||||
|
|
||||||
HttpEntity<String> entity = new HttpEntity<>("CONTENT", new HttpHeaders());
|
HttpEntity<String> entity = new HttpEntity<>("CONTENT", new HttpHeaders());
|
||||||
|
|
||||||
ResponseEntity<String> response = restTemplate.exchange(url,
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.PUT, entity, String.class);
|
||||||
HttpMethod.PUT, entity, String.class);
|
|
||||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
|
|
||||||
JSONObject json = new JSONObject(response.getBody());
|
JSONObject json = new JSONObject(response.getBody());
|
||||||
@ -111,21 +108,21 @@ public class WebFilterFactoriesLiveTest {
|
|||||||
@Test
|
@Test
|
||||||
public void whenCallDeleteThroughGateway_thenIsUnauthorizedCodeIsSet() {
|
public void whenCallDeleteThroughGateway_thenIsUnauthorizedCodeIsSet() {
|
||||||
ResponseSpec response = client.delete()
|
ResponseSpec response = client.delete()
|
||||||
.uri("/delete")
|
.uri("/delete")
|
||||||
.exchange();
|
.exchange();
|
||||||
|
|
||||||
response.expectStatus()
|
response.expectStatus()
|
||||||
.isUnauthorized();
|
.isUnauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCallFakePostThroughGateway_thenIsUnauthorizedCodeIsSet() {
|
public void whenCallFakePostThroughGateway_thenIsUnauthorizedCodeIsSet() {
|
||||||
ResponseSpec response = client.post()
|
ResponseSpec response = client.post()
|
||||||
.uri("/fake/post")
|
.uri("/fake/post")
|
||||||
.exchange();
|
.exchange();
|
||||||
|
|
||||||
response.expectStatus()
|
response.expectStatus()
|
||||||
.is3xxRedirection();
|
.is3xxRedirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user