Jan Królikowski
04/13/2023, 8:59 AMAuthorization
header with commas, using pact-go v2.0.0-beta.18
and libpact_ffi 0.4.3
. The header is configured in V3
pact as follows:
WithRequest("GET", "/endpoint", func(b *V3RequestBuilder) {
b.Header("Authorization", S("OAuth oauth_consumer_key=abcd, oauth_signature_method=\"PLAINTEXT\", oauth_version=\"1.0\", oauth_signature=\"1234&\""))
}).
and it's being sent with same payload while running the test:
req, _ := http.NewRequest("GET", fmt.Sprintf("<http://%s:%d/endpoint>", mockServerConfig.Host, mockServerConfig.Port), strings.NewReader(""))
req.Header.Add("Authorization", "OAuth oauth_consumer_key=abcd, oauth_signature_method=\"PLAINTEXT\", oauth_version=\"1.0\", oauth_signature=\"1234&\"")
_, err := <http://httpClient.Do|httpClient.Do>(req)
However, even though the headers are exactly the same, I get following error:
2023/04/13 08:34:08 [INFO] pact validation failed, errors:
Mismatch with header 'Authorization': Expected 'OAuth oauth_consumer_key=abcd, oauth_signature_method=\"PLAINTEXT\", oauth_version=\"1.0\", oauth_signature=\"1234\u0026\"' to be equal to 'OAuth oauth_consumer_key=abcd' for value at index 0
: expected: OAuth oauth_consumer_key=abcd, oauth_signature_method=\"PLAINTEXT\", oauth_version=\"1.0\", oauth_signature=\"1234\u0026\"
actual: OAuth oauth_consumer_key=abcd
Reproductible script can be found here. I verified with external proxy whether Go is stripping the header somehow, but it was sent correctly. Personally, I'd consider it as bug, especially since similar problem was already raised (and fixed) in pact-js. However, this is my first attempt to use pact-go, so maybe this is a feature I miss. In case of the latter, how I should fix the interaction definition to match the actual request?Matt (pactflow.io / pact-js / pact-go)