Skip to content

Commit 2e351cf

Browse files
author
Matt Raible
committed
Tabs to spaces
1 parent e01f993 commit 2e351cf

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

spring-cloud-gateway/api-gateway/src/main/java/com/example/apigateway/ApiGatewayApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public RouteLocator customRouteLocator(RouteLocatorBuilder builder,
3131
.route("car-service", r -> r.path("/cars")
3232
.filters(f -> f.filter(filterFactory.apply()))
3333
// .filters(f -> f.hystrix(c -> c.setName("carsFallback")
34-
// .setFallbackUri("forward:/cars-fallback")))
34+
// .setFallbackUri("forward:/cars-fallback")))
3535
.uri("lb://car-service"))
3636
.build();
3737
}

spring-cloud-gateway/api-gateway/src/test/java/com/example/apigateway/ApiGatewayApplicationTests.java

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,33 @@
2121

2222
@RunWith(SpringRunner.class)
2323
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
24-
properties = {"spring.cloud.discovery.enabled = false"})
24+
properties = {"spring.cloud.discovery.enabled = false"})
2525
public class ApiGatewayApplicationTests {
2626

27-
@Autowired
28-
WebTestClient webTestClient;
29-
30-
@MockBean
31-
ReactiveJwtDecoder jwtDecoder;
32-
33-
@Test
34-
public void testCorsConfiguration() {
35-
Jwt jwt = jwt();
36-
when(this.jwtDecoder.decode(anyString())).thenReturn(Mono.just(jwt));
37-
WebTestClient.ResponseSpec response = webTestClient.put()
38-
.uri("/")
39-
.headers(addJwt(jwt))
40-
.header("Origin", "http://example.com")
41-
.exchange();
42-
43-
response.expectHeader().valueEquals("Access-Control-Allow-Origin", "*");
44-
}
45-
46-
private Jwt jwt() {
47-
return new Jwt("token", null, null,
48-
Map.of("alg", "none"), Map.of("sub", "dave"));
49-
}
50-
51-
private Consumer<HttpHeaders> addJwt(Jwt jwt) {
52-
return headers -> headers.setBearerAuth(jwt.getTokenValue());
53-
}
27+
@Autowired
28+
WebTestClient webTestClient;
29+
30+
@MockBean
31+
ReactiveJwtDecoder jwtDecoder;
32+
33+
@Test
34+
public void testCorsConfiguration() {
35+
Jwt jwt = jwt();
36+
when(this.jwtDecoder.decode(anyString())).thenReturn(Mono.just(jwt));
37+
WebTestClient.ResponseSpec response = webTestClient.put().uri("/")
38+
.headers(addJwt(jwt))
39+
.header("Origin", "http://example.com")
40+
.exchange();
41+
42+
response.expectHeader().valueEquals("Access-Control-Allow-Origin", "*");
43+
}
44+
45+
private Jwt jwt() {
46+
return new Jwt("token", null, null,
47+
Map.of("alg", "none"), Map.of("sub", "dave"));
48+
}
49+
50+
private Consumer<HttpHeaders> addJwt(Jwt jwt) {
51+
return headers -> headers.setBearerAuth(jwt.getTokenValue());
52+
}
5453
}

0 commit comments

Comments
 (0)