1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Add magical auth command.

Authentication is now remembered by the client and will be automatically sent to the server
on every connection, including any reconnections.
This commit is contained in:
Matt Ranney
2011-02-27 23:10:44 -10:00
parent 2534f740aa
commit 1a14e24faa
7 changed files with 99 additions and 40 deletions

10
test.js
View File

@@ -3,6 +3,7 @@ var redis = require("./index"),
client = redis.createClient(),
client2 = redis.createClient(),
client3 = redis.createClient(),
client4 = redis.createClient(9006, "filefish.redistogo.com"),
assert = require("assert"),
util = require("./lib/util").util,
test_db_num = 15, // this DB will be flushed and used for testing
@@ -1049,6 +1050,7 @@ function run_next_test() {
console.log('\n completed \x1b[32m%d\x1b[0m tests in \x1b[33m%d\x1b[0m ms\n', test_count, new Date() - all_start);
client.quit();
client2.quit();
client4.quit();
}
}
@@ -1066,6 +1068,14 @@ client.on('end', function () {
ended = true;
});
// TODO - need a better way to test auth, maybe auto-config a local Redis server?
client4.auth("664b1b6aaf134e1ec281945a8de702a9", function (err, res) {
if (err) {
assert.fail(err, name);
}
assert.strictEqual("OK", res.toString(), "auth");
});
// Exit immediately on connection failure, which triggers "exit", below, which fails the test
client.on("error", function (err) {
console.error("client: " + err.stack);