Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More work to get the tests passing on node 0.12 & io.js #1442

Merged
merged 15 commits into from Mar 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()
})
})