Skip to content

Commit

Permalink
fixed escaping. fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelenglert committed Apr 18, 2018
1 parent bf89de7 commit 1b89f3d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions act.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions helpers/apiCall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 1b89f3d

Please sign in to comment.