mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-03 02:59:57 +00:00
V4 Improve Commenting and Coloring in Whitelist Test
This commit is contained in:
parent
58e28b56ef
commit
a200dc77dd
1 changed files with 50 additions and 12 deletions
|
@ -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
|
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
|
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
|
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
|
sleep 30s
|
||||||
|
|
||||||
# *******************************************************
|
# *******************************************************
|
||||||
|
@ -34,11 +63,10 @@ sleep 30s
|
||||||
# *******************************************************
|
# *******************************************************
|
||||||
|
|
||||||
run_curltest1 () {
|
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
|
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
|
else
|
||||||
echo "$(tput setaf 1)WHITELISTING FAILED - TEST FAILED"
|
echo "${bold}${red}FAILED - WHITELISTING of BAD BOT Nutch FAILED"
|
||||||
#exit 1
|
#exit 1
|
||||||
curl -v -A "Nutch" http://localhost:9000 2>&1
|
curl -v -A "Nutch" http://localhost:9000 2>&1
|
||||||
fi
|
fi
|
||||||
|
@ -50,11 +78,10 @@ run_curltest1
|
||||||
# **************************************************************
|
# **************************************************************
|
||||||
|
|
||||||
run_curltest2 () {
|
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
|
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
|
else
|
||||||
echo "$(tput setaf 1)WHITELISTING REFERRER FAILED - TEST FAILED"
|
echo "${bold}${red}FAILED - WHITELISTING OF REFERRER zx6.ru FAILED"
|
||||||
#exit 1
|
#exit 1
|
||||||
curl http://localhost:9000 -e http://zx6.ru 2>&1
|
curl http://localhost:9000 -e http://zx6.ru 2>&1
|
||||||
fi
|
fi
|
||||||
|
@ -62,7 +89,18 @@ fi
|
||||||
run_curltest2
|
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
|
# Exit With Error Number
|
||||||
|
|
Loading…
Add table
Reference in a new issue