pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.58k stars 342 forks source link

Bug: Corporate Proxy not supported during verification #1188

Closed mefellows closed 3 months ago

mefellows commented 3 months ago

Discussed in https://github.com/pact-foundation/pact-js/discussions/1187

Originally posted by **zac-poe** March 7, 2024 I am in the process of updating to the latest version of pact-js and I am encountering issues configuring a web proxy for use with the Verifier. My approach with pact 9.17 (and pact-node 10.17) was to use global-agent to leverage our https proxy and this worked successfully when my providerBaseUrl for the pact Verifier would otherwise be blocked by our web proxy. When updating to pact 12.3.0, I noticed several issues with the above approach. Initially I had to add NO_PROXY configuration for 127.0.0.1. Subsequently, I saw runtime issues with the pact parseBody.js behavior as the proxy request was already in a finished/headersSent state when this event hook was attempting to update the request. However, even after manually modifying this behavior I was observing the global agent proxy on https was still not actually being leveraged and my provider requests were not going through the web proxy. Similary, setting environment variables for HTTPS_PROXY or HTTP_PROXY does not seem to impact the underlying pact internal proxy forwarding from local to the provider URL. What is the proper way to configure use of a corporate proxy with the latest Pact Verifier? Is this a feature that would need to be requested as an enhancement (e.g. adding an optional arg for an http Agent to the Verifier)?