Fix Nginx reloading issues on Travis Container - Fix tests Ref: #264

This commit is contained in:
Mitchell Krog 2019-06-20 13:46:17 +02:00
parent a4d8a013f6
commit f14b0b258e
No known key found for this signature in database
GPG key ID: C243C388553EDE5D
2 changed files with 11 additions and 15 deletions

View file

@ -53,11 +53,7 @@ sudo cp ${TRAVIS_BUILD_DIR}/conf.d/globalblacklist-testing-version.conf /etc/ngi
# *********************
printf '\n%s\n%s\n%s\n\n' "########################" "Force Reloading of Nginx" "########################"
sudo service nginx reload
# Debug Nginx on Travis
sudo nginx -t
sudo nginx -s reload
sudo nginx -t && sudo nginx -s reload
# **********************
# Now Run our Curl Tests

View file

@ -42,7 +42,7 @@ run_curltest1 () {
truncate -s 0 ${_curltest1}
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest1}"
curl -A "80legs" http://localhost:9000/index.html 2>> ${_curltest1}
curl -A "80legs" http://localhost:9000/index.php 2>> ${_curltest1}
if grep -i '(52)' ${_curltest1}; then
echo 'BAD BOT DETECTED - TEST PASSED'
else
@ -59,7 +59,7 @@ run_curltest2 () {
truncate -s 0 ${_curltest2}
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest2}"
curl -A "Nutch" http://localhost:9000/index.html 2>> ${_curltest2}
curl -A "Nutch" http://localhost:9000/index.php 2>> ${_curltest2}
if grep -i '(52)' ${_curltest2}; then
echo 'BAD BOT DETECTED - TEST PASSED'
else
@ -76,7 +76,7 @@ run_curltest3 () {
truncate -s 0 ${_curltest3}
printf '\n%s\n%s\n%s\n\n' "##############################" "TESTING BAD REFERRER IS DENIED" "##############################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest3}"
curl -I http://localhost:9000/index.html -e http://100dollars-seo.com 2>> ${_curltest3}
curl -I http://localhost:9000/index.php -e http://100dollars-seo.com 2>> ${_curltest3}
if grep -i '(52)' ${_curltest3}; then
echo 'BAD REFERRER DETECTED - TEST PASSED'
else
@ -93,7 +93,7 @@ run_curltest4 () {
truncate -s 0 ${_curltest4}
printf '\n%s\n%s\n%s\n\n' "##############################" "TESTING BAD REFERRER IS DENIED" "##############################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest4}"
curl -I http://localhost:9000/index.html -e http://zx6.ru 2>> ${_curltest4}
curl -I http://localhost:9000/index.php -e http://zx6.ru 2>> ${_curltest4}
if grep -i '(52)' ${_curltest4}; then
echo 'BAD REFERRER DETECTED - TEST PASSED'
else
@ -110,7 +110,7 @@ run_curltest5 () {
truncate -s 0 ${_curltest5}
printf '\n%s\n%s\n%s\n\n' "###########################" "TESTING GOOD BOT IS ALLOWED" "###########################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest5}"
curl -v -A "GoogleBot" http://localhost:9000/index.html 2>&1 >> ${_curltest5}
curl -v -A "GoogleBot" http://localhost:9000/index.php 2>&1 >> ${_curltest5}
if grep -i 'Welcome' ${_curltest5}; then
echo 'GOOD BOT ALLOWED THROUGH - TEST PASSED'
else
@ -127,7 +127,7 @@ run_curltest6 () {
truncate -s 0 ${_curltest6}
printf '\n%s\n%s\n%s\n\n' "###########################" "TESTING GOOD BOT IS ALLOWED" "###########################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest6}"
curl -v -A "BingBot" http://localhost:9000/index.html 2>&1 >> ${_curltest6}
curl -v -A "BingBot" http://localhost:9000/index.php 2>&1 >> ${_curltest6}
if grep -i 'Welcome' ${_curltest6}; then
echo 'GOOD BOT ALLOWED THROUGH - TEST PASSED'
else
@ -144,7 +144,7 @@ run_curltest7 () {
truncate -s 0 ${_curltest7}
printf '\n%s\n%s\n%s\n\n' "################################" "TESTING GOOD REFERRER IS ALLOWED" "################################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest7}"
curl http://localhost:9000/index.html -e http://google.com 2>&1 >> ${_curltest7}
curl http://localhost:9000/index.php -e http://google.com 2>&1 >> ${_curltest7}
if grep -i 'Welcome' ${_curltest7}; then
echo 'GOOD REFERRER DETECTED - TEST PASSED'
else
@ -161,7 +161,7 @@ run_curltest8 () {
truncate -s 0 ${_curltest8}
printf '\n%s\n%s\n%s\n\n' "################################" "TESTING GOOD REFERRER IS ALLOWED" "################################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest8}"
curl http://localhost:9000/index.html -e http://bing.com 2>&1 >> ${_curltest8}
curl http://localhost:9000/index.php -e http://bing.com 2>&1 >> ${_curltest8}
if grep -i 'Welcome' ${_curltest8}; then
echo 'GOOD REFERRER DETECTED - TEST PASSED'
exit 0
@ -179,7 +179,7 @@ run_curltest9 () {
truncate -s 0 ${_curltest9}
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest9}"
curl -A "Googlebot/Nutch-1.7" http://localhost:9000/index.html 2>> ${_curltest9}
curl -A "Googlebot/Nutch-1.7" http://localhost:9000/index.php 2>> ${_curltest9}
if grep -i '(52)' ${_curltest9}; then
echo 'BAD BOT DETECTED - TEST PASSED'
else
@ -196,7 +196,7 @@ run_curltest10 () {
truncate -s 0 ${_curltest10}
printf '\n%s\n%s\n%s\n\n' "#########################" "TESTING BAD BOT IS DENIED" "#########################"
printf '%s%s\n\n' "Last Tested: " "$_now" >> "${_curltest10}"
curl -A "Mozilla/5.0 (compatible; Googlebot/Nutch2.1; +http://www.google.com/bot.html)" http://localhost:9000/index.html 2>> ${_curltest10}
curl -A "Mozilla/5.0 (compatible; Googlebot/Nutch2.1; +http://www.google.com/bot.html)" http://localhost:9000/index.php 2>> ${_curltest10}
if grep -i '(52)' ${_curltest10}; then
echo 'BAD BOT DETECTED - TEST PASSED'
else