ctco / cukes

Cucumber DSL for testing RESTful Web Services
Apache License 2.0
112 stars 66 forks source link

Query parameters aren't encoded properly #74

Open githubble01 opened 7 years ago

githubble01 commented 7 years ago

Hi!

Really like cuke-rest. While writing a test for the JIRA API I think I encountered a bug though...

It seems like the queryParam Type=Shipment AND createdDate>=-1d is encoded "once more" before put in the URL (the % is encoded to %25 and + is encoded to %2B ). Query params: jql=Type%3DShipment+AND+createdDate%3E%3D-1d But Request Url: http://40.68.84.149:8080/rest/api/2/search?jql=Type%253DShipment%2BAND%2BcreatedDate%253E%253D-1d

Se also full log snippet.

test.feature

    Given baseUri from property "jira.base_url"
    And content type is "application/json"
    And queryParam "jql" is "Type=Shipment AND createdDate>=-1d"
    When the client performs GET request on "/search"

cukes.properties

#default - false
cukes.url_encoding_enabled=false
#cukes.relaxed_https=false

Log snippet.

method: GET
Request params: <none>
Query params:   jql=Type%3DShipment+AND+createdDate%3E%3D-1d
Form params:    <none>
Path params:    <none>
Multiparts:     <none>
Request URI:    http://40.68.879.149:8080/rest/api/2/search?jql=Type%253DShipment%2BAND%2BcreatedDate%253E%253D-1d
X-AREQUESTID: 911x168628x1
X-ASEN: SEN-8958841
Set-Cookie: atlassian.xsrf.token=B4ZF-PZLU-TF1H-TP28|edfdaca36c2e0ad606d4ffd05c54f7abeda83a4a|lout;path=/
X-AUSERNAME: anonymous
Cache-Control: no-cache, no-store, no-transform
X-Content-Type-Options: nosniff
Content-Encoding: gzip
Vary: User-Agent
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 18 May 2017 15:11:26 GMT
Connection: close
{
    "errorMessages": [
        "Error in the JQL Query: The character '%' is a reserved JQL character. You must enclose it in a string or use the escape '\%' instead. (line 1, character 5)"
    ],
    "errors": {

    }
}
HTTP/1.1 400 
sergeytrasko commented 7 years ago

I was able to reproduce the issue only if I have cukes.url_encoding_enabled=true in cukes.properties.

Can you doublecheck that cukes.properties is in the correct place? (Usually it's inside src/test/resources)

githubble01 commented 7 years ago

Hi Sergey,

The cukes.properties is in src/test/resources.

Greets, Georg

2017-08-03 9:18 GMT+02:00 Sergey Trasko notifications@github.com:

I was able to reproduce the issue only if I have cukes.url_encoding_enabled=true in cukes.properties.

Can you doublecheck that cukes.properties is in the correct place? (Usually it's inside src/test/resources)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ctco/cukes/issues/74#issuecomment-319889238, or mute the thread https://github.com/notifications/unsubscribe-auth/ABgPAuBgThLto3k4r8Hwd_VT8aaKeHbyks5sUXRZgaJpZM4NfZkc .