3
3
var assert = require ( 'assert' ) ;
4
4
var config = require ( './lib/config' ) ;
5
5
var helper = require ( './helper' ) ;
6
+ var errors = require ( './errors' ) ;
6
7
var redis = config . redis ;
7
8
8
9
if ( process . platform === 'win32' ) {
@@ -70,11 +71,13 @@ describe('client authentication', function () {
70
71
it ( 'emits error when auth is bad without callback' , function ( done ) {
71
72
if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
72
73
73
- client = redis . createClient . apply ( null , args ) ;
74
+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
75
+ no_ready_check : true
76
+ } ) ) ;
74
77
75
78
client . once ( 'error' , function ( err ) {
76
79
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 ) ) ;
78
81
return done ( ) ;
79
82
} ) ;
80
83
@@ -84,11 +87,13 @@ describe('client authentication', function () {
84
87
it ( 'returns an error when auth is bad (empty string) with a callback' , function ( done ) {
85
88
if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
86
89
87
- client = redis . createClient . apply ( null , args ) ;
90
+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
91
+ no_ready_check : true
92
+ } ) ) ;
88
93
89
94
client . auth ( '' , function ( err , res ) {
90
95
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 ) ) ;
92
97
done ( ) ;
93
98
} ) ;
94
99
} ) ;
@@ -190,10 +195,12 @@ describe('client authentication', function () {
190
195
it ( 'should return an error if the password is not correct and a callback has been provided' , function ( done ) {
191
196
if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
192
197
193
- client = redis . createClient . apply ( null , args ) ;
198
+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
199
+ no_ready_check : true
200
+ } ) ) ;
194
201
var async = true ;
195
202
client . auth ( 'undefined' , function ( err , res ) {
196
- assert . strictEqual ( err . message , 'ERR invalid password' ) ;
203
+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
197
204
assert . strictEqual ( err . command , 'AUTH' ) ;
198
205
assert . strictEqual ( res , undefined ) ;
199
206
async = false ;
@@ -205,9 +212,11 @@ describe('client authentication', function () {
205
212
it ( 'should emit an error if the password is not correct and no callback has been provided' , function ( done ) {
206
213
if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
207
214
208
- client = redis . createClient . apply ( null , args ) ;
215
+ client = redis . createClient . apply ( null , config . configureClient ( ip , {
216
+ no_ready_check : true
217
+ } ) ) ;
209
218
client . on ( 'error' , function ( err ) {
210
- assert . strictEqual ( err . message , 'ERR invalid password' ) ;
219
+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
211
220
assert . strictEqual ( err . command , 'AUTH' ) ;
212
221
done ( ) ;
213
222
} ) ;
@@ -235,7 +244,7 @@ describe('client authentication', function () {
235
244
client = redis . createClient . apply ( null , args ) ;
236
245
client . on ( 'ready' , function ( ) {
237
246
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 ) ) ;
239
248
assert . equal ( err . code , 'NOAUTH' ) ;
240
249
assert . equal ( err . command , 'SET' ) ;
241
250
done ( ) ;
@@ -248,7 +257,7 @@ describe('client authentication', function () {
248
257
client = redis . createClient . apply ( null , args ) ;
249
258
client . on ( 'error' , function ( err ) {
250
259
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 ) ) ;
252
261
assert . equal ( err . command , 'INFO' ) ;
253
262
done ( ) ;
254
263
} ) ;
@@ -258,9 +267,10 @@ describe('client authentication', function () {
258
267
if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
259
268
client = redis . createClient ( {
260
269
password : 'wrong_password' ,
270
+ no_ready_check : true
261
271
} ) ;
262
272
client . once ( 'error' , function ( err ) {
263
- assert . strictEqual ( err . message , 'ERR invalid password' ) ;
273
+ assert . ok ( errors . invalidPassword . test ( err . message ) ) ;
264
274
done ( ) ;
265
275
} ) ;
266
276
} ) ;
@@ -277,7 +287,7 @@ describe('client authentication', function () {
277
287
client . once ( 'ready' , function ( ) {
278
288
assert . strictEqual ( client . pub_sub_mode , 1 ) ;
279
289
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 ) ) ;
281
291
done ( ) ;
282
292
} ) ;
283
293
} ) ;
0 commit comments