GHA workflow - Fix Tests 3+ [skip travis]

This commit is contained in:
Mitchell Krog 2021-07-05 08:48:47 +02:00
parent 5c31bf156f
commit fa7535856d
No known key found for this signature in database
GPG key ID: E02E9D10427B6A43
5 changed files with 155 additions and 145 deletions

View file

@ -16,6 +16,8 @@
# # # #
############################################################################## ##############################################################################
export TERM=xterm
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# MIT License # MIT License
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -64,7 +66,7 @@ printf "\n"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
echo "${bold}${green}Reloading Nginx" echo "${bold}${green}Reloading Nginx"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
sudo nginx -t && sudo nginx -s reload sudo nginx -t && sudo systemctl reload nginx
} }
waitforReload () { waitforReload () {
@ -80,11 +82,11 @@ echo "${bold}${green}----------------------------------------"
echo "${bold}${green}Activating Users bad-referrer-words.conf" echo "${bold}${green}Activating Users bad-referrer-words.conf"
echo "${bold}${green}----------------------------------------" echo "${bold}${green}----------------------------------------"
printf "\n" printf "\n"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/bad-referrer-words.conf /etc/nginx/bots.d/bad-referrer-words.conf sudo cp ./dev-tools/test_units/bad-referrer-words.conf /etc/nginx/bots.d/bad-referrer-words.conf
} }
run_curltest1 () { run_curltest1 () {
if curl -I http://localhost:9000 -e "thisisabadword" 2>&1 | grep -i '(52)'; then if curl -I http://localhost:80 -e "thisisabadword" 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - User bad-referrer-words.conf working" echo "${bold}${green}PASSED - User bad-referrer-words.conf working"
else else
echo "${bold}${red}FAILED - User bad-referrer-words.conf NOT working" echo "${bold}${red}FAILED - User bad-referrer-words.conf NOT working"
@ -93,7 +95,7 @@ fi
} }
run_curltest2 () { run_curltest2 () {
if curl -I http://localhost:9000 -e "thisisanotherbadword" 2>&1 | grep -i '(52)'; then if curl -I http://localhost:80 -e "thisisanotherbadword" 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - User bad-referrer-words.conf working" echo "${bold}${green}PASSED - User bad-referrer-words.conf working"
else else
echo "${bold}${red}FAILED - User bad-referrer-words.conf NOT working" echo "${bold}${red}FAILED - User bad-referrer-words.conf NOT working"

View file

@ -16,6 +16,8 @@
# # # #
############################################################################## ##############################################################################
export TERM=xterm
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# MIT License # MIT License
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -64,7 +66,7 @@ printf "\n"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
echo "${bold}${green}Reloading Nginx" echo "${bold}${green}Reloading Nginx"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
sudo nginx -t && sudo nginx -s reload sudo nginx -t && sudo systemctl reload nginx
} }
waitforReload () { waitforReload () {
@ -80,92 +82,92 @@ echo "${bold}${yellow}-----------------------------"
echo "${bold}${yellow}Making GoogleBot ${yellow}RATE LIMITED" echo "${bold}${yellow}Making GoogleBot ${yellow}RATE LIMITED"
echo "${bold}${yellow}-----------------------------" echo "${bold}${yellow}-----------------------------"
printf "\n" printf "\n"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/rate-limiting-user-agents.conf /etc/nginx/bots.d/blacklist-user-agents.conf sudo cp ./dev-tools/test_units/rate-limiting-user-agents.conf /etc/nginx/bots.d/blacklist-user-agents.conf
} }
testRateLimiting () { testRateLimiting () {
ratelimittestfile=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/ratelimittest-master.txt ratelimittestfile=./dev-tools/test_units/ratelimittest-master.txt
truncate -s 0 ${ratelimittestfile} truncate -s 0 ${ratelimittestfile}
curl -A "GoogleBot" http://localhost:9000 2>&1 > ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 > ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} & curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile} &
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} curl -A "GoogleBot" http://localhost:80 2>&1 >> ${ratelimittestfile}
if grep -i 'Unavailable' < ${ratelimittestfile}; then if grep -i 'Unavailable' < ${ratelimittestfile}; then
echo "${bold}${green}PASSED - ${red}GoogleBot was ${bold}${red}RATE LIMITED" echo "${bold}${green}PASSED - ${red}GoogleBot was ${bold}${red}RATE LIMITED"
@ -181,10 +183,10 @@ echo "${bold}${green}-------------------------------------------------------"
echo "${bold}${green}Backup all conf files and folders used during this test" echo "${bold}${green}Backup all conf files and folders used during this test"
echo "${bold}${green}-------------------------------------------------------" echo "${bold}${green}-------------------------------------------------------"
printf "\n" printf "\n"
sudo cp /etc/nginx/bots.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ratelimiting/bots.d/ sudo cp /etc/nginx/bots.d/* ./dev-tools/test1_conf_files_ratelimiting/bots.d/
sudo cp /etc/nginx/conf.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ratelimiting/conf.d/ sudo cp /etc/nginx/conf.d/* ./dev-tools/test1_conf_files_ratelimiting/conf.d/
sudo cp /etc/nginx/sites-available/default.vhost ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ratelimiting/default.vhost sudo cp /etc/nginx/sites-available/default.vhost ./dev-tools/test1_conf_files_ratelimiting/default.vhost
sudo cp /etc/nginx/nginx.conf ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ratelimiting/nginx.conf sudo cp /etc/nginx/nginx.conf ./dev-tools/test1_conf_files_ratelimiting/nginx.conf
} }
# ----------- # -----------

View file

@ -16,6 +16,8 @@
# # # #
############################################################################## ##############################################################################
export TERM=xterm
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# MIT License # MIT License
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -64,7 +66,7 @@ printf "\n"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
echo "${bold}${green}Reloading Nginx" echo "${bold}${green}Reloading Nginx"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
sudo nginx -t && sudo nginx -s reload sudo nginx -t && sudo systemctl reload nginx
} }
waitforReload () { waitforReload () {
@ -80,11 +82,11 @@ echo "${bold}${green}---------------------------------------"
echo "${bold}${green}Activating Users whitelist-domains.conf" echo "${bold}${green}Activating Users whitelist-domains.conf"
echo "${bold}${green}---------------------------------------" echo "${bold}${green}---------------------------------------"
printf "\n" printf "\n"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-domains.conf /etc/nginx/bots.d/whitelist-domains.conf sudo cp ./dev-tools/test_units/whitelist-domains.conf /etc/nginx/bots.d/whitelist-domains.conf
} }
run_curltest1 () { run_curltest1 () {
if curl http://localhost:9000 -e http://www.myowndomain.com 2>&1 | grep -i 'Welcome'; then if curl http://localhost:80 -e http://www.myowndomain.com 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - User whitelist-domains.conf working" echo "${bold}${green}PASSED - User whitelist-domains.conf working"
else else
echo "${bold}${red}FAILED - User whitelist-domains.conf NOT working" echo "${bold}${red}FAILED - User whitelist-domains.conf NOT working"
@ -93,7 +95,7 @@ fi
} }
run_curltest2 () { run_curltest2 () {
if curl http://localhost:9000 -e http://www.myotherdomain.com 2>&1 | grep -i 'Welcome'; then if curl http://localhost:80 -e http://www.myotherdomain.com 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - User whitelist-domains.conf working" echo "${bold}${green}PASSED - User whitelist-domains.conf working"
else else
echo "${bold}${red}FAILED - User whitelist-domains.conf NOT working" echo "${bold}${red}FAILED - User whitelist-domains.conf NOT working"

View file

@ -16,6 +16,8 @@
# # # #
############################################################################## ##############################################################################
export TERM=xterm
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# MIT License # MIT License
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -64,7 +66,7 @@ reloadNginX () {
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
echo "${bold}${green}Reloading Nginx" echo "${bold}${green}Reloading Nginx"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
sudo nginx -t && sudo nginx -s reload sudo nginx -t && sudo systemctl reload nginx
} }
waitforReload () { waitforReload () {
@ -76,7 +78,7 @@ sleep 10s
} }
run_curltest1 () { run_curltest1 () {
if curl http://localhost:9000 2>&1 | grep -i '(52)'; then if curl http://localhost:80 2>&1 | grep -i '(52)'; then
echo "${bold}${green}PASSED - ${bold}${red}blacklist own ip is WORKING" echo "${bold}${green}PASSED - ${bold}${red}blacklist own ip is WORKING"
else else
echo "${bold}${red}FAILED - blacklist own ip is NOT working" echo "${bold}${red}FAILED - blacklist own ip is NOT working"
@ -85,11 +87,11 @@ fi
} }
run_curltest2 () { run_curltest2 () {
if curl http://localhost:9000 2>&1 | grep -i 'Welcome'; then if curl http://localhost:80 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - whitelist own ip is WORKING" echo "${bold}${green}PASSED - whitelist own ip is WORKING"
else else
echo "${bold}${red}FAILED - whitelist own ip is NOT working" echo "${bold}${red}FAILED - whitelist own ip is NOT working"
curl http://localhost:9000 curl http://localhost:80
exit 1 exit 1
fi fi
} }
@ -100,28 +102,28 @@ echo "${bold}${green}-----------------------------------------------------------
echo "${bold}${green}Make Backup all conf files and folders used during this test" echo "${bold}${green}Make Backup all conf files and folders used during this test"
echo "${bold}${green}------------------------------------------------------------" echo "${bold}${green}------------------------------------------------------------"
printf "\n" printf "\n"
sudo cp /etc/nginx/bots.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ip_whitelist/bots.d/ sudo cp /etc/nginx/bots.d/* ./dev-tools/test1_conf_files_ip_whitelist/bots.d/
sudo cp /etc/nginx/conf.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ip_whitelist/conf.d/ sudo cp /etc/nginx/conf.d/* ./dev-tools/test1_conf_files_ip_whitelist/conf.d/
sudo cp /etc/nginx/sites-available/default.vhost ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ip_whitelist/default.vhost sudo cp /etc/nginx/sites-available/default.vhost ./dev-tools/test1_conf_files_ip_whitelist/default.vhost
sudo cp /etc/nginx/nginx.conf ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_ip_whitelist/nginx.conf sudo cp /etc/nginx/nginx.conf ./dev-tools/test1_conf_files_ip_whitelist/nginx.conf
} }
blacklistOwnIP () { blacklistOwnIP () {
sudo truncate -s 0 ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf sudo truncate -s 0 ./dev-tools/test_units/blacklist-ips.conf
printf '%s\t%s\n' "${thisip}" "1;" > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf printf '%s\t%s\n' "${thisip}" "1;" > ./dev-tools/test_units/blacklist-ips.conf
printf '%s\t%s\n' "127.0.0.1" "1;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf printf '%s\t%s\n' "127.0.0.1" "1;" >> ./dev-tools/test_units/blacklist-ips.conf
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf /etc/nginx/bots.d/blacklist-ips.conf sudo cp ./dev-tools/test_units/blacklist-ips.conf /etc/nginx/bots.d/blacklist-ips.conf
sudo truncate -s 0 ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf sudo truncate -s 0 ./dev-tools/test_units/whitelist-ips.conf
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf /etc/nginx/bots.d/whitelist-ips.conf sudo cp ./dev-tools/test_units/whitelist-ips.conf /etc/nginx/bots.d/whitelist-ips.conf
} }
whitelistOwnIP () { whitelistOwnIP () {
sudo truncate -s 0 ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf sudo truncate -s 0 ./dev-tools/test_units/whitelist-ips.conf
printf '%s\t%s\n' "${thisip}" "0;" > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf printf '%s\t%s\n' "${thisip}" "0;" > ./dev-tools/test_units/whitelist-ips.conf
printf '%s\t%s\n' "127.0.0.1" "0;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf printf '%s\t%s\n' "127.0.0.1" "0;" >> ./dev-tools/test_units/whitelist-ips.conf
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf /etc/nginx/bots.d/whitelist-ips.conf sudo cp ./dev-tools/test_units/whitelist-ips.conf /etc/nginx/bots.d/whitelist-ips.conf
# TEST ANY CHANGES TO botblocker-nginx-settings.conf # TEST ANY CHANGES TO botblocker-nginx-settings.conf
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/botblocker-nginx-settings.conf /etc/nginx/conf.d/botblocker-nginx-settings.conf sudo cp ./dev-tools/test_units/botblocker-nginx-settings.conf /etc/nginx/conf.d/botblocker-nginx-settings.conf
} }
# ----------- # -----------

View file

@ -16,6 +16,8 @@
# # # #
############################################################################## ##############################################################################
export TERM=xterm
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# MIT License # MIT License
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -64,7 +66,7 @@ printf "\n"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
echo "${bold}${green}Reloading Nginx" echo "${bold}${green}Reloading Nginx"
echo "${bold}${green}---------------" echo "${bold}${green}---------------"
sudo nginx -t && sudo nginx -s reload sudo nginx -t && sudo systemctl reload nginx
} }
waitforReload () { waitforReload () {
@ -76,22 +78,22 @@ sleep 10s
} }
run_curltest1 () { run_curltest1 () {
if curl -v -A "Nutch" http://localhost:9000 2>&1 | grep -i 'Welcome'; then if curl -v -A "Nutch" http://localhost:80 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - WHITELISTING OF BAD BOT Nutch ALLOWED" echo "${bold}${green}PASSED - WHITELISTING OF BAD BOT Nutch ALLOWED"
else else
echo "${bold}${red}FAILED - WHITELISTING of BAD BOT Nutch 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:80 2>&1
fi fi
} }
run_curltest2 () { run_curltest2 () {
if curl http://localhost:9000 -e http://zx6.ru 2>&1 | grep -i 'Welcome'; then if curl http://localhost:80 -e http://zx6.ru 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - WHITELISTING OF REFERRER zx6.ru ALLOWED" echo "${bold}${green}PASSED - WHITELISTING OF REFERRER zx6.ru ALLOWED"
else else
echo "${bold}${red}FAILED - WHITELISTING OF REFERRER zx6.ru 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:80 -e http://zx6.ru 2>&1
fi fi
} }
@ -103,10 +105,10 @@ printf "\n"
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Generate our custom test units turning all good to bad and all bad to good # Generate our custom test units turning all good to bad and all bad to good
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
_input1=${TRAVIS_BUILD_DIR}/_generator_lists/bad-user-agents.list _input1=./_generator_lists/bad-user-agents.list
_input2=${TRAVIS_BUILD_DIR}/.dev-tools/referrers-regex-format-whitelist-test.txt _input2=./dev-tools/referrers-regex-format-whitelist-test.txt
_inputdb1=${TRAVIS_BUILD_DIR}/.dev-tools/good-bad-user-agents.db _inputdb1=./dev-tools/good-bad-user-agents.db
_inputdb2=${TRAVIS_BUILD_DIR}/.dev-tools/good-bad-referrers.db _inputdb2=./dev-tools/good-bad-referrers.db
_tmpnginx1=_tmpnginx1 _tmpnginx1=_tmpnginx1
_tmpnginx2=_tmpnginx2 _tmpnginx2=_tmpnginx2
_start1="# START MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###" _start1="# START MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###"
@ -135,11 +137,11 @@ ed -s ${_inputdb1}<<\IN
1,/# START MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/d 1,/# START MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/d
/# END MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/,$d /# END MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/,$d
,d ,d
.r /home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/test_units/blacklist-user-agents.conf .r ./dev-tools/test_units/blacklist-user-agents.conf
/# START MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/x /# START MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/x
.t. .t.
.,/# END MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/-d .,/# END MAKE BAD BOTS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/-d
w /home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/test_units/blacklist-user-agents.conf w ./dev-tools/test_units/blacklist-user-agents.conf
q q
IN IN
rm ${_inputdb1} rm ${_inputdb1}
@ -165,11 +167,11 @@ ed -s ${_inputdb2}<<\IN
1,/# START MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/d 1,/# START MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/d
/# END MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/,$d /# END MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/,$d
,d ,d
.r /home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/test_units/custom-bad-referrers.conf .r ./dev-tools/test_units/custom-bad-referrers.conf
/# START MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/x /# START MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/x
.t. .t.
.,/# END MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/-d .,/# END MAKE BAD REFERRERS GOOD ### DO NOT EDIT THIS LINE AT ALL ###/-d
w /home/travis/build/mitchellkrogza/nginx-ultimate-bad-bot-blocker/.dev-tools/test_units/custom-bad-referrers.conf w ./dev-tools/test_units/custom-bad-referrers.conf
q q
IN IN
rm ${_inputdb2} rm ${_inputdb2}
@ -180,29 +182,29 @@ echo "${bold}${green}------------------------------------------------"
echo "${bold}${green}Activating Users User-Agents Whitelist/Blacklist" echo "${bold}${green}Activating Users User-Agents Whitelist/Blacklist"
echo "${bold}${green}------------------------------------------------" echo "${bold}${green}------------------------------------------------"
printf "\n" printf "\n"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-user-agents.conf /etc/nginx/bots.d/blacklist-user-agents.conf sudo cp ./dev-tools/test_units/blacklist-user-agents.conf /etc/nginx/bots.d/blacklist-user-agents.conf
echo "${bold}${green}----------------------------------------------" echo "${bold}${green}----------------------------------------------"
echo "${bold}${green}Activating Users Referrers Whitelist/Blacklist" echo "${bold}${green}Activating Users Referrers Whitelist/Blacklist"
echo "${bold}${green}----------------------------------------------" echo "${bold}${green}----------------------------------------------"
printf "\n" printf "\n"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/custom-bad-referrers.conf /etc/nginx/bots.d/custom-bad-referrers.conf sudo cp ./dev-tools/test_units/custom-bad-referrers.conf /etc/nginx/bots.d/custom-bad-referrers.conf
} }
testBadUserAgents () { testBadUserAgents () {
shuf -n 100 ${TRAVIS_BUILD_DIR}/_generator_lists/bad-user-agents.list > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.tmp shuf -n 100 ./_generator_lists/bad-user-agents.list > ./dev-tools/test_units/random-bots-for-whitelist-test.tmp
sed 's/\\//g' ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.tmp > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.list sed 's/\\//g' ./dev-tools/test_units/random-bots-for-whitelist-test.tmp > ./dev-tools/test_units/random-bots-for-whitelist-test.list
sudo rm ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.tmp sudo rm ./dev-tools/test_units/random-bots-for-whitelist-test.tmp
sort -u ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.list -o ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.list sort -u ./dev-tools/test_units/random-bots-for-whitelist-test.list -o ./dev-tools/test_units/random-bots-for-whitelist-test.list
printf "\n" printf "\n"
echo "${bold}${magenta}---------------------------" echo "${bold}${magenta}---------------------------"
echo "${bold}${magenta}Testing 100 Random Bad Bots" echo "${bold}${magenta}Testing 100 Random Bad Bots"
echo "${bold}${magenta}---------------------------" echo "${bold}${magenta}---------------------------"
IFS=$'\n' IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.list file=./dev-tools/test_units/random-bots-for-whitelist-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 -v -A "${line}" http://localhost:80 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${red}${line} was ${bold}${green}ALLOWED" echo "${bold}${green}PASSED - ${red}${line} was ${bold}${green}ALLOWED"
else else
echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}NOT ALLOWED" echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}NOT ALLOWED"
@ -213,20 +215,20 @@ IFS=""
} }
testBadReferrers () { testBadReferrers () {
shuf -n 100 ${TRAVIS_BUILD_DIR}/_generator_lists/bad-referrers.list > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.tmp shuf -n 100 ./_generator_lists/bad-referrers.list > ./dev-tools/test_units/random-referrers-for-whitelist-test.tmp
sed 's/\\//g' ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.tmp > ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.list sed 's/\\//g' ./dev-tools/test_units/random-referrers-for-whitelist-test.tmp > ./dev-tools/test_units/random-referrers-for-whitelist-test.list
sudo rm ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.tmp sudo rm ./dev-tools/test_units/random-referrers-for-whitelist-test.tmp
sort -u ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.list -o ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.list sort -u ./dev-tools/test_units/random-referrers-for-whitelist-test.list -o ./dev-tools/test_units/random-referrers-for-whitelist-test.list
printf "\n" printf "\n"
echo "${bold}${magenta}----------------------------" echo "${bold}${magenta}----------------------------"
echo "${bold}${magenta}Testing 100 Random Referrers" echo "${bold}${magenta}Testing 100 Random Referrers"
echo "${bold}${magenta}----------------------------" echo "${bold}${magenta}----------------------------"
IFS=$'\n' IFS=$'\n'
file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.list file=./dev-tools/test_units/random-referrers-for-whitelist-test.list
lines=$(cat ${file}) lines=$(cat ${file})
for line in ${lines}; do for line in ${lines}; do
if if
curl http://localhost:9000 -e "http://${line}" 2>&1 | grep -i 'Welcome'; then curl http://localhost:80 -e "http://${line}" 2>&1 | grep -i 'Welcome'; then
echo "${bold}${green}PASSED - ${red}${line} was ${bold}${green}ALLOWED" echo "${bold}${green}PASSED - ${red}${line} was ${bold}${green}ALLOWED"
else else
echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}NOT ALLOWED" echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}NOT ALLOWED"
@ -242,10 +244,10 @@ echo "${bold}${green}-----------------------------------------------------------
echo "${bold}${green}Make Backup all conf files and folders used during this test" echo "${bold}${green}Make Backup all conf files and folders used during this test"
echo "${bold}${green}------------------------------------------------------------" echo "${bold}${green}------------------------------------------------------------"
printf "\n" printf "\n"
sudo cp /etc/nginx/bots.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_whitelist/bots.d/ sudo cp /etc/nginx/bots.d/* ./dev-tools/test1_conf_files_whitelist/bots.d/
sudo cp /etc/nginx/conf.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_whitelist/conf.d/ sudo cp /etc/nginx/conf.d/* ./dev-tools/test1_conf_files_whitelist/conf.d/
sudo cp /etc/nginx/sites-available/default.vhost ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_whitelist/default.vhost sudo cp /etc/nginx/sites-available/default.vhost ./dev-tools/test1_conf_files_whitelist/default.vhost
sudo cp /etc/nginx/nginx.conf ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files_whitelist/nginx.conf sudo cp /etc/nginx/nginx.conf ./dev-tools/test1_conf_files_whitelist/nginx.conf
} }
# ----------- # -----------