mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 18:50:13 +00:00
Enhance Whitelist IP test [TEST]
This commit is contained in:
parent
2e83e36ab6
commit
2a13000cb9
1 changed files with 32 additions and 4 deletions
|
@ -45,6 +45,35 @@ sudo truncate -s 0 ${TRAVIS_BUILD_DIR}/.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' "127.0.0.1" "1;" >> ${TRAVIS_BUILD_DIR}/.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 truncate -s 0 ${TRAVIS_BUILD_DIR}/.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
|
||||
|
||||
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
|
||||
|
||||
# *************************************************
|
||||
# Function Curl Test 1 - Test our IP is Blacklisted
|
||||
# *************************************************
|
||||
|
||||
run_curltest1 () {
|
||||
if curl http://localhost:9000 2>&1 | grep -i '(52)'; then
|
||||
echo "${bold}${green}PASSED - ${bold}${red}blacklist own ip is WORKING"
|
||||
else
|
||||
echo "${bold}${red}FAILED - blacklist own ip is NOT working"
|
||||
fi
|
||||
}
|
||||
run_curltest1
|
||||
|
||||
|
||||
echo "${bold}${green}--------------------"
|
||||
echo "${bold}${green}Now Whitelist own IP"
|
||||
|
@ -54,7 +83,6 @@ printf "\n\n"
|
|||
sudo truncate -s 0 ${TRAVIS_BUILD_DIR}/.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' "127.0.0.1" "0;" >> ${TRAVIS_BUILD_DIR}/.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
|
||||
|
||||
# TEST ANY CHANGES TO botblocker-nginx-settings.conf
|
||||
|
@ -75,10 +103,10 @@ printf "\n\n"
|
|||
sleep 10s
|
||||
|
||||
# *************************************************
|
||||
# Function Curl Test 1 - Test User Domain Whitelist
|
||||
# Function Curl Test 2 - Test our IP is Whitelisted
|
||||
# *************************************************
|
||||
|
||||
run_curltest1 () {
|
||||
run_curltest2 () {
|
||||
if curl http://localhost:9000 2>&1 | grep -i 'Welcome'; then
|
||||
echo "${bold}${green}PASSED - whitelist own ip is WORKING"
|
||||
else
|
||||
|
@ -86,7 +114,7 @@ else
|
|||
curl http://localhost:9000
|
||||
fi
|
||||
}
|
||||
run_curltest1
|
||||
run_curltest2
|
||||
|
||||
|
||||
echo "${bold}${green}-----------------------------"
|
||||
|
|
Loading…
Add table
Reference in a new issue