@@ -567,4 +567,63 @@ describe('#compileMethodsToS3()', () => {
567
567
568
568
expect ( serverless . service . provider . compiledCloudFormationTemplate . Resources ) . to . be . empty
569
569
} )
570
+
571
+ const testRequestParameters = ( requestParametersOverride ) => {
572
+ const http = {
573
+ path : 's3' ,
574
+ method : 'post' ,
575
+ bucket : {
576
+ Ref : 'MyBucket'
577
+ } ,
578
+ action : 'PutObject' ,
579
+ key : 'static' ,
580
+ auth : { authorizationType : 'NONE' } ,
581
+ requestParameters : requestParametersOverride
582
+ }
583
+
584
+ const requestParams = {
585
+ 'method.request.header.Content-Type' : true
586
+ }
587
+
588
+ const intRequestParams = {
589
+ 'integration.request.path.object' : 'method.request.path.key' ,
590
+ 'integration.request.path.bucket' : {
591
+ 'Fn::Sub' : [
592
+ "'${bucket}'" ,
593
+ {
594
+ bucket : {
595
+ Ref : 'MyBucket'
596
+ }
597
+ }
598
+ ]
599
+ } ,
600
+ 'integration.request.header.x-amz-acl' : "'authenticated-read'" ,
601
+ 'integration.request.header.Content-Type' : 'method.request.header.Content-Type'
602
+ }
603
+
604
+ const responseParams = {
605
+ 'method.response.header.Content-Type' : true ,
606
+ 'method.response.header.Content-Length' : true
607
+ }
608
+
609
+ const intResponseParams = {
610
+ 'method.response.header.Content-Type' : 'integration.response.header.Content-Type' ,
611
+ 'method.response.header.Content-Length' : 'integration.response.header.Content-Length'
612
+ }
613
+
614
+ testSingleProxy ( {
615
+ http,
616
+ logicalId : 'ApiGatewayMethods3Post' ,
617
+ method : 'POST' ,
618
+ intMethod : 'PUT' ,
619
+ requestParams : requestParams ,
620
+ intRequestParams : _ . merge ( intRequestParams , requestParametersOverride ) ,
621
+ responseParams,
622
+ intResponseParams
623
+ } )
624
+ }
625
+
626
+ it ( 'should add custom request parameters mapping' , ( ) => {
627
+ testRequestParameters ( { 'integration.request.path.object' : 'context.requestId' } )
628
+ } )
570
629
} )
0 commit comments