@@ -187,22 +187,49 @@ describe('RefreshTokenGrantType integration', function() {
187187
188188 describe ( 'getRefreshToken()' , function ( ) {
189189 it ( 'should throw an error if the `refreshToken` parameter is missing from the request body' , async function ( ) {
190+ const client = { } ;
191+ const model = Model . from ( {
192+ getRefreshToken : ( ) => should . fail ( ) ,
193+ revokeToken : ( ) => should . fail ( ) ,
194+ saveToken : ( ) => should . fail ( )
195+ } ) ;
196+ const values = [ null , undefined ] ;
197+
198+ for ( const value of values ) {
199+ const grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model } ) ;
200+ const request = new Request ( { body : { refresh_token : value } , headers : { } , method : { } , query : { } } ) ;
201+
202+ try {
203+ await grantType . getRefreshToken ( request , client ) ;
204+
205+ should . fail ( ) ;
206+ } catch ( e ) {
207+ e . should . be . an . instanceOf ( InvalidRequestError ) ;
208+ e . message . should . equal ( 'Missing parameter: `refresh_token`' ) ;
209+ }
210+ }
211+ } ) ;
212+
213+ it ( 'should throw an error if `refreshToken` is not a valid format' , async ( ) => {
190214 const client = { } ;
191215 const model = Model . from ( {
192216 getRefreshToken : ( ) => should . fail ( ) ,
193217 revokeToken : ( ) => should . fail ( ) ,
194218 saveToken : ( ) => should . fail ( )
195219 } ) ;
196220 const grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model } ) ;
197- const request = new Request ( { body : { } , headers : { } , method : { } , query : { } } ) ;
221+ const values = [ 'toke😇n' , ( ) => { } , [ ] , Symbol ( 'test' ) ] ;
198222
199- try {
200- await grantType . getRefreshToken ( request , client ) ;
223+ for ( const value of values ) {
224+ const request = new Request ( { body : { refresh_token : value } , headers : { } , method : { } , query : { } } ) ;
225+ try {
226+ await grantType . getRefreshToken ( request , client ) ;
201227
202- should . fail ( ) ;
203- } catch ( e ) {
204- e . should . be . an . instanceOf ( InvalidRequestError ) ;
205- e . message . should . equal ( 'Missing parameter: `refresh_token`' ) ;
228+ should . fail ( ) ;
229+ } catch ( e ) {
230+ e . should . be . an . instanceOf ( InvalidRequestError ) ;
231+ e . message . should . equal ( 'Invalid parameter: `refresh_token`' ) ;
232+ }
206233 }
207234 } ) ;
208235
@@ -233,6 +260,7 @@ describe('RefreshTokenGrantType integration', function() {
233260 revokeToken : ( ) => should . fail ( ) ,
234261 saveToken : ( ) => should . fail ( )
235262 } ) ;
263+
236264 const grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model } ) ;
237265 const request = new Request ( { body : { refresh_token : '12345' } , headers : { } , method : { } , query : { } } ) ;
238266
@@ -255,16 +283,20 @@ describe('RefreshTokenGrantType integration', function() {
255283 revokeToken : ( ) => should . fail ( ) ,
256284 saveToken : ( ) => should . fail ( )
257285 } ) ;
258- const grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model } ) ;
259- const request = new Request ( { body : { refresh_token : '12345' } , headers : { } , method : { } , query : { } } ) ;
260286
261- try {
262- await grantType . getRefreshToken ( request , client ) ;
287+ const values = [ 12345 , '12345' ] ;
288+ for ( const value of values ) {
289+ const grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model } ) ;
290+ const request = new Request ( { body : { refresh_token : value } , headers : { } , method : { } , query : { } } ) ;
263291
264- should . fail ( ) ;
265- } catch ( e ) {
266- e . should . be . an . instanceOf ( ServerError ) ;
267- e . message . should . equal ( 'Server error: `getRefreshToken()` did not return a `user` object' ) ;
292+ try {
293+ await grantType . getRefreshToken ( request , client ) ;
294+
295+ should . fail ( ) ;
296+ } catch ( e ) {
297+ e . should . be . an . instanceOf ( ServerError ) ;
298+ e . message . should . equal ( 'Server error: `getRefreshToken()` did not return a `user` object' ) ;
299+ }
268300 }
269301 } ) ;
270302
0 commit comments