@@ -697,7 +697,7 @@ describe('#compileMethodsToS3()', () => {
697697 key : {
698698 pathParam : 'item'
699699 } ,
700- pathoverride : '{folder}/{item}.xml' ,
700+ pathOverride : '{folder}/{item}.xml' ,
701701 auth : { authorizationType : 'NONE' } ,
702702 requestParameters : {
703703 'integration.request.path.folder' : 'method.request.path.folder' ,
@@ -805,4 +805,122 @@ describe('#compileMethodsToS3()', () => {
805805 }
806806 } )
807807 } )
808+
809+ it ( 'should create corresponding resources when s3 GetObject proxy is given with a greedy path override' , ( ) => {
810+ serverlessApigatewayServiceProxy . validated = {
811+ events : [
812+ {
813+ serviceName : 's3' ,
814+ http : {
815+ path : '/{myPath+}' ,
816+ method : 'get' ,
817+ bucket : {
818+ Ref : 'MyBucket'
819+ } ,
820+ action : 'GetObject' ,
821+ key : {
822+ pathParam : 'myPath'
823+ } ,
824+ pathOverride : '{myPath}.xml' ,
825+ auth : { authorizationType : 'NONE' } ,
826+ requestParameters : {
827+ 'integration.request.path.myPath' : 'method.request.path.myPath'
828+ }
829+ }
830+ }
831+ ]
832+ }
833+ serverlessApigatewayServiceProxy . apiGatewayRestApiLogicalId = 'ApiGatewayRestApi'
834+ serverlessApigatewayServiceProxy . apiGatewayResources = {
835+ '/{myPath+}' : {
836+ name : 'greedyPath' ,
837+ resourceLogicalId : 'ApiGatewayPathOverrideS3'
838+ }
839+ }
840+
841+ serverlessApigatewayServiceProxy . compileMethodsToS3 ( )
842+ expect ( serverless . service . provider . compiledCloudFormationTemplate . Resources ) . to . deep . equal ( {
843+ ApiGatewayMethodgreedyPathGet : {
844+ Type : 'AWS::ApiGateway::Method' ,
845+ Properties : {
846+ HttpMethod : 'GET' ,
847+ RequestParameters : {
848+ 'method.request.path.myPath' : true
849+ } ,
850+ AuthorizationType : 'NONE' ,
851+ AuthorizationScopes : undefined ,
852+ AuthorizerId : undefined ,
853+ ApiKeyRequired : false ,
854+ ResourceId : { Ref : 'ApiGatewayPathOverrideS3' } ,
855+ RestApiId : { Ref : 'ApiGatewayRestApi' } ,
856+ Integration : {
857+ Type : 'AWS' ,
858+ IntegrationHttpMethod : 'GET' ,
859+ Credentials : { 'Fn::GetAtt' : [ 'ApigatewayToS3Role' , 'Arn' ] } ,
860+ Uri : {
861+ 'Fn::Sub' : [ 'arn:aws:apigateway:${AWS::Region}:s3:path/{bucket}/{myPath}.xml' , { } ]
862+ } ,
863+ PassthroughBehavior : 'WHEN_NO_MATCH' ,
864+ RequestParameters : {
865+ 'integration.request.path.bucket' : {
866+ 'Fn::Sub' : [
867+ "'${bucket}'" ,
868+ {
869+ bucket : {
870+ Ref : 'MyBucket'
871+ }
872+ }
873+ ]
874+ } ,
875+ 'integration.request.path.object' : 'method.request.path.myPath' ,
876+ 'integration.request.path.myPath' : 'method.request.path.myPath'
877+ } ,
878+ IntegrationResponses : [
879+ {
880+ StatusCode : 400 ,
881+ SelectionPattern : '4\\d{2}' ,
882+ ResponseParameters : { } ,
883+ ResponseTemplates : { }
884+ } ,
885+ {
886+ StatusCode : 500 ,
887+ SelectionPattern : '5\\d{2}' ,
888+ ResponseParameters : { } ,
889+ ResponseTemplates : { }
890+ } ,
891+ {
892+ StatusCode : 200 ,
893+ SelectionPattern : '2\\d{2}' ,
894+ ResponseParameters : {
895+ 'method.response.header.Content-Type' : 'integration.response.header.Content-Type' ,
896+ 'method.response.header.content-type' : 'integration.response.header.content-type'
897+ } ,
898+ ResponseTemplates : { }
899+ }
900+ ]
901+ } ,
902+ MethodResponses : [
903+ {
904+ ResponseParameters : {
905+ 'method.response.header.Content-Type' : true ,
906+ 'method.response.header.content-type' : true
907+ } ,
908+ ResponseModels : { } ,
909+ StatusCode : 200
910+ } ,
911+ {
912+ ResponseParameters : { } ,
913+ ResponseModels : { } ,
914+ StatusCode : 400
915+ } ,
916+ {
917+ ResponseParameters : { } ,
918+ ResponseModels : { } ,
919+ StatusCode : 500
920+ }
921+ ]
922+ }
923+ }
924+ } )
925+ } )
808926} )
0 commit comments