DATAREST-1397 - Polishing.

Removed the redeclaration of hasCorsConfigurationSource(…) in RepositoryRestHandlerMapping as it already inherits the one from BasePathAwareRestHandlerMapping.

Removed @Override on BasePathAwareRestHandlerMapping.hasCorsConfigurationSource(…) as we need to compile against Spring 5.1, which doesn't expose the method. Downgrades from Spring HATEOAS 1.0 API usage in tests.
This commit is contained in:
Oliver Drotbohm
2019-06-21 15:22:27 +02:00
parent 4e586495f4
commit 37b25008b0
3 changed files with 5 additions and 14 deletions

View File

@@ -23,7 +23,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.data.rest.tests.AbstractWebIntegrationTests;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ContextConfiguration;
@@ -50,7 +49,7 @@ public class LocalConfigCorsIntegrationTests extends AbstractWebIntegrationTests
@Test // DATAREST-1397
public void appliesRepositoryCorsConfiguration() throws Exception {
Link findItems = client.discoverUnique(LinkRelation.of("items"));
Link findItems = client.discoverUnique("items");
// Preflight request
mvc.perform(options(findItems.expand().getHref()).header(HttpHeaders.ORIGIN, "http://far.far.example")

View File

@@ -112,11 +112,12 @@ public class BasePathAwareHandlerMapping extends RequestMappingHandlerMapping {
return super.lookupHandlerMethod(lookupPath, new CustomAcceptHeaderHttpServletRequest(request, mediaTypes));
}
/*
* (non-Javadoc)
/**
* No {@code @Override} as the method is only available in Spring 5.2, but needed to make CORS work in general on it.
*
* @see org.springframework.web.servlet.handler.AbstractHandlerMapping#hasCorsConfigurationSource(java.lang.Object)
* @see https://github.com/spring-projects/spring-framework/issues/22273
*/
@Override
protected boolean hasCorsConfigurationSource(Object handler) {
return true;
}

View File

@@ -190,15 +190,6 @@ public class RepositoryRestHandlerMapping extends BasePathAwareHandlerMapping {
return AnnotationUtils.findAnnotation(type, RepositoryRestController.class) != null;
}
/*
* (non-Javadoc)
* @see org.springframework.web.servlet.handler.AbstractHandlerMapping#hasCorsConfigurationSource(java.lang.Object)
*/
@Override
protected boolean hasCorsConfigurationSource(Object handler) {
return true;
}
/*
* (non-Javadoc)
* @see org.springframework.web.servlet.handler.AbstractHandlerMapping#extendInterceptors(java.util.List)