@@ -170,7 +170,7 @@ describe('RefreshTokenGrantType integration', function() {
170170 } ) ;
171171
172172 describe ( 'getRefreshToken()' , function ( ) {
173- it ( 'should throw an error if the requested `refreshToken` is missing' , function ( ) {
173+ it ( 'should throw an error if the `refreshToken` parameter is missing from the request body ' , function ( ) {
174174 var client = { } ;
175175 var model = {
176176 getRefreshToken : function ( ) { } ,
@@ -190,35 +190,15 @@ describe('RefreshTokenGrantType integration', function() {
190190 }
191191 } ) ;
192192
193- it ( 'should throw an error if the requested `refreshToken` is invalid' , function ( ) {
194- var client = { } ;
195- var model = {
196- getRefreshToken : function ( ) { } ,
197- revokeToken : function ( ) { } ,
198- saveToken : function ( ) { }
199- } ;
200- var grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model : model } ) ;
201- var request = new Request ( { body : { refresh_token : [ ] } , headers : { } , method : { } , query : { } } ) ;
202-
203- try {
204- grantType . getRefreshToken ( request , client ) ;
205-
206- should . fail ( ) ;
207- } catch ( e ) {
208- e . should . be . an . instanceOf ( InvalidRequestError ) ;
209- e . message . should . equal ( 'Invalid parameter: `refresh_token`' ) ;
210- }
211- } ) ;
212-
213- it ( 'should throw an error if `refreshToken` is missing' , function ( ) {
214- var client = { } ;
193+ it ( 'should throw an error if `refreshToken` is not found' , function ( ) {
194+ var client = { id : 123 } ;
215195 var model = {
216- getRefreshToken : function ( ) { return { accessToken : 'foo' , client : { id : 123 } , user : { } } ; } ,
196+ getRefreshToken : function ( ) { return ; } ,
217197 revokeToken : function ( ) { } ,
218198 saveToken : function ( ) { }
219199 } ;
220200 var grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model : model } ) ;
221- var request = new Request ( { body : { refresh_token : 12345 } , headers : { } , method : { } , query : { } } ) ;
201+ var request = new Request ( { body : { refresh_token : ' 12345' } , headers : { } , method : { } , query : { } } ) ;
222202
223203 return grantType . getRefreshToken ( request , client )
224204 . then ( should . fail )
@@ -286,29 +266,7 @@ describe('RefreshTokenGrantType integration', function() {
286266 } ) ;
287267 } ) ;
288268
289- it ( 'should throw an error if the request body does not contain `refresh_token`' , function ( ) {
290- var client = { } ;
291- var model = {
292- getRefreshToken : function ( ) {
293- return { client : { id : 456 } , user : { } } ;
294- } ,
295- revokeToken : function ( ) { } ,
296- saveToken : function ( ) { }
297- } ;
298- var grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model : model } ) ;
299- var request = new Request ( { body : { } , headers : { } , method : { } , query : { } } ) ;
300-
301- try {
302- grantType . getRefreshToken ( request , client ) ;
303-
304- should . fail ( ) ;
305- } catch ( e ) {
306- e . should . be . an . instanceOf ( InvalidRequestError ) ;
307- e . message . should . equal ( 'Missing parameter: `refresh_token`' ) ;
308- }
309- } ) ;
310-
311- it ( 'should throw an error if `refresh_token` is invalid' , function ( ) {
269+ it ( 'should throw an error if `refresh_token` contains invalid characters' , function ( ) {
312270 var client = { } ;
313271 var model = {
314272 getRefreshToken : function ( ) {
@@ -371,6 +329,26 @@ describe('RefreshTokenGrantType integration', function() {
371329 } ) ;
372330 } ) ;
373331
332+ it ( 'should throw an error if `refreshTokenExpiresAt` is not a date value' , function ( ) {
333+ var client = { id : 123 } ;
334+ var model = {
335+ getRefreshToken : function ( ) {
336+ return { accessToken : 'foo' , client : { id : 123 } , refreshTokenExpiresAt : 'stringvalue' , user : { } } ;
337+ } ,
338+ revokeToken : function ( ) { } ,
339+ saveToken : function ( ) { }
340+ } ;
341+ var grantType = new RefreshTokenGrantType ( { accessTokenLifetime : 120 , model : model } ) ;
342+ var request = new Request ( { body : { refresh_token : 12345 } , headers : { } , method : { } , query : { } } ) ;
343+
344+ return grantType . getRefreshToken ( request , client )
345+ . then ( should . fail )
346+ . catch ( function ( e ) {
347+ e . should . be . an . instanceOf ( ServerError ) ;
348+ e . message . should . equal ( 'Server error: `refreshTokenExpiresAt` must be a Date instance' ) ;
349+ } ) ;
350+ } ) ;
351+
374352 it ( 'should return a token' , function ( ) {
375353 var client = { id : 123 } ;
376354 var token = { accessToken : 'foo' , client : { id : 123 } , user : { } } ;
0 commit comments