-
-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pact-jvm-provider-gradle] Paths containing url encoded text cannot be verified #66
Comments
We need to work out what we're doing with the URL encoding, so it's consistent between implementations. Currently, the Ruby impl leaves the URL encoding up to the user. It would seem that the JVM version does not. Arguments for and against doing it automatically? |
I think the rule should be that URLs and query parameters should be URL Decoded in the pact file. The JVM will be different depending on the HTTP client and web container used. |
So, are you saying that some JVM HTTP clients will automatically re-URL If we're going to change this, I think we should change this as part of Serialising the URL decoded value in the pact will mean that in the mock I'm not sure if this is a good thing or not. Trying to think of the pros On Sat, Oct 25, 2014 at 1:42 PM, Ronald Holshausen <notifications@github.com
|
All HTTP clients will encode the path and query string. This issue is that the JVM mock server (which uses the Netty scala library) does not URL decode the path before passing it to the handlers. Here is an example of the problem:
I have some consumer tests at my current client where we had to URL encode the paths in the expectations so that the mock server will match them correctly. Consumer tests should not have to do this. Secondly, I found the default Java URL encoder uses a plus for spaces, while some clients will use a %20 for the query parameters as well (retrofit is an example of one). For our tests where we are using retrofit as the client, the consumer tests used the default Java encoder and then replaced all pluses with %20 to get them to match. Not ideal. However, all decoders will decode both %20 and + to a space. Thus I recommend that the mock servers decode the path and query parameters, and store them decoded in the pact file. |
Yeah, I was going to say, the space between the TEST and PATH should be a So, I think I agree with you. This will be a breaking change however. If we I'm not sure if we can add test cases for this, but we'll need to note it I'm trying to think of a language agnostic test harness web app we can On Sun, Oct 26, 2014 at 11:14 AM, Ronald Holshausen <
|
I released version 2.1.2 to address this issue |
Does that mean it's now not compatible with the ruby implementation? Can we On Mon, Oct 27, 2014 at 11:43 AM, Ronald Holshausen <
|
Unfortunately, this has not solved our problem and now any url encoding we were expecting at our Provider is no longer being received causing it to return a 404. For example, we have some dynamic routing in our Provider that uses a url encoded address in the path to reference an entity id which might look something like this:
where
|
Are you using ruby to verify the pact? On Tuesday, October 28, 2014, Christopher Holmes notifications@github.com
|
I'm also having some issues with this, so I might reverse the commit and leave the fix in the gradle plugin |
This has been released with version 2.1.5 |
Does Netty still have this "problem"? |
No idea, but my assumption would be that it would. |
@uglyog Hi, actually I want " |
Is this an issue you currently have? Query parameters with a |
@uglyog like this in my pact json file: "request": "GET",
"path": "/api/xxx/xxx",
"headers": {
},
"query": "datetime=2011-12-03T10:15:30+01:00" and will be sent to my provider service (using SpringBoot). then actually I will get " |
Ok, looks like the If you are able, |
@uglyog Thanks, but I have try to replace it with |
@uglyog waiting for your reply, T^T |
There is a change to the Pact specification to store the query strings in a different form, which will have to be implemented before I can resolve this issue. It will take a bit of work to fix. |
@uglyog Thank you, I has changed it to using '2011-12-03T10:15:30Z' datetime format and it works now. |
Version 3.1.0 allows V3 format pact files which should resolve this issue. |
@uglyog |
When a path in the generated json pact file contains some already url encoded text (e.g.
xx%20xx -> xx%2520xx
), it is url encoded again after it is read in for use bygradle pactVerify
which results in the verification failing.This does not occur when the same generated json file is run using pact-provider-proxy.
The text was updated successfully, but these errors were encountered: