Function test updates
[nonrtric.git] / test / common / prodstub_api_functions.sh
index 17f987a..c70cd13 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 #  ============LICENSE_START===============================================
-#  Copyright (C) 2020 Nordix Foundation. All rights reserved.
+#  Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
 #  ========================================================================
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -94,7 +94,7 @@ __PRODSTUB_kube_delete_all() {
 # args: <log-dir> <file-prexix>
 __PRODSTUB_store_docker_logs() {
        if [ $RUNMODE == "KUBE" ]; then
-               kubectl  logs -l "autotest=PRODSTUB" -n $KUBE_SIM_NAMESPACE --tail=-1 > $1$2_prodstub.log 2>&1
+               kubectl $KUBECONF  logs -l "autotest=PRODSTUB" -n $KUBE_SIM_NAMESPACE --tail=-1 > $1$2_prodstub.log 2>&1
        else
                docker logs $PROD_STUB_APP_NAME > $1$2_prodstub.log 2>&1
        fi
@@ -119,6 +119,12 @@ __PRODSTUB_statisics_setup() {
        fi
 }
 
+# Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied
+# args: -
+__PRODSTUB_test_requirements() {
+       :
+}
+
 #######################################################
 
 # Set http as the protocol to use for all communication to the Prod stub sim
@@ -139,7 +145,7 @@ use_prod_stub_https() {
 # args: <protocol> <internal-port> <external-port>
 __prod_stub_set_protocoll() {
        echo -e $BOLD"$PROD_STUB_DISPLAY_NAME protocol setting"$EBOLD
-       echo -e " Using $BOLD http $EBOLD towards $PROD_STUB_DISPLAY_NAME"
+       echo -e " Using $BOLD $1 $EBOLD towards $PROD_STUB_DISPLAY_NAME"
 
        ## Access to Prod stub sim
 
@@ -192,13 +198,13 @@ start_prod_stub() {
                retcode_p=$?
 
                if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
-                       echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
-                       echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
+                       echo -e $RED"The $PROD_STUB_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
+                       echo -e $RED"The $PROD_STUB_APP_NAME will not be started"$ERED
                        exit
                fi
                if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
-                       echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
-                       echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
+                       echo -e $RED"The $PROD_STUB_APP_NAME app is included both as managed and prestarted in this test script"$ERED
+                       echo -e $RED"The $PROD_STUB_APP_NAME will not be started"$ERED
                        exit
                fi
 
@@ -268,8 +274,14 @@ __execute_curl_to_prodstub() {
                        proxyflag=" --proxy-insecure --proxy $KUBE_PROXY_PATH"
                fi
        fi
-       echo " CMD: $3 $proxyflag" >> $HTTPLOG
-       res="$($3 $proxyflag)"
+       if [ ! -z "$KUBE_PROXY_CURL_JWT" ]; then
+               jwt="-H "\""Authorization: Bearer $KUBE_PROXY_CURL_JWT"\"
+               echo " CMD: $3 $proxyflag $jwt" >> $HTTPLOG
+               res=$($3 $proxyflag -H "Authorization: Bearer $KUBE_PROXY_CURL_JWT")
+       else
+               echo " CMD: $3 $proxyflag" >> $HTTPLOG
+               res="$($3 $proxyflag)"
+       fi
        echo " RESP: $res" >> $HTTPLOG
        retcode=$?
     if [ $retcode -ne 0 ]; then
@@ -438,11 +450,8 @@ prodstub_check_jobdata_2() {
        __log_test_fail_general "Template file "$7" for jobdata, does not exist"
         return 1
     fi
-       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
-               targetJson="{\"info_job_identity\":\"$3\",\"info_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"info_job_data\":$jobfile,\"last_updated\":\"????\"}"
-       else
-               targetJson="{\"ei_job_identity\":\"$3\",\"ei_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"ei_job_data\":$jobfile,\"last_updated\":\"????\"}"
-    fi
+       targetJson="{\"ei_job_identity\":\"$3\",\"ei_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"ei_job_data\":$jobfile,\"last_updated\":\"????\"}"
+
        file="./tmp/.p.json"
        echo "$targetJson" > $file