From 8f7100300918fe35c882e253bd22ba6e040a61d2 Mon Sep 17 00:00:00 2001 From: Bryce Baril Date: Wed, 24 Jul 2013 08:21:28 -0700 Subject: [PATCH] Add test for auth_pass option submitted by hpeinar --- changelog.md | 3 +++ index.js | 2 +- test.js | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 5f825a76a8..2857c96bca 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,9 @@ Changelog ========= +## v0.8.5 - (pending release) +* Add `auth_pass` option to connect and immediately authenticate (Henrik Peinar) + ## v0.8.4 - June 24, 2013 Many contributed features and fixes, including: * Ignore password set if not needed. (jbergknoff) diff --git a/index.js b/index.js index 5c40333bbf..d16a15ff63 100644 --- a/index.js +++ b/index.js @@ -67,7 +67,7 @@ function RedisClient(stream, options) { this.closing = false; this.server_info = {}; this.auth_pass = null; - if(options.auth_pass !== undefined) { + if (options.auth_pass !== undefined) { this.auth_pass = options.auth_pass; } this.parser_module = null; diff --git a/test.js b/test.js index 1d447bc2ea..79907a0160 100644 --- a/test.js +++ b/test.js @@ -1962,6 +1962,24 @@ tests.auth = function () { }); }; +tests.auth2 = function () { + var name = "AUTH2", client4, ready_count = 0; + + client4 = redis.createClient(9006, "filefish.redistogo.com", {auth_pass: "664b1b6aaf134e1ec281945a8de702a9"}); + + // test auth, then kill the connection so it'll auto-reconnect and auto-re-auth + client4.on("ready", function () { + ready_count++; + if (ready_count === 1) { + client4.stream.destroy(); + } else { + client4.quit(function (err, res) { + next(name); + }); + } + }); +}; + tests.reconnectRetryMaxDelay = function() { var time = new Date().getTime(), name = 'reconnectRetryMaxDelay',