From cb166ba83232529846350989bef6ec74da8973a5 Mon Sep 17 00:00:00 2001 From: Ivo Branco Date: Thu, 11 Jul 2024 15:59:26 +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 9360b78..b0719ff 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; charset=utf-8", "SOAPAction": "''"}, + headers={"Content-type": "text/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 f9791d3..53397c0 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; charset=utf-8", called_headers["Content-type"]) + self.assertEqual("text/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"})