From d3c5e339db58ccf0e6a4635f6ab3b1752a713581 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Sun, 26 Nov 2017 20:05:32 +0100 Subject: [PATCH] DATAREST-1160 - Adapt tests to new CORS defaults in Spring Framework. Spring Framework 5.0.2 changes the default for the Allow-Credentials header to false. We now adapted our test case to that and also drop the expectation to see the request URL in the Allow-Origin header as that is only returned if Allow-Credentials is true, which it now isn't by default. --- .../data/rest/webmvc/jpa/CorsIntegrationTests.java | 1 - .../webmvc/RepositoryCorsConfigurationAccessorUnitTests.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/CorsIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/CorsIntegrationTests.java index 69d3cb8ae..f70636ebc 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/CorsIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/CorsIntegrationTests.java @@ -73,7 +73,6 @@ public class CorsIntegrationTests extends AbstractWebIntegrationTests { mvc.perform(options(findItems.expand().getHref()).header(HttpHeaders.ORIGIN, "http://far.far.away") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST")) // .andExpect(status().isOk()) // - .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "http://far.far.away")) // .andExpect( header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS,TRACE")); } diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java index b6b1d312d..98a744508 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryCorsConfigurationAccessorUnitTests.java @@ -63,7 +63,7 @@ public class RepositoryCorsConfigurationAccessorUnitTests { CorsConfiguration configuration = accessor.createConfiguration(AnnotatedRepository.class); assertThat(configuration).isNotNull(); - assertThat(configuration.getAllowCredentials()).isTrue(); + assertThat(configuration.getAllowCredentials()).isFalse(); assertThat(configuration.getAllowedHeaders()).contains("*"); assertThat(configuration.getAllowedOrigins()).contains("*"); assertThat(configuration.getAllowedMethods(),