From 5ddac62d9b24c3fb6a1900f536093b6c0aa89837 Mon Sep 17 00:00:00 2001 From: Ivo Branco Date: Thu, 11 Jul 2024 15:23:36 +0100 Subject: [PATCH] fix(x3): content type missing charset Fix missing charset on Content Type HTTP header when integrating to Sage X3. fix #309 --- apps/billing/services/processor_service.py | 2 +- apps/billing/tests/test_sagex3_processor_service.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/billing/services/processor_service.py b/apps/billing/services/processor_service.py index bb57ff0..9360b78 100644 --- a/apps/billing/services/processor_service.py +++ b/apps/billing/services/processor_service.py @@ -47,7 +47,7 @@ def send_transaction_to_processor(self) -> dict: response = requests.post( url=self.__processor_url, data=self.data, - headers={"Content-type": "application/xml", "SOAPAction": "''"}, + headers={"Content-type": "application/xml; charset=utf-8", "SOAPAction": "''"}, auth=( self.__user_processor_auth, self.__user_processor_password, diff --git a/apps/billing/tests/test_sagex3_processor_service.py b/apps/billing/tests/test_sagex3_processor_service.py index f6fbba8..f9791d3 100644 --- a/apps/billing/tests/test_sagex3_processor_service.py +++ b/apps/billing/tests/test_sagex3_processor_service.py @@ -44,7 +44,7 @@ def test_send_transaction_to_processor_header_content_type(self, mock_data, mock SageX3Processor(None).send_transaction_to_processor() _, kwargs = mock_post.call_args called_headers = kwargs["headers"] - self.assertEqual("application/xml", called_headers["Content-type"]) + self.assertEqual("application/xml; charset=utf-8", called_headers["Content-type"]) @mock.patch("requests.post", return_value=MockResponse(data="", status_code=200)) @mock.patch("apps.billing.services.processor_service.SageX3Processor.data", side_effect=lambda: {"some": "thing"})