From 8dc5d9ebbc514b4538c8cff9b855cc6f35bad53c Mon Sep 17 00:00:00 2001 From: Mitchell Krog Date: Wed, 26 Jun 2019 10:42:14 +0200 Subject: [PATCH] Test Rate Limiting REF: #175 --- .dev-tools/test-blocker-whitelist.sh | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.dev-tools/test-blocker-whitelist.sh b/.dev-tools/test-blocker-whitelist.sh index cffb1e8d8..57f15e033 100755 --- a/.dev-tools/test-blocker-whitelist.sh +++ b/.dev-tools/test-blocker-whitelist.sh @@ -116,7 +116,6 @@ IN rm ${_inputdb2} - echo "${bold}${green}------------------------------------------------" echo "${bold}${green}Activating Users User-Agents Whitelist/Blacklist" echo "${bold}${green}------------------------------------------------" @@ -138,7 +137,7 @@ 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 30s +sleep 10s # ******************************************************* # Function Curl Test 1 - Test User Whitelist for "Nutch" @@ -173,6 +172,7 @@ run_curltest2 # ************************************************ # Test 250 User-Agents from Bad-User-Agents # ************************************************ + shuf -n 250 ${TRAVIS_BUILD_DIR}/_generator_lists/bad-user-agents.list > ${TRAVIS_BUILD_DIR}/.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 sudo rm ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-bots-for-whitelist-test.tmp @@ -199,6 +199,7 @@ IFS="" # ************************************************ # Test 250 Referrers from Bad-Referrers # ************************************************ + shuf -n 250 ${TRAVIS_BUILD_DIR}/_generator_lists/bad-referrers.list > ${TRAVIS_BUILD_DIR}/.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 sudo rm ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/random-referrers-for-whitelist-test.tmp @@ -248,7 +249,6 @@ 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 -sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/custom-bad-referrers.conf /etc/nginx/bots.d/custom-bad-referrers.conf echo "${bold}${green}---------------" echo "${bold}${green}Reloading Nginx" echo "${bold}${green}---------------" @@ -259,7 +259,7 @@ 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 30s +sleep 10s curl -A "GoogleBot" http://localhost:9000 2>&1 & curl -A "GoogleBot" http://localhost:9000 2>&1 & @@ -272,21 +272,13 @@ curl -A "GoogleBot" http://localhost:9000 2>&1 & curl -A "GoogleBot" http://localhost:9000 2>&1 & curl -A "GoogleBot" http://localhost:9000 2>&1 & curl -A "GoogleBot" http://localhost:9000 2>&1 & +curl -A "GoogleBot" http://localhost:9000 2>&1 & +curl -A "GoogleBot" http://localhost:9000 2>&1 & +curl -A "GoogleBot" http://localhost:9000 2>&1 & +curl -A "GoogleBot" http://localhost:9000 2>&1 & +curl -A "GoogleBot" http://localhost:9000 2>&1 & curl -A "GoogleBot" http://localhost:9000 2>&1 -#IFS=$'\n' -#file=${TRAVIS_BUILD_DIR}/.dev-tools/test_units/rate-limit-googlebot.list -#lines=$(cat ${file}) -#for line in ${lines}; do -# if -# time curl -A "${line}" http://localhost:9000 2>&1 | grep -i 'Welcome'; then -# echo "${bold}${green}PASSED - ${red}${line} was ${bold}${green}ALLOWED" -# else -# echo "${bold}${red}FAILED - ${red}${line} was ${bold}${red}NOT ALLOWED" -# fi -#done -#IFS="" - printf "\n" echo "${bold}${green}---------------------------" echo "${bold}${green}Rate Limiting Test Complete"