Library for MQTT

Committer:
pavleradojkovic
Date:
Mon Jun 20 16:24:43 2022 +0000
Revision:
0:ba7e439238ab
Inital commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pavleradojkovic 0:ba7e439238ab 1 MQTT test plan
pavleradojkovic 0:ba7e439238ab 2 ========================
pavleradojkovic 0:ba7e439238ab 3
pavleradojkovic 0:ba7e439238ab 4 This is a test plan for the Mbed OS MQTT and MQTT-SN protocols. This describes all test cases and their intended behaviors. When an API document is not clear, use this as a reference for implementing correct behavior.
pavleradojkovic 0:ba7e439238ab 5
pavleradojkovic 0:ba7e439238ab 6 Target API
pavleradojkovic 0:ba7e439238ab 7 ----------
pavleradojkovic 0:ba7e439238ab 8
pavleradojkovic 0:ba7e439238ab 9 The target for this plan is to test (TODO: update links to point to mbed-os master after merge):
pavleradojkovic 0:ba7e439238ab 10
pavleradojkovic 0:ba7e439238ab 11 - [legacy MQTTClient paho implementation](../../features/mqtt/paho_mqtt_embedded_c/MQTTClient) with [mbed-os MQTTNetwork implementations](../../mqtt/features/mqtt/src).
pavleradojkovic 0:ba7e439238ab 12 - [new MQTTClient mbed-os wrapper (both for MQTT and MQTT-SN)](../../mqtt/src/MQTTClientNew.h).
pavleradojkovic 0:ba7e439238ab 13
pavleradojkovic 0:ba7e439238ab 14 Mbed-os tests are NOT meant to test the underlying Eclipse paho [MQTT](https://github.com/michalpasztamobica/mbed-os/tree/mqtt/features/mqtt/paho_mqtt_embedded_c) and [MQTT-SN](../../features/mqtt/paho_mqtt-sn_embedded_c) libraries. The tests provided are integration tests, checking whether MQTT works correctly with the mbed-os sockets.
pavleradojkovic 0:ba7e439238ab 15
pavleradojkovic 0:ba7e439238ab 16 Tools to use
pavleradojkovic 0:ba7e439238ab 17 ------------
pavleradojkovic 0:ba7e439238ab 18
pavleradojkovic 0:ba7e439238ab 19 - Mbed OS.
pavleradojkovic 0:ba7e439238ab 20 - Standard Mbed OS development tools as described in the [Arm Mbed tools overview](https://os.mbed.com/docs/latest/tools/index.html).
pavleradojkovic 0:ba7e439238ab 21 - Test server with an MQTT broker.
pavleradojkovic 0:ba7e439238ab 22
pavleradojkovic 0:ba7e439238ab 23 These test cases themselves do not require any special tooling, other than the MQTT test server described in "Test environment" chapter.
pavleradojkovic 0:ba7e439238ab 24
pavleradojkovic 0:ba7e439238ab 25 Test environment
pavleradojkovic 0:ba7e439238ab 26 ----------------
pavleradojkovic 0:ba7e439238ab 27
pavleradojkovic 0:ba7e439238ab 28 As a general guideline, network connectivity with public Internet access is required. This satisfies Socket tests, but specific connectivity methods might require some extra configuration or devices within the network.
pavleradojkovic 0:ba7e439238ab 29
pavleradojkovic 0:ba7e439238ab 30 The test environment consist of DUTs, network connection and an MQTT broker.
pavleradojkovic 0:ba7e439238ab 31
pavleradojkovic 0:ba7e439238ab 32 ### Test server setup
pavleradojkovic 0:ba7e439238ab 33
pavleradojkovic 0:ba7e439238ab 34 **Required services in the test server**
pavleradojkovic 0:ba7e439238ab 35
pavleradojkovic 0:ba7e439238ab 36 - MQTT protcol is enabled on TCP port 1883. Port 8883 for TLS
pavleradojkovic 0:ba7e439238ab 37 - MQTT-SN protocol is enabled on UDP port 10000.
pavleradojkovic 0:ba7e439238ab 38
pavleradojkovic 0:ba7e439238ab 39 Configure the firewall to allow this traffic to access the MQTT test server.
pavleradojkovic 0:ba7e439238ab 40
pavleradojkovic 0:ba7e439238ab 41 Some tests are wrapped with a MQTT_MBED_PUBLIC_TEST_TOPIC_AVAILABLE macro. They will only work if a topic is provided in the broker named "mbed_public_test_topic", that publishes a message with QoS = 0 and content "Test message" with a constant frequency. This is intended for use in testing the subscription without having to publish any additional messages.
pavleradojkovic 0:ba7e439238ab 42
pavleradojkovic 0:ba7e439238ab 43 **Example configuration for Debian/Ubuntu Linux**
pavleradojkovic 0:ba7e439238ab 44
pavleradojkovic 0:ba7e439238ab 45 The example test server is using an open-source [Eclipse Mosquitto MQTT broker](https://mosquitto.org/) and [Eclipse paho MQTT-SN Gateway](https://www.eclipse.org/paho/components/mqtt-sn-transparent-gateway/), which are available on many operating systems, and installing them is out of scope of this document. Below is an example of how to install these services into a Debian/Ubuntu based Linux distribution.
pavleradojkovic 0:ba7e439238ab 46
pavleradojkovic 0:ba7e439238ab 47 ***MQTT***
pavleradojkovic 0:ba7e439238ab 48
pavleradojkovic 0:ba7e439238ab 49 ```.sh
pavleradojkovic 0:ba7e439238ab 50 $ sudo apt install mosquitto
pavleradojkovic 0:ba7e439238ab 51 ```
pavleradojkovic 0:ba7e439238ab 52
pavleradojkovic 0:ba7e439238ab 53 The mosquitto broker will start automatically as a deamon on system startup. You can start, stop or restart it using:
pavleradojkovic 0:ba7e439238ab 54 ```.sh
pavleradojkovic 0:ba7e439238ab 55 $ sudo service mosquitto [start|stop|restart]
pavleradojkovic 0:ba7e439238ab 56 ```
pavleradojkovic 0:ba7e439238ab 57
pavleradojkovic 0:ba7e439238ab 58 Install the mosquitto clients to be able to test your mosquitto broker locally and generate traffic for a predefined channel:
pavleradojkovic 0:ba7e439238ab 59
pavleradojkovic 0:ba7e439238ab 60 ```.sh
pavleradojkovic 0:ba7e439238ab 61 $ sudo apt install mosquitto-clients
pavleradojkovic 0:ba7e439238ab 62 ```
pavleradojkovic 0:ba7e439238ab 63
pavleradojkovic 0:ba7e439238ab 64 When running the below commands in separate shells:
pavleradojkovic 0:ba7e439238ab 65
pavleradojkovic 0:ba7e439238ab 66 ```.sh
pavleradojkovic 0:ba7e439238ab 67 $ mosquitto_sub -p 1883 -t "testtopic"
pavleradojkovic 0:ba7e439238ab 68 $ mosquitto_pub -p 1883 -t "testtopic" -m "testmessage"
pavleradojkovic 0:ba7e439238ab 69 ```
pavleradojkovic 0:ba7e439238ab 70 You should be able to receive the "testmessage" on the subscriber side.
pavleradojkovic 0:ba7e439238ab 71
pavleradojkovic 0:ba7e439238ab 72 Create a channel that will be fed with messages in a periodic manner. An example of how this can be achieved:
pavleradojkovic 0:ba7e439238ab 73
pavleradojkovic 0:ba7e439238ab 74 ```
pavleradojkovic 0:ba7e439238ab 75 $ watch -n1 mosquitto_pub -p 1883 -m \"Test message\" -t \"mbed_public_test_topic\" -q 0
pavleradojkovic 0:ba7e439238ab 76 ```
pavleradojkovic 0:ba7e439238ab 77
pavleradojkovic 0:ba7e439238ab 78 Make sure QoS is set to 0 (`-q 0`), as this message might be received by multiple devices (or no devices after the tests ends).
pavleradojkovic 0:ba7e439238ab 79
pavleradojkovic 0:ba7e439238ab 80 Tests which will fail without this functionality are wrapped with a MQTT_MBED_PUBLIC_TEST_TOPIC_AVAILABLE macro.
pavleradojkovic 0:ba7e439238ab 81
pavleradojkovic 0:ba7e439238ab 82 Optionally edit (or create) the mosquitto broker configuration in /etc/mosquitto/conf.d/ to adjust the port that is used for communication (by default it's 1883):
pavleradojkovic 0:ba7e439238ab 83
pavleradojkovic 0:ba7e439238ab 84 ```
pavleradojkovic 0:ba7e439238ab 85 # Port to use for default listener
pavleradojkovic 0:ba7e439238ab 86 listener 1883
pavleradojkovic 0:ba7e439238ab 87 ```
pavleradojkovic 0:ba7e439238ab 88
pavleradojkovic 0:ba7e439238ab 89 To be able to access the broker from the network you need to open the tcp port that the broker is using:
pavleradojkovic 0:ba7e439238ab 90 ```.sh
pavleradojkovic 0:ba7e439238ab 91 $ sudo ufw allow 1883/tcp
pavleradojkovic 0:ba7e439238ab 92 ```
pavleradojkovic 0:ba7e439238ab 93
pavleradojkovic 0:ba7e439238ab 94 Some tests are protected with MQTT_MBED_PASSWORD_PROTECTION_AVAILABLE macro. Those tests can only be run when the MQTT broker is configured to check for a user and password. Follow [this tutorial](http://www.steves-internet-guide.com/mqtt-username-password-example/) to configure the broker.
pavleradojkovic 0:ba7e439238ab 95
pavleradojkovic 0:ba7e439238ab 96 Make sure that allow_anonymous is set to true, as most test access the broker anonymously.
pavleradojkovic 0:ba7e439238ab 97
pavleradojkovic 0:ba7e439238ab 98 The tests are by default using user "mbed" and password "1234", so consider setting those on your broker or adjust the tests.
pavleradojkovic 0:ba7e439238ab 99
pavleradojkovic 0:ba7e439238ab 100 Bear in mind that MQTT user/password is sent in raw text and it has nothing to do with proper TLS encryption described below.
pavleradojkovic 0:ba7e439238ab 101
pavleradojkovic 0:ba7e439238ab 102 ***MQTT TLS***
pavleradojkovic 0:ba7e439238ab 103
pavleradojkovic 0:ba7e439238ab 104 By default port 8883 is used for TLS-protected MQTT communication.
pavleradojkovic 0:ba7e439238ab 105
pavleradojkovic 0:ba7e439238ab 106 When the MQTT broker is set up as described above, just follow [this tutorial](http://www.steves-internet-guide.com/mosquitto-tls/) to set up the mqtt broker and all certificates. Use `tls_version tlsv1.2`.
pavleradojkovic 0:ba7e439238ab 107
pavleradojkovic 0:ba7e439238ab 108 ***MQTT-SN***
pavleradojkovic 0:ba7e439238ab 109
pavleradojkovic 0:ba7e439238ab 110 Once MQTT broker is running it is necessary to set up an MQTT-SN Gateway that would establish a connection to the broker and forward the UDP packets.
pavleradojkovic 0:ba7e439238ab 111
pavleradojkovic 0:ba7e439238ab 112 Download or clone the [Eclipse paho MQTT-SN implementation](https://github.com/eclipse/paho.mqtt-sn.embedded-c/tree/master/MQTTSNGateway). Follow the guidelines in their repository.
pavleradojkovic 0:ba7e439238ab 113
pavleradojkovic 0:ba7e439238ab 114 Make sure you adjust the gateway.conf file:
pavleradojkovic 0:ba7e439238ab 115
pavleradojkovic 0:ba7e439238ab 116 ```
pavleradojkovic 0:ba7e439238ab 117 BrokerName=localhost
pavleradojkovic 0:ba7e439238ab 118 ```
pavleradojkovic 0:ba7e439238ab 119
pavleradojkovic 0:ba7e439238ab 120 Also it might be necessary to allow the `PredefinedTopicsList` option in case the Gateway crashes when starting up.
pavleradojkovic 0:ba7e439238ab 121
pavleradojkovic 0:ba7e439238ab 122 Finally, make sure the Gateway port is emabled for external devices:
pavleradojkovic 0:ba7e439238ab 123
pavleradojkovic 0:ba7e439238ab 124 ```.sh
pavleradojkovic 0:ba7e439238ab 125 $ sudo ufw allow 10000/udp
pavleradojkovic 0:ba7e439238ab 126 ```
pavleradojkovic 0:ba7e439238ab 127
pavleradojkovic 0:ba7e439238ab 128 Providing custom configuration (optional)
pavleradojkovic 0:ba7e439238ab 129 -----------------------------------------
pavleradojkovic 0:ba7e439238ab 130
pavleradojkovic 0:ba7e439238ab 131 By default the tests will run on a predefined local server as configured in mbed_lib.json.
pavleradojkovic 0:ba7e439238ab 132
pavleradojkovic 0:ba7e439238ab 133 It is possible to override the default configuration by providing an `mbed_app.json` file.
pavleradojkovic 0:ba7e439238ab 134
pavleradojkovic 0:ba7e439238ab 135 The example below will configure the tests to run on a `flespi.io` public MQTT server:
pavleradojkovic 0:ba7e439238ab 136
pavleradojkovic 0:ba7e439238ab 137 ```
pavleradojkovic 0:ba7e439238ab 138 {
pavleradojkovic 0:ba7e439238ab 139 "config": {
pavleradojkovic 0:ba7e439238ab 140
pavleradojkovic 0:ba7e439238ab 141 },
pavleradojkovic 0:ba7e439238ab 142 "target_overrides": {
pavleradojkovic 0:ba7e439238ab 143 "*": {
pavleradojkovic 0:ba7e439238ab 144 "mbed-mqtt.tests-broker-hostname": "\"mqtt.flespi.io\"",
pavleradojkovic 0:ba7e439238ab 145 "mbed-mqtt.tests-topic": "\"test\"",
pavleradojkovic 0:ba7e439238ab 146 "mbed-mqtt.tests-public-topic-enable": "false",
pavleradojkovic 0:ba7e439238ab 147 "mbed-mqtt.tests-public-topic-name": "\"mbed_public_test_topic\"",
pavleradojkovic 0:ba7e439238ab 148 "mbed-mqtt.tests-username-password-protection-enable": "true",
pavleradojkovic 0:ba7e439238ab 149 "mbed-mqtt.tests-tls-enable": "false",
pavleradojkovic 0:ba7e439238ab 150 "mbed-mqtt.tests-username": "\"YOUR_FLESPI_TOKEN\"",
pavleradojkovic 0:ba7e439238ab 151 "mbed-mqtt.tests-password": "\"\"",
pavleradojkovic 0:ba7e439238ab 152 "mbed-mqtt.tests-username-always": "false",
pavleradojkovic 0:ba7e439238ab 153 "mbed-mqtt.tests-mqtt-sn-enable": "false",
pavleradojkovic 0:ba7e439238ab 154 "target.network-default-interface-type": "ETHERNET"
pavleradojkovic 0:ba7e439238ab 155 }
pavleradojkovic 0:ba7e439238ab 156 }
pavleradojkovic 0:ba7e439238ab 157 }
pavleradojkovic 0:ba7e439238ab 158 ```
pavleradojkovic 0:ba7e439238ab 159
pavleradojkovic 0:ba7e439238ab 160 Building test binaries
pavleradojkovic 0:ba7e439238ab 161 --------------------------
pavleradojkovic 0:ba7e439238ab 162
pavleradojkovic 0:ba7e439238ab 163 For testing the board and driver, test against the Mbed OS master branch to get the most recent, up-to-date test cases and drivers.
pavleradojkovic 0:ba7e439238ab 164
pavleradojkovic 0:ba7e439238ab 165 To create a build environment:
pavleradojkovic 0:ba7e439238ab 166
pavleradojkovic 0:ba7e439238ab 167 ```.sh
pavleradojkovic 0:ba7e439238ab 168 mbed new network_test
pavleradojkovic 0:ba7e439238ab 169 cd network_test
pavleradojkovic 0:ba7e439238ab 170 cd mbed-os
pavleradojkovic 0:ba7e439238ab 171 git checkout master
pavleradojkovic 0:ba7e439238ab 172 cd ..
pavleradojkovic 0:ba7e439238ab 173 ```
pavleradojkovic 0:ba7e439238ab 174
pavleradojkovic 0:ba7e439238ab 175 MQTT tests will run on any type of connection. See the [relevant section of netsocket tests](../netsocket/README.md#building-test-binaries) to find more information on how to establish connectivity.
pavleradojkovic 0:ba7e439238ab 176
pavleradojkovic 0:ba7e439238ab 177 Now build test binaries:
pavleradojkovic 0:ba7e439238ab 178
pavleradojkovic 0:ba7e439238ab 179 ```.sh
pavleradojkovic 0:ba7e439238ab 180 mbed test --compile -t <toolchain> -m <target> -n mbed-os-tests-mqtt-mqtt
pavleradojkovic 0:ba7e439238ab 181 ```
pavleradojkovic 0:ba7e439238ab 182
pavleradojkovic 0:ba7e439238ab 183 Running tests
pavleradojkovic 0:ba7e439238ab 184 -------------
pavleradojkovic 0:ba7e439238ab 185
pavleradojkovic 0:ba7e439238ab 186 When device is connected to network, or in case of wireless device near the access point.
pavleradojkovic 0:ba7e439238ab 187
pavleradojkovic 0:ba7e439238ab 188 ```.sh
pavleradojkovic 0:ba7e439238ab 189 mbed test -n mbed-os-tests-mqtt-mqtt
pavleradojkovic 0:ba7e439238ab 190 ```
pavleradojkovic 0:ba7e439238ab 191
pavleradojkovic 0:ba7e439238ab 192 Test cases for MQTT
pavleradojkovic 0:ba7e439238ab 193 -------------------
pavleradojkovic 0:ba7e439238ab 194
pavleradojkovic 0:ba7e439238ab 195 The API for legacy MQTT and new MQTT wrapper are identical, so the tests description apply to both of them.
pavleradojkovic 0:ba7e439238ab 196
pavleradojkovic 0:ba7e439238ab 197 Also the MQTT-SN has the same interface as MQTT, so all "MQTT_*" test also apply to MQTT-SN.
pavleradojkovic 0:ba7e439238ab 198
pavleradojkovic 0:ba7e439238ab 199 The only difference is in how the Client class is created.
pavleradojkovic 0:ba7e439238ab 200
pavleradojkovic 0:ba7e439238ab 201
pavleradojkovic 0:ba7e439238ab 202 ### MQTT_CONNECT
pavleradojkovic 0:ba7e439238ab 203
pavleradojkovic 0:ba7e439238ab 204 **Description:**
pavleradojkovic 0:ba7e439238ab 205
pavleradojkovic 0:ba7e439238ab 206 Client can connect to broker.
pavleradojkovic 0:ba7e439238ab 207
pavleradojkovic 0:ba7e439238ab 208 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 209
pavleradojkovic 0:ba7e439238ab 210 Device is connected to network and connection to MQTT server is established.
pavleradojkovic 0:ba7e439238ab 211
pavleradojkovic 0:ba7e439238ab 212 **Test steps:**
pavleradojkovic 0:ba7e439238ab 213
pavleradojkovic 0:ba7e439238ab 214 1. Call `client.connect()` with an valid connectData provided. Check that no error is returned.
pavleradojkovic 0:ba7e439238ab 215
pavleradojkovic 0:ba7e439238ab 216 **Expected result:**
pavleradojkovic 0:ba7e439238ab 217
pavleradojkovic 0:ba7e439238ab 218 Call to `client.connect()` succeeds (returns NSAPI_ERROR_OK).
pavleradojkovic 0:ba7e439238ab 219
pavleradojkovic 0:ba7e439238ab 220
pavleradojkovic 0:ba7e439238ab 221 ### MQTT_CONNECT_NOT_CONNECTED
pavleradojkovic 0:ba7e439238ab 222
pavleradojkovic 0:ba7e439238ab 223 **Description:**
pavleradojkovic 0:ba7e439238ab 224
pavleradojkovic 0:ba7e439238ab 225 Client fails to connect when network is not connected.
pavleradojkovic 0:ba7e439238ab 226
pavleradojkovic 0:ba7e439238ab 227 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 228
pavleradojkovic 0:ba7e439238ab 229 Device is connected to network.
pavleradojkovic 0:ba7e439238ab 230
pavleradojkovic 0:ba7e439238ab 231 **Test steps:**
pavleradojkovic 0:ba7e439238ab 232
pavleradojkovic 0:ba7e439238ab 233 1. Try to connect to a nonexistent MQTT server address or incorrect port.
pavleradojkovic 0:ba7e439238ab 234 2. Call `client.connect()` with a valid connectData provided.
pavleradojkovic 0:ba7e439238ab 235
pavleradojkovic 0:ba7e439238ab 236 **Expected result:**
pavleradojkovic 0:ba7e439238ab 237
pavleradojkovic 0:ba7e439238ab 238 Connection fails in step 1. Call to `client.connect()` returns -1 error in step 2.
pavleradojkovic 0:ba7e439238ab 239
pavleradojkovic 0:ba7e439238ab 240
pavleradojkovic 0:ba7e439238ab 241 ### MQTT_SUBSCRIBE
pavleradojkovic 0:ba7e439238ab 242
pavleradojkovic 0:ba7e439238ab 243 Client can subscribe to a topic.
pavleradojkovic 0:ba7e439238ab 244
pavleradojkovic 0:ba7e439238ab 245 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 246
pavleradojkovic 0:ba7e439238ab 247 Device is connected to network, connection to MQTT broker is established (see the _CONNECT tests).
pavleradojkovic 0:ba7e439238ab 248
pavleradojkovic 0:ba7e439238ab 249 **Test steps:**
pavleradojkovic 0:ba7e439238ab 250
pavleradojkovic 0:ba7e439238ab 251 1. Call `client.subscribe()` with a valid topic and QoS0.
pavleradojkovic 0:ba7e439238ab 252
pavleradojkovic 0:ba7e439238ab 253 **Expected result:**
pavleradojkovic 0:ba7e439238ab 254
pavleradojkovic 0:ba7e439238ab 255 Call to `client.connect()` succeeds (returns NSAPI_ERROR_OK) in step 1.
pavleradojkovic 0:ba7e439238ab 256
pavleradojkovic 0:ba7e439238ab 257
pavleradojkovic 0:ba7e439238ab 258 ### MQTT_SUBSCRIBE_NETWORK_NOT_CONNECTED
pavleradojkovic 0:ba7e439238ab 259
pavleradojkovic 0:ba7e439238ab 260 Client returns an error if subscribing to a topic when there is no connection to MQTT server.
pavleradojkovic 0:ba7e439238ab 261
pavleradojkovic 0:ba7e439238ab 262 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 263
pavleradojkovic 0:ba7e439238ab 264 Device is connected to network, but not connected to broker or server.
pavleradojkovic 0:ba7e439238ab 265
pavleradojkovic 0:ba7e439238ab 266 **Test steps:**
pavleradojkovic 0:ba7e439238ab 267
pavleradojkovic 0:ba7e439238ab 268 1. Call `client.subscribe()` with a valid topic and QoS0.
pavleradojkovic 0:ba7e439238ab 269
pavleradojkovic 0:ba7e439238ab 270 **Expected result:**
pavleradojkovic 0:ba7e439238ab 271
pavleradojkovic 0:ba7e439238ab 272 Call to `client.subscribe()` returns -1 in step 1.
pavleradojkovic 0:ba7e439238ab 273
pavleradojkovic 0:ba7e439238ab 274
pavleradojkovic 0:ba7e439238ab 275 ### MQTT_SUBSCRIBE_CLIENT_NOT_CONNECTED
pavleradojkovic 0:ba7e439238ab 276
pavleradojkovic 0:ba7e439238ab 277 Client returns an error if subscribing to a topic when there is no connection to MQTT broker.
pavleradojkovic 0:ba7e439238ab 278
pavleradojkovic 0:ba7e439238ab 279 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 280
pavleradojkovic 0:ba7e439238ab 281 Device is connected to network and a connection to MQTT server is established.
pavleradojkovic 0:ba7e439238ab 282
pavleradojkovic 0:ba7e439238ab 283 **Test steps:**
pavleradojkovic 0:ba7e439238ab 284
pavleradojkovic 0:ba7e439238ab 285 1. Call `client.connect()` with an invalid connectData provided (for example: empty clientID).
pavleradojkovic 0:ba7e439238ab 286 2. Call `client.subscribe()` with a valid topic and QoS0.
pavleradojkovic 0:ba7e439238ab 287
pavleradojkovic 0:ba7e439238ab 288 **Expected result:**
pavleradojkovic 0:ba7e439238ab 289
pavleradojkovic 0:ba7e439238ab 290 Call to `client.subscribe()` returns -1 in step 3.
pavleradojkovic 0:ba7e439238ab 291
pavleradojkovic 0:ba7e439238ab 292
pavleradojkovic 0:ba7e439238ab 293 ### MQTT_SUBSCRIBE_TOPIC_TOO_LONG
pavleradojkovic 0:ba7e439238ab 294
pavleradojkovic 0:ba7e439238ab 295 Client returns an error if subscribing to a topic longer than MAX_MQTT_PACKET_SIZE.
pavleradojkovic 0:ba7e439238ab 296
pavleradojkovic 0:ba7e439238ab 297 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 298
pavleradojkovic 0:ba7e439238ab 299 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 300
pavleradojkovic 0:ba7e439238ab 301 **Test steps:**
pavleradojkovic 0:ba7e439238ab 302
pavleradojkovic 0:ba7e439238ab 303 1. Generate a valid string of length larger than MAX_MQTT_PACKET_SIZE.
pavleradojkovic 0:ba7e439238ab 304 2. Call `client.subscribe()` with the too long topic created in step 1 and QoS0.
pavleradojkovic 0:ba7e439238ab 305
pavleradojkovic 0:ba7e439238ab 306 **Expected result:**
pavleradojkovic 0:ba7e439238ab 307
pavleradojkovic 0:ba7e439238ab 308 Call to `client.subscribe()` returns -1 in step 2.
pavleradojkovic 0:ba7e439238ab 309
pavleradojkovic 0:ba7e439238ab 310
pavleradojkovic 0:ba7e439238ab 311 ### MQTT_SUBSCRIBE_INVALID_MESSAGE_HANDLER
pavleradojkovic 0:ba7e439238ab 312
pavleradojkovic 0:ba7e439238ab 313 Client returns an error if subscribing to a topic without providing a valid message handler.
pavleradojkovic 0:ba7e439238ab 314
pavleradojkovic 0:ba7e439238ab 315 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 316
pavleradojkovic 0:ba7e439238ab 317 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 318
pavleradojkovic 0:ba7e439238ab 319 **Test steps:**
pavleradojkovic 0:ba7e439238ab 320
pavleradojkovic 0:ba7e439238ab 321 1. Call `client.connect()` with an invalid connectData provided (for example: empty clientID).
pavleradojkovic 0:ba7e439238ab 322 2. Call `client.subscribe()` with a valid topic, QoS0 and NULL provided intead of message handler function pointer.
pavleradojkovic 0:ba7e439238ab 323
pavleradojkovic 0:ba7e439238ab 324 **Expected result:**
pavleradojkovic 0:ba7e439238ab 325
pavleradojkovic 0:ba7e439238ab 326 Call to `client.subscribe()` returns -1 in step 2.
pavleradojkovic 0:ba7e439238ab 327
pavleradojkovic 0:ba7e439238ab 328
pavleradojkovic 0:ba7e439238ab 329 ### MQTT_SUBSCRIBE_RECEIVE
pavleradojkovic 0:ba7e439238ab 330
pavleradojkovic 0:ba7e439238ab 331 Client is able to receive MQTT messages after subscribing to a predefined topic.
pavleradojkovic 0:ba7e439238ab 332
pavleradojkovic 0:ba7e439238ab 333 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 334
pavleradojkovic 0:ba7e439238ab 335 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 336
pavleradojkovic 0:ba7e439238ab 337 The MQTT broker has a topic "mbed_public_test_topic", which is guaranteed to generate a message before the test times out.
pavleradojkovic 0:ba7e439238ab 338
pavleradojkovic 0:ba7e439238ab 339 **Test steps:**
pavleradojkovic 0:ba7e439238ab 340
pavleradojkovic 0:ba7e439238ab 341 1. Call `client.subscribe()` with topic set to "mbed_public_test_topic", QoS0 and a message handler that would prove successful message reception (for example increment a counter).
pavleradojkovic 0:ba7e439238ab 342 2. Wait until a message is received.
pavleradojkovic 0:ba7e439238ab 343 3. Verify that a message was received.
pavleradojkovic 0:ba7e439238ab 344 4. Unsubscribe from the "mbed_public_test_topic" topic.
pavleradojkovic 0:ba7e439238ab 345
pavleradojkovic 0:ba7e439238ab 346 **Expected result:**
pavleradojkovic 0:ba7e439238ab 347
pavleradojkovic 0:ba7e439238ab 348 A message is received from the topic in steps 2 and 3. Test does not time out.
pavleradojkovic 0:ba7e439238ab 349
pavleradojkovic 0:ba7e439238ab 350
pavleradojkovic 0:ba7e439238ab 351 ### MQTT_UNSUBSCRIBE_WITHOUT_SUBSCRIBE
pavleradojkovic 0:ba7e439238ab 352
pavleradojkovic 0:ba7e439238ab 353 Client is able to unsubscribe without subscribing to any topic.
pavleradojkovic 0:ba7e439238ab 354
pavleradojkovic 0:ba7e439238ab 355 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 356
pavleradojkovic 0:ba7e439238ab 357 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 358
pavleradojkovic 0:ba7e439238ab 359 **Test steps:**
pavleradojkovic 0:ba7e439238ab 360
pavleradojkovic 0:ba7e439238ab 361 1. Unsubscribe from a valid topic.
pavleradojkovic 0:ba7e439238ab 362
pavleradojkovic 0:ba7e439238ab 363 **Expected result:**
pavleradojkovic 0:ba7e439238ab 364
pavleradojkovic 0:ba7e439238ab 365 Call to `client.unsubscribe()` returns NSAPI_ERROR_OK.
pavleradojkovic 0:ba7e439238ab 366
pavleradojkovic 0:ba7e439238ab 367
pavleradojkovic 0:ba7e439238ab 368 ### MQTT_UNSUBSCRIBE_INVALID
pavleradojkovic 0:ba7e439238ab 369
pavleradojkovic 0:ba7e439238ab 370 Client returns an error when invalid topic name is provided.
pavleradojkovic 0:ba7e439238ab 371
pavleradojkovic 0:ba7e439238ab 372 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 373
pavleradojkovic 0:ba7e439238ab 374 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 375
pavleradojkovic 0:ba7e439238ab 376 **Test steps:**
pavleradojkovic 0:ba7e439238ab 377
pavleradojkovic 0:ba7e439238ab 378 1. Unsubscribe from a topic which is an empty string.
pavleradojkovic 0:ba7e439238ab 379 2. Unsubscribe from a topic which has topic of length longer than MAX_MQTT_PACKET_SIZE.
pavleradojkovic 0:ba7e439238ab 380
pavleradojkovic 0:ba7e439238ab 381 **Expected result:**
pavleradojkovic 0:ba7e439238ab 382
pavleradojkovic 0:ba7e439238ab 383 Both calls to `client.unsubscribe()` return -1.
pavleradojkovic 0:ba7e439238ab 384
pavleradojkovic 0:ba7e439238ab 385 ### MQTT_PUBLISH
pavleradojkovic 0:ba7e439238ab 386
pavleradojkovic 0:ba7e439238ab 387 Client is able to publish MQTT messages to a topic.
pavleradojkovic 0:ba7e439238ab 388
pavleradojkovic 0:ba7e439238ab 389 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 390
pavleradojkovic 0:ba7e439238ab 391 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 392
pavleradojkovic 0:ba7e439238ab 393 **Test steps:**
pavleradojkovic 0:ba7e439238ab 394
pavleradojkovic 0:ba7e439238ab 395 1. Call `client.publish()` with a valid topic and message with QoS1.
pavleradojkovic 0:ba7e439238ab 396 2. Call `client.publish()` with a valid topic and message with QoS2.
pavleradojkovic 0:ba7e439238ab 397 3. Call `client.publish()` with a valid topic and message with QoS3.
pavleradojkovic 0:ba7e439238ab 398
pavleradojkovic 0:ba7e439238ab 399 **Expected result:**
pavleradojkovic 0:ba7e439238ab 400
pavleradojkovic 0:ba7e439238ab 401 All calls return NSAPI_ERROR_OK.
pavleradojkovic 0:ba7e439238ab 402
pavleradojkovic 0:ba7e439238ab 403 ### MQTT_PUBLISH_NOT_CONNECTED
pavleradojkovic 0:ba7e439238ab 404
pavleradojkovic 0:ba7e439238ab 405 Client returns an error if publishing to a topic when there is no connection to MQTT broker.
pavleradojkovic 0:ba7e439238ab 406
pavleradojkovic 0:ba7e439238ab 407 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 408
pavleradojkovic 0:ba7e439238ab 409 Device is connected to network and a connection to MQTT server is established.
pavleradojkovic 0:ba7e439238ab 410
pavleradojkovic 0:ba7e439238ab 411 **Test steps:**
pavleradojkovic 0:ba7e439238ab 412
pavleradojkovic 0:ba7e439238ab 413 1. Call `client.publish()` with a valid topic and QoS0.
pavleradojkovic 0:ba7e439238ab 414
pavleradojkovic 0:ba7e439238ab 415 **Expected result:**
pavleradojkovic 0:ba7e439238ab 416
pavleradojkovic 0:ba7e439238ab 417 Call to `client.publish()` returns -1 in step 1.
pavleradojkovic 0:ba7e439238ab 418
pavleradojkovic 0:ba7e439238ab 419
pavleradojkovic 0:ba7e439238ab 420 ### MQTT_PUBLISH_TOPIC_TOO_LONG
pavleradojkovic 0:ba7e439238ab 421
pavleradojkovic 0:ba7e439238ab 422 Client returns an error if publishing to a topic with name longer than MAX_MQTT_PACKET_SIZE.
pavleradojkovic 0:ba7e439238ab 423
pavleradojkovic 0:ba7e439238ab 424 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 425
pavleradojkovic 0:ba7e439238ab 426 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 427
pavleradojkovic 0:ba7e439238ab 428 **Test steps:**
pavleradojkovic 0:ba7e439238ab 429
pavleradojkovic 0:ba7e439238ab 430 1. Generate a valid string of length larger than MAX_MQTT_PACKET_SIZE.
pavleradojkovic 0:ba7e439238ab 431 2. Call `client.subscribe()` with the too long topic created in step 1 and QoS0.
pavleradojkovic 0:ba7e439238ab 432
pavleradojkovic 0:ba7e439238ab 433 **Expected result:**
pavleradojkovic 0:ba7e439238ab 434
pavleradojkovic 0:ba7e439238ab 435 Call to `client.publish()` returns -1 in step 2.
pavleradojkovic 0:ba7e439238ab 436
pavleradojkovic 0:ba7e439238ab 437 ### MQTT_CONNECT_USER_PASSWORD_INCORRECT
pavleradojkovic 0:ba7e439238ab 438
pavleradojkovic 0:ba7e439238ab 439 Client returns an error when incorrect password is provided to a password-protected broker.
pavleradojkovic 0:ba7e439238ab 440
pavleradojkovic 0:ba7e439238ab 441 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 442
pavleradojkovic 0:ba7e439238ab 443 Device is connected to network and a connection to MQTT server is established.
pavleradojkovic 0:ba7e439238ab 444
pavleradojkovic 0:ba7e439238ab 445 The broker is password-protected (see set up instructions for details).
pavleradojkovic 0:ba7e439238ab 446
pavleradojkovic 0:ba7e439238ab 447 **Test steps:**
pavleradojkovic 0:ba7e439238ab 448
pavleradojkovic 0:ba7e439238ab 449 1. Call `client.connect()` with an incorrect user and password specified.
pavleradojkovic 0:ba7e439238ab 450
pavleradojkovic 0:ba7e439238ab 451 **Expected result:**
pavleradojkovic 0:ba7e439238ab 452
pavleradojkovic 0:ba7e439238ab 453 Call to `client.connect()` returns -1.
pavleradojkovic 0:ba7e439238ab 454
pavleradojkovic 0:ba7e439238ab 455 ### MQTT_CONNECT_SUBSCRIBE_PUBLISH
pavleradojkovic 0:ba7e439238ab 456
pavleradojkovic 0:ba7e439238ab 457 Client is able to subscribe to a topic, publish to it and receive its own messages in a loopback.
pavleradojkovic 0:ba7e439238ab 458
pavleradojkovic 0:ba7e439238ab 459 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 460
pavleradojkovic 0:ba7e439238ab 461 Device is connected to network and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 462
pavleradojkovic 0:ba7e439238ab 463 **Test steps:**
pavleradojkovic 0:ba7e439238ab 464
pavleradojkovic 0:ba7e439238ab 465 All steps should be performed for QoS 0, 1 and 2.
pavleradojkovic 0:ba7e439238ab 466
pavleradojkovic 0:ba7e439238ab 467 1. Call `client.subscribe()` with a valid topic and register a message handler to verify that messages are recieved (for example with a message counter).
pavleradojkovic 0:ba7e439238ab 468 2. Call `client.publish()` with a previously used topic.
pavleradojkovic 0:ba7e439238ab 469 3. Compare the message counter
pavleradojkovic 0:ba7e439238ab 470
pavleradojkovic 0:ba7e439238ab 471 **Expected result:**
pavleradojkovic 0:ba7e439238ab 472
pavleradojkovic 0:ba7e439238ab 473 All calls return no errors and the message is received correctly (for example - message counter increases).
pavleradojkovic 0:ba7e439238ab 474
pavleradojkovic 0:ba7e439238ab 475 ### MQTT_CONNECT_SUBSCRIBE_PUBLISH_USER_PASSWORD
pavleradojkovic 0:ba7e439238ab 476
pavleradojkovic 0:ba7e439238ab 477 Client is able to provide user and password and subscribe to a topic, publish to it and receive its own messages in a loopback.
pavleradojkovic 0:ba7e439238ab 478
pavleradojkovic 0:ba7e439238ab 479 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 480
pavleradojkovic 0:ba7e439238ab 481 Device is connected to network and a connection to MQTT server is established.
pavleradojkovic 0:ba7e439238ab 482
pavleradojkovic 0:ba7e439238ab 483 The broker is password-protected (see set up instructions for details).
pavleradojkovic 0:ba7e439238ab 484
pavleradojkovic 0:ba7e439238ab 485 **Test steps:**
pavleradojkovic 0:ba7e439238ab 486
pavleradojkovic 0:ba7e439238ab 487 All steps should be performed for QoS 0, 1 and 2.
pavleradojkovic 0:ba7e439238ab 488
pavleradojkovic 0:ba7e439238ab 489 1. Call `client.connect()` with a valid and correct user and password specified.
pavleradojkovic 0:ba7e439238ab 490 2. Call `client.subscribe()` with a valid topic and register a message handler to verify that messages are recieved (for example with a message counter).
pavleradojkovic 0:ba7e439238ab 491 3. Call `client.publish()` with a previously used topic.
pavleradojkovic 0:ba7e439238ab 492 4. Compare the message counter.
pavleradojkovic 0:ba7e439238ab 493
pavleradojkovic 0:ba7e439238ab 494 **Expected result:**
pavleradojkovic 0:ba7e439238ab 495
pavleradojkovic 0:ba7e439238ab 496 All calls return no errors and the message is received correctly (for example - message counter increases).
pavleradojkovic 0:ba7e439238ab 497
pavleradojkovic 0:ba7e439238ab 498 Test case for MQTT with TLS
pavleradojkovic 0:ba7e439238ab 499 ---------------------------
pavleradojkovic 0:ba7e439238ab 500
pavleradojkovic 0:ba7e439238ab 501 These tests apply only for TLSSocket class both for MQTT legacy API and the new mbed-os wrapper.
pavleradojkovic 0:ba7e439238ab 502
pavleradojkovic 0:ba7e439238ab 503 In fact MQTT does not provide any TLS support, it uses the underlying TLSSocket to take care of this.
pavleradojkovic 0:ba7e439238ab 504
pavleradojkovic 0:ba7e439238ab 505 The test case is however relevant in order to verify correct integration of MQTT with TLSSocket and provides a valuable example of how to set up a secure MQTT connection.
pavleradojkovic 0:ba7e439238ab 506
pavleradojkovic 0:ba7e439238ab 507 ### MQTT_TLS_CONNECT_SUBSCRIBE_PUBLISH
pavleradojkovic 0:ba7e439238ab 508
pavleradojkovic 0:ba7e439238ab 509 Client is able to securely subscribe to a topic, publish to it and receive its own messages in a loopback.
pavleradojkovic 0:ba7e439238ab 510
pavleradojkovic 0:ba7e439238ab 511 Important: a secure port should be used for this test (by default 8883).
pavleradojkovic 0:ba7e439238ab 512
pavleradojkovic 0:ba7e439238ab 513 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 514
pavleradojkovic 0:ba7e439238ab 515 Device is connected to network over a secured socket and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 516
pavleradojkovic 0:ba7e439238ab 517 **Test steps:**
pavleradojkovic 0:ba7e439238ab 518
pavleradojkovic 0:ba7e439238ab 519 All steps should be performed for QoS 0, 1 and 2.
pavleradojkovic 0:ba7e439238ab 520
pavleradojkovic 0:ba7e439238ab 521 1. Call `client.subscribe()` with a valid topic and register a message handler to verify that messages are recieved (for example with a message counter).
pavleradojkovic 0:ba7e439238ab 522 2. Call `client.publish()` with a previously used topic.
pavleradojkovic 0:ba7e439238ab 523 3. Compare the message counter
pavleradojkovic 0:ba7e439238ab 524
pavleradojkovic 0:ba7e439238ab 525 **Expected result:**
pavleradojkovic 0:ba7e439238ab 526
pavleradojkovic 0:ba7e439238ab 527 All calls return no errors and the message is received correctly (for example - message counter increases).
pavleradojkovic 0:ba7e439238ab 528
pavleradojkovic 0:ba7e439238ab 529
pavleradojkovic 0:ba7e439238ab 530 Test cases for MQTT-SN
pavleradojkovic 0:ba7e439238ab 531 ----------------------
pavleradojkovic 0:ba7e439238ab 532
pavleradojkovic 0:ba7e439238ab 533 Most of the MQTT-SN API is identical to MQTT and should follow the tests described earlier. Exceptions:
pavleradojkovic 0:ba7e439238ab 534
pavleradojkovic 0:ba7e439238ab 535 * MQTT-SN does not provide the user/password functionality so MQTT_CONNECT_USER_PASSWORD_INCORRECT and MQTT_CONNECT_SUBSCRIBE_PUBLISH_USER_PASSWORD cannot be executed for MQTT-SN
pavleradojkovic 0:ba7e439238ab 536
pavleradojkovic 0:ba7e439238ab 537 The MQTT-SN-specific tests are listed below.
pavleradojkovic 0:ba7e439238ab 538
pavleradojkovic 0:ba7e439238ab 539 ### MQTTSN_IS_CONNECTED
pavleradojkovic 0:ba7e439238ab 540
pavleradojkovic 0:ba7e439238ab 541 Client can tell that it is connected.
pavleradojkovic 0:ba7e439238ab 542
pavleradojkovic 0:ba7e439238ab 543 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 544
pavleradojkovic 0:ba7e439238ab 545 Device is connected to network and a connection to MQTT-SN broker is established.
pavleradojkovic 0:ba7e439238ab 546
pavleradojkovic 0:ba7e439238ab 547 **Test steps:**
pavleradojkovic 0:ba7e439238ab 548
pavleradojkovic 0:ba7e439238ab 549 1. Call `client.isConnected()`
pavleradojkovic 0:ba7e439238ab 550
pavleradojkovic 0:ba7e439238ab 551 **Expected result:**
pavleradojkovic 0:ba7e439238ab 552
pavleradojkovic 0:ba7e439238ab 553 Call to `client.isConnected()` returns true.
pavleradojkovic 0:ba7e439238ab 554
pavleradojkovic 0:ba7e439238ab 555 ### MQTTSN_IS_CONNECTED_CLIENT_NOT_CONNECTED
pavleradojkovic 0:ba7e439238ab 556
pavleradojkovic 0:ba7e439238ab 557 Client can tell that it is not connected.
pavleradojkovic 0:ba7e439238ab 558
pavleradojkovic 0:ba7e439238ab 559 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 560
pavleradojkovic 0:ba7e439238ab 561 Device is connected to network and a connection to MQTT-SN server (but not broker) is established.
pavleradojkovic 0:ba7e439238ab 562
pavleradojkovic 0:ba7e439238ab 563 **Test steps:**
pavleradojkovic 0:ba7e439238ab 564
pavleradojkovic 0:ba7e439238ab 565 1. Call `client.isConnected()`
pavleradojkovic 0:ba7e439238ab 566
pavleradojkovic 0:ba7e439238ab 567 **Expected result:**
pavleradojkovic 0:ba7e439238ab 568
pavleradojkovic 0:ba7e439238ab 569 Call to `client.isConnected()` returns false.
pavleradojkovic 0:ba7e439238ab 570
pavleradojkovic 0:ba7e439238ab 571 ### MQTTSN_IS_CONNECTED_NETWORK_NOT_CONNECTED
pavleradojkovic 0:ba7e439238ab 572
pavleradojkovic 0:ba7e439238ab 573 Client can tell that it is not connected.
pavleradojkovic 0:ba7e439238ab 574
pavleradojkovic 0:ba7e439238ab 575 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 576
pavleradojkovic 0:ba7e439238ab 577 Device is connected to network.
pavleradojkovic 0:ba7e439238ab 578
pavleradojkovic 0:ba7e439238ab 579 **Test steps:**
pavleradojkovic 0:ba7e439238ab 580
pavleradojkovic 0:ba7e439238ab 581 1. Call `client.isConnected()`
pavleradojkovic 0:ba7e439238ab 582 2. Try to connect client to a non-existent broker.
pavleradojkovic 0:ba7e439238ab 583 3. Call `client.isConnected()`
pavleradojkovic 0:ba7e439238ab 584
pavleradojkovic 0:ba7e439238ab 585 **Expected result:**
pavleradojkovic 0:ba7e439238ab 586
pavleradojkovic 0:ba7e439238ab 587 Connection fails in step 2.
pavleradojkovic 0:ba7e439238ab 588 Call to `client.isConnected()` returns false in steps 1 and 3.
pavleradojkovic 0:ba7e439238ab 589
pavleradojkovic 0:ba7e439238ab 590 ### MQTTSN_UDP_CONNECT_SUBSCRIBE_PUBLISH
pavleradojkovic 0:ba7e439238ab 591
pavleradojkovic 0:ba7e439238ab 592 Client is able to use a UDP Socket to subscribe to a topic, publish to it and receive its own messages in a loopback.
pavleradojkovic 0:ba7e439238ab 593
pavleradojkovic 0:ba7e439238ab 594 Important: See MQTT-SN section to set up an MQTT-SN gateway for communication. Use an appropriate port (by default 10000).
pavleradojkovic 0:ba7e439238ab 595
pavleradojkovic 0:ba7e439238ab 596 **Preconditions:**
pavleradojkovic 0:ba7e439238ab 597
pavleradojkovic 0:ba7e439238ab 598 Device is connected to network over a UDP socket and a connection to MQTT broker is established.
pavleradojkovic 0:ba7e439238ab 599
pavleradojkovic 0:ba7e439238ab 600 **Test steps:**
pavleradojkovic 0:ba7e439238ab 601
pavleradojkovic 0:ba7e439238ab 602 All steps should be performed for QoS 0, 1 and 2.
pavleradojkovic 0:ba7e439238ab 603
pavleradojkovic 0:ba7e439238ab 604 1. Call `client.subscribe()` with a valid topic and register a message handler to verify that messages are recieved (for example with a message counter).
pavleradojkovic 0:ba7e439238ab 605 2. Call `client.publish()` with a previously used topic.
pavleradojkovic 0:ba7e439238ab 606 3. Compare the message counter
pavleradojkovic 0:ba7e439238ab 607
pavleradojkovic 0:ba7e439238ab 608 **Expected result:**
pavleradojkovic 0:ba7e439238ab 609
pavleradojkovic 0:ba7e439238ab 610 All calls return no errors and the message is received correctly (for example - message counter increases).