mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 18:50:13 +00:00
FINALIZE Rate Limiting Test Closes: #175
This commit is contained in:
parent
cf17b87f31
commit
21b0e6d915
4 changed files with 103 additions and 62 deletions
|
@ -60,6 +60,7 @@ sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/test-blocker-badwords.sh
|
|||
sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/test-blocker-whitelist-domains.sh
|
||||
sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/test-blocker-whitelist-ips.sh
|
||||
sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/test-blocker-blacklist-domains.sh
|
||||
sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/test-blocker-rate-limiting.sh
|
||||
sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/test-blocker-whitelist.sh
|
||||
sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/prepare-robots-input.sh
|
||||
sudo chmod +x ${TRAVIS_BUILD_DIR}/.dev-tools/install-nginx-1.sh
|
||||
|
|
101
.dev-tools/test-blocker-rate-limiting.sh
Normal file
101
.dev-tools/test-blocker-rate-limiting.sh
Normal file
|
@ -0,0 +1,101 @@
|
|||
#!/bin/bash
|
||||
# Curl Testing Script for Nginx Ultimate Bad Bot Blocker
|
||||
# Created by: Mitchell Krog (mitchellkrog@gmail.com)
|
||||
# Copyright: Mitchell Krog - https://github.com/mitchellkrogza
|
||||
# Repo Url: https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker
|
||||
|
||||
##############################################################################
|
||||
# _ __ _ #
|
||||
# / |/ /__ _(_)__ __ __ #
|
||||
# / / _ `/ / _ \\ \ / #
|
||||
# /_/|_/\_, /_/_//_/_\_\ #
|
||||
# __/___/ __ ___ __ ___ __ __ #
|
||||
# / _ )___ ____/ / / _ )___ / /_ / _ )/ /__ ____/ /_____ ____ #
|
||||
# / _ / _ `/ _ / / _ / _ \/ __/ / _ / / _ \/ __/ '_/ -_) __/ #
|
||||
# /____/\_,_/\_,_/ /____/\___/\__/ /____/_/\___/\__/_/\_\\__/_/ #
|
||||
# #
|
||||
##############################################################################
|
||||
|
||||
# ************************
|
||||
# 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)
|
||||
|
||||
# ******************
|
||||
# TEST RATE LIMITING
|
||||
# ******************
|
||||
|
||||
printf "\n"
|
||||
echo "${bold}${green}---------------------------"
|
||||
echo "${bold}${green}Starting Rate Limiting Test"
|
||||
echo "${bold}${green}---------------------------"
|
||||
printf "\n\n"
|
||||
|
||||
# ***************************
|
||||
# Make GoogleBot Rate Limited
|
||||
# ***************************
|
||||
|
||||
echo "${bold}${yellow}-----------------------------"
|
||||
echo "${bold}${yellow}Making GoogleBot ${yellow}RATE LIMITED"
|
||||
echo "${bold}${yellow}-----------------------------"
|
||||
printf "\n\n"
|
||||
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/rate-limiting-user-agents.conf /etc/nginx/bots.d/blacklist-user-agents.conf
|
||||
|
||||
echo "${bold}${green}---------------"
|
||||
echo "${bold}${green}Reloading Nginx"
|
||||
echo "${bold}${green}---------------"
|
||||
printf "\n\n"
|
||||
sudo nginx -t && sudo nginx -s reload
|
||||
|
||||
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
||||
echo "${bold}${yellow}Sleeping for 10 seconds to allow Nginx to Properly Reload inside Travis"
|
||||
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
||||
printf "\n\n"
|
||||
sleep 10s
|
||||
|
||||
ratelimittestfile=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/ratelimittest.txt
|
||||
truncate -s 0 ${ratelimittestfile}
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 > ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile}
|
||||
|
||||
if grep -i 'Unavailable' < ${ratelimittestfile}; then
|
||||
echo "${bold}${green}PASSED - ${red}GoogleBot was ${bold}${red}RATE LIMITED"
|
||||
else
|
||||
echo "${bold}${red}FAILED - ${red}GoogleBot was ${bold}${red}NOT RATE LIMITED"
|
||||
fi
|
||||
|
||||
printf "\n"
|
||||
echo "${bold}${green}---------------------------"
|
||||
echo "${bold}${green}Rate Limiting Test Complete"
|
||||
echo "${bold}${green}---------------------------"
|
||||
printf "\n\n"
|
||||
|
||||
# **********************
|
||||
# Exit With Error Number
|
||||
# **********************
|
||||
|
||||
exit ${?}
|
||||
|
||||
|
|
@ -229,68 +229,6 @@ echo "${bold}${green}Whitelisting Test Complete"
|
|||
echo "${bold}${green}--------------------------"
|
||||
printf "\n\n"
|
||||
|
||||
# ******************
|
||||
# TEST RATE LIMITING
|
||||
# ******************
|
||||
|
||||
printf "\n"
|
||||
echo "${bold}${green}---------------------------"
|
||||
echo "${bold}${green}Starting Rate Limiting Test"
|
||||
echo "${bold}${green}---------------------------"
|
||||
printf "\n\n"
|
||||
|
||||
# ***************************
|
||||
# Make GoogleBot Rate Limited
|
||||
# ***************************
|
||||
|
||||
echo "${bold}${yellow}-----------------------------"
|
||||
echo "${bold}${yellow}Making GoogleBot ${yellow}RATE LIMITED"
|
||||
echo "${bold}${yellow}-----------------------------"
|
||||
printf "\n\n"
|
||||
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/rate-limiting-user-agents.conf /etc/nginx/bots.d/blacklist-user-agents.conf
|
||||
|
||||
echo "${bold}${green}---------------"
|
||||
echo "${bold}${green}Reloading Nginx"
|
||||
echo "${bold}${green}---------------"
|
||||
printf "\n\n"
|
||||
sudo nginx -t && sudo nginx -s reload
|
||||
|
||||
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 10s
|
||||
|
||||
ratelimittestfile=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/ratelimittest.txt
|
||||
truncate -s 0 ${ratelimittestfile}
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 > ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile} &
|
||||
curl -A "GoogleBot" http://localhost:9000 2>&1 >> ${ratelimittestfile}
|
||||
|
||||
if grep -i 'Unavailable' < ${ratelimittestfile}; then
|
||||
echo "${bold}${green}PASSED - ${red}GoogleBot was ${bold}${red}RATE LIMITED"
|
||||
else
|
||||
echo "${bold}${red}FAILED - ${red}GoogleBot was ${bold}${red}NOT RATE LIMITED"
|
||||
fi
|
||||
|
||||
printf "\n"
|
||||
echo "${bold}${green}---------------------------"
|
||||
echo "${bold}${green}Rate Limiting Test Complete"
|
||||
echo "${bold}${green}---------------------------"
|
||||
printf "\n\n"
|
||||
|
||||
# *******************
|
||||
# RELEASE NEW VERSION
|
||||
# *******************
|
||||
|
|
|
@ -51,6 +51,7 @@ script:
|
|||
- bash .dev-tools/test-blocker-badwords.sh
|
||||
- bash .dev-tools/test-blocker-whitelist-domains.sh
|
||||
- bash .dev-tools/test-blocker-whitelist-ips.sh
|
||||
- bash .dev-tools/test-blocker-rate-limiting.sh
|
||||
- bash .dev-tools/test-blocker-whitelist.sh
|
||||
- bash .dev-tools/modify-files-and-commit.sh
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue