Skip to content

Commit

Permalink
chore: test https change
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimoravcik committed Dec 2, 2024
1 parent 84ef1c8 commit 915c9ac
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const util = require('util');
const { expect, assert } = require('chai');
const proxy = require('proxy');
const http = require('http');
const https = require('https');
const portastic = require('portastic');
const request = require('request');
const WebSocket = require('faye-websocket');
Expand Down Expand Up @@ -1337,6 +1338,45 @@ it('supports localAddress', async () => {
}
});

it('supports https proxy relay', async () => {
const target = https.createServer(() => {
});
target.listen(() => {
});

const proxyServer = new ProxyChain.Server({
port: 6666,
prepareRequestFunction: () => {
console.log(`https://localhost:${target.address().port}`);
return {
upstreamProxyUrl: `https://localhost:${target.address().port}`,
};
},
});
let proxyServerError = false;
proxyServer.on('requestFailed', () => {
// requestFailed will be called if we pass an invalid proxy url
proxyServerError = true;
});

await proxyServer.listen();

try {
await requestPromised({
url: 'https://www.google.com',
proxy: 'http://localhost:6666',
strictSSL: false,
});
} catch (e) {
// the request will fail with the following error:
// Error: tunneling socket could not be established, statusCode=599
}
expect(proxyServerError).to.be.equal(false);

proxyServer.close();
target.close();
});

it('supports custom CONNECT server handler', async () => {
const server = new Server({
port: 0,
Expand Down

0 comments on commit 915c9ac

Please sign in to comment.