@@ -681,4 +681,128 @@ describe('#compileMethodsToS3()', () => {
681
681
'method.request.path.key' : true
682
682
} )
683
683
} )
684
+
685
+ it ( 'should create corresponding resources when s3 GetObject proxy is given with path override' , ( ) => {
686
+ serverlessApigatewayServiceProxy . validated = {
687
+ events : [
688
+ {
689
+ serviceName : 's3' ,
690
+ http : {
691
+ path : '/{folder}/{item}' ,
692
+ method : 'get' ,
693
+ bucket : {
694
+ Ref : 'MyBucket'
695
+ } ,
696
+ action : 'GetObject' ,
697
+ key : {
698
+ pathParam : 'item'
699
+ } ,
700
+ pathoverride : '{folder}/{item}.xml' ,
701
+ auth : { authorizationType : 'NONE' } ,
702
+ requestParameters : {
703
+ 'integration.request.path.folder' : 'method.request.path.folder' ,
704
+ 'integration.request.path.item' : 'method.request.path.item'
705
+ }
706
+ }
707
+ }
708
+ ]
709
+ }
710
+ serverlessApigatewayServiceProxy . apiGatewayRestApiLogicalId = 'ApiGatewayRestApi'
711
+ serverlessApigatewayServiceProxy . apiGatewayResources = {
712
+ '/{folder}/{item}' : {
713
+ name : 'po' ,
714
+ resourceLogicalId : 'ApiGatewayPathOverrideS3'
715
+ }
716
+ }
717
+
718
+ serverlessApigatewayServiceProxy . compileMethodsToS3 ( )
719
+ expect ( serverless . service . provider . compiledCloudFormationTemplate . Resources ) . to . deep . equal ( {
720
+ ApiGatewayMethodpoGet : {
721
+ Type : 'AWS::ApiGateway::Method' ,
722
+ Properties : {
723
+ HttpMethod : 'GET' ,
724
+ RequestParameters : {
725
+ 'method.request.path.folder' : true ,
726
+ 'method.request.path.item' : true
727
+ } ,
728
+ AuthorizationType : 'NONE' ,
729
+ AuthorizationScopes : undefined ,
730
+ AuthorizerId : undefined ,
731
+ ApiKeyRequired : false ,
732
+ ResourceId : { Ref : 'ApiGatewayPathOverrideS3' } ,
733
+ RestApiId : { Ref : 'ApiGatewayRestApi' } ,
734
+ Integration : {
735
+ Type : 'AWS' ,
736
+ IntegrationHttpMethod : 'GET' ,
737
+ Credentials : { 'Fn::GetAtt' : [ 'ApigatewayToS3Role' , 'Arn' ] } ,
738
+ Uri : {
739
+ 'Fn::Sub' : [
740
+ 'arn:aws:apigateway:${AWS::Region}:s3:path/{bucket}/{folder}/{item}.xml' ,
741
+ { }
742
+ ]
743
+ } ,
744
+ PassthroughBehavior : 'WHEN_NO_MATCH' ,
745
+ RequestParameters : {
746
+ 'integration.request.path.bucket' : {
747
+ 'Fn::Sub' : [
748
+ "'${bucket}'" ,
749
+ {
750
+ bucket : {
751
+ Ref : 'MyBucket'
752
+ }
753
+ }
754
+ ]
755
+ } ,
756
+ 'integration.request.path.object' : 'method.request.path.item' ,
757
+ 'integration.request.path.folder' : 'method.request.path.folder' ,
758
+ 'integration.request.path.item' : 'method.request.path.item'
759
+ } ,
760
+ IntegrationResponses : [
761
+ {
762
+ StatusCode : 400 ,
763
+ SelectionPattern : '4\\d{2}' ,
764
+ ResponseParameters : { } ,
765
+ ResponseTemplates : { }
766
+ } ,
767
+ {
768
+ StatusCode : 500 ,
769
+ SelectionPattern : '5\\d{2}' ,
770
+ ResponseParameters : { } ,
771
+ ResponseTemplates : { }
772
+ } ,
773
+ {
774
+ StatusCode : 200 ,
775
+ SelectionPattern : '2\\d{2}' ,
776
+ ResponseParameters : {
777
+ 'method.response.header.Content-Type' : 'integration.response.header.Content-Type' ,
778
+ 'method.response.header.content-type' : 'integration.response.header.content-type'
779
+ } ,
780
+ ResponseTemplates : { }
781
+ }
782
+ ]
783
+ } ,
784
+ MethodResponses : [
785
+ {
786
+ ResponseParameters : {
787
+ 'method.response.header.Content-Type' : true ,
788
+ 'method.response.header.content-type' : true
789
+ } ,
790
+ ResponseModels : { } ,
791
+ StatusCode : 200
792
+ } ,
793
+ {
794
+ ResponseParameters : { } ,
795
+ ResponseModels : { } ,
796
+ StatusCode : 400
797
+ } ,
798
+ {
799
+ ResponseParameters : { } ,
800
+ ResponseModels : { } ,
801
+ StatusCode : 500
802
+ }
803
+ ]
804
+ }
805
+ }
806
+ } )
807
+ } )
684
808
} )
0 commit comments