diff --git a/moto/iotdata/responses.py b/moto/iotdata/responses.py index fe085c6cf..ca35653d9 100644 --- a/moto/iotdata/responses.py +++ b/moto/iotdata/responses.py @@ -1,6 +1,7 @@ from moto.core.responses import BaseResponse from .models import iotdata_backends, IoTDataPlaneBackend import json +from typing import Any from urllib.parse import unquote @@ -8,6 +9,11 @@ class IoTDataPlaneResponse(BaseResponse): def __init__(self) -> None: super().__init__(service_name="iot-data") + def setup_class( + self, request: Any, full_url: str, headers: Any, use_raw_body: bool = False + ) -> None: + super().setup_class(request, full_url, headers, use_raw_body=True) + def _get_action(self) -> str: if self.path and self.path.startswith("/topics/"): # Special usecase - there is no way identify this action, besides the URL diff --git a/tests/test_iotdata/test_iotdata.py b/tests/test_iotdata/test_iotdata.py index 59df5c06d..d935e47c8 100644 --- a/tests/test_iotdata/test_iotdata.py +++ b/tests/test_iotdata/test_iotdata.py @@ -112,14 +112,14 @@ def test_publish(): client = boto3.client("iot-data", region_name=region_name) client.publish(topic="test/topic1", qos=1, payload=b"pl1") client.publish(topic="test/topic2", qos=1, payload=b"pl2") - client.publish(topic="test/topic3", qos=1, payload=b"pl3") + client.publish(topic="test/topic3", qos=1, payload=b"\xbf") if not settings.TEST_SERVER_MODE: mock_backend = moto.iotdata.models.iotdata_backends[ACCOUNT_ID][region_name] mock_backend.published_payloads.should.have.length_of(3) - mock_backend.published_payloads.should.contain(("test/topic1", "pl1")) - mock_backend.published_payloads.should.contain(("test/topic2", "pl2")) - mock_backend.published_payloads.should.contain(("test/topic3", "pl3")) + mock_backend.published_payloads.should.contain(("test/topic1", b"pl1")) + mock_backend.published_payloads.should.contain(("test/topic2", b"pl2")) + mock_backend.published_payloads.should.contain(("test/topic3", b"\xbf")) @mock_iot