def test_uninvited_puback(host, port): record = [ Frame( send=True, data=Connect(client_id=u"test_puback", flags=ConnectFlags(clean_session=True))), Frame( send=False, data=ConnACK(session_present=False, return_code=0)), Frame( send=True, data=PubACK(packet_identifier=1234)), Frame( send=False, data=b""), Frame( send=True, data=Disconnect()), ConnectionLoss(), ] r = SelectReactor() f = ReplayClientFactory(r, record) e = TCP4ClientEndpoint(r, host, port) e.connect(f) r.run() return Result("uninvited_puback", f.success, f.reason, f.client_transcript)
def test_qos2_send_wrong_confirm(host, port): record = [ Frame( send=True, data=Connect(client_id=u"test_wrong_confirm_qos2", flags=ConnectFlags(clean_session=True))), Frame( send=False, data=ConnACK(session_present=False, return_code=0)), Frame( send=True, data=Subscribe(packet_identifier=1234, topic_requests=[SubscriptionTopicRequest(u"foo", 2)])), Frame( send=False, data=SubACK(packet_identifier=1234, return_codes=[2])), Frame( send=True, data=Publish(duplicate=False, qos_level=2, topic_name=u"foo", payload=b"abc", retain=False, packet_identifier=12)), Frame( send=False, data=[ PubREC(packet_identifier=12), Publish(duplicate=False, qos_level=2, topic_name=u"foo", payload=b"abc", retain=False, packet_identifier=1), PubCOMP(packet_identifier=12)]), Frame( send=True, data=PubREL(packet_identifier=12)), Frame( send=True, data=PubACK(packet_identifier=1)), Frame( send=False, data=b""), Frame( send=True, data=Disconnect()), ConnectionLoss(), ] r = SelectReactor() f = ReplayClientFactory(r, record) e = TCP4ClientEndpoint(r, host, port) e.connect(f) r.run() return Result("qos2_wrong_confirm", f.success, f.reason, f.client_transcript)
def test_qos1_send_wrong_confirm(host, port): record = [ Frame(send=True, data=Connect(client_id="test_wrong_confirm_qos1", flags=ConnectFlags(clean_session=True))), Frame(send=False, data=ConnACK(session_present=False, return_code=0)), Frame(send=True, data=Subscribe( packet_identifier=1234, topic_requests=[SubscriptionTopicRequest("foo", 2)])), Frame(send=False, data=SubACK(packet_identifier=1234, return_codes=[2])), Frame(send=True, data=Publish(duplicate=False, qos_level=1, topic_name="foo", payload=b"abc", retain=False, packet_identifier=12)), Frame(send=False, data=[ PubACK(packet_identifier=12), Publish(duplicate=False, qos_level=1, topic_name="foo", payload=b"abc", retain=False, packet_identifier=1) ]), # We send a pubrel to the packet_id expecting a puback Frame(send=True, data=PubREL(packet_identifier=1)), # ..aaaaand we get a pubcomp back (even though mosquitto warns). Frame(send=False, data=PubCOMP(packet_identifier=1)), Frame(send=True, data=Disconnect()), ConnectionLoss(), ] r = SelectReactor() f = ReplayClientFactory(r, record) e = TCP4ClientEndpoint(r, host, port) e.connect(f) r.run() return Result("qos1_wrong_confirm", f.success, f.reason, f.client_transcript)