Closed marcozet closed 4 months ago
If you use the MultipartEntityBuilder
from the Apache HTTP client, you can set the boundary to a fixed value (using setBoundary
).
Example test using MultipartEntityBuilder https://github.com/pact-foundation/pact-jvm/blob/4752365ad30c9ba5640f37578d8b4a7b673d3653/consumer/junit/src/test/groovy/au/com/dius/pact/consumer/junit/ExampleMultipartSpec.groovy#L18
OK, got it! Now it works... Thanks.
We have a scenario where we need to upload a bunch of files using post with Content-Type multipart/form-data.
So the request body looks like...
and the Pact is generated as...
No issues so far.
We use the Pact Broker / Pact webhook workflow, so we publish the Pact file to the broker and the provider verification is triggered via the webhook when the content of the Pact file has changed (on contract_content_changed event).
But unfortunately, the generated and published Pact file differs from test run to test run, as the boundary in the request body that marks the various parts is generated dynamically.
As a result, the Pact broker triggers the provider verification for each consumer build, even though the Pact itself has not been changed (except for the boundary attribute).
Can I set the boundary attribute statically so that the Pact doesn't change?
I found a similar problem here: https://github.com/pact-foundation/pact-net/issues/410#issuecomment-1457853792