pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Request path gets decoded on both consumer and provider side. #1326

Open ZawadaZSE opened 3 years ago

ZawadaZSE commented 3 years ago

Hey,

I've got an endpoint that takes value via path param. This value can contain forward slash ie Some/Value.

I'm using pact-jvm in version 4.2.0.

I want to write consumer test against that endpoint. My client encodes this value to Some%2FValue. I've got interaction defined with .path("/endpoint/Some%2FValue"). I've debugged execution and it fails to match request to expectation. I'm using default MockHttpServer and when HttpExchange gets transformed to Request path gets decoded, ergo does not match expectation.

Same problem is visible on provider side. I've manually edited contract file to contain "/endpoint/Some%2FValue". Unfortunately my endpoint gets called with "/endpoint/Some/Value".

I've seen couple old closed tickets here that say it should work. Documentation is pretty vague about it. Is it regression or am I doing something wrong?

uglyog commented 3 years ago

It must be a regression

uglyog commented 3 years ago

If you use the KTor mock server instead of the Java Http one, it works.

uglyog commented 3 years ago

On the provider side, you need to set the pact.verifier.disableUrlPathDecoding JVM system propery

uglyog commented 3 years ago

Released 4.2.3