X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Ftest%2Fcommon%2Ftest_common.sh;fp=near-rt-ric-simulator%2Ftest%2Fcommon%2Ftest_common.sh;h=6d2f80e2573c62b7e67d58a2e23848ab343a516f;hb=e220bfc2cb1727996da2fe120b676a9454cf982e;hp=a45a6ffeb83ea2345772921d2f8f720a578aad9c;hpb=2b8adeb97b5c8ad8a769ec0018056b1b2f20e877;p=sim%2Fa1-interface.git diff --git a/near-rt-ric-simulator/test/common/test_common.sh b/near-rt-ric-simulator/test/common/test_common.sh index a45a6ff..6d2f80e 100755 --- a/near-rt-ric-simulator/test/common/test_common.sh +++ b/near-rt-ric-simulator/test/common/test_common.sh @@ -73,4 +73,53 @@ do_curl() { fi fi fi -} \ No newline at end of file +} + +do_curl_ext_srv() { + if [ $# -lt 3 ]; then + echo "Need 3 or more parameters, [file]: "$@ + echo "Exiting test script....." + exit 1 + fi + curlstr="curl -X "$1" -skw %{http_code} $HTTPX_EXT_SRV://localhost:"${PORT_EXT_SRV}${2}" -H accept:*/*" + if [ $# -gt 3 ]; then + curlstr=$curlstr" -H Content-Type:application/json --data-binary @"$4 + fi + echo " CMD (${BASH_LINENO[0]}):"$curlstr + res=$($curlstr) + status=${res:${#res}-3} + body=${res:0:${#res}-3} + if [ $status -ne $3 ]; then + echo " Error status :"$status" Expected status: "$3 + echo " Body :"$body + echo "Exiting test script....." + exit 1 + else + echo " OK, code :"$status" (Expected)" + echo " Body :"$body + if [ "$RESULT" == "*" ]; then + echo " Body contents not checked" + elif [[ "$RESULT" == "json:"* ]]; then + result=${RESULT:5:${#RESULT}} #Remove 'json:' from the result string + res=$(python ../common/compare_json.py "$result" "$body") + if [ $res -eq 0 ]; then + echo " Expected json body :"$result + echo " Body as expected" + else + echo " Expected json body :"$result + echo "Exiting....." + exit 1 + fi + else + body="$(echo $body | tr -d '\n' )" + if [ "$RESULT" == "$body" ]; then + echo " Expected body :"$RESULT + echo " Body as expected" + else + echo " Expected body :"$RESULT + echo "Exiting....." + exit 1 + fi + fi + fi +}