@@ -48,12 +48,12 @@ describe("client authentication", function () {
48
48
client . auth ( auth + 'bad' ) ;
49
49
} ) ;
50
50
51
- it ( "returns an error when auth is bad with a callback" , function ( done ) {
51
+ it ( "returns an error when auth is bad (empty string) with a callback" , function ( done ) {
52
52
if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
53
53
54
54
client = redis . createClient . apply ( redis . createClient , args ) ;
55
55
56
- client . auth ( auth + 'bad ', function ( err , res ) {
56
+ client . auth ( ' ', function ( err , res ) {
57
57
assert . strictEqual ( err . command_used , 'AUTH' ) ;
58
58
assert . ok ( / E R R i n v a l i d p a s s w o r d / . test ( err . message ) ) ;
59
59
done ( ) ;
@@ -122,6 +122,30 @@ describe("client authentication", function () {
122
122
}
123
123
} ) ;
124
124
} ) ;
125
+
126
+ it ( 'should return an error if the password is not of type string and a callback has been provided' , function ( done ) {
127
+ if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
128
+
129
+ client = redis . createClient . apply ( redis . createClient , args ) ;
130
+ client . auth ( undefined , function ( err , res ) {
131
+ assert . strictEqual ( err . message , 'The password has to be of type "string"' ) ;
132
+ assert . strictEqual ( err . command_used , 'AUTH' ) ;
133
+ assert . strictEqual ( res , undefined ) ;
134
+ done ( ) ;
135
+ } ) ;
136
+ } ) ;
137
+
138
+ it ( 'should emit an error if the password is not of type string and no callback has been provided' , function ( done ) {
139
+ if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
140
+
141
+ client = redis . createClient . apply ( redis . createClient , args ) ;
142
+ client . on ( 'error' , function ( err ) {
143
+ assert . strictEqual ( err . message , 'The password has to be of type "string"' ) ;
144
+ assert . strictEqual ( err . command_used , 'AUTH' ) ;
145
+ done ( ) ;
146
+ } ) ;
147
+ client . auth ( 234567 ) ;
148
+ } ) ;
125
149
} ) ;
126
150
} ) ;
127
151
0 commit comments