Nginx Test BETA - Reduce Verbose Curls

This commit is contained in:
Mitchell Krog 2019-06-29 20:04:38 +02:00
parent 246c1a39af
commit 7465ca0a14
No known key found for this signature in database
GPG key ID: C243C388553EDE5D

View file

@ -77,17 +77,17 @@ sleep 10s
} }
run_curltest1 () { run_curltest1 () {
if curl -v -A "80legs" http://localhost:9000 2>&1 | grep -i '(52)'; then if curl -A "80legs" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}80legs BAD BOT DETECTED" echo "${bold}${green}PASSED - ${red}80legs BAD BOT DETECTED"
else else
echo "${bold}${red}FAILED - ${red}80legs BAD BOT NOT DETECTED" echo "${bold}${red}FAILED - ${red}80legs BAD BOT NOT DETECTED"
curl -v -A "80legs" http://localhost:9000 2>&1 curl -A "80legs" http://localhost:9000 2>&1
exit 1 exit 1
fi fi
} }
run_curltest2 () { run_curltest2 () {
if curl -v -A "Nutch" http://localhost:9000 2>&1 | grep -i '(52)'; then if curl -A "Nutch" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}Nutch BAD BOT DETECTED" echo "${bold}${green}PASSED - ${red}Nutch BAD BOT DETECTED"
else else
echo "${bold}${red}FAILED - ${red}Nutch BAD BOT NOT DETECTED" echo "${bold}${red}FAILED - ${red}Nutch BAD BOT NOT DETECTED"
@ -114,7 +114,7 @@ fi
} }
run_curltest5 () { run_curltest5 () {
if curl -v -A "GoogleBot" http://localhost:9000 2>&1 | grep -i 'Welcome'; then if curl -A "GoogleBot" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}GoogleBot GOOD BOT ALLOWED THROUGH" echo "${bold}${green}PASSED - ${green}GoogleBot GOOD BOT ALLOWED THROUGH"
else else
echo "${bold}${red}FAILED - ${red}GoogleBot GOOD BOT NOT ALLOWED THROUGH" echo "${bold}${red}FAILED - ${red}GoogleBot GOOD BOT NOT ALLOWED THROUGH"
@ -123,7 +123,7 @@ fi
} }
run_curltest6 () { run_curltest6 () {
if curl -v -A "BingBot" http://localhost:9000 2>&1 | grep -i 'Welcome'; then if curl -A "BingBot" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}BingBot GOOD BOT ALLOWED THROUGH" echo "${bold}${green}PASSED - ${green}BingBot GOOD BOT ALLOWED THROUGH"
else else
echo "${bold}${red}FAILED - ${red}BingBot GOOD BOT NOT ALLOWED THROUGH" echo "${bold}${red}FAILED - ${red}BingBot GOOD BOT NOT ALLOWED THROUGH"
@ -177,7 +177,7 @@ fi
} }
run_curltest12 () { run_curltest12 () {
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 if curl -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 on Googlebot-Image/Snutch\-/-2.1" echo "${bold}${green}PASSED - NO FALSE POSITIVE on Googlebot-Image/Snutch\-/-2.1"
else else
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on Googlebot-Image/Snutch\-/-2.1" echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on Googlebot-Image/Snutch\-/-2.1"
@ -186,7 +186,7 @@ fi
} }
run_curltest13 () { run_curltest13 () {
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 if curl -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 on SnutchMozilla/5.0" echo "${bold}${green}PASSED - NO FALSE POSITIVE on SnutchMozilla/5.0"
else else
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on SnutchMozilla/5.0" echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on SnutchMozilla/5.0"
@ -195,7 +195,7 @@ fi
} }
run_curltest14 () { run_curltest14 () {
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 if curl -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 on Mozilla/5.0" echo "${bold}${green}PASSED - NO FALSE POSITIVE on Mozilla/5.0"
else else
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on Mozilla/5.0" echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on Mozilla/5.0"
@ -204,7 +204,7 @@ fi
} }
run_curltest15 () { run_curltest15 () {
if curl -v -A "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Mobile/15E148 Safari/604.1" http://localhost:9000 2>&1 | grep -i 'Welcome'; then if curl -A "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Mobile/15E148 Safari/604.1" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - NO FALSE POSITIVE on Safari" echo "${bold}${green}PASSED - NO FALSE POSITIVE on Safari"
else else
echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on Safari" echo "${bold}${red}FAILED - FALSE POSITIVE FOUND on Safari"
@ -226,7 +226,7 @@ file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-test.list
lines=$(cat ${file}) lines=$(cat ${file})
for line in ${lines}; do for line in ${lines}; do
if if
curl -v -A "${line}" http://localhost:9000 2>&1 | grep -i '(52)'; then curl -A "${line}" http://localhost:9000 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${red}${line} was ${bold}${red}BLOCKED" echo "${bold}${green}PASSED - ${red}${line} was ${bold}${red}BLOCKED"
else else
echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}NOT BLOCKED" echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}NOT BLOCKED"
@ -246,7 +246,7 @@ file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/good-bots-for-test.list
lines=$(cat ${file}) lines=$(cat ${file})
for line in ${lines}; do for line in ${lines}; do
if if
curl -v -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then curl -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED" echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED"
else else
echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}BLOCKED" echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}BLOCKED"
@ -266,7 +266,7 @@ file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/allowed-bots-for-test.list
lines=$(cat ${file}) lines=$(cat ${file})
for line in ${lines}; do for line in ${lines}; do
if if
curl -v -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then curl -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED" echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED"
else else
echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}BLOCKED" echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}BLOCKED"
@ -286,7 +286,7 @@ file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/limited-bots-for-test.list
lines=$(cat ${file}) lines=$(cat ${file})
for line in ${lines}; do for line in ${lines}; do
if if
curl -v -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then curl -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED and ${bold}${red}RATE LIMITED" echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED and ${bold}${red}RATE LIMITED"
else else
echo "${bold}${green}FAILED - ${red}${line} was ${bold}${red}BLOCKED" echo "${bold}${green}FAILED - ${red}${line} was ${bold}${red}BLOCKED"
@ -326,7 +326,7 @@ file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/good-referrers-for-test.list
lines=$(cat ${file}) lines=$(cat ${file})
for line in ${lines}; do for line in ${lines}; do
if if
curl -v -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then curl -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED" echo "${bold}${green}PASSED - ${green}${line} was ${bold}${green}ALLOWED"
else else
echo "${bold}${green}FAILED - ${red}${line} was ${bold}${red}BLOCKED" echo "${bold}${green}FAILED - ${red}${line} was ${bold}${red}BLOCKED"