Merge pull request #15670 from miri64/tests/enh/emcute-qos-0-publish

tests/emcute: add check for message ID with PUBLISH QoS 0
This commit is contained in:
Hauke Petersen 2020-12-18 13:46:22 +01:00 committed by GitHub
commit bf0aa101a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,6 +101,11 @@ class MQTTSNServer(Automaton):
def _check_pkt_qos(self, pkt): def _check_pkt_qos(self, pkt):
qos_types = [mqttsn.PUBLISH, mqttsn.SUBSCRIBE] qos_types = [mqttsn.PUBLISH, mqttsn.SUBSCRIBE]
# see MQTT-SN 1.2 spec 5.4.12
if (pkt.type == mqttsn.PUBLISH) and \
(pkt.qos not in [mqttsn.QOS_1, mqttsn.QOS_2]) and \
(pkt.mid != 0):
return False
return (pkt.type not in qos_types) or (pkt.qos == self._qos_flags) return (pkt.type not in qos_types) or (pkt.qos == self._qos_flags)
def _get_tid(self, topic_name): def _get_tid(self, topic_name):