hmpatel / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Unicode control caracters in parameters - java.lang.IllegalArgumentException: Illegal number of path parameters. Expected 1, was 2. #404

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
Parameters in get() method that have unicode control caracters fail with an 
IllegalArgumentException

Example:
                String request = "param1={param1Value}&param2={param2Value}";
        String param1Value =  "Hello";
        String param2Value =  "Hello\u0085";
        System.out.println(param1Value);
        RestAssured.get(request, param1Value, param2Value);

What is the expected output? What do you see instead?
Success of method call get()

What version of the product are you using? On what operating system?
2.4.1

Please provide any additional information below.

The error is in com.jayway.restassured.internal.RequestSpecificationImpl:
     def hasAnyTemplateLeft = ~/.*\{\w+\}.*/

This regex only takes words and not others caracters.

 if (queryParams.matches(pathTemplate)) {
        def hasAnyTemplateLeft = ~/.*\{\w+\}.*/
        def replacePattern = ~/\{\w+\}/
        def definedParams

..... else {
          throw new IllegalArgumentException("Illegal number of path parameters. Expected $numberOfUsedPathParameters, was $expectedNumberOfUsedPathParameters.")
        }
      }

Original issue reported on code.google.com by carlant...@gmail.com on 22 May 2015 at 5:07

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 26 May 2015 at 9:15

GoogleCodeExporter commented 9 years ago
Thanks for reporting. If you would like to help out I would very much 
appreciate a pull request.

Original comment by johan.ha...@gmail.com on 26 May 2015 at 9:15

GoogleCodeExporter commented 9 years ago
I used another library as the performance of rest-assured was 50x to 100x 
slower than regular httpclient and json-simple. 

Original comment by carlant...@gmail.com on 26 May 2015 at 11:41

GoogleCodeExporter commented 9 years ago
Because of this issue?!

Original comment by johan.ha...@gmail.com on 26 May 2015 at 5:47

GoogleCodeExporter commented 9 years ago
Because of this issue I found that rest-assured is super slow for the kind of 
work I do. I execute concurrent tests that run for hours (> 200K requests), 
Rest-assured is very inefficient because of groovy code I suppose.

Original comment by carlant...@gmail.com on 27 May 2015 at 1:34