diff options
author | Johan Bergström <bugs@bergstroem.nu> | 2015-03-04 12:11:21 +1100 |
---|---|---|
committer | Shigeki Ohtsu <ohtsu@iij.ad.jp> | 2015-03-05 10:31:41 +0900 |
commit | 671fbd5a9de03c5ede968ef6c6b365965a546a55 (patch) | |
tree | 771b3158d781911def96ffbd50bd9d4cad4b0077 /test/parallel/test-http-default-port.js | |
parent | c7ad320472d69962b48e10e564682f24dd31d1d1 (diff) | |
download | android-node-v8-671fbd5a9de03c5ede968ef6c6b365965a546a55.tar.gz android-node-v8-671fbd5a9de03c5ede968ef6c6b365965a546a55.tar.bz2 android-node-v8-671fbd5a9de03c5ede968ef6c6b365965a546a55.zip |
test: refactor all tests that depends on crypto
we had a few ways versions of looking for support before executing a test. this
commit unifies them as well as add the check for all tests that previously
lacked them. found by running `./configure --without-ssl && make test`. also,
produce tap skip output if the test is skipped.
PR-URL: https://github.com/iojs/io.js/pull/1049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
Diffstat (limited to 'test/parallel/test-http-default-port.js')
-rw-r--r-- | test/parallel/test-http-default-port.js | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/test/parallel/test-http-default-port.js b/test/parallel/test-http-default-port.js index 29ade45bb4..5f70207312 100644 --- a/test/parallel/test-http-default-port.js +++ b/test/parallel/test-http-default-port.js @@ -1,6 +1,5 @@ var common = require('../common'); var http = require('http'), - https = require('https'), PORT = common.PORT, SSLPORT = common.PORT + 1, assert = require('assert'), @@ -15,15 +14,21 @@ var http = require('http'), gotHttpsResp = false, gotHttpResp = false; +if (common.hasCrypto) { + var https = require('https'); +} else { + console.log('1..0 # Skipped: missing crypto'); +} + process.on('exit', function() { - assert(gotHttpsResp); + if (common.hasCrypto) { + assert(gotHttpsResp); + } assert(gotHttpResp); console.log('ok'); }); http.globalAgent.defaultPort = PORT; -https.globalAgent.defaultPort = SSLPORT; - http.createServer(function(req, res) { assert.equal(req.headers.host, hostExpect); assert.equal(req.headers['x-port'], PORT); @@ -42,21 +47,24 @@ http.createServer(function(req, res) { }); }); -https.createServer(options, function(req, res) { - assert.equal(req.headers.host, hostExpect); - assert.equal(req.headers['x-port'], SSLPORT); - res.writeHead(200); - res.end('ok'); - this.close(); -}).listen(SSLPORT, function() { - var req = https.get({ - host: 'localhost', - rejectUnauthorized: false, - headers: { - 'x-port': SSLPORT - } - }, function(res) { - gotHttpsResp = true; - res.resume(); +if (common.hasCrypto) { + https.globalAgent.defaultPort = SSLPORT; + https.createServer(options, function(req, res) { + assert.equal(req.headers.host, hostExpect); + assert.equal(req.headers['x-port'], SSLPORT); + res.writeHead(200); + res.end('ok'); + this.close(); + }).listen(SSLPORT, function() { + var req = https.get({ + host: 'localhost', + rejectUnauthorized: false, + headers: { + 'x-port': SSLPORT + } + }, function(res) { + gotHttpsResp = true; + res.resume(); + }); }); -}); +} |