diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index b8b4bcb597..390188b167 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -27,18 +27,6 @@ jobs: ports: - 27017:27017 - mosquitto: - # Needed by MQTT notification tests - image: eclipse-mosquitto:1.6.15 - ports: - - 1883:1883 - - mosquitto-extra: - # Needed by MQTT notification tests (multi broker) - image: eclipse-mosquitto:1.6.15 - ports: - - 1884:1883 - name: functional - ${{ matrix.payload.name }} strategy: @@ -58,6 +46,17 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run Mosquitto container with authenticated user + # Why don't to use a service for this (as moquitto-extra above)? It would be the desirable solution, but I haven't able to + # configure volumes properly for it (the mosquitto container as service has problems to get the configuration files). Feedback welcome! :) + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + + - name: Run Extra Mosquitto container used in multibroker tests + # Note we are reusing the same volume (although the extra broker does not require authenticated user). We use a service in the past + # to implement this (using eclipse-mosquitto:1.6.15) but in eclipse-mosquitto:2.0.11 it seems something in the internal configuration + # has changed and it doesn't work if we don't provide the configuration files in the volume. Again, feedback is welcome! :) + run: docker run -d --name mosquitto-extra -p 1884:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + - name: Run functional test run: | docker run --network host -t --rm -e REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} ${{ matrix.payload.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts functional diff --git a/.github/workflows/valgrind-nocache.yml b/.github/workflows/valgrind-nocache.yml index e8ff06e31b..e7c7e4eb9c 100644 --- a/.github/workflows/valgrind-nocache.yml +++ b/.github/workflows/valgrind-nocache.yml @@ -29,18 +29,6 @@ jobs: image: mongo:6.0 ports: - 27017:27017 - - mosquitto: - # Needed by MQTT notification tests - image: eclipse-mosquitto:1.6.15 - ports: - - 1883:1883 - - mosquitto-extra: - # Needed by MQTT notification tests (multi broker) - image: eclipse-mosquitto:1.6.15 - ports: - - 1884:1883 name: valgrind - ${{ matrix.payload.name }} @@ -56,6 +44,17 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run Mosquitto container with authenticated user + # Why don't to use a service for this (as moquitto-extra above)? It would be the desirable solution, but I haven't able to + # configure volumes properly for it (the mosquitto container as service has problems to get the configuration files). Feedback welcome! :) + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + + - name: Run Extra Mosquitto container used in multibroker tests + # Note we are reusing the same volume (although the extra broker does not require authenticated user). We use a service in the past + # to implement this (using eclipse-mosquitto:1.6.15) but in eclipse-mosquitto:2.0.11 it seems something in the internal configuration + # has changed and it doesn't work if we don't provide the configuration files in the volume. Again, feedback is welcome! :) + run: docker run -d --name mosquitto-extra -p 1884:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + - name: Run valgrind test run: | docker run --privileged --network host -t --rm -e REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} ${{ matrix.payload.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts valgrind diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 33010b755d..483a9d0c34 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -26,18 +26,6 @@ jobs: image: mongo:6.0 ports: - 27017:27017 - - mosquitto: - # Needed by MQTT notification tests - image: eclipse-mosquitto:1.6.15 - ports: - - 1883:1883 - - mosquitto-extra: - # Needed by MQTT notification tests (multi broker) - image: eclipse-mosquitto:1.6.15 - ports: - - 1884:1883 name: valgrind - ${{ matrix.payload.name }} @@ -53,6 +41,17 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run Mosquitto container with authenticated user + # Why don't to use a service for this (as moquitto-extra above)? It would be the desirable solution, but I haven't able to + # configure volumes properly for it (the mosquitto container as service has problems to get the configuration files). Feedback welcome! :) + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + + - name: Run Extra Mosquitto container used in multibroker tests + # Note we are reusing the same volume (although the extra broker does not require authenticated user). We use a service in the past + # to implement this (using eclipse-mosquitto:1.6.15) but in eclipse-mosquitto:2.0.11 it seems something in the internal configuration + # has changed and it doesn't work if we don't provide the configuration files in the volume. Again, feedback is welcome! :) + run: docker run -d --name mosquitto-extra -p 1884:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + - name: Run valgrind test run: | docker run --privileged --network host -t --rm -e REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} ${{ matrix.payload.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts valgrind diff --git a/scripts/check_files_compliance.py b/scripts/check_files_compliance.py index d14574cb39..0ccc974e21 100755 --- a/scripts/check_files_compliance.py +++ b/scripts/check_files_compliance.py @@ -138,7 +138,7 @@ def ignore(root, file): 'ContributionPolicy.txt', 'CHANGES_NEXT_RELEASE', 'Changelog', 'compileInfo.h', 'unittests_that_fail_sporadically.txt', 'Vagrantfile', 'contextBroker.ubuntu', 'mkdocs.yml', 'fiware-ngsiv2-reference.errata', 'ServiceRoutines.txt', '.readthedocs.yml', 'uncrustify.cfg', - 'requirements.txt'] + 'requirements.txt', 'mosquitto_passwd' ] if file in files_names: return True if 'scripts' in root and (file == 'cpplint.py' or file == 'pdi-pep8.py' or file == 'uncrustify.cfg' \ diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_notification.test b/test/functionalTest/cases/3001_mqtt/mqtt_notification.test index 8e60fee1e6..52377cd61e 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_notification.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_notification.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub for entity E with topic sub1 # 02. Create MQTT sub for entity E with topic sub2 diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test b/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test index ecc29badba..844c37c5be 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT custom sub for entity E with topic sub/{$id} payload A:{$A} # 02. Create entity E1 with A=1 diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test b/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test index a0adbcf1f6..4316fc7cc8 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub for entity E with topic sub0 and qos=0 # 02. Create MQTT sub for entity E with topic sub1 and qos=1 diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test b/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test index a63f157e54..f8ca62e270 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test @@ -35,8 +35,8 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT brokers needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 -# docker run -d -p 1884:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 +# docker run -d -p 1884:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub1 at localhost:1883 (1) # 02. Create MQTT sub2 at localhost:1883 (2) diff --git a/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test b/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test index 979feb7bdf..72f4863cf0 100644 --- a/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test +++ b/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. POST /v2/entities, creating E1/T1 # 02. Subscribe to E1 on condition A2 diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test index 8f85a26087..d172a45782 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test @@ -32,8 +32,7 @@ brokerStart CB 0 IPv4 -logSummary 5 --SHELL-- # -# FIXME: this test relies on an external service (mqtt.flespi.io) which we don't control -# It would be better to use a MQTT broker running by us (docker?) +# This test requires a MQTT broker with authentication enabled. See test/functionalTest/mosquittoConf/README.md # # 01. Sleep 6 and see 0-0 raised and 0-0 released # 02. Create MQTT sub with wrong user/pass @@ -67,8 +66,8 @@ payload='{ }, "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user", + "url": "mqtt://localhost:1883", + "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } @@ -118,8 +117,8 @@ echo "========================================" payload='{ "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", + "url": "mqtt://localhost:1883", + "user": "user1", "passwd": "xxxx", "topic": "sub1" } diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test index 35ee20c7c3..6d25daaf1a 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test @@ -32,7 +32,7 @@ brokerStart CB 0 IPV4 # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub with right enpdoint (localhost:1883) # 02. Upsert three times to trigger three MQTT notifications diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test index f531b4247f..8108b226cc 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test @@ -30,10 +30,7 @@ brokerStart CB 0 IPV4 --SHELL-- # -# FIXME: this test relies on an external service (mqtt.flespi.io) which we don't control -# It would be better to use a MQTT broker running by us (docker?) -# Given the MQTT broker is a remote system in the Internet, we have to wait at some points -# so subscription status and logs get consolidated before checking it +# This test requires a MQTT broker with authentication enabled. See test/functionalTest/mosquittoConf/README.md # # 01. Create MQTT sub with wrong user/pass # 02. Upsert to trigger first MQTT notification, which fails and raises alarm @@ -59,8 +56,8 @@ payload='{ }, "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user", + "url": "mqtt://localhost:1883", + "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } @@ -91,7 +88,6 @@ echo echo "03. Get sub and see timesSent:1, failsCounter:1 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -114,7 +110,6 @@ echo echo "05. Get sub and see timesSent:1, failsCounter:2 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -125,8 +120,8 @@ echo "========================================" payload='{ "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", + "url": "mqtt://localhost:1883", + "user": "user1", "passwd": "xxxx", "topic": "sub1" } @@ -154,7 +149,6 @@ echo echo "08. Get sub and see timesSent:3, lastFailure (old) and lastSuccess but not failsCounter" echo "=======================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -193,7 +187,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -210,8 +204,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 1 @@ -248,7 +242,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -265,8 +259,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 2 @@ -311,7 +305,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 566 +Content-Length: 502 [ { @@ -328,8 +322,8 @@ Content-Length: 566 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ" + "url": "mqtt://localhost:1883", + "user": "user1" }, "onlyChangedAttrs": false, "timesSent": 3 @@ -354,16 +348,16 @@ Content-Length: 566 09. Check logs and see 1 raised alarm and 1 released alarm ========================================================== #SORT_START -Request received: POST /v2/subscriptions, request payload (181 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "user", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 +Request received: POST /v2/subscriptions, request payload (184 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Raising alarm MqttConnectionError mqtt.flespi.io:1883: Connection Refused: bad user name or password. +Raising alarm MqttConnectionError localhost:1883: Connection Refused: not authorised. Request received: GET /v2/subscriptions, response code: 200 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 Request received: GET /v2/subscriptions, response code: 200 -Request received: PATCH /v2/subscriptions/SUB_ID, request payload (182 bytes): { "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 +Request received: PATCH /v2/subscriptions/SUB_ID, request payload (118 bytes): { "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user1", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Releasing alarm MqttConnectionError mqtt.flespi.io:1883 -MQTT Notif delivered (subId: SUB_ID): broker: mqtt.flespi.io:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} +Releasing alarm MqttConnectionError localhost:1883 +MQTT Notif delivered (subId: SUB_ID): broker: localhost:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} Request received: GET /v2/subscriptions, response code: 200 #SORT_END diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test index c60bf280d5..8e077ed571 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test @@ -30,10 +30,7 @@ brokerStart CB 0 IPV4 -relogAlarms --SHELL-- # -# FIXME: this test relies on an external service (mqtt.flespi.io) which we don't control -# It would be better to use a MQTT broker running by us (docker?) -# Given the MQTT broker is a remote system in the Internet, we have to wait at some points -# so subscription status and logs get consolidated before checking it +# This test requires a MQTT broker with authentication enabled. See test/functionalTest/mosquittoConf/README.md # # 01. Create MQTT sub with wrong user/pass # 02. Upsert to trigger first MQTT notification, which fails and raises alarm @@ -59,8 +56,8 @@ payload='{ }, "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user", + "url": "mqtt://localhost:1883", + "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } @@ -91,7 +88,6 @@ echo echo "03. Get sub and see timesSent:1, failsCounter:1 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -114,7 +110,6 @@ echo echo "05. Get sub and see timesSent:1, failsCounter:2 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -125,8 +120,8 @@ echo "========================================" payload='{ "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", + "url": "mqtt://localhost:1883", + "user": "user1", "passwd": "xxxx", "topic": "sub1" } @@ -154,7 +149,6 @@ echo echo "08. Get sub and see timesSent:3, lastFailure (old) and lastSuccess but not failsCounter" echo "=======================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -193,7 +187,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -210,8 +204,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 1 @@ -248,7 +242,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -265,8 +259,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 2 @@ -311,7 +305,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 566 +Content-Length: 502 [ { @@ -328,8 +322,8 @@ Content-Length: 566 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ" + "url": "mqtt://localhost:1883", + "user": "user1" }, "onlyChangedAttrs": false, "timesSent": 3 @@ -354,17 +348,17 @@ Content-Length: 566 09. Check logs and see 1 raised alarm, 1 repeat alarm and 1 released alarm ========================================================================== #SORT_START -Request received: POST /v2/subscriptions, request payload (181 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "user", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 +Request received: POST /v2/subscriptions, request payload (184 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Raising alarm MqttConnectionError mqtt.flespi.io:1883: Connection Refused: bad user name or password. +Raising alarm MqttConnectionError localhost:1883: Connection Refused: not authorised. Request received: GET /v2/subscriptions, response code: 200 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 Request received: GET /v2/subscriptions, response code: 200 -Repeated MqttConnectionError mqtt.flespi.io:1883: Connection Refused: bad user name or password. -Request received: PATCH /v2/subscriptions/SUB_ID, request payload (182 bytes): { "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 +Repeated MqttConnectionError localhost:1883: Connection Refused: not authorised. +Request received: PATCH /v2/subscriptions/SUB_ID, request payload (118 bytes): { "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user1", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Releasing alarm MqttConnectionError mqtt.flespi.io:1883 -MQTT Notif delivered (subId: SUB_ID): broker: mqtt.flespi.io:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} +Releasing alarm MqttConnectionError localhost:1883 +MQTT Notif delivered (subId: SUB_ID): broker: localhost:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} Request received: GET /v2/subscriptions, response code: 200 #SORT_END diff --git a/test/functionalTest/mosquittoConf/README.md b/test/functionalTest/mosquittoConf/README.md new file mode 100644 index 0000000000..9b4c01410c --- /dev/null +++ b/test/functionalTest/mosquittoConf/README.md @@ -0,0 +1,21 @@ +This directory contains some configuration files, to be used (mounting a volume) by mosquitto docker containers. See functional.yml (and some other GitActions) for an example on how they are used. + +The `mosquitto_passwd` file containts a harmless credential: `user1` with password `xxxx`, used in `cases/3001_mqtt_alarms` tests. The password file works for mosquitto 2.0 version but other versions (specifically, 1.6) could not recognize its format. + +This files can be also being used in a local mosquitto instance. For instance + +``` +$ sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf +$ # edit the /etc/mosquitto/conf.d/local.conf file to change the password_file location to /etc/mosquitto/passwd +$ sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto_passwd /etc/mosquitto/passwd +$ sudo chmod 640 /etc/mosquitto/passwd +$ sudo chown root:mosquitto /etc/mosquitto/passwd +``` + +Alternativelly you can add users to password file using a command like this one: + +``` +$ sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 +``` + + diff --git a/test/functionalTest/mosquittoConf/mosquitto.conf b/test/functionalTest/mosquittoConf/mosquitto.conf new file mode 100644 index 0000000000..9d5d46d789 --- /dev/null +++ b/test/functionalTest/mosquittoConf/mosquitto.conf @@ -0,0 +1,23 @@ +# Copyright 2025 Telefonica Investigacion y Desarrollo, S.A.U +# +# This file is part of Orion Context Broker. +# +# Orion Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# iot_support at tid dot es + +password_file /mosquitto/config/mosquitto_passwd +allow_anonymous true +listener 1883 0.0.0.0 diff --git a/test/functionalTest/mosquittoConf/mosquitto_passwd b/test/functionalTest/mosquittoConf/mosquitto_passwd new file mode 100644 index 0000000000..eb65166dae --- /dev/null +++ b/test/functionalTest/mosquittoConf/mosquitto_passwd @@ -0,0 +1 @@ +user1:$7$101$eqgU7wUvh4Y3VQAm$ovEPI43qOwAskK5M+OFmNJAoXtLRx5GI2tBjTX4AOf3ZTB79IRv1CMgbHrPnKY+/K/RKMm2i/XFp9syteeOCvg==