@@ -177,11 +177,12 @@ describe('PasswordGrantType integration', function() {
177
177
getUser : ( ) => should . fail ( ) ,
178
178
saveToken : ( ) => should . fail ( )
179
179
} ;
180
+ const client = { id : 'foobar' } ;
180
181
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
181
182
const request = new Request ( { body : { } , headers : { } , method : { } , query : { } } ) ;
182
183
183
184
try {
184
- await grantType . getUser ( request ) ;
185
+ await grantType . getUser ( request , client ) ;
185
186
186
187
should . fail ( ) ;
187
188
} catch ( e ) {
@@ -195,11 +196,12 @@ describe('PasswordGrantType integration', function() {
195
196
getUser : ( ) => should . fail ( ) ,
196
197
saveToken : ( ) => should . fail ( )
197
198
} ;
199
+ const client = { id : 'foobar' } ;
198
200
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
199
201
const request = new Request ( { body : { username : 'foo' } , headers : { } , method : { } , query : { } } ) ;
200
202
201
203
try {
202
- await grantType . getUser ( request ) ;
204
+ await grantType . getUser ( request , client ) ;
203
205
204
206
should . fail ( ) ;
205
207
} catch ( e ) {
@@ -213,11 +215,12 @@ describe('PasswordGrantType integration', function() {
213
215
getUser : ( ) => should . fail ( ) ,
214
216
saveToken : ( ) => should . fail ( )
215
217
} ;
218
+ const client = { id : 'foobar' } ;
216
219
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
217
220
const request = new Request ( { body : { username : '\r\n' , password : 'foobar' } , headers : { } , method : { } , query : { } } ) ;
218
221
219
222
try {
220
- await grantType . getUser ( request ) ;
223
+ await grantType . getUser ( request , client ) ;
221
224
222
225
should . fail ( ) ;
223
226
} catch ( e ) {
@@ -231,11 +234,12 @@ describe('PasswordGrantType integration', function() {
231
234
getUser : ( ) => should . fail ( ) ,
232
235
saveToken : ( ) => should . fail ( )
233
236
} ;
237
+ const client = { id : 'foobar' } ;
234
238
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
235
239
const request = new Request ( { body : { username : 'foobar' , password : '\r\n' } , headers : { } , method : { } , query : { } } ) ;
236
240
237
241
try {
238
- await grantType . getUser ( request ) ;
242
+ await grantType . getUser ( request , client ) ;
239
243
240
244
should . fail ( ) ;
241
245
} catch ( e ) {
@@ -249,11 +253,12 @@ describe('PasswordGrantType integration', function() {
249
253
getUser : async ( ) => undefined ,
250
254
saveToken : ( ) => should . fail ( )
251
255
} ;
256
+ const client = { id : 'foobar' } ;
252
257
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
253
258
const request = new Request ( { body : { username : 'foo' , password : 'bar' } , headers : { } , method : { } , query : { } } ) ;
254
259
255
260
try {
256
- await grantType . getUser ( request ) ;
261
+ await grantType . getUser ( request , client ) ;
257
262
should . fail ( ) ;
258
263
} catch ( e ) {
259
264
e . should . be . an . instanceOf ( InvalidGrantError ) ;
@@ -263,6 +268,7 @@ describe('PasswordGrantType integration', function() {
263
268
264
269
it ( 'should return a user' , async function ( ) {
265
270
const user = { email :
'[email protected] ' } ;
271
+ const client = { id : 'foobar' } ;
266
272
const model = {
267
273
getUser : function ( username , password ) {
268
274
username . should . equal ( 'foo' ) ;
@@ -274,32 +280,34 @@ describe('PasswordGrantType integration', function() {
274
280
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
275
281
const request = new Request ( { body : { username : 'foo' , password : 'bar' } , headers : { } , method : { } , query : { } } ) ;
276
282
277
- const data = await grantType . getUser ( request ) ;
283
+ const data = await grantType . getUser ( request , client ) ;
278
284
data . should . equal ( user ) ;
279
285
} ) ;
280
286
281
287
it ( 'should support promises' , function ( ) {
282
288
const user = { email :
'[email protected] ' } ;
289
+ const client = { id : 'foobar' } ;
283
290
const model = {
284
291
getUser : async function ( ) { return user ; } ,
285
292
saveToken : ( ) => should . fail ( )
286
293
} ;
287
294
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
288
295
const request = new Request ( { body : { username : 'foo' , password : 'bar' } , headers : { } , method : { } , query : { } } ) ;
289
296
290
- grantType . getUser ( request ) . should . be . an . instanceOf ( Promise ) ;
297
+ grantType . getUser ( request , client ) . should . be . an . instanceOf ( Promise ) ;
291
298
} ) ;
292
299
293
300
it ( 'should support non-promises' , function ( ) {
294
301
const user = { email :
'[email protected] ' } ;
302
+ const client = { id : 'foobar' } ;
295
303
const model = {
296
304
getUser : function ( ) { return user ; } ,
297
305
saveToken : ( ) => should . fail ( )
298
306
} ;
299
307
const grantType = new PasswordGrantType ( { accessTokenLifetime : 123 , model } ) ;
300
308
const request = new Request ( { body : { username : 'foo' , password : 'bar' } , headers : { } , method : { } , query : { } } ) ;
301
309
302
- grantType . getUser ( request ) . should . be . an . instanceOf ( Promise ) ;
310
+ grantType . getUser ( request , client ) . should . be . an . instanceOf ( Promise ) ;
303
311
} ) ;
304
312
} ) ;
305
313
0 commit comments