Remove Banner Printing / Update Quick Test Commenting

This commit is contained in:
Mitchell Krog 2019-06-24 13:01:36 +02:00
parent fa5e6941df
commit 7f6a2a72f2
No known key found for this signature in database
GPG key ID: C243C388553EDE5D
2 changed files with 114 additions and 82 deletions

View file

@ -16,30 +16,58 @@
# #
##############################################################################
# ************************
# Set Terminal Font Colors
# ************************
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)
# *******************************************
# Set Location of our Curl Test Results Files
# *******************************************
echo "Tests Starting"
echo "Disable any User Whitelisting and set to Default"
echo "${bold}${green}------------------------------------------------"
echo "${bold}${green}Disable any User Whitelisting and set to Default"
echo "${bold}${green}------------------------------------------------"
printf "\n\n"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-user-agents-none.conf /etc/nginx/bots.d/blacklist-user-agents.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 Properly Reload inside Travis"
echo "${bold}${yellow}--------------------------------------------------------------------"
printf "\n\n"
sleep 30s
echo "${bold}${green}--------------"
echo "${bold}${green}Tests Starting"
echo "${bold}${green}--------------"
printf "\n\n"
# *************************************************
# Function Curl Test 1 - Check for Bad Bot "80legs"
# *************************************************
run_curltest1 () {
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
if curl -v -A "80legs" http://localhost:9000/index.html 2>&1 | grep -i '(52)'; then
echo "$(tput setaf 1)BAD BOT DETECTED - $(tput setaf 2)TEST PASSED"
if curl -v -A "80legs" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}BAD BOT DETECTED"
else
echo "$(tput setaf 1)BAD BOT NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}BAD BOT NOT DETECTED"
exit 1
fi
}
@ -52,10 +80,10 @@ run_curltest1
run_curltest2 () {
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
if curl -v -A "Nutch" http://localhost:9000/index.html 2>&1 | grep -i '(52)'; then
echo "$(tput setaf 1)BAD BOT DETECTED - $(tput setaf 2)TEST PASSED"
if curl -v -A "Nutch" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}BAD BOT DETECTED"
else
echo "$(tput setaf 1)BAD BOT NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}BAD BOT NOT DETECTED"
exit 1
fi
}
@ -68,10 +96,10 @@ run_curltest2
run_curltest3 () {
printf '\n%s\n%s\n%s\n\n' "##############################" "TESTING BAD REFERRER IS DENIED" "##############################"
if curl -I http://localhost:9000/index.html -e http://100dollars-seo.com 2>&1 | grep -i '(52)'; then
echo "$(tput setaf 1)BAD REFERRER DETECTED - $(tput setaf 2)TEST PASSED"
if curl -I http://localhost:9000 -e http://100dollars-seo.com 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}BAD REFERRER DETECTED"
else
echo "$(tput setaf 1)BAD REFERRER NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}BAD REFERRER NOT DETECTED"
exit 1
fi
}
@ -84,10 +112,10 @@ run_curltest3
run_curltest4 () {
printf '\n%s\n%s\n%s\n\n' "##############################" "TESTING BAD REFERRER IS DENIED" "##############################"
if curl -I http://localhost:9000/index.html -e http://zx6.ru 2>&1 | grep -i '(52)'; then
echo "$(tput setaf 1)BAD REFERRER DETECTED - $(tput setaf 2)TEST PASSED"
if curl -I http://localhost:9000 -e http://zx6.ru 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}BAD REFERRER DETECTED"
else
echo "$(tput setaf 1)BAD REFERRER NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}BAD REFERRER NOT DETECTED"
exit 1
fi
}
@ -99,10 +127,10 @@ run_curltest4
run_curltest5 () {
printf '\n%s\n%s\n%s\n\n' "###########################" "TESTING GOOD BOT IS ALLOWED" "###########################"
if curl -v -A "GoogleBot" http://localhost:9000/index.html 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)GOOD BOT ALLOWED THROUGH - TEST PASSED"
if curl -v -A "GoogleBot" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}GOOD BOT ALLOWED THROUGH"
else
echo "$(tput setaf 1)GOOD BOT NOT ALLOWED THROUGH - TEST FAILED"
echo "${bold}${red}FAILED - ${red}GOOD BOT NOT ALLOWED THROUGH"
exit 1
fi
}
@ -114,10 +142,10 @@ run_curltest5
run_curltest6 () {
printf '\n%s\n%s\n%s\n\n' "###########################" "TESTING GOOD BOT IS ALLOWED" "###########################"
if curl -v -A "BingBot" http://localhost:9000/index.html 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)GOOD BOT ALLOWED THROUGH - TEST PASSED"
if curl -v -A "BingBot" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}GOOD BOT ALLOWED THROUGH"
else
echo "$(tput setaf 1)GOOD BOT NOT ALLOWED THROUGH - TEST FAILED"
echo "${bold}${red}FAILED - ${red}GOOD BOT NOT ALLOWED THROUGH"
exit 1
fi
}
@ -129,10 +157,10 @@ run_curltest6
run_curltest7 () {
printf '\n%s\n%s\n%s\n\n' "################################" "TESTING GOOD REFERRER IS ALLOWED" "################################"
if curl http://localhost:9000/index.html -e http://google.com 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)GOOD REFERRER DETECTED - TEST PASSED"
if curl http://localhost:9000 -e http://google.com 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}GOOD REFERRER DETECTED"
else
echo "$(tput setaf 1)GOOD REFERRER NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}GOOD REFERRER NOT DETECTED"
exit 1
fi
}
@ -144,10 +172,10 @@ run_curltest7
run_curltest8 () {
printf '\n%s\n%s\n%s\n\n' "################################" "TESTING GOOD REFERRER IS ALLOWED" "################################"
if curl http://localhost:9000/index.html -e http://bing.com 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)GOOD REFERRER DETECTED - TEST PASSED"
if curl http://localhost:9000 -e http://bing.com 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${red}GOOD REFERRER DETECTED"
else
echo "$(tput setaf 1)GOOD REFERRER NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}GOOD REFERRER NOT DETECTED"
exit 1
fi
}
@ -159,10 +187,10 @@ run_curltest8
run_curltest9 () {
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
if curl -A "Googlebot/Nutch-1.7" http://localhost:9000/index.html 2>&1 | grep -i '(52)'; then
echo "$(tput setaf 1)BAD BOT DETECTED - $(tput setaf 2)TEST PASSED"
if curl -A "Googlebot/Nutch-1.7" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}BAD BOT DETECTED"
else
echo "$(tput setaf 1)BAD BOT NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}BAD BOT NOT DETECTED"
#exit 1
fi
}
@ -174,10 +202,10 @@ run_curltest9
run_curltest10 () {
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
if curl -A "Mozilla/5.0 (compatible; Googlebot/Nutch2.1; +http://www.google.com/bot.html)" http://localhost:9000/index.html 2>&1 | grep -i '(52)'; then
echo "$(tput setaf 1)BAD BOT DETECTED - $(tput setaf 2)TEST PASSED"
if curl -A "Mozilla/5.0 (compatible; Googlebot/Nutch2.1; +http://www.google.com/bot.html)" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}BAD BOT DETECTED"
else
echo "$(tput setaf 1)BAD BOT NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - ${red}BAD BOT NOT DETECTED"
#exit 1
fi
}
@ -189,10 +217,10 @@ run_curltest10
run_curltest11 () {
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
if curl -A "Mozilla/5.0 (compatible; Googlebot/nutch/-2.1; +http://www.google.com/bot.html)" http://localhost:9000/index.html 2>&1 | grep -i '(52)'; then
echo "$(tput setaf 1)BAD BOT DETECTED - $(tput setaf 2)TEST PASSED"
if curl -A "Mozilla/5.0 (compatible; Googlebot/nutch/-2.1; +http://www.google.com/bot.html)" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}BAD BOT DETECTED"
else
echo "$(tput setaf 1)BAD BOT NOT DETECTED - TEST FAILED"
echo "${bold}${red}FAILED - BAD BOT NOT DETECTED"
#exit 1
fi
}
@ -204,10 +232,10 @@ run_curltest11
run_curltest12 () {
printf '\n%s\n%s\n%s\n\n' "############################" "TESTING FALSE POSITIVE CASES" "############################"
if curl -v -A "Mozilla/5.0 (compatible; Googlebot-Image/Snutch\-/-2.1; +http://www.google.com/bot.html)" http://localhost:9000/index.html 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)NO FALSE POSITIVE - TEST PASSED"
if curl -v -A "Mozilla/5.0 (compatible; Googlebot-Image/Snutch\-/-2.1; +http://www.google.com/bot.html)" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - NO FALSE POSITIVE"
else
echo "$(tput setaf 1)FALSE POSITIVE - TEST FAILED"
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND"
#exit 1
fi
}
@ -219,10 +247,10 @@ run_curltest12
run_curltest13 () {
printf '\n%s\n%s\n%s\n\n' "############################" "TESTING FALSE POSITIVE CASES" "############################"
if curl -v -A "SnutchMozilla/5.0 (compatible; Googlebot-Image/SMutch\-/-2.1; +http://www.google.com/bot.html)" http://localhost:9000/index.html 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)NO FALSE POSITIVE - TEST PASSED"
if curl -v -A "SnutchMozilla/5.0 (compatible; Googlebot-Image/SMutch\-/-2.1; +http://www.google.com/bot.html)" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - NO FALSE POSITIVE"
else
echo "$(tput setaf 1)FALSE POSITIVE - TEST FAILED"
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND"
#exit 1
fi
}
@ -234,10 +262,10 @@ run_curltest13
run_curltest14 () {
printf '\n%s\n%s\n%s\n\n' "############################" "TESTING FALSE POSITIVE CASES" "############################"
if curl -v -A "Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0" http://localhost:9000/index.html 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)NO FALSE POSITIVE - TEST PASSED"
if curl -v -A "Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - NO FALSE POSITIVE"
else
echo "$(tput setaf 1)FALSE POSITIVE - TEST FAILED"
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND"
#exit 1
fi
}
@ -250,27 +278,28 @@ run_curltest14
run_curltest15 () {
printf '\n%s\n%s\n%s\n\n' "############################" "TESTING FALSE POSITIVE CASES" "############################"
if curl -v -A "Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0" http://localhost:9000/index.html 2>&1 | grep -i 'Welcome'; then
echo "$(tput setaf 2)NO FALSE POSITIVE - TEST PASSED"
if curl -v -A "Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - NO FALSE POSITIVE"
else
echo "$(tput setaf 1)FALSE POSITIVE - TEST FAILED"
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND"
#exit 1
fi
}
run_curltest15
bold=$(tput bold)
red=$(tput setaf 1)
green=$(tput setaf 2)
# ************************************************
# Test 50 Random User-Agents from Bad-User-Agents
# Test 50 User-Agents from Bad-User-Agents
# ************************************************
shuf -n 50 ${TRAVIS_BUILD_DIR}/_generator_lists/bad-user-agents.list > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test-quick.tmp
sed 's/\\//g' ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test-quick.tmp > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test-quick.list
sudo rm ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test-quick.tmp
sort -u ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test-quick.list -o ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test-quick.list
echo "Testing 250 Random Bad Bots"
printf "\n\n"
echo "${bold}${magenta}---------------------------"
echo "${bold}${magenta}Testing 50 Random Bad Bots"
echo "${bold}${magenta}---------------------------"
printf "\n\n"
IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test-quick.list
lines=$(cat ${file})
@ -289,7 +318,11 @@ IFS=""
# ************************************************
sed 's/\\//g' ${TRAVIS_BUILD_DIR}/_generator_lists/good-user-agents.list > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/good-bots-for-test.list
echo "Testing All Good Bots"
printf "\n\n"
echo "${bold}${magenta}---------------------"
echo "${bold}${magenta}Testing All Good Bots"
echo "${bold}${magenta}---------------------"
printf "\n\n"
IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/good-bots-for-test.list
lines=$(cat ${file})
@ -309,7 +342,11 @@ IFS=""
# *****************************************************
sed 's/\\//g' ${TRAVIS_BUILD_DIR}/_generator_lists/allowed-user-agents.list > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/allowed-bots-for-test.list
echo "Testing All Allowed Bots"
printf "\n\n"
echo "${bold}${magenta}------------------------"
echo "${bold}${magenta}Testing All Allowed Bots"
echo "${bold}${magenta}------------------------"
printf "\n\n"
IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/allowed-bots-for-test.list
lines=$(cat ${file})
@ -328,7 +365,11 @@ IFS=""
# *****************************************************
sed 's/\\//g' ${TRAVIS_BUILD_DIR}/_generator_lists/limited-user-agents.list > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/limited-bots-for-test.list
echo "Testing All Limited Bots"
printf "\n\n"
echo "${bold}${magenta}------------------------"
echo "${bold}${magenta}Testing All Limited Bots"
echo "${bold}${magenta}------------------------"
printf "\n\n"
IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/limited-bots-for-test.list
lines=$(cat ${file})
@ -348,9 +389,13 @@ IFS=""
shuf -n 100 ${TRAVIS_BUILD_DIR}/_generator_lists/bad-referrers.list > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-test-quick.list
sort -u ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-test-quick.list -o ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-test-quick.list
echo "Testing 100 Random Bad Referrers"
printf "\n\n"
echo "${bold}${magenta}--------------------------------"
echo "${bold}${magenta}Testing 100 Random Bad Referrers"
echo "${bold}${magenta}--------------------------------"
printf "\n\n"
IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-test-quick.list
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-test.list
lines=$(cat ${file})
for line in ${lines}; do
if
@ -366,7 +411,11 @@ IFS=""
# Test Good Referrer Domains
# **************************
echo "Testing Good Referrers"
printf "\n\n"
echo "${bold}${magenta}----------------------"
echo "${bold}${magenta}Testing Good Referrers"
echo "${bold}${magenta}----------------------"
printf "\n\n"
IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/good-referrers-for-test.list
lines=$(cat ${file})
@ -381,7 +430,10 @@ done
IFS=""
echo "Tests Completed"
printf "\n"
echo "${bold}${cyan}Tests Completed"
echo "${bold}${gren}All Tests Passed"
echo "${bold}${magenta}Now We Test Whitelisting and then Release a new build"
# **********************
# Exit With Error Number

View file

@ -29,7 +29,6 @@ magenta=$(tput setaf 5)
cyan=$(tput setaf 6)
white=$(tput setaf 7)
defaultcolor=$(tput setaf default)
banner=$(cat ${TRAVIS_BUILD_DIR}/.dev-tools/banner.txt)
# *******************************************
# Set Location of our Curl Test Results Files
@ -436,25 +435,6 @@ echo "${bold}${cyan}Tests Completed"
echo "${bold}${gren}All Tests Passed"
echo "${bold}${magenta}Now We Test Whitelisting and then Release a new build"
printf "\n"
${bold}${yellow}
cat << "EOF"
##############################################################################
# _ __ _ #
# / |/ /__ _(_)__ __ __ #
# / / _ `/ / _ \\ \ / #
# /_/|_/\_, /_/_//_/_\_\ #
# __/___/ __ ___ __ ___ __ __ #
# / _ )___ ____/ / / _ )___ / /_ / _ )/ /__ ____/ /_____ ____ #
# / _ / _ `/ _ / / _ / _ \/ __/ / _ / / _ \/ __/ '_/ -_) __/ #
# /____/\_,_/\_,_/ /____/\___/\__/ /____/_/\___/\__/_/\_\\__/_/ #
# #
##############################################################################
EOF
${defaultcolor}
# **********************
# Exit With Error Number
# **********************