Commit 68910f2b authored by Phillip Webb's avatar Phillip Webb

Polish

parent cd23de6e
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
...@@ -43,9 +43,11 @@ import org.springframework.context.annotation.Condition; ...@@ -43,9 +43,11 @@ import org.springframework.context.annotation.Condition;
* } * }
* </pre> * </pre>
* <p> * <p>
* The {@link ConfigurationPhase} should be specified according to the conditions that * The
* are defined. In the example above, all conditions are static and can be evaluated * {@link org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase
* early so {@code PARSE_CONFIGURATION} is a right fit. * ConfigurationPhase} should be specified according to the conditions that are defined.
* In the example above, all conditions are static and can be evaluated early so
* {@code PARSE_CONFIGURATION} is a right fit.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 1.3.0 * @since 1.3.0
......
...@@ -45,9 +45,11 @@ import org.springframework.core.annotation.Order; ...@@ -45,9 +45,11 @@ import org.springframework.core.annotation.Order;
* } * }
* </pre> * </pre>
* <p> * <p>
* The {@link ConfigurationPhase} should be specified according to the conditions that * The
* are defined. In the example above, all conditions are static and can be evaluated * {@link org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase
* early so {@code PARSE_CONFIGURATION} is a right fit. * ConfigurationPhase} should be specified according to the conditions that are defined.
* In the example above, all conditions are static and can be evaluated early so
* {@code PARSE_CONFIGURATION} is a right fit.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 1.2.0 * @since 1.2.0
......
...@@ -43,9 +43,11 @@ import org.springframework.context.annotation.Condition; ...@@ -43,9 +43,11 @@ import org.springframework.context.annotation.Condition;
* } * }
* </pre> * </pre>
* <p> * <p>
* The {@link ConfigurationPhase} should be specified according to the conditions that * The
* are defined. In the example above, all conditions are static and can be evaluated * {@link org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase
* early so {@code PARSE_CONFIGURATION} is a right fit. * ConfigurationPhase} should be specified according to the conditions that are defined.
* In the example above, all conditions are static and can be evaluated early so
* {@code PARSE_CONFIGURATION} is a right fit.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 1.3.0 * @since 1.3.0
......
...@@ -264,8 +264,8 @@ public class ResourceServerTokenServicesConfigurationTests { ...@@ -264,8 +264,8 @@ public class ResourceServerTokenServicesConfigurationTests {
EnvironmentTestUtils.addEnvironment(this.environment, EnvironmentTestUtils.addEnvironment(this.environment,
"security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys"); "security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys");
this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class, this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class,
ResourceConfiguration.class) ResourceConfiguration.class).environment(this.environment).web(false)
.environment(this.environment).web(false).run(); .run();
assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1); assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1);
} }
...@@ -273,8 +273,9 @@ public class ResourceServerTokenServicesConfigurationTests { ...@@ -273,8 +273,9 @@ public class ResourceServerTokenServicesConfigurationTests {
public void jwtTokenStoreShouldBeConditionalOnMissingBean() throws Exception { public void jwtTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
EnvironmentTestUtils.addEnvironment(this.environment, EnvironmentTestUtils.addEnvironment(this.environment,
"security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY); "security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY);
this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class, ResourceConfiguration.class) this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class,
.environment(this.environment).web(false).run(); ResourceConfiguration.class).environment(this.environment).web(false)
.run();
assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1); assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1);
} }
......
...@@ -28,11 +28,6 @@ import org.springframework.context.annotation.Bean; ...@@ -28,11 +28,6 @@ import org.springframework.context.annotation.Bean;
@SpringBootApplication @SpringBootApplication
public class ExitCodeApplication { public class ExitCodeApplication {
public static void main(String[] args) {
System.exit(SpringApplication.exit(
SpringApplication.run(ExitCodeApplication.class, args)));
}
@Bean @Bean
public ExitCodeGenerator exitCodeGenerator() { public ExitCodeGenerator exitCodeGenerator() {
return new ExitCodeGenerator() { return new ExitCodeGenerator() {
...@@ -43,5 +38,10 @@ public class ExitCodeApplication { ...@@ -43,5 +38,10 @@ public class ExitCodeApplication {
}; };
} }
public static void main(String[] args) {
System.exit(SpringApplication
.exit(SpringApplication.run(ExitCodeApplication.class, args)));
}
} }
// end::example[] // end::example[]
...@@ -51,37 +51,37 @@ public class CorsSampleActuatorApplicationTests { ...@@ -51,37 +51,37 @@ public class CorsSampleActuatorApplicationTests {
@Test @Test
public void sensitiveEndpointShouldReturnUnauthorized() throws Exception { public void sensitiveEndpointShouldReturnUnauthorized() throws Exception {
ResponseEntity<Map> entity = this.testRestTemplate.getForEntity("/env", Map.class); ResponseEntity<?> entity = this.testRestTemplate.getForEntity("/env", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
} }
@Test @Test
public void preflightRequestForInsensitiveShouldReturnOk() throws Exception { public void preflightRequestForInsensitiveShouldReturnOk() throws Exception {
RequestEntity<?> healthRequest = RequestEntity.options(new URI("/health")) RequestEntity<?> healthRequest = RequestEntity.options(new URI("/health"))
.header("Origin","http://localhost:8080") .header("Origin", "http://localhost:8080")
.header("Access-Control-Request-Method", "GET") .header("Access-Control-Request-Method", "GET").build();
.build(); ResponseEntity<?> exchange = this.testRestTemplate.exchange(healthRequest,
ResponseEntity<Map> exchange = this.testRestTemplate.exchange(healthRequest, Map.class); Map.class);
assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@Test @Test
public void preflightRequestForSensitiveEndpointShouldReturnOk() throws Exception { public void preflightRequestForSensitiveEndpointShouldReturnOk() throws Exception {
RequestEntity<?> entity = RequestEntity.options(new URI("/env")) RequestEntity<?> entity = RequestEntity.options(new URI("/env"))
.header("Origin","http://localhost:8080") .header("Origin", "http://localhost:8080")
.header("Access-Control-Request-Method", "GET") .header("Access-Control-Request-Method", "GET").build();
.build(); ResponseEntity<?> env = this.testRestTemplate.exchange(entity, Map.class);
ResponseEntity<Map> env = this.testRestTemplate.exchange(entity, Map.class);
assertThat(env.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(env.getStatusCode()).isEqualTo(HttpStatus.OK);
} }
@Test @Test
public void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden() throws Exception { public void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden()
throws Exception {
RequestEntity<?> entity = RequestEntity.options(new URI("/health")) RequestEntity<?> entity = RequestEntity.options(new URI("/health"))
.header("Origin","http://localhost:9095") .header("Origin", "http://localhost:9095")
.header("Access-Control-Request-Method", "GET") .header("Access-Control-Request-Method", "GET").build();
.build(); ResponseEntity<byte[]> exchange = this.testRestTemplate.exchange(entity,
ResponseEntity<byte[]> exchange = this.testRestTemplate.exchange(entity, byte[].class); byte[].class);
assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment