mirror of
https://github.com/cypress-io/cypress.git
synced 2026-03-13 12:59:07 -05:00
Do not send requests for SNI server through upstream proxy (#4275)
* add test to ensure that SNI server will never go through proxy * prevent test from false positive * ensure that SNI server requests never go through proxy * e2e test that https-proxy does not pass sni reqs thru upstream * improve debug logging in https-proxy * fix using cwd, not workspaceFolder for terminals manager * remove dead code * stop the debug proxy after each test Co-authored-by: Brian Mann <brian.mann86@gmail.com>
This commit is contained in:
committed by
Brian Mann
parent
ef5c38d178
commit
b568e82545
@@ -5,6 +5,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
|
||||
_ = require("lodash")
|
||||
DebugProxy = require("@cypress/debugging-proxy")
|
||||
net = require("net")
|
||||
network = require("@packages/network")
|
||||
path = require("path")
|
||||
Promise = require("bluebird")
|
||||
proxy = require("../helpers/proxy")
|
||||
@@ -241,6 +242,27 @@ describe "Proxy", ->
|
||||
expect(socket.destroyed).to.be.true
|
||||
resolve()
|
||||
|
||||
## https://github.com/cypress-io/cypress/issues/4257
|
||||
it "passes through to SNI when it is intercepted and not through proxy", ->
|
||||
createSocket = @sandbox.stub(network.connect, 'createRetryingSocket').callsArgWith(1, new Error('stub'))
|
||||
createProxyConn = @sandbox.spy(network.agent.httpsAgent, 'createUpstreamProxyConnection')
|
||||
|
||||
request({
|
||||
strictSSL: false
|
||||
url: "https://localhost:8443"
|
||||
proxy: "http://localhost:3333"
|
||||
resolveWithFullResponse: true
|
||||
forever: false
|
||||
})
|
||||
.then =>
|
||||
throw new Error('should not succeed')
|
||||
.catch { message: 'Error: socket hang up' }, =>
|
||||
expect(createProxyConn).to.not.be.called
|
||||
expect(createSocket).to.be.calledWith({
|
||||
port: @proxy._sniPort
|
||||
host: 'localhost'
|
||||
})
|
||||
|
||||
afterEach ->
|
||||
@upstream.stop()
|
||||
delete process.env.HTTP_PROXY
|
||||
|
||||
@@ -5,6 +5,7 @@ sinonChai = require("sinon-chai")
|
||||
sinonPromise = require("sinon-as-promised")(Promise)
|
||||
|
||||
global.request = require("request-promise")
|
||||
global.sinon = sinon
|
||||
global.supertest = require("supertest")
|
||||
|
||||
chai.use(sinonChai)
|
||||
@@ -15,4 +16,4 @@ beforeEach ->
|
||||
@sandbox = sinon.sandbox.create()
|
||||
|
||||
afterEach ->
|
||||
@sandbox.restore()
|
||||
@sandbox.restore()
|
||||
|
||||
Reference in New Issue
Block a user