diff --git a/.travis.yml b/.travis.yml index 6d3d2cf..2b61cc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,29 @@ language: python - +services: +- docker python: - - "2.7" - +- '2.7' +before_install: +- docker pull eclipse-mosquitto +- docker run -d -p 1883:1883 -p 9001:9001 -v $(pwd)/mosquitto:/mosquitto/config eclipse-mosquitto install: - - "pip install -r requirements.txt" - +- pip install -r requirements.txt script: - - pybot -P src -e local-only tests +- pybot -P src tests +deploy: + - provider: pypi + user: randomsync + password: + secure: JGikGMEMaDKQr50zDtj/ZE9haWhoJgC8nJEaNwrj9PaHePwQQ7tvDsi453k1zd3T3yQrrVe8oKB1fqzLViwSv6y3LO4j12fVrKTYcLPJCUSJo+FV/m3aDwD5Ps1QjcSO16zRudqyikcn+ESoWHl3VnVJ2f9h/88/XBRpChpyZuk= + on: + repo: randomsync/robotframework-mqttlibrary + tags: true + - provider: releases + api_key: + secure: JAaqldr74M3AwKBUAyCoeEdeFotPgXlSO7ML6IWpv327UXsz/CZyZg3lDnFZEPyUfzr/pndUEN/M/eeHTuLMXVhv5rdaiMWS5pXXcs6mmR7irT5LK3giRJKJpfNWcOTCRkotHJRkMC7vOuHWhuLrJ0a7v4yxZyTcqBsQUq+Qk/Q= + file: dist/* + skip_cleanup: true + draft: true + on: + repo: randomsync/robotframework-mqttlibrary + tags: true diff --git a/README.rst b/README.rst index 69758f7..3425611 100644 --- a/README.rst +++ b/README.rst @@ -51,7 +51,7 @@ Connect to the broker, subscribe and validate that a message is received: .. code-block:: robotframework *** Test Cases *** - Subsribe and Validate + Subscribe and Validate Connect 127.0.0.1 Subscribe and Validate topic=test/mqtt_test qos=1 payload=test [Teardown] Disconnect @@ -65,3 +65,25 @@ For general information about using test libraries with Robot Framework, see `Robot Framework User Guide`__. __ http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-test-libraries + +Contributing +------------ + +The keywords in this library are based on some of the methods available in eclipse paho client library. If you'd like to add keywords, see instructions_ on creating/updating libraries for Robot Framework. + +The tests are in ``tests`` folder and make use of Robot Framework itself. They are run automatically through travis when code is pushed to a branch. Most of the tests rely on the public mqtt broker at iot.eclipse.org, but some that validate authentication rely on a local broker. You can start a local broker with the provided configuration. You can then run the tests locally:: + + docker pull eclipse-mosquitto + docker run -d -p 1883:1883 -p 9001:9001 -v $(pwd)/mosquitto:/mosquitto/config eclipse-mosquitto + pybot -P src tests + + +Make sure to stop the docker container when it is no longer needed. + +.. _instructions: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-libraries + +License +------- +MQTTLibrary is open source software provided under the `Apache License 2.0`__. + +__ http://apache.org/licenses/LICENSE-2.0 \ No newline at end of file diff --git a/doc/MQTTLibrary.html b/docs/MQTTLibrary.html similarity index 100% rename from doc/MQTTLibrary.html rename to docs/MQTTLibrary.html diff --git a/mosquitto/mosquitto.conf b/mosquitto/mosquitto.conf new file mode 100644 index 0000000..5f47cb3 --- /dev/null +++ b/mosquitto/mosquitto.conf @@ -0,0 +1,2 @@ +allow_anonymous false +password_file ./mosquitto/config/passwd_file \ No newline at end of file diff --git a/mosquitto/passwd_file b/mosquitto/passwd_file new file mode 100644 index 0000000..d66db5e --- /dev/null +++ b/mosquitto/passwd_file @@ -0,0 +1,2 @@ +authuser1:$6$TR6FgFf+wMRzsgUQ$2AGKs3SinFVlSKbaqm9vcWNfmFM4c/Sg53SfpXJNXDb6iFjRdmqkMhEYM5sHRMFwXEosC3HQtuooPu6piRVb4A== +authuser2:$6$l/sj6c5ubQOEFoKi$9qWQ47H3IBI4LeORK7PpUBP2FYhOxHBanwtaBahv039nO+6AVXLNwmdmUnekYB+u8BV8Kx0UqdBhplpYoM737Q== diff --git a/tests/pubsub.txt b/tests/pubsub.txt index c5e9b7b..a864e8e 100644 --- a/tests/pubsub.txt +++ b/tests/pubsub.txt @@ -129,22 +129,28 @@ | | LOG | ${messages} | | Length Should Be | ${messages} | 0 -| Publish to a broker that requires username, password authentication -| | [Tags] | local-only +| Publish and Subscribe to a broker that requires username, password authentication +| | [Tags] | auth | | ${time} | Get Time | epoch | | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time} | | ${topic} | Set Variable | test -| | Set username and password | user1 | test1 -| | Connect | 127.0.0.1 | 1883 | ${client} -| | Publish | ${topic} | test message with username and password +| | ${message} | Set Variable | subscription test message +| | Set username and password | authuser1 | password1 +| | Run Keyword And Expect Error | The expected payload didn't arrive in the topic +| | ... | Subscribe to MQTT Broker and Validate | broker.uri=127.0.0.1 | client.id=${client} +| | ... | topic=${topic} | message=${message} +| | Connect | 127.0.0.1 +| | Publish | ${topic} | test message with username and password | qos=1 +| | Subscribe to MQTT Broker and Validate +| | ... | broker.uri=127.0.0.1 | client.id=${client} | topic=${topic} | message=test message with username and password | | [Teardown] | Disconnect -| Publish to a broker that requires username, password authentication with invalid password -| | [Tags] | local-only +| Publish to a broker that requires authentication with invalid password +| | [Tags] | auth | | ${time} | Get Time | epoch | | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time} | | ${topic} | Set Variable | test -| | Set username and password | user1 | test +| | Set username and password | authuser1 | invalidpwd | | Run Keyword and expect error | The client disconnected unexpectedly | | ... | Connect | 127.0.0.1 | 1883 | ${client} | | [Teardown] | Disconnect