aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/datafilecollector-testharness/common
diff options
context:
space:
mode:
authorecaiyanlinux <martin.c.yan@est.tech>2019-08-21 12:10:33 +0000
committerDaniel Rose <dr695h@att.com>2019-08-29 17:35:36 +0000
commit796e8fe4255036b5785a2071ddd6a0240464556a (patch)
treeb5d9ee29c9c07d91ea4848dafb12c5ae9cd7336d /test/mocks/datafilecollector-testharness/common
parent190a2f42b5c0af56b8c8da7e05a90ad3999598d3 (diff)
Add tls-init-container to simulator
1.replace dr-sim/dr-redir-sim cert/key 2.update mr-sim, make it support https 3.update ftpes cert/key Change-Id: I7bbde98f352d1e7d7c8775acf3d8af89a6ef7bdc Issue-ID: DCAEGEN2-1702 Signed-off-by: ecaiyanlinux <martin.c.yan@est.tech>
Diffstat (limited to 'test/mocks/datafilecollector-testharness/common')
-rw-r--r--test/mocks/datafilecollector-testharness/common/test_env.sh3
-rwxr-xr-xtest/mocks/datafilecollector-testharness/common/testcase_common.sh52
2 files changed, 50 insertions, 5 deletions
diff --git a/test/mocks/datafilecollector-testharness/common/test_env.sh b/test/mocks/datafilecollector-testharness/common/test_env.sh
index f4d443bff..7ba35ef27 100644
--- a/test/mocks/datafilecollector-testharness/common/test_env.sh
+++ b/test/mocks/datafilecollector-testharness/common/test_env.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# This env variable is only needed if the auto test scripts tests are executed in a different folder than 'auto-test' in the integration repo
+# This env variable is only needed if the auto test scripts tests are executed in a different folder than 'auto-test' in the integration repo
# Change '<local-path>' to your path to the integration repo. In addition to the auto-test, the 'common' dir is needed if not executed in the
# integration repo.
#
@@ -26,6 +26,7 @@ CONSUL_HOST="consul-server"
CONSUL_PORT=8500
CONFIG_BINDING_SERVICE="config-binding-service"
MR_PORT=2222
+MR_PORT_SECURE=2223
DR_PORT=3906
DR_PORT_SECURE=3907
DRR_PORT=3908
diff --git a/test/mocks/datafilecollector-testharness/common/testcase_common.sh b/test/mocks/datafilecollector-testharness/common/testcase_common.sh
index b0a14aa35..02aae7195 100755
--- a/test/mocks/datafilecollector-testharness/common/testcase_common.sh
+++ b/test/mocks/datafilecollector-testharness/common/testcase_common.sh
@@ -70,7 +70,7 @@ fi
TESTLOGS=$PWD/logs
# Create a log dir for the test case
-mkdir -p $TESTLOGS/$ATC
+mkdir -p $TESTLOGS/$ATC
# Clear the log dir for the test case
rm $TESTLOGS/$ATC/*.log &> /dev/null
@@ -99,7 +99,7 @@ if [ -z "$SIM_GROUP" ]; then
echo "Trying to set env var SIM_GROUP to dir 'simulator-group' in the integration repo, but failed."
echo "Please set the SIM_GROUP manually in the test_env.sh"
exit 1
- else
+ else
echo "SIM_GROUP auto set to: " $SIM_GROUP
fi
elif [ $SIM_GROUP = *simulator_group ]; then
@@ -198,7 +198,7 @@ __print_err() {
#<flag-to-strip-new-line> may contain any string, it is just a flag
# Returns the variable value (if success) and return code 0 or an error message and return code 1
__do_curl() {
- res=$(curl -sw "%{http_code}" $1)
+ res=$(curl -skw "%{http_code}" $1)
http_code="${res:${#res}-3}"
if [ ${#res} -eq 3 ]; then
echo "<no-response-from-server>"
@@ -543,7 +543,7 @@ start_dfc() {
if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
__print_err "arg should be 0.."$DFC_MAX_IDX
exit 1
- fi
+ fi
appname=$DFC_APP_BASE$1
STARTED_DFCS=$STARTED_DFCS"_"$appname"_"
@@ -781,6 +781,15 @@ mr_print() {
echo -e "---- MR sim, \033[1m $1 \033[0m: $(__do_curl http://127.0.0.1:$MR_PORT/$1)"
}
+# Print a variable value from the MR https simulator. Arg: <variable-name>
+mr_secure_print() {
+ if [ $# != 1 ]; then
+ __print_err "need one arg, <sim-param>"
+ exit 1
+ fi
+ echo -e "---- MR sim, \033[1m $1 \033[0m: $(__do_curl https://127.0.0.1:$MR_PORT_SECURE/$1)"
+}
+
# Print a variable value from the DR simulator. Arg: <variable-name>
dr_print() {
if [ $# != 1 ]; then
@@ -818,6 +827,11 @@ mr_read() {
echo "$(__do_curl http://127.0.0.1:$MR_PORT/$1)"
}
+# Read a variable value from MR https sim and send to stdout. Arg: <variable-name>
+mr_secure_read() {
+ echo "$(__do_curl https://127.0.0.1:$MR_PORT_SECURE/$1)"
+}
+
# Read a variable value from DR sim and send to stdout. Arg: <variable-name>
dr_read() {
echo "$(__do_curl http://127.0.0.1:$DR_PORT/$1)"
@@ -894,6 +908,14 @@ mr_equal() {
fi
}
+mr_secure_equal() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "=" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_equal, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
+
# Tests if a variable value in the MR simulator is greater than a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
# greater than the target or not.
@@ -908,6 +930,14 @@ mr_greater() {
fi
}
+mr_secure_greater() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 ">" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_greater, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
+
# Tests if a variable value in the MR simulator is less than a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
# less than the target or not.
@@ -921,6 +951,13 @@ mr_less() {
__print_err "Wrong args to mr_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
fi
}
+mr_secure_less() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "<" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
# Tests if a variable value in the MR simulator contains the target string and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable contains
@@ -935,6 +972,13 @@ mr_contain_str() {
__print_err "Wrong args to mr_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
fi
}
+mr_secure_contain_str() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "contain_str" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
# Tests if a variable value in the DR simulator is equal to a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is