Skip to content

Commit

Permalink
contenttype and contentencoding property name change
Browse files Browse the repository at this point in the history
  • Loading branch information
c-ryan-k committed Dec 12, 2024
1 parent cda3326 commit c1f1167
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
17 changes: 17 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
Release History
===============

0.26.0
+++++++++++++++

**General updates**

* We have dropped support for Python 3.8
* This extension now supports Python 3.12 as the CLI core is packaging newer releases with this python version,
* **[Breaking Change]** Older versions of `uamqp` (below `1.6.6`) are not compatible with Python 3.12
* If you update your packaged AZ CLI version (`2.66.0` or later) or otherwise change your environment's Python version to 3.12, you will need to update your `uamqp` dependency to `1.6.6` or above in order to use commands like `az iot hub monitor-events`
* You can repair this dependency at command runtime by utilizing the `--repair` / `-r` argument in `az iot hub monitor-events`

**IoT device updates**

* **[Breaking Change]** Device c2d messages (`az iot device c2d-message`) have been updated to support the following service-side changes:
* `ContentEncoding` system property is now `content-encoding`
* `ContentType` system property is now `content-type`


0.25.0
+++++++++++++++
Expand Down
4 changes: 2 additions & 2 deletions azext_iot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"iothub-expiry",
"iothub-deliverycount",
"iothub-enqueuedtime",
"ContentType",
"ContentEncoding",
"content-type",
"content-encoding",
]
METHOD_INVOKE_MAX_TIMEOUT_SEC = 300
METHOD_INVOKE_MIN_TIMEOUT_SEC = 10
Expand Down
4 changes: 2 additions & 2 deletions azext_iot/iothub/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ def load_iothub_help():
to `application/octet-stream`.
Note: The command only works for symmetric key auth (SAS) based devices.
To enable querying on a message body in message routing, the contentType
system property must be application/JSON and the contentEncoding system
To enable querying on a message body in message routing, the content-type
system property must be application/JSON and the content-encoding system
property must be one of the UTF encoding values supported by that system
property(UTF-8, UTF-16 or UTF-32). If the content encoding isn't set when
Azure Storage is used as routing endpoint, then IoT Hub writes the messages
Expand Down
2 changes: 1 addition & 1 deletion azext_iot/iothub/providers/device_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _c2d_message_receive(self, lock_timeout: int = 60, ack: Optional[str] = None
payload["properties"]["system"] = sys_props

if result.content:
target_encoding = result.headers.get("ContentEncoding", "utf-8")
target_encoding = result.headers.get("content-encoding", "utf-8")
payload["data"] = NON_DECODABLE_PAYLOAD
if target_encoding in ["utf-8", "utf8", "utf-16", "utf16", "utf-32", "utf32"]:
logger.info(f"Decoding message data encoded with: {target_encoding}")
Expand Down
25 changes: 12 additions & 13 deletions azext_iot/tests/iothub/core/test_iot_messaging_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ def test_uamqp_device_messaging(self):
assert result["data"] == test_body

system_props = result["properties"]["system"]
# TODO - @c-ryan-k - no system properties
# assert system_props["ContentEncoding"] == test_ce
# assert system_props["ContentType"] == test_ct
assert system_props["content-encoding"] == test_ce
assert system_props["content-type"] == test_ct
assert system_props["iothub-correlationid"] == test_cid
assert system_props["iothub-messageid"] == test_mid
assert system_props["iothub-expiry"]
Expand Down Expand Up @@ -159,8 +158,8 @@ def test_uamqp_device_messaging(self):
self._remove_newlines_spaces(payload=self.kwargs["messaging_data"])

system_props = result["properties"]["system"]
# assert system_props["ContentEncoding"] == test_ce
# assert system_props["ContentType"] == 'application/json'
assert system_props["content-encoding"] == test_ce
assert system_props["content-type"] == 'application/json'
assert system_props["iothub-correlationid"] == test_cid
assert system_props["iothub-messageid"] == test_mid
assert system_props["iothub-expiry"]
Expand Down Expand Up @@ -211,8 +210,8 @@ def test_uamqp_device_messaging(self):
assert result["data"] == self.kwargs["messaging_unicodable_data"]

system_props = result["properties"]["system"]
# assert system_props["ContentEncoding"] == test_ce
# assert system_props["ContentType"] == 'application/octet-stream'
assert system_props["content-encoding"] == test_ce
assert system_props["content-type"] == 'application/octet-stream'
assert system_props["iothub-correlationid"] == test_cid
assert system_props["iothub-messageid"] == test_mid
assert system_props["iothub-expiry"]
Expand Down Expand Up @@ -263,8 +262,8 @@ def test_uamqp_device_messaging(self):
assert result["data"] == self.kwargs["messaging_non_unicodable_data"]

system_props = result["properties"]["system"]
# assert system_props["ContentEncoding"] == test_ce
# assert system_props["ContentType"] == 'application/octet-stream'
assert system_props["content-encoding"] == test_ce
assert system_props["content-type"] == 'application/octet-stream'
assert system_props["iothub-correlationid"] == test_cid
assert system_props["iothub-messageid"] == test_mid
assert system_props["iothub-expiry"]
Expand Down Expand Up @@ -316,8 +315,8 @@ def test_uamqp_device_messaging(self):
# assert result["data"] == self.kwargs["messaging_non_unicodable_data"]

system_props = result["properties"]["system"]
# assert system_props["ContentEncoding"] == 'gzip'
# assert system_props["ContentType"] == 'application/octet-stream'
assert system_props["content-encoding"] == 'gzip'
assert system_props["content-type"] == 'application/octet-stream'
assert system_props["iothub-correlationid"] == test_cid
assert system_props["iothub-messageid"] == test_mid
assert system_props["iothub-expiry"]
Expand Down Expand Up @@ -392,8 +391,8 @@ def test_uamqp_device_messaging(self):
assert result["data"] == self.kwargs["c2d_json_send_data"]

system_props = result["properties"]["system"]
# assert system_props["ContentEncoding"] == test_ce
# assert system_props["ContentType"] == test_ct
assert system_props["content-encoding"] == test_ce
assert system_props["content-type"] == test_ct
assert system_props["iothub-correlationid"] == test_cid
assert system_props["iothub-messageid"] == test_mid
assert system_props["iothub-expiry"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ def test_iothub_c2d_messages(self):
).get_output_in_json()

# TODO - @c-ryan-k - when using login auth type, the payload is not decoded correctly
assert c2d_receive_result["data"] == (NON_DECODABLE_PAYLOAD if auth_phase == AuthenticationTypeDataplane.login.value else test_body)
assert c2d_receive_result["data"] == test_body

# Assert system properties
received_system_props = c2d_receive_result["properties"]["system"]
# TODO - @c-ryan-k - no system props returned
# assert received_system_props["ContentEncoding"] == test_ce
# assert received_system_props["ContentType"] == test_ct
assert received_system_props["content-encoding"] == test_ce
assert received_system_props["content-type"] == test_ct
assert received_system_props["iothub-correlationid"] == test_cid
assert received_system_props["iothub-messageid"] == test_mid
assert received_system_props["iothub-expiry"]
Expand Down

0 comments on commit c1f1167

Please sign in to comment.