GH-1025 Ad more test for DELETE method
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.function.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.function.context.FunctionProperties;
|
||||
|
||||
@@ -27,60 +25,59 @@ import org.springframework.cloud.function.context.FunctionProperties;
|
||||
* @since 4.0.4
|
||||
*
|
||||
*/
|
||||
|
||||
@ConfigurationProperties(prefix = FunctionProperties.PREFIX + ".http")
|
||||
public class FunctionHttpProperties {
|
||||
|
||||
/**
|
||||
* Blah.
|
||||
* Function definition mappings for GET method (e.g. 'spring.cloud.function.http.GET=foo;bar|baz')
|
||||
*/
|
||||
public List<String> get;
|
||||
public String get;
|
||||
|
||||
|
||||
/**
|
||||
* Blah.
|
||||
* Function definition mappings for POST method (e.g. 'spring.cloud.function.http.POST=foo;bar|baz')
|
||||
*/
|
||||
public List<String> post;
|
||||
public String post;
|
||||
|
||||
/**
|
||||
* Blah.
|
||||
* Function definition mappings for PUT method (e.g. 'spring.cloud.function.http.PUT=foo;bar|baz')
|
||||
*/
|
||||
public List<String> put;
|
||||
public String put;
|
||||
|
||||
/**
|
||||
* Blah.
|
||||
* Function definition mappings for DELETE method (e.g. 'spring.cloud.function.http.DELETE=foo;bar|baz')
|
||||
*/
|
||||
public List<String> delete;
|
||||
public String delete;
|
||||
|
||||
public List<String> getGet() {
|
||||
public String getGet() {
|
||||
return this.get;
|
||||
}
|
||||
|
||||
public void setGet(List<String> get) {
|
||||
public void setGet(String get) {
|
||||
this.get = get;
|
||||
}
|
||||
|
||||
public List<String> getPost() {
|
||||
public String getPost() {
|
||||
return post;
|
||||
}
|
||||
|
||||
public void setPost(List<String> post) {
|
||||
public void setPost(String post) {
|
||||
this.post = post;
|
||||
}
|
||||
|
||||
public List<String> getPut() {
|
||||
public String getPut() {
|
||||
return put;
|
||||
}
|
||||
|
||||
public void setPut(List<String> put) {
|
||||
public void setPut(String put) {
|
||||
this.put = put;
|
||||
}
|
||||
|
||||
public List<String> getDelete() {
|
||||
public String getDelete() {
|
||||
return delete;
|
||||
}
|
||||
|
||||
public void setDelete(List<String> delete) {
|
||||
public void setDelete(String delete) {
|
||||
this.delete = delete;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.stream.Collectors;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.netty.http.server.HttpServerRequest;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry.FunctionInvocationWrapper;
|
||||
@@ -56,8 +55,6 @@ import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mark Fisher
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.function.web.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -34,7 +35,6 @@ import org.springframework.cloud.function.web.FunctionHttpProperties;
|
||||
import org.springframework.cloud.function.web.constants.WebRequestConstants;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.RequestEntity.HeadersBuilder;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.ResponseEntity.BodyBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -42,8 +42,6 @@ import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* !INTERNAL USE ONLY!
|
||||
*
|
||||
@@ -74,7 +72,7 @@ public final class FunctionWebRequestProcessingHelper {
|
||||
}
|
||||
|
||||
public static boolean isValidFunction(String httpMethod, String functionDefinition, FunctionHttpProperties functionHttpProperties) {
|
||||
List<String> functionDefinitions = null;
|
||||
String functionDefinitions = null;
|
||||
switch (httpMethod) {
|
||||
case "GET":
|
||||
functionDefinitions = functionHttpProperties.getGet();
|
||||
@@ -91,7 +89,10 @@ public final class FunctionWebRequestProcessingHelper {
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return CollectionUtils.isEmpty(functionDefinitions) || functionDefinitions.contains(functionDefinition);
|
||||
if (StringUtils.hasText(functionDefinitions)) {
|
||||
return Arrays.asList(functionDefinitions.split(";")).contains(functionDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String buildBadMappingErrorMessage(String httpMethod, String functionDefinition) {
|
||||
|
||||
Reference in New Issue
Block a user