This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 5088223018ce0301862d88c3cc14224c0d97d3d1 Author: Michael Blow <[email protected]> AuthorDate: Wed Mar 24 20:17:26 2021 -0400 [NO ISSUE][TEST] += paramsfromquery - Add 'paramsfromquery' test file directive, to transform http query into form post parameters Change-Id: I05c9eae65ff30d001b4a5f4190f9a35ef911d46a Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/10686 Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Blow <[email protected]> Reviewed-by: Ali Alsuliman <[email protected]> --- .../org/apache/asterix/test/common/TestExecutor.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java index 730ed46..453ed59 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java @@ -109,6 +109,7 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.AuthCache; @@ -118,6 +119,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.methods.RequestBuilder; import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.HttpMultipartMode; @@ -186,6 +188,9 @@ public class TestExecutor { private static final Pattern VARIABLE_REF_PATTERN = Pattern.compile("\\$(\\w+)"); private static final Pattern HTTP_PARAM_PATTERN = Pattern.compile("param (?<name>[\\w-$]+)(?::(?<type>\\w+))?=(?<value>.*)", Pattern.MULTILINE); + private static final Pattern HTTP_PARAMS_FROM_QUERY_PATTERN = + Pattern.compile("paramsfromquery (?<value>.*)", Pattern.MULTILINE); + private static final Pattern HTTP_AUTH_PATTERN = Pattern.compile("auth (?<username>.*):(?<password>.*)", Pattern.MULTILINE); private static final Pattern HTTP_BODY_PATTERN = Pattern.compile("body=(.*)", Pattern.MULTILINE); @@ -1930,7 +1935,7 @@ public class TestExecutor { public static List<Parameter> extractParameters(String statement) { List<Parameter> params = new ArrayList<>(); - final Matcher m = HTTP_PARAM_PATTERN.matcher(statement); + Matcher m = HTTP_PARAM_PATTERN.matcher(statement); while (m.find()) { final Parameter param = new Parameter(); String name = m.group("name"); @@ -1948,6 +1953,16 @@ public class TestExecutor { } params.add(param); } + m = HTTP_PARAMS_FROM_QUERY_PATTERN.matcher(statement); + while (m.find()) { + String queryString = m.group("value"); + for (NameValuePair queryParam : URLEncodedUtils.parse(queryString, UTF_8)) { + Parameter param = new Parameter(); + param.setName(queryParam.getName()); + param.setValue(queryParam.getValue()); + params.add(param); + } + } return params; }
