33var assert = require ( 'assert' ) ;
44var config = require ( './lib/config' ) ;
55var helper = require ( './helper' ) ;
6+ var errors = require ( './errors' ) ;
67var redis = config . redis ;
78
89if ( process . platform === 'win32' ) {
@@ -70,11 +71,13 @@ describe('client authentication', function () {
7071 it ( 'emits error when auth is bad without callback' , function ( done ) {
7172 if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
7273
73- client = redis . createClient . apply ( null , args ) ;
74+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
75+ no_ready_check : true
76+ } ) ) ;
7477
7578 client . once ( 'error' , function ( err ) {
7679 assert . strictEqual ( err . command , 'AUTH' ) ;
77- assert . ok ( / E R R i n v a l i d p a s s w o r d / . test ( err . message ) ) ;
80+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
7881 return done ( ) ;
7982 } ) ;
8083
@@ -84,11 +87,13 @@ describe('client authentication', function () {
8487 it ( 'returns an error when auth is bad (empty string) with a callback' , function ( done ) {
8588 if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
8689
87- client = redis . createClient . apply ( null , args ) ;
90+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
91+ no_ready_check : true
92+ } ) ) ;
8893
8994 client . auth ( '' , function ( err , res ) {
9095 assert . strictEqual ( err . command , 'AUTH' ) ;
91- assert . ok ( / E R R i n v a l i d p a s s w o r d / . test ( err . message ) ) ;
96+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
9297 done ( ) ;
9398 } ) ;
9499 } ) ;
@@ -190,10 +195,12 @@ describe('client authentication', function () {
190195 it ( 'should return an error if the password is not correct and a callback has been provided' , function ( done ) {
191196 if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
192197
193- client = redis . createClient . apply ( null , args ) ;
198+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
199+ no_ready_check : true
200+ } ) ) ;
194201 var async = true ;
195202 client . auth ( 'undefined' , function ( err , res ) {
196- assert . strictEqual ( err . message , 'ERR invalid password' ) ;
203+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
197204 assert . strictEqual ( err . command , 'AUTH' ) ;
198205 assert . strictEqual ( res , undefined ) ;
199206 async = false ;
@@ -205,9 +212,11 @@ describe('client authentication', function () {
205212 it ( 'should emit an error if the password is not correct and no callback has been provided' , function ( done ) {
206213 if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
207214
208- client = redis . createClient . apply ( null , args ) ;
215+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
216+ no_ready_check : true
217+ } ) ) ;
209218 client . on ( 'error' , function ( err ) {
210- assert . strictEqual ( err . message , 'ERR invalid password' ) ;
219+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
211220 assert . strictEqual ( err . command , 'AUTH' ) ;
212221 done ( ) ;
213222 } ) ;
@@ -235,7 +244,7 @@ describe('client authentication', function () {
235244 client = redis . createClient . apply ( null , args ) ;
236245 client . on ( 'ready' , function ( ) {
237246 client . set ( 'foo' , 'bar' , function ( err , res ) {
238- assert . equal ( err . message , ' NOAUTH Authentication required.' ) ;
247+ assert . ok ( / ^ N O A U T H A u t h e n t i c a t i o n r e q u i r e d \. ( \r \n ) ? $ / . test ( err . message ) ) ;
239248 assert . equal ( err . code , 'NOAUTH' ) ;
240249 assert . equal ( err . command , 'SET' ) ;
241250 done ( ) ;
@@ -248,7 +257,7 @@ describe('client authentication', function () {
248257 client = redis . createClient . apply ( null , args ) ;
249258 client . on ( 'error' , function ( err ) {
250259 assert . equal ( err . code , 'NOAUTH' ) ;
251- assert . equal ( err . message , ' Ready check failed: NOAUTH Authentication required.' ) ;
260+ assert . ok ( / ^ R e a d y c h e c k f a i l e d : N O A U T H A u t h e n t i c a t i o n r e q u i r e d \. ( \r \n ) ? $ / . test ( err . message ) ) ;
252261 assert . equal ( err . command , 'INFO' ) ;
253262 done ( ) ;
254263 } ) ;
@@ -258,9 +267,10 @@ describe('client authentication', function () {
258267 if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
259268 client = redis . createClient ( {
260269 password : 'wrong_password' ,
270+ no_ready_check : true
261271 } ) ;
262272 client . once ( 'error' , function ( err ) {
263- assert . strictEqual ( err . message , 'ERR invalid password' ) ;
273+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
264274 done ( ) ;
265275 } ) ;
266276 } ) ;
@@ -277,7 +287,7 @@ describe('client authentication', function () {
277287 client . once ( 'ready' , function ( ) {
278288 assert . strictEqual ( client . pub_sub_mode , 1 ) ;
279289 client . get ( 'foo' , function ( err , res ) {
280- assert ( / E R R o n l y \( P \) S U B S C R I B E \/ \( P \) U N S U B S C R I B E / . test ( err . message ) ) ;
290+ assert . ok ( errors . subscribeUnsubscribeOnly . test ( err . message ) ) ;
281291 done ( ) ;
282292 } ) ;
283293 } ) ;
0 commit comments