@@ -288,8 +288,10 @@ describe('#methods()', () => {
288
288
method : 'post' ,
289
289
} ;
290
290
291
- expect ( serverlessStepFunctions . getMethodAuthorization ( event )
292
- . Properties . AuthorizationType ) . to . equal ( 'NONE' ) ;
291
+ const authorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
292
+
293
+ expect ( authorization . Properties . AuthorizationType ) . to . equal ( 'NONE' ) ;
294
+ expect ( authorization . Properties . AuthorizationScopes ) . to . equal ( undefined ) ;
293
295
} ) ;
294
296
295
297
it ( 'should return resource properties with AuthorizationType: AWS_IAM' , ( ) => {
@@ -300,8 +302,10 @@ describe('#methods()', () => {
300
302
} ,
301
303
} ;
302
304
303
- expect ( serverlessStepFunctions . getMethodAuthorization ( event )
304
- . Properties . AuthorizationType ) . to . equal ( 'AWS_IAM' ) ;
305
+ const authorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
306
+
307
+ expect ( authorization . Properties . AuthorizationType ) . to . equal ( 'AWS_IAM' ) ;
308
+ expect ( authorization . Properties . AuthorizationScopes ) . to . equal ( undefined ) ;
305
309
} ) ;
306
310
307
311
it ( 'should return properties with AuthorizationType: CUSTOM and authotizerId' , ( ) => {
@@ -312,10 +316,11 @@ describe('#methods()', () => {
312
316
} ,
313
317
} ;
314
318
315
- expect ( serverlessStepFunctions . getMethodAuthorization ( event )
316
- . Properties . AuthorizationType ) . to . equal ( 'CUSTOM' ) ;
317
- expect ( serverlessStepFunctions . getMethodAuthorization ( event )
318
- . Properties . AuthorizerId ) . to . equal ( 'foo12345' ) ;
319
+ const authorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
320
+
321
+ expect ( authorization . Properties . AuthorizationType ) . to . equal ( 'CUSTOM' ) ;
322
+ expect ( authorization . Properties . AuthorizerId ) . to . equal ( 'foo12345' ) ;
323
+ expect ( authorization . Properties . AuthorizationScopes ) . to . equal ( undefined ) ;
319
324
} ) ;
320
325
321
326
it ( 'should return properties with AuthorizationType: CUSTOM and resource reference' , ( ) => {
@@ -328,11 +333,9 @@ describe('#methods()', () => {
328
333
} ,
329
334
} ;
330
335
331
- const autorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
332
- expect ( autorization . Properties . AuthorizationType )
333
- . to . equal ( 'CUSTOM' ) ;
334
-
335
- expect ( autorization . Properties . AuthorizerId )
336
+ const authorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
337
+ expect ( authorization . Properties . AuthorizationType ) . to . equal ( 'CUSTOM' ) ;
338
+ expect ( authorization . Properties . AuthorizerId )
336
339
. to . deep . equal ( { Ref : 'AuthorizerApiGatewayAuthorizer' } ) ;
337
340
} ) ;
338
341
@@ -341,14 +344,41 @@ describe('#methods()', () => {
341
344
authorizer : {
342
345
name : 'authorizer' ,
343
346
arn : 'arn:aws:cognito-idp:us-east-1:xxx:userpool/us-east-1_ZZZ' ,
347
+ scopes : [
348
+ 'scope1' ,
349
+ 'scope2' ,
350
+ ] ,
344
351
} ,
345
352
} ;
346
353
347
- const autorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
348
- expect ( autorization . Properties . AuthorizationType )
349
- . to . equal ( 'COGNITO_USER_POOLS' ) ;
350
- expect ( autorization . Properties . AuthorizerId )
354
+ const authorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
355
+ expect ( authorization . Properties . AuthorizationType ) . to . equal ( 'COGNITO_USER_POOLS' ) ;
356
+ expect ( authorization . Properties . AuthorizerId )
351
357
. to . deep . equal ( { Ref : 'AuthorizerApiGatewayAuthorizer' } ) ;
358
+ expect ( authorization . Properties . AuthorizationScopes )
359
+ . to . deep . equal ( [ 'scope1' , 'scope2' ] ) ;
360
+ } ) ;
361
+
362
+ it ( 'should return properties with AuthorizationType when type is "COGNITO_USER_POOLS"' , ( ) => {
363
+ const event = {
364
+ authorizer : {
365
+ type : 'COGNITO_USER_POOLS' ,
366
+ authorizerId : {
367
+ Ref : 'ApiGatewayAuthorizer' ,
368
+ } ,
369
+ scopes : [
370
+ 'scope1' ,
371
+ 'scope2' ,
372
+ ] ,
373
+ } ,
374
+ } ;
375
+
376
+ const authorization = serverlessStepFunctions . getMethodAuthorization ( event ) ;
377
+ expect ( authorization . Properties . AuthorizationType ) . to . equal ( 'COGNITO_USER_POOLS' ) ;
378
+ expect ( authorization . Properties . AuthorizerId )
379
+ . to . deep . equal ( { Ref : 'ApiGatewayAuthorizer' } ) ;
380
+ expect ( authorization . Properties . AuthorizationScopes )
381
+ . to . deep . equal ( [ 'scope1' , 'scope2' ] ) ;
352
382
} ) ;
353
383
} ) ;
354
384
} ) ;
0 commit comments