1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Check that the password is from type string

This commit is contained in:
Ruben Bridgewater
2015-09-15 22:33:46 +02:00
parent e24f056b2d
commit c269b7539c
2 changed files with 37 additions and 3 deletions

View File

@@ -48,12 +48,12 @@ describe("client authentication", function () {
client.auth(auth + 'bad');
});
it("returns an error when auth is bad with a callback", function (done) {
it("returns an error when auth is bad (empty string) with a callback", function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
client = redis.createClient.apply(redis.createClient, args);
client.auth(auth + 'bad', function (err, res) {
client.auth('', function (err, res) {
assert.strictEqual(err.command_used, 'AUTH');
assert.ok(/ERR invalid password/.test(err.message));
done();
@@ -122,6 +122,30 @@ describe("client authentication", function () {
}
});
});
it('should return an error if the password is not of type string and a callback has been provided', function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
client = redis.createClient.apply(redis.createClient, args);
client.auth(undefined, function(err, res) {
assert.strictEqual(err.message, 'The password has to be of type "string"');
assert.strictEqual(err.command_used, 'AUTH');
assert.strictEqual(res, undefined);
done();
});
});
it('should emit an error if the password is not of type string and no callback has been provided', function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
client = redis.createClient.apply(redis.createClient, args);
client.on('error', function (err) {
assert.strictEqual(err.message, 'The password has to be of type "string"');
assert.strictEqual(err.command_used, 'AUTH');
done();
});
client.auth(234567);
});
});
});