Are header names modified by the mock service?
See original GitHub issueI’m attempting to mock a vendor’s service for unit test purposes, and it requires an access_token header (specifically “access_token”) and would like to assert that the request at least contains a header with that name. Problem is, when I include something like this in my ProviderServiceRequest object:
Headers = new Dictionary<string, Object>()
{
["Content-Type"] = "application/json; charset=utf-8",
["access_token"] = Match.Type(Token.WriteToken())
}
…I get something like the following in my pact log:
Description of differences
--------------------------------------
* Could not find key "access_token" (keys present are: Content-Length, Content-Type, Accept, Access-Token, Host, Expect, Version) at $.headers
Notice that Access-Token is an options, but access_token is not. I’ve verified both that, when I debug an application processing this request, the header name is reflected as access_token in the current HttpContext, and that the code under test works with the vendor’s service (whereas manually sending Access-Token does not.)
Is Pact changing the header names it receives prior to checking for valid interactions?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (10 by maintainers)
Top GitHub Comments
Yes, it is. It’s actually Rack, the http library that does the http calls in the test cases. It assumes that all headers are in the standard format (underscores really aren’t standard, I have to say). Nonetheless, there is a workaround for this scenario. I’ll ferret it out and get back to you.
@bethesque Oh cool! Yep updated to 1.43.1