From 1bf780976864f0040d2c82a73e86f1829de57d5b Mon Sep 17 00:00:00 2001 From: Peng-Yu Chen Date: Mon, 2 Sep 2024 09:49:50 +0100 Subject: [PATCH] chore: minor test enhancements (#551) --- test/README.md | 7 ++++++- test/server.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/README.md b/test/README.md index 198503bb..a5284949 100644 --- a/test/README.md +++ b/test/README.md @@ -3,7 +3,12 @@ To run the tests, you need to add the following line to your `/etc/hosts`: ``` # Used by proxy-chain NPM package tests +127.0.0.1 localhost 127.0.0.1 localhost-test ``` -This is a workaround to PhantomJS' behavior where it skips proxy servers for localhost addresses. \ No newline at end of file +The `localhost` entry is for avoiding dual-stack issues, e.g. when the test server listens at ::1 +(results of getaddrinfo have specifed order) and the client attempts to connect to 127.0.0.1 . + +The `localhost-test` entry is a workaround to PhantomJS' behavior where it skips proxy servers for +localhost addresses. diff --git a/test/server.js b/test/server.js index a3d4fb8c..534f5c8c 100644 --- a/test/server.js +++ b/test/server.js @@ -855,7 +855,12 @@ const createTestSuite = ({ // For SSL, we need to return curl's stderr to check what kind of error was there const output = await curlGet(curlUrl, `http://bad:password@127.0.0.1:${mainProxyServerPort}`, !useSsl); if (useSsl) { - expect(output).to.contain('Received HTTP code 407 from proxy after CONNECT'); + expect(output).to.contain.oneOf([ + // Old error message before dafdb20a26d0c890e83dea61a104b75408481ebd + 'Received HTTP code 407 from proxy after CONNECT', + // and that after + 'CONNECT tunnel failed, response 407', + ]); } else { expect(output).to.contain('Proxy credentials required'); }