1
0
mirror of https://github.com/qt/qtmqtt.git synced 2026-10-25 16:16:26 +00:00

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 <alexander.blasche@qt.io>
This commit is contained in:
Maurice Kalinowski 2019-04-17 13:14:34 +02:00
parent af08406cd3
commit acff2f2611

View File

@ -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);