Commit 502e4bc6 authored by Arnaud Fontaine's avatar Arnaud Fontaine

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 6687262a
...@@ -86,6 +86,7 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -86,6 +86,7 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish(person.getPath() + '/erp5_logo.png', response = self.publish(person.getPath() + '/erp5_logo.png',
request_method='PUT', request_method='PUT',
stdin=file_object, stdin=file_object,
env={"CONTENT_TYPE": 'image/png'},
basic=self.authentication) basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED) self.assertEqual(response.getStatus(), httplib.CREATED)
image = person['erp5_logo.png'] image = person['erp5_logo.png']
...@@ -105,6 +106,8 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -105,6 +106,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename), response = self.publish('%s/%s' % (path, filename),
request_method='PUT', request_method='PUT',
stdin=file_object, stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication) basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED) self.assertEqual(response.getStatus(), httplib.CREATED)
...@@ -127,6 +130,8 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -127,6 +130,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename), response = self.publish('%s/%s' % (path, filename),
request_method='PUT', request_method='PUT',
stdin=file_object, stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication) basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED) self.assertEqual(response.getStatus(), httplib.CREATED)
...@@ -198,6 +203,8 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -198,6 +203,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename), response = self.publish('%s/%s' % (path, filename),
request_method='PUT', request_method='PUT',
stdin=file_object, stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication) basic=self.authentication)
# Convert to base format and run conversion into utf-8 # Convert to base format and run conversion into utf-8
self.tic() self.tic()
...@@ -225,6 +232,8 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -225,6 +232,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename), response = self.publish('%s/%s' % (path, filename),
request_method='PUT', request_method='PUT',
stdin=file_object, stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication) basic=self.authentication)
document_module = self.getDocumentModule() document_module = self.getDocumentModule()
document = document_module[filename] document = document_module[filename]
...@@ -263,6 +272,8 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -263,6 +272,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename), response = self.publish('%s/%s' % (path, filename),
request_method='PUT', request_method='PUT',
stdin=file_object, stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication) basic=self.authentication)
document_module = self.getDocumentModule() document_module = self.getDocumentModule()
document = document_module[filename] document = document_module[filename]
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
############################################################################## ##############################################################################
import json import json
from six.moves import urllib
from io import BytesIO from io import BytesIO
from urlparse import parse_qs from urlparse import parse_qs
...@@ -461,8 +460,7 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -461,8 +460,7 @@ class TestStripePaymentSession(ERP5TypeTestCase):
) )
ret = self.publish( ret = self.publish(
"%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(), "%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(),
stdin=BytesIO(urllib.parse.urlencode({ stdin=BytesIO(json.dumps({
"BODY": json.dumps({
"url": "https://stripe.url", "url": "https://stripe.url",
"id": "evt_%s" % "abc321_expired", "id": "evt_%s" % "abc321_expired",
"object": "event", "object": "event",
...@@ -474,9 +472,9 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -474,9 +472,9 @@ class TestStripePaymentSession(ERP5TypeTestCase):
"object": "checkout.session" "object": "checkout.session"
} }
} }
})
}).encode()), }).encode()),
request_method="POST", request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False) handle_errors=False)
self.assertEqual(200, ret.getStatus()) self.assertEqual(200, ret.getStatus())
self.tic() self.tic()
...@@ -658,8 +656,7 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -658,8 +656,7 @@ class TestStripePaymentSession(ERP5TypeTestCase):
) )
ret = self.publish( ret = self.publish(
"%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(), "%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(),
stdin=BytesIO(urllib.parse.urlencode({ stdin=BytesIO(json.dumps({
"BODY": json.dumps({
"id": "evt_%s" % session_id, "id": "evt_%s" % session_id,
"object": "event", "object": "event",
"data": { "data": {
...@@ -670,9 +667,9 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -670,9 +667,9 @@ class TestStripePaymentSession(ERP5TypeTestCase):
"object": "checkout.session" "object": "checkout.session"
} }
} }
})
}).encode()), }).encode()),
request_method="POST", request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False) handle_errors=False)
self.assertEqual(200, ret.getStatus()) self.assertEqual(200, ret.getStatus())
self.tic() 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