Fix regression in WebFlux support for WebDAV methods
This commit ensures that WebFlux's RequestMethodsRequestCondition supports HTTP methods that are not in the RequestMethod enum. - RequestMethod::resolve is introduced, to convert from a HttpMethod (name) to enum values. - RequestMethod::asHttpMethod is introduced, to convert from enum value to HttpMethod. - HttpMethod::valueOf replaced Map-based lookup to a switch statement - Enabled tests that check for WebDAV methods See gh-27697 Closes gh-29981
This commit is contained in:
@@ -19,7 +19,6 @@ package org.springframework.web.reactive.result.condition;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -44,8 +43,6 @@ import static org.springframework.web.bind.annotation.RequestMethod.PUT;
|
||||
*/
|
||||
public class RequestMethodsRequestConditionTests {
|
||||
|
||||
// TODO: custom method, CORS pre-flight (see @Disabled)
|
||||
|
||||
@Test
|
||||
public void getMatchingCondition() throws Exception {
|
||||
testMatch(new RequestMethodsRequestCondition(GET), GET);
|
||||
@@ -73,7 +70,6 @@ public class RequestMethodsRequestConditionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getMatchingConditionWithCustomMethod() throws Exception {
|
||||
ServerWebExchange exchange = getExchange("PROPFIND");
|
||||
assertThat(new RequestMethodsRequestCondition().getMatchingCondition(exchange)).isNotNull();
|
||||
@@ -81,11 +77,12 @@ public class RequestMethodsRequestConditionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getMatchingConditionWithCorsPreFlight() throws Exception {
|
||||
ServerWebExchange exchange = getExchange("OPTIONS");
|
||||
exchange.getRequest().getHeaders().add("Origin", "https://example.com");
|
||||
exchange.getRequest().getHeaders().add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PUT");
|
||||
public void getMatchingConditionWithCorsPreFlight() {
|
||||
MockServerHttpRequest request = MockServerHttpRequest.method(HttpMethod.valueOf("OPTIONS"), "/")
|
||||
.header("Origin", "https://example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PUT")
|
||||
.build();
|
||||
ServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||
|
||||
assertThat(new RequestMethodsRequestCondition().getMatchingCondition(exchange)).isNotNull();
|
||||
assertThat(new RequestMethodsRequestCondition(PUT).getMatchingCondition(exchange)).isNotNull();
|
||||
|
||||
Reference in New Issue
Block a user