From 1b89f3d1b67ef38e07a4b9499ddb2db7105a4844 Mon Sep 17 00:00:00 2001 From: Michi Date: Wed, 18 Apr 2018 21:04:10 +0200 Subject: [PATCH] fixed escaping. fixed tests. --- act.sh | 6 +++--- helpers/apiCall.sh | 4 ++-- test.sh | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/act.sh b/act.sh index db761ff..5870504 100755 --- a/act.sh +++ b/act.sh @@ -1,6 +1,6 @@ #!/bin/bash ACT_VERSION="v0.3.0" -ACT_LAST_COMMIT="13b1692a909cb01fbf21c38ef46ac9950d92b7be" +ACT_LAST_COMMIT="bf89de71a23bb6b3df269b8fca4c95da5ec34b40" USER_CONFIG="$HOME/.appdynamics/act/config.sh" GLOBAL_CONFIG="/etc/appdynamics/act/config.sh" CONFIG_CONTROLLER_COOKIE_LOCATION="/tmp/appdynamics-controller-cookie.txt" @@ -113,7 +113,7 @@ function apiCall { shiftOptInd shift $SHIFTS fi - while [[ $PAYLOAD =~ \${([a-zA-Z])(\??)} ]] ; do + while [[ $PAYLOAD =~ \$\{([a-zA-Z])(\??)\} ]] ; do if [ -z "$1" ] && [[ "${OPTIONAL_OPTIONS}" != *"${BASH_REMATCH[1]}"* ]] ; then local MISSING=${BASH_REMATCH:2:1} if [ "${MISSING}" == "a" ] && [ -n "${CONFIG_CONTROLLER_DEFAULT_APPLICATION}" ] ; then @@ -126,7 +126,7 @@ function apiCall { PAYLOAD=${PAYLOAD//${BASH_REMATCH[0]}/$1} shift done - while [[ $ENDPOINT =~ \${([a-zA-Z])(\??)} ]] ; do + while [[ $ENDPOINT =~ \$\{([a-zA-Z])(\??)\} ]] ; do if [ -z "$1" ] && [[ "${OPTIONAL_OPTIONS}" != *"${BASH_REMATCH[1]}"* ]] ; then local MISSING=${BASH_REMATCH:2:1} if [ "${MISSING}" == "a" ] && [ -n "${CONFIG_CONTROLLER_DEFAULT_APPLICATION}" ] ; then diff --git a/helpers/apiCall.sh b/helpers/apiCall.sh index a5c89bd..0b82180 100755 --- a/helpers/apiCall.sh +++ b/helpers/apiCall.sh @@ -68,7 +68,7 @@ function apiCall { shift $SHIFTS fi - while [[ $PAYLOAD =~ \${([a-zA-Z])(\??)} ]] ; do + while [[ $PAYLOAD =~ \$\{([a-zA-Z])(\??)\} ]] ; do if [ -z "$1" ] && [[ "${OPTIONAL_OPTIONS}" != *"${BASH_REMATCH[1]}"* ]] ; then local MISSING=${BASH_REMATCH:2:1} if [ "${MISSING}" == "a" ] && [ -n "${CONFIG_CONTROLLER_DEFAULT_APPLICATION}" ] ; then @@ -82,7 +82,7 @@ function apiCall { shift done - while [[ $ENDPOINT =~ \${([a-zA-Z])(\??)} ]] ; do + while [[ $ENDPOINT =~ \$\{([a-zA-Z])(\??)\} ]] ; do if [ -z "$1" ] && [[ "${OPTIONAL_OPTIONS}" != *"${BASH_REMATCH[1]}"* ]] ; then local MISSING=${BASH_REMATCH:2:1} if [ "${MISSING}" == "a" ] && [ -n "${CONFIG_CONTROLLER_DEFAULT_APPLICATION}" ] ; then diff --git a/test.sh b/test.sh index a402c09..c18b174 100755 --- a/test.sh +++ b/test.sh @@ -44,7 +44,7 @@ function assert_empty { function assert_contains_substring { TEST_COUNTER=$TEST_COUNTER+1 - if [[ $2 == *$1* ]]; then + if [[ $2 = *$1* ]]; then SUCCESS_COUNTER=$SUCCESS_COUNTER+1 echo -en "\033[0;32m.\033[0m" LAST_TEST_STATUS=0 @@ -91,12 +91,13 @@ if [[ $CREATE_APPLICATION =~ \"id\"\ \:\ ([0-9]+) ]] ; then ##### Database Collector Create, List, Get, Delete ##### DBMON_NAME="act_test_collector_$RANDOM" CREATE_DBMON="`${ACT} dbmon create -i ${DBMON_NAME} -h localhost -n db -u user -a "Default Database Agent" -t DB2 -p 1555 -s password`" - assert_contains_substring "\"name\" : \"${DBMON_NAME}\"," "$CREATE_DBMON" "Create Database Collector" + assert_contains_substring "\"name\" : \"${DBMON_NAME}\"," "${CREATE_DBMON}" "Create Database Collector" + sleep 10 assert_contains_substring "\"name\" : \"${DBMON_NAME}\"," "`${ACT} dbmon list`" "List Database Collectors" if [[ $CREATE_DBMON =~ \"id\"\ \:\ ([0-9]+) ]] ; then COLLECTOR_ID=${BASH_REMATCH[1]} - assert_contains_substring "\"name\" : \"${DBMON_NAME}\"," "`${ACT} dbmon get $COLLECTOR_ID`" - assert_contains_substring '"status" : "SUCCESS",' "`${ACT} dbmon delete $COLLECTOR_ID`" + assert_contains_substring "\"name\" : \"${DBMON_NAME}\"," "`${ACT} dbmon get -c $COLLECTOR_ID`" + assert_contains_substring '"status" : "SUCCESS",' "`${ACT} dbmon delete -c $COLLECTOR_ID`" else SKIP_COUNTER=$SKIP_COUNTER+2 echo -en "\033[0;33m!!\033[0m"