@@ -11,9 +11,6 @@ const template = {
1111 Type : 'AWS::ApiGateway::Method' ,
1212 Properties : {
1313 RequestParameters : { } ,
14- AuthorizationType : 'NONE' ,
15- AuthorizationScopes : undefined ,
16- AuthorizerId : undefined ,
1714 ApiKeyRequired : false ,
1815 ResourceId : { Ref : 'ApiGatewayResourceS3' } ,
1916 RestApiId : { Ref : 'ApiGatewayRestApi' } ,
@@ -104,6 +101,9 @@ describe('#compileMethodsToS3()', () => {
104101 const diff = {
105102 Properties : {
106103 HttpMethod : method ,
104+ AuthorizationType : http . auth . authorizationType ,
105+ AuthorizationScopes : http . auth . authorizationScopes ,
106+ AuthorizerId : http . auth . authorizerId ,
107107 RequestParameters : requestParams ,
108108 Integration : {
109109 IntegrationHttpMethod : intMethod ,
@@ -471,4 +471,70 @@ describe('#compileMethodsToS3()', () => {
471471 }
472472 } )
473473 } )
474+
475+ const testAuthorization = ( auth ) => {
476+ const http = {
477+ path : 's3' ,
478+ method : 'get' ,
479+ bucket : {
480+ Ref : 'MyBucket'
481+ } ,
482+ action : 'GetObject' ,
483+ key : { pathParam : 'key' } ,
484+ auth
485+ }
486+
487+ const requestParams = { 'method.request.path.key' : true }
488+
489+ const intRequestParams = {
490+ 'integration.request.path.object' : 'method.request.path.key' ,
491+ 'integration.request.path.bucket' : {
492+ 'Fn::Sub' : [
493+ "'${bucket}'" ,
494+ {
495+ bucket : {
496+ Ref : 'MyBucket'
497+ }
498+ }
499+ ]
500+ }
501+ }
502+
503+ const responseParams = {
504+ 'method.response.header.content-type' : true ,
505+ 'method.response.header.Content-Type' : true
506+ }
507+
508+ const intResponseParams = {
509+ 'method.response.header.content-type' : 'integration.response.header.content-type' ,
510+ 'method.response.header.Content-Type' : 'integration.response.header.Content-Type'
511+ }
512+
513+ testSingleProxy ( {
514+ http,
515+ logicalId : 'ApiGatewayMethods3Get' ,
516+ method : 'GET' ,
517+ intMethod : 'GET' ,
518+ requestParams,
519+ intRequestParams,
520+ responseParams,
521+ intResponseParams
522+ } )
523+ }
524+
525+ it ( 'should create corresponding resources with "NONE" authorization type' , ( ) => {
526+ testAuthorization ( { authorizationType : 'NONE' } )
527+ } )
528+
529+ it ( 'should create corresponding resources with "CUSTOM" authorization type' , ( ) => {
530+ testAuthorization ( { authorizationType : 'CUSTOM' , authorizerId : { Ref : 'AuthorizerLogicalId' } } )
531+ } )
532+
533+ it ( 'should create corresponding resources with "AWS_IAM" authorization type' , ( ) => {
534+ testAuthorization ( { authorizationType : 'AWS_IAM' } )
535+ } )
536+
537+ it ( 'should create corresponding resources with "AWS_IAM" authorization type' , ( ) => {
538+ testAuthorization ( { authorizationType : 'COGNITO_USER_POOLS' , authorizationScopes : [ 'admin' ] } )
539+ } )
474540} )
0 commit comments