Skip to content

Commit b91692e

Browse files
author
Ruben Bridgewater
committed
Skip tls tests on windows and stunnel
This will also remove the libwrap option to work on arch
1 parent 0596480 commit b91692e

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ node_modules
44
coverage
55
*.log
66
*.rdb
7+
stunnel.conf
8+
stunnel.pid

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ addons:
88
- ubuntu-toolchain-r-test
99
packages:
1010
- g++-4.8
11+
env:
12+
- TRAVIS=true
1113
node_js:
1214
- "0.10"
1315
- "0.12"

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function RedisClient (options) {
4646
cnx_options.family = (!options.family && net.isIP(cnx_options.host)) || (options.family === 'IPv6' ? 6 : 4);
4747
this.address = cnx_options.host + ':' + cnx_options.port;
4848
}
49+
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
4950
for (var tls_option in options.tls) { // jshint ignore: line
5051
cnx_options[tls_option] = options.tls[tls_option];
5152
}
@@ -91,7 +92,7 @@ function RedisClient (options) {
9192
this.options = options;
9293
// Init parser once per instance
9394
this.init_parser();
94-
self.create_stream();
95+
this.create_stream();
9596
}
9697
util.inherits(RedisClient, events.EventEmitter);
9798

@@ -105,6 +106,7 @@ RedisClient.prototype.create_stream = function () {
105106
this.stream.destroy();
106107
}
107108

109+
/* istanbul ignore if: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
108110
if (this.options.tls) {
109111
this.stream = tls.connect(this.connection_options);
110112
} else {
@@ -118,8 +120,9 @@ RedisClient.prototype.create_stream = function () {
118120
});
119121
}
120122

123+
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
121124
var connect_event = this.options.tls ? "secureConnect" : "connect";
122-
this.stream.on(connect_event, function () {
125+
this.stream.once(connect_event, function () {
123126
this.removeAllListeners("timeout");
124127
self.on_connect();
125128
});
@@ -134,6 +137,7 @@ RedisClient.prototype.create_stream = function () {
134137
self.on_error(err);
135138
});
136139

140+
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
137141
this.stream.on('clientError', function (err) {
138142
self.on_error(err);
139143
});

test/conf/stunnel.conf.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ cert = __dirname/redis.js.org.cert
55
key = __dirname/redis.js.org.key
66
client = no
77
foreground = yes
8-
libwrap = no
98
debug = 7
109
[redis]
1110
accept = 127.0.0.1:6380

test/connection.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe("connection tests", function () {
103103
max_attempts: 1
104104
};
105105
client = redis.createClient(options);
106-
assert.strictEqual(client.connection_option.family, ip === 'IPv6' ? 6 : 4);
106+
assert.strictEqual(client.connection_options.family, ip === 'IPv6' ? 6 : 4);
107107
assert.strictEqual(Object.keys(options).length, 4);
108108
var end = helper.callFuncAfter(done, 2);
109109

@@ -142,7 +142,7 @@ describe("connection tests", function () {
142142
assert(client.stream._events.timeout);
143143
});
144144
assert.strictEqual(client.address, '192.168.74.167:6379');
145-
assert.strictEqual(client.connection_option.family, 4);
145+
assert.strictEqual(client.connection_options.family, 4);
146146
var time = Date.now();
147147

148148
client.on("reconnecting", function (params) {
@@ -162,7 +162,7 @@ describe("connection tests", function () {
162162
host: '2001:db8::ff00:42:8329' // auto detect ip v6
163163
});
164164
assert.strictEqual(client.address, '2001:db8::ff00:42:8329:6379');
165-
assert.strictEqual(client.connection_option.family, 6);
165+
assert.strictEqual(client.connection_options.family, 6);
166166
process.nextTick(function() {
167167
assert.strictEqual(client.stream._events.timeout, undefined);
168168
});
@@ -240,7 +240,7 @@ describe("connection tests", function () {
240240

241241
it("connects with a port only", function (done) {
242242
client = redis.createClient(6379);
243-
assert.strictEqual(client.connection_option.family, 4);
243+
assert.strictEqual(client.connection_options.family, 4);
244244
client.on("error", done);
245245

246246
client.once("ready", function () {

test/tls.spec.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,29 @@ var tls_options = {
1515

1616
var tls_port = 6380;
1717

18+
if (process.platform === 'win32') {
19+
return;
20+
}
21+
22+
// Wait until stunnel4 is in the travis whitelist
23+
// Check: https://github.com/travis-ci/apt-package-whitelist/issues/403
24+
// If this is merged, remove the travis env checks
1825
describe("TLS connection tests", function () {
1926
before(function (done) {
27+
if (process.env.TRAVIS === 'true') {
28+
done();
29+
return;
30+
}
2031
helper.stopStunnel(function () {
2132
helper.startStunnel(done);
2233
});
2334
});
2435

2536
after(function (done) {
37+
if (process.env.TRAVIS === 'true') {
38+
done();
39+
return;
40+
}
2641
helper.stopStunnel(done);
2742
});
2843

@@ -33,13 +48,12 @@ describe("TLS connection tests", function () {
3348
var client;
3449

3550
afterEach(function () {
36-
if (client) {
37-
client.end();
38-
}
51+
client.end(true);
3952
});
4053

4154
describe("on lost connection", function () {
4255
it("emit an error after max retry attempts and do not try to reconnect afterwards", function (done) {
56+
if (process.env.TRAVIS === 'true') this.skip();
4357
var max_attempts = 4;
4458
var options = {
4559
parser: parser,
@@ -69,6 +83,7 @@ describe("TLS connection tests", function () {
6983
});
7084

7185
it("emit an error after max retry timeout and do not try to reconnect afterwards", function (done) {
86+
if (process.env.TRAVIS === 'true') this.skip();
7287
var connect_timeout = 500; // in ms
7388
client = redis.createClient({
7489
parser: parser,
@@ -97,6 +112,7 @@ describe("TLS connection tests", function () {
97112
});
98113

99114
it("end connection while retry is still ongoing", function (done) {
115+
if (process.env.TRAVIS === 'true') this.skip();
100116
var connect_timeout = 1000; // in ms
101117
client = redis.createClient({
102118
parser: parser,
@@ -116,6 +132,7 @@ describe("TLS connection tests", function () {
116132
});
117133

118134
it("can not connect with wrong host / port in the options object", function (done) {
135+
if (process.env.TRAVIS === 'true') this.skip();
119136
var options = {
120137
host: 'somewhere',
121138
max_attempts: 1,
@@ -136,6 +153,7 @@ describe("TLS connection tests", function () {
136153
describe("when not connected", function () {
137154

138155
it("connect with host and port provided in the options object", function (done) {
156+
if (process.env.TRAVIS === 'true') this.skip();
139157
client = redis.createClient({
140158
host: 'localhost',
141159
parser: parser,
@@ -150,6 +168,7 @@ describe("TLS connection tests", function () {
150168
});
151169

152170
it("connects correctly with args", function (done) {
171+
if (process.env.TRAVIS === 'true') this.skip();
153172
var args_host = args[1];
154173
var args_options = args[2] || {};
155174
args_options.tls = tls_options;
@@ -166,6 +185,7 @@ describe("TLS connection tests", function () {
166185

167186
if (ip === 'IPv4') {
168187
it('allows connecting with the redis url and no auth and options as second parameter', function (done) {
188+
if (process.env.TRAVIS === 'true') this.skip();
169189
var options = {
170190
detect_buffers: false,
171191
magic: Math.random(),
@@ -176,6 +196,7 @@ describe("TLS connection tests", function () {
176196
// verify connection is using TCP, not UNIX socket
177197
assert.strictEqual(client.connection_options.host, config.HOST[ip]);
178198
assert.strictEqual(client.connection_options.port, tls_port);
199+
assert(typeof client.stream.getCipher === 'function');
179200
// verify passed options are in use
180201
assert.strictEqual(client.options.magic, options.magic);
181202
client.on("ready", function () {
@@ -184,6 +205,7 @@ describe("TLS connection tests", function () {
184205
});
185206

186207
it('allows connecting with the redis url and no auth and options as third parameter', function (done) {
208+
if (process.env.TRAVIS === 'true') this.skip();
187209
client = redis.createClient('redis://' + config.HOST[ip] + ':' + tls_port, null, {
188210
detect_buffers: false,
189211
tls: tls_options

0 commit comments

Comments
 (0)