Skip to content

Commit

Permalink
Merge pull request #1442 from mammaldev/iojs-tests
Browse files Browse the repository at this point in the history
Fixed the issue with strictSSL tests on  0.12 & io.js by explicitly setting a cipher that matches the cert.
  • Loading branch information
simov committed Mar 9, 2015
2 parents 17a0903 + 117e962 commit 4d3807b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
@@ -1,6 +1,12 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "io.js"
matrix:
allow_failures:
- node_js: "0.12"
- node_js: "io.js"
after_script: ./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape tests/test-*.js --report lcovonly && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js --verbose
webhooks:
urls: https://webhooks.gitter.im/e/237280ed4796c19cc626
Expand Down
4 changes: 3 additions & 1 deletion request.js
Expand Up @@ -322,7 +322,9 @@ Request.prototype.init = function (options) {
if (!self.method) {
self.method = options.method || 'GET'
}
self.localAddress = options.localAddress
if (!self.localAddress) {
self.localAddress = options.localAddress
}

if (!self.qsLib) {
self.qsLib = (options.useQuerystring ? querystring : qs)
Expand Down
2 changes: 1 addition & 1 deletion tests/server.js
Expand Up @@ -34,7 +34,7 @@ exports.createSSLServer = function(port, opts) {
}

for (i in options) {
if (i !== 'requestCert' && i !== 'rejectUnauthorized') {
if (i !== 'requestCert' && i !== 'rejectUnauthorized' && i !== 'ciphers') {
options[i] = fs.readFileSync(options[i])
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/test-https.js
Expand Up @@ -13,6 +13,7 @@ var s = server.createSSLServer()
, caFile = path.resolve(__dirname, 'ssl/ca/ca.crt')
, ca = fs.readFileSync(caFile)
, opts = {
ciphers: 'AES256-SHA',
key: path.resolve(__dirname, 'ssl/ca/server.key'),
cert: path.resolve(__dirname, 'ssl/ca/server.crt')
}
Expand Down
32 changes: 27 additions & 5 deletions tests/test-localAddress.js
@@ -1,27 +1,49 @@
'use strict'

var request = require('../index')
, tape = require('tape')

tape('bind to invalid address', function(t) {
tape('bind to invalid address', function (t) {
request.get({
uri: 'http://www.google.com',
localAddress: '1.2.3.4'
}, function(err, res) {
}, function (err, res) {
t.notEqual(err, null)
t.equal(true, /bind EADDRNOTAVAIL/.test(err.message))
t.equal(res, undefined)
t.end()
})
})

tape('bind to local address', function(t) {
tape('bind to local address', function (t) {
request.get({
uri: 'http://www.google.com',
localAddress: '127.0.0.1'
}, function(err, res) {
}, function (err, res) {
t.notEqual(err, null)
t.equal(res, undefined)
t.end()
})
})

tape('bind to local address on redirect', function (t) {
var os = require('os')
var localInterfaces = os.networkInterfaces()
var localIPS = []
Object.keys(localInterfaces).forEach(function (ifname) {
localInterfaces[ifname].forEach(function (iface) {
if (iface.family !== 'IPv4' || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
return
}
localIPS.push(iface.address)
})
})
request.get({
uri: 'http://google.com', //redirects to 'http://google.com'
localAddress: localIPS[0]
}, function (err, res) {
t.equal(err, null)
t.equal(res.request.localAddress, localIPS[0])
t.end()
})
})

0 comments on commit 4d3807b

Please sign in to comment.