Protect RequestCondition against unkown HTTP methods
The RequestMethodsRequestCondition is now protected against HTTP request method values not present in the RequestMethod enumeration (e.g. PROPFIND). Issue: SPR-9815
This commit is contained in:
committed by
Rossen Stoyanchev
parent
b0153ada19
commit
c0729756d7
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.servlet.mvc.condition;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -47,7 +48,7 @@ public class RequestMethodsRequestConditionTests {
|
||||
|
||||
assertNull(condition.getMatchingCondition(request));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void multipleMethodsMatch() {
|
||||
RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.POST);
|
||||
@@ -66,6 +67,15 @@ public class RequestMethodsRequestConditionTests {
|
||||
assertNotNull(condition.getMatchingCondition(new MockHttpServletRequest("HEAD", "")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownMethodType() throws Exception {
|
||||
RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.POST);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("PROPFIND", "/foo");
|
||||
|
||||
assertNull(condition.getMatchingCondition(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareTo() {
|
||||
RequestMethodsRequestCondition condition1 = new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.HEAD);
|
||||
@@ -73,7 +83,7 @@ public class RequestMethodsRequestConditionTests {
|
||||
RequestMethodsRequestCondition condition3 = new RequestMethodsRequestCondition();
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
|
||||
|
||||
int result = condition1.compareTo(condition2, request);
|
||||
assertTrue("Invalid comparison result: " + result, result < 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user