From acff2f2611e271b83c9190b060d42c88bb292fa5 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 17 Apr 2019 13:14:34 +0200 Subject: Fix server test code For MQTT 5 the fake server did not send any property information. Hence, the client (potentially) read among the buffer. Change-Id: I58c7d1b4a1f15a0803c04495c82537f648c8a642 Reviewed-by: Alex Blasche --- tests/auto/qmqttclient/tst_qmqttclient.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/auto/qmqttclient/tst_qmqttclient.cpp b/tests/auto/qmqttclient/tst_qmqttclient.cpp index 8aec3d5..c4da40d 100644 --- a/tests/auto/qmqttclient/tst_qmqttclient.cpp +++ b/tests/auto/qmqttclient/tst_qmqttclient.cpp @@ -486,6 +486,8 @@ public slots: } else { response += char(0); // ackFlags response += char(0); // result + if (version == QMqttClient::MQTT_5_0) + response += char(0); // No properties } qDebug() << "Fake server response:" << connectionSuccess; socket->write(response); @@ -493,6 +495,7 @@ public slots: public: QTcpServer *server; QTcpSocket *socket; + QMqttClient::ProtocolVersion version{QMqttClient::MQTT_3_1_1}; bool connectionSuccess{false}; }; @@ -509,6 +512,8 @@ void Tst_QMqttClient::reconnect_QTBUG65726() client.setHostname(QLatin1String("localhost")); client.setPort(5726); + server.version = client.protocolVersion(); + client.connectToHost(); QTRY_COMPARE(client.state(), QMqttClient::Disconnected); QTRY_COMPARE(client.error(), QMqttClient::ProtocolViolation); -- cgit v1.2.3