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