From a200dc77ddc442aa27fbd068d882d6affc85adeb Mon Sep 17 00:00:00 2001 From: Mitchell Krog Date: Mon, 24 Jun 2019 15:26:50 +0200 Subject: [PATCH] V4 Improve Commenting and Coloring in Whitelist Test --- .dev-tools/test-blocker-whitelist.sh | 62 ++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/.dev-tools/test-blocker-whitelist.sh b/.dev-tools/test-blocker-whitelist.sh index dd41f6297..d48ebc51d 100755 --- a/.dev-tools/test-blocker-whitelist.sh +++ b/.dev-tools/test-blocker-whitelist.sh @@ -16,17 +16,46 @@ # # ############################################################################## -echo "Whitelist Tests Starting" +# ************************ +# Set Terminal Font Colors +# ************************ -echo "Activating Users User-Agents Whitelist/Blacklist" +bold=$(tput bold) +red=$(tput setaf 1) +green=$(tput setaf 2) +yellow=$(tput setaf 3) +blue=$(tput setaf 4) +magenta=$(tput setaf 5) +cyan=$(tput setaf 6) +white=$(tput setaf 7) +defaultcolor=$(tput setaf default) + +echo "${bold}${green}--------------------------" +echo "${bold}${green}Whitelisting Test Starting" +echo "${bold}${green}--------------------------" +printf "\n\n" + +echo "${bold}${green}------------------------------------------------" +echo "${bold}${green}Activating Users User-Agents Whitelist/Blacklist" +echo "${bold}${green}------------------------------------------------" +printf "\n\n" sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-user-agents.conf /etc/nginx/bots.d/blacklist-user-agents.conf -echo "Activating Users Referrers Whitelist/Blacklist" +echo "${bold}${green}----------------------------------------------" +echo "${bold}${green}Activating Users Referrers Whitelist/Blacklist" +echo "${bold}${green}----------------------------------------------" +printf "\n\n" sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/custom-bad-referrers.conf /etc/nginx/bots.d/custom-bad-referrers.conf -echo "Reloading Nginx" +echo "${bold}${green}---------------" +echo "${bold}${green}Reloading Nginx" +echo "${bold}${green}---------------" +printf "\n\n" sudo nginx -t && sudo nginx -s reload -echo "Sleeping for 30 seconds to allow Nginx Properly Reload inside Travis" +echo "${bold}${yellow}-----------------------------------------------------------------------" +echo "${bold}${yellow}Sleeping for 30 seconds to allow Nginx to Properly Reload inside Travis" +echo "${bold}${yellow}-----------------------------------------------------------------------" +printf "\n\n" sleep 30s # ******************************************************* @@ -34,11 +63,10 @@ sleep 30s # ******************************************************* run_curltest1 () { -printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING USER WHITELIST" "#########################" if curl -v -A "Nutch" http://localhost:9000 2>&1 | grep -i 'Welcome'; then - echo "$(tput setaf 2)WHITELISTING OF BAD BOT ALLOWED - TEST PASSED" + echo "${bold}${green}PASSED - WHITELISTING OF BAD BOT Nutch ALLOWED" else - echo "$(tput setaf 1)WHITELISTING FAILED - TEST FAILED" + echo "${bold}${red}FAILED - WHITELISTING of BAD BOT Nutch FAILED" #exit 1 curl -v -A "Nutch" http://localhost:9000 2>&1 fi @@ -50,11 +78,10 @@ run_curltest1 # ************************************************************** run_curltest2 () { -printf '\n%s\n%s\n%s\n\n' "##############################" "TESTING BAD REFERRER IS DENIED" "##############################" if curl http://localhost:9000 -e http://zx6.ru 2>&1 | grep -i 'Welcome'; then - echo "$(tput setaf 2)WHITELISTING OF REFERRER ALLOWED - TEST PASSED" + echo "${bold}${green}PASSED - WHITELISTING OF REFERRER zx6.ru ALLOWED" else - echo "$(tput setaf 1)WHITELISTING REFERRER FAILED - TEST FAILED" + echo "${bold}${red}FAILED - WHITELISTING OF REFERRER zx6.ru FAILED" #exit 1 curl http://localhost:9000 -e http://zx6.ru 2>&1 fi @@ -62,7 +89,18 @@ fi run_curltest2 -echo "Whitelist Tests Completed" +printf "\n" +echo "${bold}${green}--------------------------" +echo "${bold}${green}Whitelisting Test Complete" +echo "${bold}${green}--------------------------" +printf "\n\n" + +latestbuild=V4.${YEAR}.${MONTH}.${TRAVIS_BUILD_NUMBER} +printf "\n" +echo "${bold}${green}All Nginx Tests Completed" +echo "${bold}${green}All Bot and Referrer Testing Completed" +echo "${bold}${green}All Function Testing Completed" +echo "${bold}${magenta}Releasing ${latestbuild}" # ********************** # Exit With Error Number