@@ -48,12 +48,12 @@ describe("client authentication", function () {
4848 client . auth ( auth + 'bad' ) ;
4949 } ) ;
5050
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 ) {
5252 if ( helper . redisProcess ( ) . spawnFailed ( ) ) this . skip ( ) ;
5353
5454 client = redis . createClient . apply ( redis . createClient , args ) ;
5555
56- client . auth ( auth + 'bad ', function ( err , res ) {
56+ client . auth ( ' ', function ( err , res ) {
5757 assert . strictEqual ( err . command_used , 'AUTH' ) ;
5858 assert . ok ( / E R R i n v a l i d p a s s w o r d / . test ( err . message ) ) ;
5959 done ( ) ;
@@ -122,6 +122,30 @@ describe("client authentication", function () {
122122 }
123123 } ) ;
124124 } ) ;
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+ } ) ;
125149 } ) ;
126150 } ) ;
127151
0 commit comments