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 478 forks source link

Content-length in header cause Request Failed - Related -https://github.com/pact-foundation/pact-jvm/issues/255 #1540

Open tl-madhulika-mitra opened 2 years ago

tl-madhulika-mitra commented 2 years ago

@uglyog - We use Wiremock pact generator to generate our pact and the header content-length auto generates. And when we try to test the provider side, the test fails with 408. We are using a Pact Broker to test, so cannot remove headers at runtime(not sure if there exists a way). Imagining this thread is quite old, is there a way to work around this.

PS: Test works completely fine, without this header

Originally posted by @tl-madhulika-mitra in https://github.com/pact-foundation/pact-jvm/issues/255#issuecomment-1112503131

YOU54F commented 2 years ago

you can whitelist headers in your consumer tests, see the wiremock-pact-generator docs

https://bitbucket.org/atlassian/wiremock-pact-generator/src/master/

Whitelist request/response headers You can define what request/response headers should be recorded in the interactions by providing a whitelist of header names (case insensitive).

By default, if no whitelist is provided, all headers are captured.

    WireMockPactGenerator
        .builder("myConsumer", "myProvider")
        .withRequestHeaderWhitelist("header-1", "header-2")
        .withResponseHeaderWhitelist("header-3")
        .build()
mefellows commented 2 years ago

Just jumping in here to say that I would not recommend using the wiremock generator with a pact provider verification as there are no matching rues which can make verification very brittle (it will only match exact values).

It's designed for use with another schema comparison tool, or with Pactflow's bidirectional contract testing feature.

YOU54F commented 2 years ago

@tl-madhulika-mitra are you sorted with this issue and can I close it, as wiremock-pact-generator will not work for traditional consumer driven contract tests with a Pact provided verifier