@@ -67,6 +67,7 @@ def test_non_multipart_content_type_no_mesh_metadata(self):
6767
6868 def test_multipart_content_type (self ):
6969 body = "\r \n " .join ([
70+ "" ,
7071 "--12345678" ,
7172 'Content-Disposition: form-data; name="File"; filename="test-csv-file.csv"' ,
7273 "Content-Type: text/csv" ,
@@ -91,6 +92,7 @@ def test_multipart_content_type(self):
9192
9293 def test_multipart_content_type_multiple_parts (self ):
9394 body = "\r \n " .join ([
95+ "" ,
9496 "--12345678" ,
9597 'Content-Disposition: form-data; name="File"; filename="test-csv-file.csv"' ,
9698 "Content-Type: text/csv" ,
@@ -120,6 +122,7 @@ def test_multipart_content_type_multiple_parts(self):
120122
121123 def test_multipart_content_type_without_filename (self ):
122124 body = "\r \n " .join ([
125+ "" ,
123126 "--12345678" ,
124127 'Content-Disposition: form-data' ,
125128 "Content-Type: text/csv" ,
@@ -144,6 +147,7 @@ def test_multipart_content_type_without_filename(self):
144147
145148 def test_multipart_content_type_without_headers (self ):
146149 body = "\r \n " .join ([
150+ "" ,
147151 "--12345678" ,
148152 "" ,
149153 "some CSV content" ,
@@ -166,6 +170,7 @@ def test_multipart_content_type_without_headers(self):
166170
167171 def test_multipart_content_type_with_unix_line_endings (self ):
168172 body = "\r \n " .join ([
173+ "" ,
169174 "--12345678" ,
170175 'Content-Disposition: form-data; name="File"; filename="test-csv-file.csv"' ,
171176 "Content-Type: text/csv" ,
@@ -187,3 +192,51 @@ def test_multipart_content_type_with_unix_line_endings(self):
187192 response = s3 .get_object (Bucket = "destination-bucket" , Key = "test-csv-file.csv" )
188193 body = response ["Body" ].read ().decode ("utf-8" )
189194 assert body == "some CSV content\n split across\n multiple lines"
195+
196+ def test_multipart_content_type_missing_first_newline (self ):
197+ body = "\r \n " .join ([
198+ "--12345678" ,
199+ 'Content-Disposition: form-data; name="File"; filename="test-csv-file.csv"' ,
200+ "Content-Type: text/csv" ,
201+ "" ,
202+ "some CSV content" ,
203+ "--12345678--" ,
204+ ""
205+ ])
206+ s3 = boto3 .client ("s3" , region_name = "eu-west-2" )
207+ s3 .put_object (
208+ Bucket = "source-bucket" ,
209+ Key = "test-dat-file.dat" ,
210+ Body = body .encode ("utf-8" ),
211+ ContentType = "multipart/form-data; boundary=12345678" ,
212+ )
213+
214+ invoke_lambda ("test-dat-file.dat" )
215+
216+ response = s3 .get_object (Bucket = "destination-bucket" , Key = "test-csv-file.csv" )
217+ body = response ["Body" ].read ().decode ("utf-8" )
218+ assert body == "some CSV content"
219+
220+ def test_multipart_content_type_missing_final_newline (self ):
221+ body = "\r \n " .join ([
222+ "" ,
223+ "--12345678" ,
224+ 'Content-Disposition: form-data; name="File"; filename="test-csv-file.csv"' ,
225+ "Content-Type: text/csv" ,
226+ "" ,
227+ "some CSV content" ,
228+ "--12345678--" ,
229+ ])
230+ s3 = boto3 .client ("s3" , region_name = "eu-west-2" )
231+ s3 .put_object (
232+ Bucket = "source-bucket" ,
233+ Key = "test-dat-file.dat" ,
234+ Body = body .encode ("utf-8" ),
235+ ContentType = "multipart/form-data; boundary=12345678" ,
236+ )
237+
238+ invoke_lambda ("test-dat-file.dat" )
239+
240+ response = s3 .get_object (Bucket = "destination-bucket" , Key = "test-csv-file.csv" )
241+ body = response ["Body" ].read ().decode ("utf-8" )
242+ assert body == "some CSV content"
0 commit comments