pact-foundation / pact-reference

Reference implementations for the pact specifications
https://pact.io
MIT License
91 stars 46 forks source link

Add Custom Header option not replacing already existing headers #275

Closed RChild0916 closed 7 months ago

RChild0916 commented 1 year ago

Hello all!

I'm working on a provider side API that uses pact-net, and recently wanted to add authentication to our pact tests. We decided to leverage the WithCustomHeader function to add an authorization token, however it appears that the FFI does not replace existing headers if one is already present within the consumer side pact file. Is there any way this functionality can be added?

Reference issue in pact-net: https://github.com/pact-foundation/pact-net/issues/460

rholshausen commented 1 year ago

That link is going to avidxchange.service-now.com, is there a link I can access? I need to know the FFI functions that are being used. I assume it is add_custom_header.

RChild0916 commented 1 year ago

That link is going to avidxchange.service-now.com, is there a link I can access? I need to know the FFI functions that are being used. I assume it is add_custom_header.

Apologies, I updated the message to have the correct link

YOU54F commented 1 year ago

Thanks @RChild0916

It looks like Ron's guess was spot on and he has had a go at implementing a fix, you can see the test cases here

https://github.com/pact-foundation/pact-reference/commit/71b38a87258590a689d58f0b8b28a620121a139f#diff-f828d31e810f569f6f953f74128ae3978e665c6816eeae0ff57b53720f94dc99R451