@@ -288,8 +288,10 @@ describe('#methods()', () => {
288288 method : 'post' ,
289289 } ;
290290
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 ) ;
293295 } ) ;
294296
295297 it ( 'should return resource properties with AuthorizationType: AWS_IAM' , ( ) => {
@@ -300,8 +302,10 @@ describe('#methods()', () => {
300302 } ,
301303 } ;
302304
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 ) ;
305309 } ) ;
306310
307311 it ( 'should return properties with AuthorizationType: CUSTOM and authotizerId' , ( ) => {
@@ -312,10 +316,11 @@ describe('#methods()', () => {
312316 } ,
313317 } ;
314318
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 ) ;
319324 } ) ;
320325
321326 it ( 'should return properties with AuthorizationType: CUSTOM and resource reference' , ( ) => {
@@ -328,11 +333,9 @@ describe('#methods()', () => {
328333 } ,
329334 } ;
330335
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 )
336339 . to . deep . equal ( { Ref : 'AuthorizerApiGatewayAuthorizer' } ) ;
337340 } ) ;
338341
@@ -341,14 +344,41 @@ describe('#methods()', () => {
341344 authorizer : {
342345 name : 'authorizer' ,
343346 arn : 'arn:aws:cognito-idp:us-east-1:xxx:userpool/us-east-1_ZZZ' ,
347+ scopes : [
348+ 'scope1' ,
349+ 'scope2' ,
350+ ] ,
344351 } ,
345352 } ;
346353
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 )
351357 . 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' ] ) ;
352382 } ) ;
353383 } ) ;
354384} ) ;
0 commit comments