Merge branch '1.5.x'

This commit is contained in:
Phillip Webb 2017-07-19 10:23:23 -07:00
commit 9db72450da
7 changed files with 45 additions and 36 deletions

View File

@ -69,6 +69,7 @@ import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetada
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvider;
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProviders;
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
@ -99,7 +100,7 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
*/
@Configuration
@AutoConfigureBefore({ EndpointAutoConfiguration.class })
@AutoConfigureAfter({ CassandraAutoConfiguration.class,
@AutoConfigureAfter({ ActiveMQAutoConfiguration.class, CassandraAutoConfiguration.class,
CassandraDataAutoConfiguration.class, CouchbaseDataAutoConfiguration.class,
DataSourceAutoConfiguration.class, ElasticsearchAutoConfiguration.class,
JestAutoConfiguration.class, JmsAutoConfiguration.class,

View File

@ -43,9 +43,11 @@ import org.springframework.context.annotation.Condition;
* }
* </pre>
* <p>
* The {@link 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.
* The
* {@link org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase
* 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
* @since 1.3.0

View File

@ -45,9 +45,11 @@ import org.springframework.core.annotation.Order;
* }
* </pre>
* <p>
* The {@link 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.
* The
* {@link org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase
* 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
* @since 1.2.0

View File

@ -43,9 +43,11 @@ import org.springframework.context.annotation.Condition;
* }
* </pre>
* <p>
* The {@link 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.
* The
* {@link org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase
* 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
* @since 1.3.0

View File

@ -270,18 +270,18 @@ public class ResourceServerTokenServicesConfigurationTests {
.of("security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys")
.applyTo(this.environment);
this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class,
ResourceConfiguration.class)
.environment(this.environment).web(false).run();
ResourceConfiguration.class).environment(this.environment).web(false)
.run();
assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1);
}
@Test
public void jwtTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
TestPropertyValues
.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY)
TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY)
.applyTo(this.environment);
this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class, ResourceConfiguration.class)
.environment(this.environment).web(false).run();
this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class,
ResourceConfiguration.class).environment(this.environment).web(false)
.run();
assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1);
}

View File

@ -28,15 +28,15 @@ import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class ExitCodeApplication {
public static void main(String[] args) {
System.exit(SpringApplication.exit(
SpringApplication.run(ExitCodeApplication.class, args)));
}
@Bean
public ExitCodeGenerator exitCodeGenerator() {
return () -> 42;
}
public static void main(String[] args) {
System.exit(SpringApplication
.exit(SpringApplication.run(ExitCodeApplication.class, args)));
}
}
// end::example[]

View File

@ -51,37 +51,39 @@ public class CorsSampleActuatorApplicationTests {
@Test
public void sensitiveEndpointShouldReturnUnauthorized() throws Exception {
ResponseEntity<Map> entity = this.testRestTemplate.getForEntity("/application/env", Map.class);
ResponseEntity<?> entity = this.testRestTemplate.getForEntity("/application/env",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@Test
public void preflightRequestForInsensitiveShouldReturnOk() throws Exception {
RequestEntity<?> healthRequest = RequestEntity.options(new URI("/application/health"))
.header("Origin","http://localhost:8080")
.header("Access-Control-Request-Method", "GET")
.build();
ResponseEntity<Map> exchange = this.testRestTemplate.exchange(healthRequest, Map.class);
RequestEntity<?> healthRequest = RequestEntity
.options(new URI("/application/health"))
.header("Origin", "http://localhost:8080")
.header("Access-Control-Request-Method", "GET").build();
ResponseEntity<?> exchange = this.testRestTemplate.exchange(healthRequest,
Map.class);
assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
public void preflightRequestForSensitiveEndpointShouldReturnOk() throws Exception {
RequestEntity<?> entity = RequestEntity.options(new URI("/application/env"))
.header("Origin","http://localhost:8080")
.header("Access-Control-Request-Method", "GET")
.build();
ResponseEntity<Map> env = this.testRestTemplate.exchange(entity, Map.class);
.header("Origin", "http://localhost:8080")
.header("Access-Control-Request-Method", "GET").build();
ResponseEntity<?> env = this.testRestTemplate.exchange(entity, Map.class);
assertThat(env.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
public void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden() throws Exception {
public void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden()
throws Exception {
RequestEntity<?> entity = RequestEntity.options(new URI("/application/health"))
.header("Origin","http://localhost:9095")
.header("Access-Control-Request-Method", "GET")
.build();
ResponseEntity<byte[]> exchange = this.testRestTemplate.exchange(entity, byte[].class);
.header("Origin", "http://localhost:9095")
.header("Access-Control-Request-Method", "GET").build();
ResponseEntity<byte[]> exchange = this.testRestTemplate.exchange(entity,
byte[].class);
assertThat(exchange.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
}