+ __log_test_pass
+ return 0
+}
+
+# CR API: Check a single (oldest) json in md5 format (or none if empty) for path.
+# Note that if a json message is given, it shall be compact, no ws except inside string.
+# The MD5 will generate different hash if ws is present or not in otherwise equivalent json
+# arg: <response-code> <cr-path-id> <topic-url> (EMPTY | <data-msg> )
+# (Function for test scripts)
+cr_api_check_single_generic_event_md5() {
+ __log_test_start $@
+
+ if [ $# -ne 4 ]; then
+ __print_err "<response-code> <cr-path-id> <topic-url> (EMPTY | <data-msg> )" $@
+ return 1
+ fi
+
+ CR_SERVICE_PATH=$(__cr_get_service_path $2)
+ CR_ADAPTER=$CR_SERVICE_PATH
+ if [ $? -ne 0 ]; then
+ __print_err "<cr-path-id> missing or incorrect" $@
+ return 1
+ fi
+
+ query="/get-event/"$3
+ res="$(__do_curl_to_api CR GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+ body=${res:0:${#res}-3}
+ if [ $4 == "EMPTY" ]; then
+ if [ ${#body} -ne 0 ]; then
+ __log_test_fail_body
+ return 1
+ else
+ __log_test_pass
+ return 0
+ fi
+ fi
+ command -v md5 > /dev/null # Mac
+ if [ $? -eq 0 ]; then
+ targetMd5=$(echo -n "$4" | md5)
+ else
+ command -v md5sum > /dev/null # Linux
+ if [ $? -eq 0 ]; then
+ targetMd5=$(echo -n "$4" | md5sum | cut -d' ' -f 1) # Need to cut additional info printed by cmd
+ else
+ __log_test_fail_general "Command md5 nor md5sum is available"
+ return 1
+ fi
+ fi
+ targetMd5="\""$targetMd5"\"" #Quotes needed
+
+ echo " TARGET MD5 hash: $targetMd5" >> $HTTPLOG
+
+ if [ "$body" != "$targetMd5" ]; then
+ __log_test_fail_body
+ return 1
+ fi
+
+ __log_test_pass
+ return 0
+}
+
+# CR API: Check a single (oldest) event in md5 format (or none if empty) for path.
+# Note that if a file with json message is given, the json shall be compact, no ws except inside string and not newlines.
+# The MD5 will generate different hash if ws/newlines is present or not in otherwise equivalent json
+# arg: <response-code> <cr-path-id> <topic-url> (EMPTY | <data-file> )
+# (Function for test scripts)
+cr_api_check_single_generic_event_md5_file() {
+ __log_test_start $@
+
+ if [ $# -ne 4 ]; then
+ __print_err "<response-code> <cr-path-id> <topic-url> (EMPTY | <data-file> )" $@
+ return 1
+ fi
+
+ CR_SERVICE_PATH=$(__cr_get_service_path $2)
+ CR_ADAPTER=$CR_SERVICE_PATH
+ if [ $? -ne 0 ]; then
+ __print_err "<cr-path-id> missing or incorrect" $@
+ return 1
+ fi
+
+ query="/get-event/"$3
+ res="$(__do_curl_to_api CR GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+ body=${res:0:${#res}-3}
+ if [ $4 == "EMPTY" ]; then
+ if [ ${#body} -ne 0 ]; then
+ __log_test_fail_body
+ return 1
+ else
+ __log_test_pass
+ return 0
+ fi
+ fi
+
+ if [ ! -f $4 ]; then
+ __log_test_fail_general "File $3 does not exist"
+ return 1
+ fi
+
+ filedata=$(cat $4)
+
+ command -v md5 > /dev/null # Mac
+ if [ $? -eq 0 ]; then
+ targetMd5=$(echo -n "$filedata" | md5)
+ else
+ command -v md5sum > /dev/null # Linux
+ if [ $? -eq 0 ]; then
+ targetMd5=$(echo -n "$filedata" | md5sum | cut -d' ' -f 1) # Need to cut additional info printed by cmd
+ else
+ __log_test_fail_general "Command md5 nor md5sum is available"
+ return 1
+ fi
+ fi
+ targetMd5="\""$targetMd5"\"" #Quotes needed
+
+ echo " TARGET MD5 hash: $targetMd5" >> $HTTPLOG
+
+ if [ "$body" != "$targetMd5" ]; then
+ __log_test_fail_body
+ return 1
+ fi
+