You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Skip tls tests on windows and stunnel
This will also remove the libwrap option to work on arch
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ node_modules
|
|||||||
coverage
|
coverage
|
||||||
*.log
|
*.log
|
||||||
*.rdb
|
*.rdb
|
||||||
|
stunnel.conf
|
||||||
|
stunnel.pid
|
@@ -8,6 +8,8 @@ addons:
|
|||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
packages:
|
packages:
|
||||||
- g++-4.8
|
- g++-4.8
|
||||||
|
env:
|
||||||
|
- TRAVIS=true
|
||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
- "0.10"
|
||||||
- "0.12"
|
- "0.12"
|
||||||
|
8
index.js
8
index.js
@@ -46,6 +46,7 @@ function RedisClient (options) {
|
|||||||
cnx_options.family = (!options.family && net.isIP(cnx_options.host)) || (options.family === 'IPv6' ? 6 : 4);
|
cnx_options.family = (!options.family && net.isIP(cnx_options.host)) || (options.family === 'IPv6' ? 6 : 4);
|
||||||
this.address = cnx_options.host + ':' + cnx_options.port;
|
this.address = cnx_options.host + ':' + cnx_options.port;
|
||||||
}
|
}
|
||||||
|
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
|
||||||
for (var tls_option in options.tls) { // jshint ignore: line
|
for (var tls_option in options.tls) { // jshint ignore: line
|
||||||
cnx_options[tls_option] = options.tls[tls_option];
|
cnx_options[tls_option] = options.tls[tls_option];
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ function RedisClient (options) {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
// Init parser once per instance
|
// Init parser once per instance
|
||||||
this.init_parser();
|
this.init_parser();
|
||||||
self.create_stream();
|
this.create_stream();
|
||||||
}
|
}
|
||||||
util.inherits(RedisClient, events.EventEmitter);
|
util.inherits(RedisClient, events.EventEmitter);
|
||||||
|
|
||||||
@@ -105,6 +106,7 @@ RedisClient.prototype.create_stream = function () {
|
|||||||
this.stream.destroy();
|
this.stream.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore if: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
|
||||||
if (this.options.tls) {
|
if (this.options.tls) {
|
||||||
this.stream = tls.connect(this.connection_options);
|
this.stream = tls.connect(this.connection_options);
|
||||||
} else {
|
} else {
|
||||||
@@ -118,8 +120,9 @@ RedisClient.prototype.create_stream = function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
|
||||||
var connect_event = this.options.tls ? "secureConnect" : "connect";
|
var connect_event = this.options.tls ? "secureConnect" : "connect";
|
||||||
this.stream.on(connect_event, function () {
|
this.stream.once(connect_event, function () {
|
||||||
this.removeAllListeners("timeout");
|
this.removeAllListeners("timeout");
|
||||||
self.on_connect();
|
self.on_connect();
|
||||||
});
|
});
|
||||||
@@ -134,6 +137,7 @@ RedisClient.prototype.create_stream = function () {
|
|||||||
self.on_error(err);
|
self.on_error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
|
||||||
this.stream.on('clientError', function (err) {
|
this.stream.on('clientError', function (err) {
|
||||||
self.on_error(err);
|
self.on_error(err);
|
||||||
});
|
});
|
||||||
|
@@ -5,7 +5,6 @@ cert = __dirname/redis.js.org.cert
|
|||||||
key = __dirname/redis.js.org.key
|
key = __dirname/redis.js.org.key
|
||||||
client = no
|
client = no
|
||||||
foreground = yes
|
foreground = yes
|
||||||
libwrap = no
|
|
||||||
debug = 7
|
debug = 7
|
||||||
[redis]
|
[redis]
|
||||||
accept = 127.0.0.1:6380
|
accept = 127.0.0.1:6380
|
||||||
|
@@ -103,7 +103,7 @@ describe("connection tests", function () {
|
|||||||
max_attempts: 1
|
max_attempts: 1
|
||||||
};
|
};
|
||||||
client = redis.createClient(options);
|
client = redis.createClient(options);
|
||||||
assert.strictEqual(client.connection_option.family, ip === 'IPv6' ? 6 : 4);
|
assert.strictEqual(client.connection_options.family, ip === 'IPv6' ? 6 : 4);
|
||||||
assert.strictEqual(Object.keys(options).length, 4);
|
assert.strictEqual(Object.keys(options).length, 4);
|
||||||
var end = helper.callFuncAfter(done, 2);
|
var end = helper.callFuncAfter(done, 2);
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ describe("connection tests", function () {
|
|||||||
assert(client.stream._events.timeout);
|
assert(client.stream._events.timeout);
|
||||||
});
|
});
|
||||||
assert.strictEqual(client.address, '192.168.74.167:6379');
|
assert.strictEqual(client.address, '192.168.74.167:6379');
|
||||||
assert.strictEqual(client.connection_option.family, 4);
|
assert.strictEqual(client.connection_options.family, 4);
|
||||||
var time = Date.now();
|
var time = Date.now();
|
||||||
|
|
||||||
client.on("reconnecting", function (params) {
|
client.on("reconnecting", function (params) {
|
||||||
@@ -162,7 +162,7 @@ describe("connection tests", function () {
|
|||||||
host: '2001:db8::ff00:42:8329' // auto detect ip v6
|
host: '2001:db8::ff00:42:8329' // auto detect ip v6
|
||||||
});
|
});
|
||||||
assert.strictEqual(client.address, '2001:db8::ff00:42:8329:6379');
|
assert.strictEqual(client.address, '2001:db8::ff00:42:8329:6379');
|
||||||
assert.strictEqual(client.connection_option.family, 6);
|
assert.strictEqual(client.connection_options.family, 6);
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
assert.strictEqual(client.stream._events.timeout, undefined);
|
assert.strictEqual(client.stream._events.timeout, undefined);
|
||||||
});
|
});
|
||||||
@@ -240,7 +240,7 @@ describe("connection tests", function () {
|
|||||||
|
|
||||||
it("connects with a port only", function (done) {
|
it("connects with a port only", function (done) {
|
||||||
client = redis.createClient(6379);
|
client = redis.createClient(6379);
|
||||||
assert.strictEqual(client.connection_option.family, 4);
|
assert.strictEqual(client.connection_options.family, 4);
|
||||||
client.on("error", done);
|
client.on("error", done);
|
||||||
|
|
||||||
client.once("ready", function () {
|
client.once("ready", function () {
|
||||||
|
@@ -15,14 +15,29 @@ var tls_options = {
|
|||||||
|
|
||||||
var tls_port = 6380;
|
var tls_port = 6380;
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait until stunnel4 is in the travis whitelist
|
||||||
|
// Check: https://github.com/travis-ci/apt-package-whitelist/issues/403
|
||||||
|
// If this is merged, remove the travis env checks
|
||||||
describe("TLS connection tests", function () {
|
describe("TLS connection tests", function () {
|
||||||
before(function (done) {
|
before(function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') {
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
helper.stopStunnel(function () {
|
helper.stopStunnel(function () {
|
||||||
helper.startStunnel(done);
|
helper.startStunnel(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function (done) {
|
after(function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') {
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
helper.stopStunnel(done);
|
helper.stopStunnel(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -33,13 +48,12 @@ describe("TLS connection tests", function () {
|
|||||||
var client;
|
var client;
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
if (client) {
|
client.end(true);
|
||||||
client.end();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("on lost connection", function () {
|
describe("on lost connection", function () {
|
||||||
it("emit an error after max retry attempts and do not try to reconnect afterwards", function (done) {
|
it("emit an error after max retry attempts and do not try to reconnect afterwards", function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
var max_attempts = 4;
|
var max_attempts = 4;
|
||||||
var options = {
|
var options = {
|
||||||
parser: parser,
|
parser: parser,
|
||||||
@@ -69,6 +83,7 @@ describe("TLS connection tests", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("emit an error after max retry timeout and do not try to reconnect afterwards", function (done) {
|
it("emit an error after max retry timeout and do not try to reconnect afterwards", function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
var connect_timeout = 500; // in ms
|
var connect_timeout = 500; // in ms
|
||||||
client = redis.createClient({
|
client = redis.createClient({
|
||||||
parser: parser,
|
parser: parser,
|
||||||
@@ -97,6 +112,7 @@ describe("TLS connection tests", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("end connection while retry is still ongoing", function (done) {
|
it("end connection while retry is still ongoing", function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
var connect_timeout = 1000; // in ms
|
var connect_timeout = 1000; // in ms
|
||||||
client = redis.createClient({
|
client = redis.createClient({
|
||||||
parser: parser,
|
parser: parser,
|
||||||
@@ -116,6 +132,7 @@ describe("TLS connection tests", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("can not connect with wrong host / port in the options object", function (done) {
|
it("can not connect with wrong host / port in the options object", function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
var options = {
|
var options = {
|
||||||
host: 'somewhere',
|
host: 'somewhere',
|
||||||
max_attempts: 1,
|
max_attempts: 1,
|
||||||
@@ -136,6 +153,7 @@ describe("TLS connection tests", function () {
|
|||||||
describe("when not connected", function () {
|
describe("when not connected", function () {
|
||||||
|
|
||||||
it("connect with host and port provided in the options object", function (done) {
|
it("connect with host and port provided in the options object", function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
client = redis.createClient({
|
client = redis.createClient({
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
parser: parser,
|
parser: parser,
|
||||||
@@ -150,6 +168,7 @@ describe("TLS connection tests", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("connects correctly with args", function (done) {
|
it("connects correctly with args", function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
var args_host = args[1];
|
var args_host = args[1];
|
||||||
var args_options = args[2] || {};
|
var args_options = args[2] || {};
|
||||||
args_options.tls = tls_options;
|
args_options.tls = tls_options;
|
||||||
@@ -166,6 +185,7 @@ describe("TLS connection tests", function () {
|
|||||||
|
|
||||||
if (ip === 'IPv4') {
|
if (ip === 'IPv4') {
|
||||||
it('allows connecting with the redis url and no auth and options as second parameter', function (done) {
|
it('allows connecting with the redis url and no auth and options as second parameter', function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
var options = {
|
var options = {
|
||||||
detect_buffers: false,
|
detect_buffers: false,
|
||||||
magic: Math.random(),
|
magic: Math.random(),
|
||||||
@@ -176,6 +196,7 @@ describe("TLS connection tests", function () {
|
|||||||
// verify connection is using TCP, not UNIX socket
|
// verify connection is using TCP, not UNIX socket
|
||||||
assert.strictEqual(client.connection_options.host, config.HOST[ip]);
|
assert.strictEqual(client.connection_options.host, config.HOST[ip]);
|
||||||
assert.strictEqual(client.connection_options.port, tls_port);
|
assert.strictEqual(client.connection_options.port, tls_port);
|
||||||
|
assert(typeof client.stream.getCipher === 'function');
|
||||||
// verify passed options are in use
|
// verify passed options are in use
|
||||||
assert.strictEqual(client.options.magic, options.magic);
|
assert.strictEqual(client.options.magic, options.magic);
|
||||||
client.on("ready", function () {
|
client.on("ready", function () {
|
||||||
@@ -184,6 +205,7 @@ describe("TLS connection tests", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows connecting with the redis url and no auth and options as third parameter', function (done) {
|
it('allows connecting with the redis url and no auth and options as third parameter', function (done) {
|
||||||
|
if (process.env.TRAVIS === 'true') this.skip();
|
||||||
client = redis.createClient('redis://' + config.HOST[ip] + ':' + tls_port, null, {
|
client = redis.createClient('redis://' + config.HOST[ip] + ':' + tls_port, null, {
|
||||||
detect_buffers: false,
|
detect_buffers: false,
|
||||||
tls: tls_options
|
tls: tls_options
|
||||||
|
Reference in New Issue
Block a user