Commit 86dd451e authored by Arnaud Fontaine's avatar Arnaud Fontaine Committed by Jérome Perrin

zope5: Since 5.8.1 missing Content-Type HTTP header is interpreted as...

zope5: Since 5.8.1 missing Content-Type HTTP header is interpreted as application/x-www-form-urlencoded.

Zope.git:
  commit 5b324f6c461f5ea1cc069739b6c32a1a5ff59df9
  Date:   Thu Jan 19 07:15:18 2023 +0100
    replace `cgi.FieldStorage` by `multipart` (#1094)
    * interpret a missing `CONTENT_TYPE` as `application/x-www-form-urlencoded`

With cgi.FieldStorage, it was interpretated as text/plain so Content-Type has to
be provided now (even for WebDAV despite RFC 4918 stating that it *SHOULD* be
provided).

Some Unit Tests did not provide such header at all but this was wrong (such as
erp5_stripe:testStripe where the real request has application/json as
Content-Type and not text/plain).
parent b819f8da
......@@ -86,6 +86,7 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish(person.getPath() + '/erp5_logo.png',
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'image/png'},
basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED)
image = person['erp5_logo.png']
......@@ -105,6 +106,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED)
......@@ -127,6 +130,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED)
......@@ -198,6 +203,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
# Convert to base format and run conversion into utf-8
self.tic()
......@@ -225,6 +232,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule()
document = document_module[filename]
......@@ -263,6 +272,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule()
document = document_module[filename]
......
......@@ -26,7 +26,6 @@
##############################################################################
import json
from six.moves import urllib
from io import BytesIO
from urlparse import parse_qs
......@@ -461,8 +460,7 @@ class TestStripePaymentSession(ERP5TypeTestCase):
)
ret = self.publish(
"%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(),
stdin=BytesIO(urllib.parse.urlencode({
"BODY": json.dumps({
stdin=BytesIO(json.dumps({
"url": "https://stripe.url",
"id": "evt_%s" % "abc321_expired",
"object": "event",
......@@ -474,9 +472,9 @@ class TestStripePaymentSession(ERP5TypeTestCase):
"object": "checkout.session"
}
}
})
}).encode()),
request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False)
self.assertEqual(200, ret.getStatus())
self.tic()
......@@ -658,8 +656,7 @@ class TestStripePaymentSession(ERP5TypeTestCase):
)
ret = self.publish(
"%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(),
stdin=BytesIO(urllib.parse.urlencode({
"BODY": json.dumps({
stdin=BytesIO(json.dumps({
"id": "evt_%s" % session_id,
"object": "event",
"data": {
......@@ -670,9 +667,9 @@ class TestStripePaymentSession(ERP5TypeTestCase):
"object": "checkout.session"
}
}
})
}).encode()),
request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False)
self.assertEqual(200, ret.getStatus())
self.tic()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment