IOTData: publish() should be able to handle non-Unicode bytes (#6509)
This commit is contained in:
parent
971568f226
commit
2dbbdc3123
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user