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

71 Commits

Author SHA1 Message Date
Maurice Kalinowski
d25a0abe78 Allow empty will messages
A will message is allowed to be empty. Hence, check whether a will topic
exists to identify incorporating the last will to the connect message.

Task-number: QTBUG-76783
Change-Id: Ifb7f5467e8e7e70c6d9c050b36a35df2419f4171
Reviewed-by: hjk <hjk@qt.io>
2019-07-02 12:52:04 +02:00
Maurice Kalinowski
acff2f2611 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>
2019-04-18 08:13:48 +00:00
Maurice Kalinowski
7d2525e623 Rename shared subscription functions
As agreed on the review process, using sharedSubscription(Name) is more
verbose and descriptive.

Change-Id: I81fa5d9f74ecd12d3b90d485f67b52dfb4f70bf5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2018-09-12 10:42:52 +00:00
Maurice Kalinowski
b3ee3a0fe1 Add test for subscription overlap
Furthermore also verifies subscription IDs are handled
properly.

Change-Id: I7bad65d6cbbe60fb005056dc0e31ef4e7a0a8ffa
Reviewed-by: hjk <hjk@qt.io>
2018-08-20 06:28:08 +00:00
Qt Forward Merge Bot
4bae427962 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I780e10a6fa43d24e2770be9b610a0579d4e66454
2018-08-18 03:00:50 +02:00
Kevin Funk
d84eeec724 Fix CMake unit tests
Before failed with:
.../qtmqtt/tests/auto/cmake/build/module_includes/main.cpp:4:16: fatal error: QMqtt: No such file or directory
       #include <QMqtt>
                ^~~~~~~

Task-number: QTBUG-68343
Change-Id: I1000f533b2b29558f3c2b0d23c64c2c621e641e5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-16 09:37:52 +00:00
Maurice Kalinowski
5ef7e409fb Add support for message status updates
A user might be interested in knowing the exact state of a message while
publishing or when a message is received.

Task-number: QTPM-1453
Task-number: QTBUG-66599
Change-Id: Ibf977f76ba6078b5b525ba00b6988d4b69960176
Reviewed-by: hjk <hjk@qt.io>
2018-08-14 03:47:04 +00:00
Maurice Kalinowski
d7cd172677 Fix tests for brokers with no server connection properties
VerneMQ does not send any server connection properties at all and relies
on the default values set by the standard. All other implementations
behave differently so far, mostly to set lower limits (i.e. max packet
size).

Change-Id: I01824640021651cfe752523803b9797aed197fc9
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-08-10 13:23:26 +00:00
Maurice Kalinowski
e8bdfe7b4c Rename QMqttPublishProperties::subscriptionIdentifiers
The standard did not mention it explicitly to be a list. However,
quoting "Multiple Subscription Identifiers will be included if the
publication is the result of a match to more than one subscription, in
this case their order is not significant" clearly indicates that
multiple subscription ids can be part of a publish message.

Change-Id: I1a45564a719847020e24aec7d0385807f3be3aa4
Reviewed-by: hjk <hjk@qt.io>
2018-08-09 10:30:36 +00:00
Maurice Kalinowski
b9ac8d04f2 MQTT5: Rename QMqttServerConnectionProperties::reasonString
Use reason() as name for consistency with other cases.

Change-Id: I9219a0fd47520f10f1c4b85fd0c4428dcc2d39a1
Reviewed-by: hjk <hjk@qt.io>
2018-08-09 10:30:17 +00:00
Maurice Kalinowski
0deebaab6d MQTT5: Introduce support for topic aliases
Task-number: QTPM-1490
Change-Id: Ie666d4c0dd75c08083a6860f345144ee1efb3d83
Reviewed-by: hjk <hjk@qt.io>
2018-08-08 04:39:20 +00:00
Maurice Kalinowski
4ffc9efc7b MQTT5: Introduce AUTH support
Task-number: QTPM-1455
Change-Id: I8eef500fe5eb0e8a36f449534c70e35487c04a7b
Reviewed-by: hjk <hjk@qt.io>
2018-08-02 09:15:55 +00:00
Maurice Kalinowski
bcc2a4e7b5 Disallow property changes while connected
Certain properties cannot be changed while connected and hence this
should be reflected in the behavior.

Task-number: QTBUG-67176
Change-Id: Ib9baafa1ac8d99d7a071839c892187efb51491e0
Reviewed-by: hjk <hjk@qt.io>
2018-08-02 07:43:40 +00:00
Maurice Kalinowski
001c3e7edc MQTT5: Add support for shared subscriptions
The scheme to create a shared subscription is $share/sharename/
topicfilter. During QMqttSubscription creation, the topic gets split and
shareName is a newly introduced property to verify whether a
subscription has been shared.

Task-number: QTPM-1452
Change-Id: I99c1aa9bb3bf8db2a930ce031c1a0a4882f01bcd
Reviewed-by: hjk <hjk@qt.io>
2018-07-30 11:52:32 +00:00
Maurice Kalinowski
f9ad481abc MQTT5: Introduce QMqttUnsubscriptionProperties
While removing a subscription, properties can be passed. V5.0 only
specifies user properties.

Task-number: QTPM-1454
Change-Id: Id068875c1947c9479175f6e5458713e038f7454f
Reviewed-by: hjk <hjk@qt.io>
2018-07-26 10:10:07 +00:00
Maurice Kalinowski
19475c3403 Move qWarning to categorized logging
qWarning could potentially quit an application while it is easily
possible to recover from an error state. Hence avoid usage of qWarning
inside the module.

Task-number: QTBUG-69544
Change-Id: I7340f38d80e6716450fbcd0918226e9435d37daa
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2018-07-26 08:16:07 +00:00
Maurice Kalinowski
86b2366942 Enable server client id test
When a client connects without a client id, the server might decide to
assign one to the client. The test was disabled so far, but
QMqttServerConnectionProperties handles this properly now.

Change-Id: If013ba67aa1f08c8842b872a6125e7d2bfa6430d
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-24 12:32:43 +00:00
Maurice Kalinowski
ba94777b84 MQTT5: Add support for last will properties
Task-number: QTPM-1451
Change-Id: I26a12b944eddb029f7fffe8c1af1610ff79cc494
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2018-07-24 12:32:37 +00:00
Maurice Kalinowski
29420b9f6c Move PayloadFormatIndicator to dedicated namespace
The PayloadFormatIndicator is used on multiple places.
Consequently, avoid duplication of this enum and move it to
a module namespace. It is not sufficient to have it inside QMqttClient.

Change-Id: I1113de55e69a5f548cdf4feba435b806949a8153
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2018-07-24 12:32:24 +00:00
hjk
629f52ae27 Avoid a few compiler warnings
Signed/unsigned comparison and an unused argument.

Change-Id: Iec452f058d6e40d24dc66261cb221b45cc89d59a
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-24 12:32:17 +00:00
hjk
47c4ef3e53 Suppress some signed vs unsigned warnings in tests
Change-Id: Iae17f5ce94ef28dcf510cdbd1a78acc5ffc05e35
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-20 12:30:17 +00:00
Maurice Kalinowski
de25c6b78d Make test topics unique to test class
Always use a prefix for topics inside a test class. Otherwise running
multiple tests concurrently can cause failures as test data is shared
among the broker and behavior becomes unreliable.

Task-number: QTBUG-69549
Change-Id: Ia9886826f65e8e40826fcd9a83bb8ec5a1a8e850
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-20 11:55:23 +00:00
Maurice Kalinowski
4816c09e20 MQTT5: Add QMqttSubscriptionProperties auto tests
Change-Id: Ib8eb4a657210574bfc3a8a6cf223582dd5ad2915
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-20 11:54:30 +00:00
Maurice Kalinowski
56d3a0f98a MQTT5: Add QMqttPublishProperties auto tests
Change-Id: I12b161e5aeddd254ba1ec7f29f0153a75f4a69ff
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-20 11:54:13 +00:00
Maurice Kalinowski
f18abd4703 MQTT5: Add QMqttConnectionProperties tests
Change-Id: Ia1c3bf862731bc5c3e8919f1d61a52ec3af0b78e
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-20 11:53:49 +00:00
Maurice Kalinowski
307eaa2cf8 MQTT5: Update tests
Some tests require checks for MQTT5

Change-Id: If3c22c9c805a137d90b27bae0bdc9d77e17cd8a1
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-20 11:53:40 +00:00
Maurice Kalinowski
ac666587dd MQTT5: Add initial support
With this patch it is possible to set the version to MQTT5 and
use the same features as against version 3.1.1. No MQTT5 specific
features are enabled.

Change-Id: I129ff8a2c996d7bcc582565fccda9e38edc48c62
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-07-20 11:53:14 +00:00
Maurice Kalinowski
c0b9b02896 Remove superfluous wait
Prefer QTRY_ instead of using wait and VERIFY.

Change-Id: I4699dd6e7865b2043534d624875071b0882cce45
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2018-06-13 11:17:20 +00:00
Maurice Kalinowski
0aa6dadcf5 Allow overwriting client defaults
Some test brokers require credentials to allow a connection. To be able
to verify the module against those, add a mean to pass those to the
client and run the auto tests without modification.

Change-Id: I10b8e2343f7fc66199d70f5f238f69b07665110a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2018-06-13 11:17:13 +00:00
Maurice Kalinowski
434ed83741 Fix connecting via an already open QIODevice transport
In case a transport is handed over to QMqttClient which is based on
QIODevice and already opened, the implementation was not sending a
CONNECT request and hence the broker never got informed about a new
client establishing connection. Hence manually send the connect
statement.

For QAbstractSocket based transports this was done already.

Task-number: QTBUG-66955
Change-Id: I50cba1b6dd03d0af561d4e39a3b57af5b2161a4b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-03-12 09:10:50 +00:00
Maurice Kalinowski
539bc149f0 Fix memory leak in tests
The QTcpServer did not get deleted on destruction.

Change-Id: I525b6d4602aaf23dde193ef2d0dc49bc30898741
Reviewed-by: Andrew O'Doherty <andrew.odoherty@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-03-07 07:35:08 +00:00
Maurice Kalinowski
68fe97befd Fix reconnecting after transport error
In case a connection fails due to a transport error, the client must be
able to try to reconnect. Hence, reset the error state when
connectToHost is called. Furthermore the socket needs to be re-created
if it has been instantiated by QMqttClient previously.

Task-number: QTBUG-65726
Change-Id: Id54e5f91a8ca4d0c7be6f51f1ad79e090c681584
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-02-02 07:59:24 +00:00
Maurice Kalinowski
6b6d2749e6 Fix subscriptions at reconnect
When a client reconnects with a cleanSession, all previous subscriptions
need to be disabled due to not being valid anymore. Furthermore, a
broker can decide to not restore a session even though cleanSession was
false. Take this into account by disabling existing subscriptions in
that case as well.

Task-number: QTBUG-64042
Change-Id: I618bc1fe4bb30651a34d70ec9d9e95e48b1c25d5
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-11-15 14:06:41 +00:00
Lorenz Haas
6eca6f914d Introduce specific types for topic names and filters
For "topics" the standard defines topic names and topic filters with
specific characteristics. QMqttTopicName and QMqttTopicFilter implement
this requirements.

[ChangeLog][General] Added QMqttTopicName and QMqttTopicFilter

Change-Id: Ie2b6851ec9249f20d05c4b8df3c2f27afc2be4b9
Reviewed-by: hjk <hjk@qt.io>
2017-11-15 13:18:31 +00:00
Maurice Kalinowski
70b7ee03c5 Fix publishing of data containing arbitrary content
Using QByteArray::append(const char*) checks for \0 and stops copying
into the payload. Instead use the QByteArray version, which ideally just
shares the data or uses the explicit size of the data, ignoring the
content of the data.

Change-Id: Ifdabd7508c738fbd9b3967a745904f1cc95dfb7d
Reviewed-by: Lorenz Haas <lorenz.haas@histomatics.de>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-11-14 07:21:19 +00:00
Jani Heikkinen
984527e516 Update license headers
Change-Id: If9b7f82a71ec554b152485ddd91a9d105019c6ce
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-09-25 11:58:23 +00:00
Maurice Kalinowski
0693346b4e Revert "Disable auto tests"
This reverts commit ca21591cdb.

Provisioning scripts should be done now and tests be able to run
on Windows and Linux.

Change-Id: I04eeb12ebcf6486902fa624f55fed0f4728c473d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-23 06:38:07 +00:00
Maurice Kalinowski
ca21591cdb Disable auto tests
Currently updating the provisioning scripts is not possible. Hence, the
paho test broker cannot be installed on test machines and tests not be
run.

Change-Id: I3ba2c5453101dc52378c96684e5324a3c06367a8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-04 13:49:12 +00:00
Maurice Kalinowski
5986b03bad Change signature of QMqttClient::subscribe
Instead of returning a QSharedPointer, return the same pointer. This
improves readability as well as using the subscription from a user
perspective.

The ownership has to stay with the client though, otherwise behavior
is unexpected.

Change-Id: I72d3c15a12faf45c9575af8b3a790dfff1a30c2a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-01 18:52:20 +00:00
Maurice Kalinowski
e3ea7f3b1a Only run tests on supported platforms
Change-Id: I49e3b69cfd514c6a37f8069295b1325548d1f8af
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-08-30 13:29:56 +00:00
Maurice Kalinowski
1252cdd4b1 Rename test class name
Change-Id: I3a4f547bea9101154814060bcf16ff0c2b6c013a
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-08-30 07:37:08 +00:00
Maurice Kalinowski
16061d50b0 Prefer using limits instead of header defines macros
Also fixes build on Android.

Change-Id: Iad3617d57ec7c97dfaae2108054333669e635f23
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-30 08:35:51 +00:00
Maurice Kalinowski
faf6c7f20b Add support for multiple wildcards
When using the + wildcard, there is no limit on the amount of this
wildcard to be used.

Add unit test in addition.

Change-Id: Id6eaa77390f08e9901779a6296f7d4c3de41ffa6
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-29 15:50:47 +00:00
Maurice Kalinowski
41440a51f0 Refactor test server connection
Introduce common header to handle broker identification. By default the
paho test broker which gets provisioned on the test machines will be
used.

Still it can be overwritten by specifying MQTT_TEST_BROKER to point to
another location.

Change-Id: Ic0d2c6a025e9de246e79a4309e490c67225e1536
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-06-29 12:47:45 +00:00
Maurice Kalinowski
e8d5b83dde Add conformance tests
Conformance tests are supposed to go through the specs and test each
item stated, to an extend possible. As a base, the paho test suite is
used, more specifically all tests of client_test.py.

In conjunction with tests for the Qt classes, we reach 72% conformance,
which is higher than the client test by paho reaches itself.

Change-Id: I5672a3664c340fe7f856de3eaf63bf117075acb6
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-29 12:31:04 +00:00
Maurice Kalinowski
97219421f0 Fix compilation for non developer build
Change-Id: I624f3cb621193e7fec51efa156243a8dcd1c0d53
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-06-27 13:26:56 +00:00
Maurice Kalinowski
c27344129a Rename QMqttMessage::content to payload
This is a way more consistent naming.

Change-Id: Id1236a76fc8f88f09a62490ec01370c1e13de4f8
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-06-15 12:43:54 +00:00
Maurice Kalinowski
042b828c14 Update license
Change-Id: Iafccea66a89d8290f9beb92f4c0360016bc827e8
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-05-19 11:40:05 +00:00
Maurice Kalinowski
5a05823961 Introduce QMqttMessage
QMqttMessage stores all information about a published message being
received on a subscription. A user might be interested in more details,
hence provide all known details. Keep the class as lean as possible,
because its lifetime usually is very limited.

Change-Id: I6bfc3d8e93117cef370b1f02eb0d432c04341947
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2017-05-19 06:59:23 +00:00
Maurice Kalinowski
4a9a5fc600 Move protocol version to enum
In addition, MQTT 4 is not an official term, rather what people talk
about in a flexible way.

Change-Id: Ie86c577d1e59096bc326e8de1e76fb7441b1b057
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-05-16 08:45:21 +00:00