Skip to content

Commit

Permalink
chore: minor test enhancements (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
starrify authored Sep 2, 2024
1 parent b326f95 commit 1bf7809
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
7 changes: 6 additions & 1 deletion test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]:${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');
}
Expand Down

0 comments on commit 1bf7809

Please sign in to comment.