diff --git a/TAF/config/global_variables.py b/TAF/config/global_variables.py index a862cca8..c8a886a5 100644 --- a/TAF/config/global_variables.py +++ b/TAF/config/global_variables.py @@ -29,6 +29,7 @@ APP_HTTP_EXPORT_PORT = 59704 APP_MQTT_EXPORT_PORT = 59703 APP_FUNCTIOAL_TESTS_PORT = 59705 +APP_EXTERNAL_MQTT_TRIGGER_PORT = 59706 REGISTRY_PORT = 8500 if SECURITY_SERVICE_NEEDED == 'true': diff --git a/TAF/testData/app-service/secrets_data.json b/TAF/testData/app-service/secrets_data.json index faa1bc2d..b188043c 100644 --- a/TAF/testData/app-service/secrets_data.json +++ b/TAF/testData/app-service/secrets_data.json @@ -60,5 +60,15 @@ "value": "httpuser" } ] + }, + "External MQTT Trigger Auth": { + "apiVersion" : "v2", + "path" : "mqtt-trigger", + "secretData" : [ + { + "key" : "api-key", + "value": "externalmqttuser" + } + ] } } diff --git a/TAF/testScenarios/integrationTest/UC_app_service_configurable/external_mqtt_trigger.robot b/TAF/testScenarios/integrationTest/UC_app_service_configurable/external_mqtt_trigger.robot new file mode 100644 index 00000000..02d2455a --- /dev/null +++ b/TAF/testScenarios/integrationTest/UC_app_service_configurable/external_mqtt_trigger.robot @@ -0,0 +1,40 @@ +*** Settings *** +Library Process +Resource TAF/testCaseModules/keywords/common/commonKeywords.robot +Resource TAF/testCaseModules/keywords/app-service/AppServiceAPI.robot +Suite Setup Setup Suite +Suite Teardown Run Teardown Keywords +Force Tags MessageQueue=redis + +*** Variables *** +${SUITE} External MQTT Trigger +${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/external_mqtt_trigger.log + +*** Test Cases *** +ExternalTrigger001 - Test external mqtt trigger works + Given Set Test Variable ${publish_msg} Message from mqtt publisher + And Set Test Variable ${mqtt_trigger_topic} external-request + And Set Test Variable ${mqtt_export_topic} edgex-export + And Subscribe MQTT Broker Topics + When Run process python ${WORK_DIR}/TAF/utils/src/setup/mqtt-publisher.py ${mqtt_trigger_topic} "${publish_msg}" + ... shell=True + Then Message Is Recevied By ${mqtt_trigger_topic} Topic + And Message Is Recevied By ${mqtt_export_topic} Topic + [Teardown] Terminate All Processes kill=True + + +*** Keywords *** +Subscribe MQTT Broker Topics + ${topics} Create List ${mqtt_trigger_topic} ${mqtt_export_topic} + FOR ${topic} IN @{topics} + Start process python ${WORK_DIR}/TAF/utils/src/setup/mqtt-subscriber.py ${topic} ${publish_msg} arg # Process for MQTT Subscriber + ... shell=True stdout=${WORK_DIR}/TAF/testArtifacts/logs/${topic}.log + END + +Message Is Recevied By ${topic} Topic + ${subscribe_msg} Grep File ${WORK_DIR}/TAF/testArtifacts/logs/${topic}.log ${publish_msg} + Should Not Be Empty ${subscribe_msg} + +Store Secret With ${service} To Vault + Set Test Variable ${url} http://${BASE_URL}:${APP_EXTERNAL_MQTT_TRIGGER_PORT} + Store Secret Data With ${service} Auth diff --git a/TAF/utils/src/setup/mqtt-publisher.py b/TAF/utils/src/setup/mqtt-publisher.py new file mode 100644 index 00000000..0c2d31c8 --- /dev/null +++ b/TAF/utils/src/setup/mqtt-publisher.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import paho.mqtt.client as mqtt +import sys + +topic = sys.argv[1] +message = sys.argv[2] + + +client = mqtt.Client() +client.connect("localhost", 1883, 60) +client.publish(topic, message) +client.disconnect()