GitHub
04/24/2023, 7:23 AMMac OSX 11.6.1
• Pact Node version: v10.14.0
• Node Version: v12.22.1
Issue Checklist
Please confirm the following:
☑︎ I have upgraded to the latest - I've tested latest as well but logs are from slightly older version, core issue is needle though but wanted to call it out here as it impacts Pact usability with a corporate proxy
☑︎ I have the read the FAQs in the Readme
☑︎ I have triple checked, that there are no unhandled promises in my code
☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle - actually on trace
☐ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem
Root Cause
I want to be clear this is a problem introduced with a pact update when moving from request to needle but the root cause is a Needle issue not respecting `NO_PROXY`. This causes Pact to fail as we run it behind a corporate proxy. This worked as expected prior to the move to needle.
Expected behaviour
As a user behind a corporate proxy Pact should be able to make a successful network request to the mock service it spins up while respecting HTTP_PROXY and NO_PROXY environment variables (note it was working as expected with these older versions of pact & pact-node)
[2021-11-30 21:49:24.080 +0000] INFO (10049 on MLRW20127616): pact-node@10.12.2: Pact running on port 62080
[2021-11-30 21:49:24.532 +0000] INFO (10049 on MLRW20127616): pact@9.15.5: Setting up Pact with Consumer "xxxxx" and Provider "yyyyy"
using mock service on Port: "62080"
Actual behaviour
Since move from request to needle connection to mock server fails on machines behind a corporate proxy despite setting NO_PROXY for localhost/127.0.0.1 (something the request library previously respected). In my use case needle's http request is intercepted and redirected by our corporate proxy causing it never to connect to the pact mock server thus causing pact contract tests to fail/not run.
[2021-12-01 15:17:15.403 +0000] INFO (33800 on MLRW20127616): pact-node@10.14.0: Pact running on port 54284
[2021-12-01 15:17:15.489 +0000] TRACE (33800 on MLRW20127616): pact@9.16.5: outgoing request
[2021-12-01 15:17:15.575 +0000] TRACE (33800 on MLRW20127616): pact@9.16.5:
body: "<HTML><HEAD>\n<TITLE>Redirect</TITLE>\n</HEAD>\n<BODY>\n<FONT face=\"Helvetica\">\n<big><strong></strong></big><BR>\n</FONT>\n<blockquote>\n<TABLE border=0 cellPadding=1 width=\"80%\">\n<TR><TD>\n<FONT face=\"Helvetica\">\n<big>Redirect (authentication_redirect_to_virtual_host)</big>\n<BR>\n<BR>\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face=\"Helvetica\">\nYou are being redirected to the authentication virtual host.\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face=\"Helvetica\">\n\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face=\"Helvetica\" SIZE=2>\n<BR>\nFor assistance, contact your network support team.<br><br>Your request was categorized by Blue Coat Web Filter as 'none'. <br>If you wish to question or dispute this result, please click <a href=\"http://sitereview.bluecoat.com/sitereview.jsp?referrer=136&url=http://127.0.0.1:54284/\">here</a>.\n</FONT>\n</TD></TR>\n</TABLE>\n</blockquote>\n</FONT>\n</BODY></HTML>\n"
headers: {
"location": "<http://www.cfauth.com/?cfru=aHR0cDovLzEyNy4wLjAuMTo1NDI4NC8=>",
"cache-control": "no-cache",
"pragma": "no-cache",
"x-xss-protection": "1",
"content-type": "text/html; charset=utf-8",
"proxy-connection": "close",
"connection": "close",
"content-length": "867"
}
statusCode: 302
[2021-12-01 15:17:16.105 +0000] TRACE (33800 on MLRW20127616): pact@9.16.5: outgoing request
[2021-12-01 15:17:16.106 +0000] TRACE (33800 on MLRW20127616): pact@9.16.5:
Steps to reproduce
This happens when running any consumer test, specifically initiated during the call to `@pact-foundation/pact`'s setup function when attempting to start the mock server.
pact-foundation/pact-js-coreGitHub
04/24/2023, 7:23 AM