From 8f31ac60caa23e1e1f5c144577b8bd2ddb4e36c2 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 29 Sep 2014 11:40:40 +0100 Subject: [PATCH] if password is passed rename it to auth_pass --- libraries/redis-wrapper/index.coffee | 4 +++- libraries/redis-wrapper/package.json | 2 +- libraries/redis-wrapper/test.coffee | 29 +++++++++++++++++++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/libraries/redis-wrapper/index.coffee b/libraries/redis-wrapper/index.coffee index 4c8a028d8e..1135d90c36 100644 --- a/libraries/redis-wrapper/index.coffee +++ b/libraries/redis-wrapper/index.coffee @@ -3,7 +3,9 @@ _ = require("underscore") module.exports = createClient: (opts)-> - + if opts.password? + opts.auth_pass = opts.password + delete opts.password if opts.endpoints? standardOpts = _.clone(opts) delete standardOpts.endpoints diff --git a/libraries/redis-wrapper/package.json b/libraries/redis-wrapper/package.json index e221b1c537..43026b0085 100644 --- a/libraries/redis-wrapper/package.json +++ b/libraries/redis-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "redis-sharelatex", - "version": "0.0.2", + "version": "0.0.3", "description": "redis wrapper for node which will either use sentinal or normal redis", "main": "index.coffee", "author": "henry oswald @ sharelatex", diff --git a/libraries/redis-wrapper/test.coffee b/libraries/redis-wrapper/test.coffee index 50f551331c..f166c34ba8 100644 --- a/libraries/redis-wrapper/test.coffee +++ b/libraries/redis-wrapper/test.coffee @@ -22,14 +22,14 @@ describe "index", -> "redis-sentinel":@sentinel "redis":@normalRedis @auth_pass = "1234 pass" - - describe "sentinel", -> - - beforeEach -> - @endpoints = [ + @endpoints = [ {host: '127.0.0.1', port: 26379}, {host: '127.0.0.1', port: 26380} ] + describe "sentinel", -> + + beforeEach -> + @masterName = "my master" @sentinelOptions = endpoints:@endpoints @@ -67,5 +67,24 @@ describe "index", -> + describe "setting the password", -> + beforeEach -> + @standardOpts = + password: @auth_pass + port: 1234 + host: "redis.mysite.env" + + @sentinelOptions = + endpoints:@endpoints + masterName:@masterName + password: @auth_pass + + it "should set the auth_pass from password if password exists for normal redis", -> + client = @redis.createClient @standardOpts + @normalRedis.createClient.calledWith(@standardOpts.port, @standardOpts.host, auth_pass:@auth_pass).should.equal true + + it "should set the auth_pass from password if password exists for sentinal", -> + client = @redis.createClient @sentinelOptions + @sentinel.createClient.calledWith(@endpoints, @masterName, auth_pass:@auth_pass).should.equal true