Skip to content

Conversation

aggarw13
Copy link
Contributor

Allow BROKER_ENDPOINT and ROOT_CA_CERT_PATH (only for basic TLS demo) to be specified through build command for CI.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2020

Codecov Report

Merging #1124 into development will increase coverage by 1.93%.
The diff coverage is 81.48%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #1124      +/-   ##
===============================================
+ Coverage        96.54%   98.47%   +1.93%     
===============================================
  Files                9        4       -5     
  Lines             5643     1313    -4330     
  Branches           641      391     -250     
===============================================
- Hits              5448     1293    -4155     
+ Misses               9        0       -9     
+ Partials           186       20     -166     
Impacted Files Coverage Δ
libraries/standard/mqtt/src/mqtt.c 99.48% <ø> (+5.06%) ⬆️
libraries/standard/mqtt/src/mqtt_lightweight.c 97.44% <ø> (+2.92%) ⬆️
libraries/standard/mqtt/src/mqtt_state.c 98.46% <ø> (+2.52%) ⬆️
libraries/standard/http/src/http_client.c 98.53% <81.48%> (+11.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f602495...30e60b7. Read the comment docs.

leegeth
leegeth previously approved these changes Aug 13, 2020
muneebahmed10
muneebahmed10 previously approved these changes Aug 13, 2020
@@ -56,26 +56,30 @@
* the instructions in https://mosquitto.org/ for running a Mosquitto broker
* locally.
*/
#define BROKER_ENDPOINT "test.mosquitto.org"
#ifndef BROKER_ENDPOINT
Copy link
Contributor

@sarenameas sarenameas Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The philosophy of this file demo_config.h already is that applications can edit it.
In mqtt_demo_basic_tls.c we should have:

#ifndef BROKER_ENDPOINT
    #error "Please define an MQTT broker endpoint, BROKER_ENDPOINT in demo_config.h."
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that our demo source files should have build-time failures for no definitions of these macros. Have added them in source files.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how would this build-time failures for no definitions of these macros work for our demo sources? Wont this file always define BROKER_ENDPOINT ? So by the time we get to our demo source files, wont the check for ifndef BROKER_ENDPOINT always say that BROKER_ENDPOINT is defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to guard against accidental removals of the BROKER_ENDPOINT by the customer. It provides a helpful message to remind them that the BROKER_ENDPOINT macro is required for the demo to run instead of giving them regular gcc build failures (at the source code points that use the macro)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still different from what the README says about Mutual Auth Demos.

@aggarw13 aggarw13 dismissed stale reviews from muneebahmed10 and leegeth via 30e60b7 August 13, 2020 18:54
@@ -61,8 +61,11 @@
* These configuration settings are required to run the basic TLS demo.
* Throw compilation error if the below configs are not defined.
*/
#ifndef BROKER_ENDPOINT
#error "Please define an MQTT broker endpoint, BROKER_ENDPOINT, in demo_config.h."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this error ever trigger? Because we defined this macro in the config if it wasn't defined already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the customer happens to remove it from the config file, then this failure would remind them instead.

@@ -53,7 +53,9 @@
* This demo uses the Mosquitto test server. This is a public MQTT server; do not
* publish anything sensitive to this server.
*/
#define BROKER_ENDPOINT "test.mosquitto.org"
#ifndef BROKER_ENDPOINT
#define BROKER_ENDPOINT "test.mosquitto.org"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cautionary language on lines 53-55 is not sufficient here. From the test.mosquitto.org documentation, the test.mosquitto.org broker "...will often be running unreleased or experimental code and may not be as stable as you might hope.". Additional cautionary language on their website asks "...please do not abuse or rely upon it for anything of importance.".

I would recommend removing references to test.mosquitto.org from this (and any other) MQTT demos. If someone wishes to use it, they of course may do so. However the best way to test this by running a broker locally, and we can easily provide instructions for setting up mosquitto or another broker to run locally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such directions are available in the readme too.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Gary's comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good suggestion to not suggest test.mosquitto.org in our demos. I had added instructions on the REAMDE for a way to setup the Mosquitto broker locally: https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/development#installing-mosquitto-to-run-mqtt-demos-locally

We could update the comments on our demo_config.h to point to these instructions

@aggarw13 aggarw13 merged commit b7d2b8f into aws:development Aug 13, 2020
@aggarw13 aggarw13 deleted the demos/allow-broker-endpoint-to-be-overrided branch August 13, 2020 21:19
yourslab pushed a commit to yourslab/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 17, 2020
…overridden (aws#1124)

* Add #ifndefs around config macros in demos to allow them to be overridden

* Add #error statements for BROKER_ENDPOINT in demo source files
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 27, 2020
…overridden (aws#1124)

* Add #ifndefs around config macros in demos to allow them to be overridden

* Add #error statements for BROKER_ENDPOINT in demo source files
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 28, 2020
…overridden (aws#1124)

* Add #ifndefs around config macros in demos to allow them to be overridden

* Add #error statements for BROKER_ENDPOINT in demo source files
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Aug 31, 2020
…overridden (aws#1124)

* Add #ifndefs around config macros in demos to allow them to be overridden

* Add #error statements for BROKER_ENDPOINT in demo source files
leegeth pushed a commit to leegeth/aws-iot-device-sdk-embedded-C that referenced this pull request Sep 1, 2020
…overridden (aws#1124)

* Add #ifndefs around config macros in demos to allow them to be overridden

* Add #error statements for BROKER_ENDPOINT in demo source files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants