Avoid registering CorsConfiguration for methods without @CrossOrigin
Issue: SPR-12931
This commit is contained in:
@@ -66,7 +66,7 @@ public class CrossOriginTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noAnnotation() throws Exception {
|
||||
public void noAnnotationWithoutOrigin() throws Exception {
|
||||
this.handlerMapping.registerHandler(new MethodLevelController());
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/no");
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(request);
|
||||
@@ -74,6 +74,25 @@ public class CrossOriginTests {
|
||||
assertNull(config);
|
||||
}
|
||||
|
||||
@Test // SPR-12931
|
||||
public void noAnnotationWithOrigin() throws Exception {
|
||||
this.handlerMapping.registerHandler(new MethodLevelController());
|
||||
this.request.setRequestURI("/no");
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(request);
|
||||
CorsConfiguration config = getCorsConfiguration(chain, false);
|
||||
assertNull(config);
|
||||
}
|
||||
|
||||
@Test // SPR-12931
|
||||
public void noAnnotationPostWithOrigin() throws Exception {
|
||||
this.handlerMapping.registerHandler(new MethodLevelController());
|
||||
this.request.setMethod("POST");
|
||||
this.request.setRequestURI("/no");
|
||||
HandlerExecutionChain chain = this.handlerMapping.getHandler(request);
|
||||
CorsConfiguration config = getCorsConfiguration(chain, false);
|
||||
assertNull(config);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultAnnotation() throws Exception {
|
||||
this.handlerMapping.registerHandler(new MethodLevelController());
|
||||
@@ -203,6 +222,10 @@ public class CrossOriginTests {
|
||||
public void noAnnotation() {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/no", method = RequestMethod.POST)
|
||||
public void noAnnotationPost() {
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "/default", method = RequestMethod.GET)
|
||||
public void defaultAnnotation() {
|
||||
|
||||
Reference in New Issue
Block a user