Fix allowCredentials property handling

Closes gh-3059
This commit is contained in:
izeye 2015-05-28 21:08:42 +09:00 committed by Stephane Nicoll
parent fc067d1b75
commit 88612393f3
2 changed files with 10 additions and 1 deletions

View File

@ -133,7 +133,7 @@ public class MvcEndpointCorsProperties {
corsConfiguration.setMaxAge(this.maxAge); corsConfiguration.setMaxAge(this.maxAge);
} }
if (this.allowCredentials != null) { if (this.allowCredentials != null) {
corsConfiguration.setAllowCredentials(true); corsConfiguration.setAllowCredentials(this.allowCredentials);
} }
return corsConfiguration; return corsConfiguration;
} }

View File

@ -160,6 +160,15 @@ public class MvcEndpointCorsIntegrationTests {
header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")); header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"));
} }
@Test
public void credentialsCanBeDisabled() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context,
"endpoints.cors.allowed-origins:foo.example.com",
"endpoints.cors.allow-credentials:false");
performAcceptedCorsRequest().andExpect(
header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS));
}
@Test @Test
public void jolokiaEndpointUsesGlobalCorsConfiguration() throws Exception { public void jolokiaEndpointUsesGlobalCorsConfiguration() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, EnvironmentTestUtils.addEnvironment(this.context,