Skip to content

Commit

Permalink
Fix tests and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanprjcts committed Nov 4, 2020
1 parent 528e4f1 commit 0cc1126
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions docs/about/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ To upgrade Sdklib to the latest version, use pip:
Sdklib 1.10.x series
===================

Sdklib 1.10.5
-------------

- Fix multipart boundary characters according to RFC (https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html).

Sdklib 1.10.3
-------------

Expand Down
24 changes: 12 additions & 12 deletions tests/test_multipart_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_encode_multipart_data_files(self):

r = MultiPartRenderer()
body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand All @@ -30,12 +30,12 @@ def test_encode_multipart_data_as_2tuple_files(self):

r = MultiPartRenderer()
body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(
b'------------ThIs_Is_tHe_bouNdaRY_$\r\nContent-Disposition: form-data; name="param1"\r\nContent-Type: myContentType\r\n\r\nvalue1\r\n',
b'------------ThIs_Is_tHe_bouNdaRY\r\nContent-Disposition: form-data; name="param1"\r\nContent-Type: myContentType\r\n\r\nvalue1\r\n',
body)
self.assertIn(
b'------------ThIs_Is_tHe_bouNdaRY_$\r\nContent-Disposition: form-data; name="param2"\r\n\r\nvalue2\r\n',
b'------------ThIs_Is_tHe_bouNdaRY\r\nContent-Disposition: form-data; name="param2"\r\n\r\nvalue2\r\n',
body)
self.assertIn(b"file_upload", body)
self.assertIn(b"file.pdf", body)
Expand All @@ -52,7 +52,7 @@ def test_encode_multipart_data_files_as_2tuple_parameter(self):

r = MultiPartRenderer()
body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand All @@ -71,7 +71,7 @@ def test_encode_multipart_data_files_as_3tuple_parameter(self):

r = MultiPartRenderer()
body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand All @@ -87,7 +87,7 @@ def test_encode_multipart_data_files_as_4tuple_parameter(self):

r = MultiPartRenderer()
body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand All @@ -103,7 +103,7 @@ def test_encode_multipart_data_and_no_files(self):

r = MultiPartRenderer()
body, content_type = r.encode_params(None, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"file_upload", body)
self.assertIn(b"file.pdf", body)
self.assertIn(b"Content-Type: application/pdf", body)
Expand All @@ -113,7 +113,7 @@ def test_encode_multipart_no_data_and_files(self):

r = MultiPartRenderer()
body, content_type = r.encode_params(data, None)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand Down Expand Up @@ -160,7 +160,7 @@ def test_encode_multipart_data_files_using_boundary_as_parameter(self):
self.assertIn(b"Content-Type: application/pdf", body)

body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand All @@ -185,7 +185,7 @@ def test_encode_multipart_data_files_boolean(self):
self.assertIn(b"Content-Type: application/pdf", body)

body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand All @@ -210,7 +210,7 @@ def test_encode_multipart_data_files_none(self):
self.assertIn(b"Content-Type: application/pdf", body)

body, content_type = r.encode_params(data, files)
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY_$")
self.assertEqual(content_type, "multipart/form-data; boundary=----------ThIs_Is_tHe_bouNdaRY")
self.assertIn(b"param1", body)
self.assertIn(b"value1", body)
self.assertIn(b"param2", body)
Expand Down

0 comments on commit 0cc1126

Please sign in to comment.