@@ -1149,5 +1149,52 @@ describe('internal-extension/index.test.js', () => {
1149
1149
delete strippedPayload . body ;
1150
1150
expect ( JSON . parse ( request . input . body ) ) . to . deep . equal ( strippedPayload ) ;
1151
1151
} ) ;
1152
+
1153
+ it ( 'should strip large request bodies' , async ( ) => {
1154
+ const payload = {
1155
+ version : '2.0' ,
1156
+ routeKey : 'POST /v2' ,
1157
+ rawPath : '/v2' ,
1158
+ rawQueryString : 'lone=value&multi=one,stillone&multi=two' ,
1159
+ headers : {
1160
+ 'content-length' : '385' ,
1161
+ 'content-type' :
1162
+ 'multipart/form-data; boundary=--------------------------419073009317249310175915' ,
1163
+ 'multi' : 'one,stillone,two' ,
1164
+ } ,
1165
+ queryStringParameters : {
1166
+ lone : 'value' ,
1167
+ multi : 'one,stillone,two' ,
1168
+ } ,
1169
+ requestContext : {
1170
+ accountId : '205994128558' ,
1171
+ apiId : 'xxx' ,
1172
+ domainName : 'xxx.execute-api.us-east-1.amazonaws.com' ,
1173
+ domainPrefix : 'xx' ,
1174
+ http : {
1175
+ method : 'POST' ,
1176
+ path : '/v2' ,
1177
+ protocol : 'HTTP/1.1' ,
1178
+ sourceIp : '80.55.87.22' ,
1179
+ userAgent : 'PostmanRuntime/7.29.0' ,
1180
+ } ,
1181
+ requestId : 'XyGnwhe0oAMEJJw=' ,
1182
+ routeKey : 'POST /v2' ,
1183
+ stage : '$default' ,
1184
+ time : '01/Sep/2022:13:46:51 +0000' ,
1185
+ timeEpoch : 1662040011065 ,
1186
+ } ,
1187
+ body : `{"s":"${ 't' . repeat ( 130 * 1000 ) } "}` ,
1188
+ isBase64Encoded : false ,
1189
+ } ;
1190
+
1191
+ const { request } = await handleInvocation ( 'api-endpoint' , {
1192
+ isApiEndpoint : true ,
1193
+ isBodyAltered : true ,
1194
+ payload,
1195
+ } ) ;
1196
+
1197
+ expect ( request . body ) . to . equal ( undefined ) ;
1198
+ } ) ;
1152
1199
} ) ;
1153
1200
} ) ;
0 commit comments