pact-jvm
pact-jvm copied to clipboard
Pact parser is removing quoting on Content-Type params
Hi 👋 ,
Is this by design or a BUG?
- You are running a PROVIDER Contract Test that fetches contracts to validate from PactBroker
- The PACT framework parses contract coming from defined PactBroker
- This particular contract has this header
Content-Type: multipart/related; type="application/json"; boundary=myBoundary
- When parsing this contract quotes disappear on PACT Request Model (that can be ok)
- But when PACT serializes the Request Model the generated header miss quotes so is outside standard when param values has special symbols like
/
as intype
in this particular case:Content-Type: multipart/related; type=application/json; boundary=myBoundary
I'm having issues during provider verification because generated request doesn't contain quotes and provider requires them to dispatch it
I guess this can be useful: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
The involved code is in class au.com.dius.pact.core.model.HeaderParser
. This serialization code isn´t dealing with quotes
private fun hvToString(headerValue: HeaderValue): String {
return if (headerValue.params.isEmpty()) {
headerValue.value.trim()
} else {
headerValue.value.trim() + ";" + headerValue.params.joinToString(";") { it.name + "=" + it.value }
}
}
Hi there,
we're also having a problem with this. We should send an Accept Header with Accept: application/hal+json;profile="https://api.example.de/examples+v1"
and receive the same value in the Content-Type Header. When using a pact file for the test and sending a query the quoting is removed and the test fails.