From 8608a5d641788924f111ad5e4073b2b48a71cc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Juli=C3=A1n=20Merelo=20Guerv=C3=B3s?= Date: Wed, 24 Nov 2021 20:59:26 +0100 Subject: [PATCH] fix: remove/upgrade outdated deps (#11) Co-authored-by: Chris Breiding --- package.json | 11 +- tests/test-tunnel.js | 592 ++++++++++++++++++++++--------------------- 2 files changed, 303 insertions(+), 300 deletions(-) diff --git a/package.json b/package.json index 003b5caa9..94157f0cb 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", + "http-signature": "~1.3.6", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", "json-stringify-safe": "~5.0.1", @@ -64,11 +63,11 @@ "function-bind": "^1.0.2", "karma": "^3.0.0", "karma-browserify": "^5.0.1", - "karma-cli": "^1.0.0", - "karma-coverage": "^1.0.0", + "karma-cli": "^2.0.0", + "karma-coverage": "^2.0.3", "karma-phantomjs-launcher": "^1.0.0", - "karma-tap": "^3.0.1", - "nyc": "^14.1.1", + "karma-tap": "^4.2.0", + "nyc": "^15.1.0", "phantomjs-prebuilt": "^2.1.3", "rimraf": "^2.2.8", "server-destroy": "^1.0.1", diff --git a/tests/test-tunnel.js b/tests/test-tunnel.js index fa2ebce33..b78649bc8 100644 --- a/tests/test-tunnel.js +++ b/tests/test-tunnel.js @@ -14,9 +14,6 @@ var destroyable = require('server-destroy') var events = [] var caFile = path.resolve(__dirname, 'ssl/ca/ca.crt') var ca = fs.readFileSync(caFile) -var clientCert = fs.readFileSync(path.resolve(__dirname, 'ssl/ca/client.crt')) -var clientKey = fs.readFileSync(path.resolve(__dirname, 'ssl/ca/client-enc.key')) -var clientPassword = 'password' var sslOpts = { key: path.resolve(__dirname, 'ssl/ca/localhost.key'), cert: path.resolve(__dirname, 'ssl/ca/localhost.crt') @@ -118,7 +115,7 @@ function runTest (name, opts, expected) { tape(name, function (t) { opts.ca = ca if (opts.proxy === ss.url) { - customCaCount = (opts.url === ss.url ? 2 : 1) + customCaCount = opts.url === ss.url ? 2 : 1 } request(opts, function (err, res, body) { event(err ? 'err ' + err.message : res.statusCode + ' ' + body) @@ -132,317 +129,324 @@ function runTest (name, opts, expected) { function addTests () { // HTTP OVER HTTP - runTest('http over http, tunnel=true', { - url: s.url, - proxy: s.url, - tunnel: true - }, [ - 'http connect to localhost:' + s.port, - 'http response', - '200 http ok' - ]) - - runTest('http over http, tunnel=false', { - url: s.url, - proxy: s.url, - tunnel: false - }, [ - 'http proxy to http', - 'http response', - '200 http ok' - ]) - - runTest('http over http, tunnel=default', { - url: s.url, - proxy: s.url - }, [ - 'http proxy to http', - 'http response', - '200 http ok' - ]) + runTest( + 'http over http, tunnel=true', + { + url: s.url, + proxy: s.url, + tunnel: true + }, + ['http connect to localhost:' + s.port, 'http response', '200 http ok'] + ) + + runTest( + 'http over http, tunnel=false', + { + url: s.url, + proxy: s.url, + tunnel: false + }, + ['http proxy to http', 'http response', '200 http ok'] + ) + + runTest( + 'http over http, tunnel=default', + { + url: s.url, + proxy: s.url + }, + ['http proxy to http', 'http response', '200 http ok'] + ) // HTTP OVER HTTPS - runTest('http over https, tunnel=true', { - url: s.url, - proxy: ss.url, - tunnel: true - }, [ - 'https connect to localhost:' + s.port, - 'http response', - '200 http ok' - ]) - - runTest('http over https, tunnel=false', { - url: s.url, - proxy: ss.url, - tunnel: false - }, [ - 'https proxy to http', - 'http response', - '200 http ok' - ]) - - runTest('http over https, tunnel=default', { - url: s.url, - proxy: ss.url - }, [ - 'https proxy to http', - 'http response', - '200 http ok' - ]) + runTest( + 'http over https, tunnel=true', + { + url: s.url, + proxy: ss.url, + tunnel: true + }, + ['https connect to localhost:' + s.port, 'http response', '200 http ok'] + ) + + runTest( + 'http over https, tunnel=false', + { + url: s.url, + proxy: ss.url, + tunnel: false + }, + ['https proxy to http', 'http response', '200 http ok'] + ) + + runTest( + 'http over https, tunnel=default', + { + url: s.url, + proxy: ss.url + }, + ['https proxy to http', 'http response', '200 http ok'] + ) // HTTPS OVER HTTP - runTest('https over http, tunnel=true', { - url: ss.url, - proxy: s.url, - tunnel: true - }, [ - 'http connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) - - runTest('https over http, tunnel=false', { - url: ss.url, - proxy: s.url, - tunnel: false - }, [ - 'http proxy to https', - 'https response', - '200 https ok' - ]) - - runTest('https over http, tunnel=default', { - url: ss.url, - proxy: s.url - }, [ - 'http connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) + runTest( + 'https over http, tunnel=true', + { + url: ss.url, + proxy: s.url, + tunnel: true + }, + ['http connect to localhost:' + ss.port, 'https response', '200 https ok'] + ) + + runTest( + 'https over http, tunnel=false', + { + url: ss.url, + proxy: s.url, + tunnel: false + }, + ['http proxy to https', 'https response', '200 https ok'] + ) + + runTest( + 'https over http, tunnel=default', + { + url: ss.url, + proxy: s.url + }, + ['http connect to localhost:' + ss.port, 'https response', '200 https ok'] + ) // HTTPS OVER HTTPS - runTest('https over https, tunnel=true', { - url: ss.url, - proxy: ss.url, - tunnel: true - }, [ - 'https connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) - - runTest('https over https, tunnel=false', { - url: ss.url, - proxy: ss.url, - tunnel: false, - pool: false // must disable pooling here or Node.js hangs - }, [ - 'https proxy to https', - 'https response', - '200 https ok' - ]) - - runTest('https over https, tunnel=default', { - url: ss.url, - proxy: ss.url - }, [ - 'https connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) + runTest( + 'https over https, tunnel=true', + { + url: ss.url, + proxy: ss.url, + tunnel: true + }, + ['https connect to localhost:' + ss.port, 'https response', '200 https ok'] + ) + + runTest( + 'https over https, tunnel=false', + { + url: ss.url, + proxy: ss.url, + tunnel: false, + pool: false // must disable pooling here or Node.js hangs + }, + ['https proxy to https', 'https response', '200 https ok'] + ) + + runTest( + 'https over https, tunnel=default', + { + url: ss.url, + proxy: ss.url + }, + ['https connect to localhost:' + ss.port, 'https response', '200 https ok'] + ) // HTTP->HTTP OVER HTTP - runTest('http->http over http, tunnel=true', { - url: s.url + '/redirect/http', - proxy: s.url, - tunnel: true - }, [ - 'http connect to localhost:' + s.port, - 'http redirect to http', - 'http connect to localhost:' + s.port, - 'http response', - '200 http ok' - ]) - - runTest('http->http over http, tunnel=false', { - url: s.url + '/redirect/http', - proxy: s.url, - tunnel: false - }, [ - 'http proxy to http->http', - 'http redirect to http', - 'http proxy to http', - 'http response', - '200 http ok' - ]) - - runTest('http->http over http, tunnel=default', { - url: s.url + '/redirect/http', - proxy: s.url - }, [ - 'http proxy to http->http', - 'http redirect to http', - 'http proxy to http', - 'http response', - '200 http ok' - ]) + runTest( + 'http->http over http, tunnel=true', + { + url: s.url + '/redirect/http', + proxy: s.url, + tunnel: true + }, + [ + 'http connect to localhost:' + s.port, + 'http redirect to http', + 'http connect to localhost:' + s.port, + 'http response', + '200 http ok' + ] + ) + + runTest( + 'http->http over http, tunnel=false', + { + url: s.url + '/redirect/http', + proxy: s.url, + tunnel: false + }, + [ + 'http proxy to http->http', + 'http redirect to http', + 'http proxy to http', + 'http response', + '200 http ok' + ] + ) + + runTest( + 'http->http over http, tunnel=default', + { + url: s.url + '/redirect/http', + proxy: s.url + }, + [ + 'http proxy to http->http', + 'http redirect to http', + 'http proxy to http', + 'http response', + '200 http ok' + ] + ) // HTTP->HTTPS OVER HTTP - runTest('http->https over http, tunnel=true', { - url: s.url + '/redirect/https', - proxy: s.url, - tunnel: true - }, [ - 'http connect to localhost:' + s.port, - 'http redirect to https', - 'http connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) - - runTest('http->https over http, tunnel=false', { - url: s.url + '/redirect/https', - proxy: s.url, - tunnel: false - }, [ - 'http proxy to http->https', - 'http redirect to https', - 'http proxy to https', - 'https response', - '200 https ok' - ]) - - runTest('http->https over http, tunnel=default', { - url: s.url + '/redirect/https', - proxy: s.url - }, [ - 'http proxy to http->https', - 'http redirect to https', - 'http connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) + runTest( + 'http->https over http, tunnel=true', + { + url: s.url + '/redirect/https', + proxy: s.url, + tunnel: true + }, + [ + 'http connect to localhost:' + s.port, + 'http redirect to https', + 'http connect to localhost:' + ss.port, + 'https response', + '200 https ok' + ] + ) + + runTest( + 'http->https over http, tunnel=false', + { + url: s.url + '/redirect/https', + proxy: s.url, + tunnel: false + }, + [ + 'http proxy to http->https', + 'http redirect to https', + 'http proxy to https', + 'https response', + '200 https ok' + ] + ) + + runTest( + 'http->https over http, tunnel=default', + { + url: s.url + '/redirect/https', + proxy: s.url + }, + [ + 'http proxy to http->https', + 'http redirect to https', + 'http connect to localhost:' + ss.port, + 'https response', + '200 https ok' + ] + ) // HTTPS->HTTP OVER HTTP - runTest('https->http over http, tunnel=true', { - url: ss.url + '/redirect/http', - proxy: s.url, - tunnel: true - }, [ - 'http connect to localhost:' + ss.port, - 'https redirect to http', - 'http connect to localhost:' + s.port, - 'http response', - '200 http ok' - ]) - - runTest('https->http over http, tunnel=false', { - url: ss.url + '/redirect/http', - proxy: s.url, - tunnel: false - }, [ - 'http proxy to https->http', - 'https redirect to http', - 'http proxy to http', - 'http response', - '200 http ok' - ]) - - runTest('https->http over http, tunnel=default', { - url: ss.url + '/redirect/http', - proxy: s.url - }, [ - 'http connect to localhost:' + ss.port, - 'https redirect to http', - 'http proxy to http', - 'http response', - '200 http ok' - ]) + runTest( + 'https->http over http, tunnel=true', + { + url: ss.url + '/redirect/http', + proxy: s.url, + tunnel: true + }, + [ + 'http connect to localhost:' + ss.port, + 'https redirect to http', + 'http connect to localhost:' + s.port, + 'http response', + '200 http ok' + ] + ) + + runTest( + 'https->http over http, tunnel=false', + { + url: ss.url + '/redirect/http', + proxy: s.url, + tunnel: false + }, + [ + 'http proxy to https->http', + 'https redirect to http', + 'http proxy to http', + 'http response', + '200 http ok' + ] + ) + + runTest( + 'https->http over http, tunnel=default', + { + url: ss.url + '/redirect/http', + proxy: s.url + }, + [ + 'http connect to localhost:' + ss.port, + 'https redirect to http', + 'http proxy to http', + 'http response', + '200 http ok' + ] + ) // HTTPS->HTTPS OVER HTTP - runTest('https->https over http, tunnel=true', { - url: ss.url + '/redirect/https', - proxy: s.url, - tunnel: true - }, [ - 'http connect to localhost:' + ss.port, - 'https redirect to https', - 'http connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) - - runTest('https->https over http, tunnel=false', { - url: ss.url + '/redirect/https', - proxy: s.url, - tunnel: false - }, [ - 'http proxy to https->https', - 'https redirect to https', - 'http proxy to https', - 'https response', - '200 https ok' - ]) - - runTest('https->https over http, tunnel=default', { - url: ss.url + '/redirect/https', - proxy: s.url - }, [ - 'http connect to localhost:' + ss.port, - 'https redirect to https', - 'http connect to localhost:' + ss.port, - 'https response', - '200 https ok' - ]) - - // MUTUAL HTTPS OVER HTTP - - runTest('mutual https over http, tunnel=true', { - url: ss2.url, - proxy: s.url, - tunnel: true, - cert: clientCert, - key: clientKey, - passphrase: clientPassword - }, [ - 'http connect to localhost:' + ss2.port, - 'https response', - '200 https ok' - ]) - - // XXX causes 'Error: socket hang up' - // runTest('mutual https over http, tunnel=false', { - // url : ss2.url, - // proxy : s.url, - // tunnel : false, - // cert : clientCert, - // key : clientKey, - // passphrase : clientPassword - // }, [ - // 'http connect to localhost:' + ss2.port, - // 'https response', - // '200 https ok' - // ]) - - runTest('mutual https over http, tunnel=default', { - url: ss2.url, - proxy: s.url, - cert: clientCert, - key: clientKey, - passphrase: clientPassword - }, [ - 'http connect to localhost:' + ss2.port, - 'https response', - '200 https ok' - ]) + runTest( + 'https->https over http, tunnel=true', + { + url: ss.url + '/redirect/https', + proxy: s.url, + tunnel: true + }, + [ + 'http connect to localhost:' + ss.port, + 'https redirect to https', + 'http connect to localhost:' + ss.port, + 'https response', + '200 https ok' + ] + ) + + runTest( + 'https->https over http, tunnel=false', + { + url: ss.url + '/redirect/https', + proxy: s.url, + tunnel: false + }, + [ + 'http proxy to https->https', + 'https redirect to https', + 'http proxy to https', + 'https response', + '200 https ok' + ] + ) + + runTest( + 'https->https over http, tunnel=default', + { + url: ss.url + '/redirect/https', + proxy: s.url + }, + [ + 'http connect to localhost:' + ss.port, + 'https redirect to https', + 'http connect to localhost:' + ss.port, + 'https response', + '200 https ok' + ] + ) } tape('setup', function (t) {