Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/node-gyp/test/test-download.js')
-rw-r--r--node_modules/node-gyp/test/test-download.js97
1 files changed, 96 insertions, 1 deletions
diff --git a/node_modules/node-gyp/test/test-download.js b/node_modules/node-gyp/test/test-download.js
index 738a43f27..fe373e328 100644
--- a/node_modules/node-gyp/test/test-download.js
+++ b/node_modules/node-gyp/test/test-download.js
@@ -90,6 +90,101 @@ test('download over https with custom ca', function (t) {
})
})
+test('download over http with proxy', function (t) {
+ t.plan(2)
+
+ var server = http.createServer(function (req, res) {
+ t.strictEqual(req.headers['user-agent'],
+ 'node-gyp v42 (node ' + process.version + ')')
+ res.end('ok')
+ pserver.close(function () {
+ server.close()
+ })
+ })
+
+ var pserver = http.createServer(function (req, res) {
+ t.strictEqual(req.headers['user-agent'],
+ 'node-gyp v42 (node ' + process.version + ')')
+ res.end('proxy ok')
+ server.close(function () {
+ pserver.close()
+ })
+ })
+
+ var host = 'localhost'
+ server.listen(0, host, function () {
+ var port = this.address().port
+ pserver.listen(port + 1, host, function () {
+ var gyp = {
+ opts: {
+ proxy: 'http://' + host + ':' + (port + 1)
+ },
+ version: '42'
+ }
+ var url = 'http://' + host + ':' + port
+ var req = install.test.download(gyp, {}, url)
+ req.on('response', function (res) {
+ var body = ''
+ res.setEncoding('utf8')
+ res.on('data', function (data) {
+ body += data
+ })
+ res.on('end', function () {
+ t.strictEqual(body, 'proxy ok')
+ })
+ })
+ })
+ })
+})
+
+test('download over http with noproxy', function (t) {
+ t.plan(2)
+
+ var server = http.createServer(function (req, res) {
+ t.strictEqual(req.headers['user-agent'],
+ 'node-gyp v42 (node ' + process.version + ')')
+ res.end('ok')
+ pserver.close(function () {
+ server.close()
+ })
+ })
+
+ var pserver = http.createServer(function (req, res) {
+ t.strictEqual(req.headers['user-agent'],
+ 'node-gyp v42 (node ' + process.version + ')')
+ res.end('proxy ok')
+ server.close(function () {
+ pserver.close()
+ })
+ })
+
+ var host = 'localhost'
+ server.listen(0, host, function () {
+ var port = this.address().port
+ pserver.listen(port + 1, host, function () {
+ var gyp = {
+ opts: {
+ proxy: 'http://' + host + ':' + (port + 1),
+ noproxy: 'localhost'
+ },
+ version: '42'
+ }
+ var url = 'http://' + host + ':' + port
+ var req = install.test.download(gyp, {}, url)
+ req.on('response', function (res) {
+ var body = ''
+ res.setEncoding('utf8')
+ res.on('data', function (data) {
+ body += data
+ })
+ res.on('end', function () {
+ t.strictEqual(body, 'ok')
+ })
+ })
+ })
+ })
+})
+
test('download with missing cafile', function (t) {
t.plan(1)
var gyp = {
@@ -116,7 +211,7 @@ test('download headers (actual)', function (t) {
process.release.name !== 'node' ||
semver.prerelease(process.version) !== null ||
semver.satisfies(process.version, '<10')) {
- return t.skip('Skipping acutal download of headers due to test environment configuration')
+ return t.skip('Skipping actual download of headers due to test environment configuration')
}
t.plan(17)