Merge pull request #3059 from izeye/patch-12

* patch-12:
  Fix allowCredentials property handling
pull/3059/merge
Stephane Nicoll 10 years ago
commit 6575b31fb1

@ -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;
} }

@ -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,

Loading…
Cancel
Save