mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 10:40:36 +00:00
Enhance Whitelist Domains test [TEST]
This commit is contained in:
parent
6c8b7f95aa
commit
5249538f81
1 changed files with 40 additions and 20 deletions
|
@ -16,9 +16,9 @@
|
||||||
# #
|
# #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# ************************
|
# ------------------------
|
||||||
# Set Terminal Font Colors
|
# Set Terminal Font Colors
|
||||||
# ************************
|
# ------------------------
|
||||||
|
|
||||||
bold=$(tput bold)
|
bold=$(tput bold)
|
||||||
red=$(tput setaf 1)
|
red=$(tput setaf 1)
|
||||||
|
@ -30,32 +30,33 @@ cyan=$(tput setaf 6)
|
||||||
white=$(tput setaf 7)
|
white=$(tput setaf 7)
|
||||||
defaultcolor=$(tput setaf default)
|
defaultcolor=$(tput setaf default)
|
||||||
|
|
||||||
echo "${bold}${green}-------------------------------"
|
# ---------
|
||||||
echo "${bold}${green}Whitelist Domains Test Starting"
|
# FUNCTIONS
|
||||||
echo "${bold}${green}-------------------------------"
|
# ---------
|
||||||
printf "\n\n"
|
|
||||||
|
|
||||||
echo "${bold}${green}---------------------------------------"
|
reloadNginX () {
|
||||||
echo "${bold}${green}Activating Users whitelist-domains.conf"
|
|
||||||
echo "${bold}${green}---------------------------------------"
|
|
||||||
printf "\n\n"
|
|
||||||
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-domains.conf /etc/nginx/bots.d/whitelist-domains.conf
|
|
||||||
echo "${bold}${green}---------------"
|
echo "${bold}${green}---------------"
|
||||||
echo "${bold}${green}Reloading Nginx"
|
echo "${bold}${green}Reloading Nginx"
|
||||||
echo "${bold}${green}---------------"
|
echo "${bold}${green}---------------"
|
||||||
printf "\n\n"
|
printf "\n\n"
|
||||||
sudo nginx -t && sudo nginx -s reload
|
sudo nginx -t && sudo nginx -s reload
|
||||||
|
}
|
||||||
|
|
||||||
|
waitforReload () {
|
||||||
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
||||||
echo "${bold}${yellow}Sleeping for 10 seconds to allow Nginx to Properly Reload inside Travis"
|
echo "${bold}${yellow}Sleeping for 10 seconds to allow Nginx to Properly Reload inside Travis"
|
||||||
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
||||||
printf "\n\n"
|
printf "\n\n"
|
||||||
sleep 10s
|
sleep 10s
|
||||||
|
}
|
||||||
|
|
||||||
# *************************************************
|
whitelistOwnDomain () {
|
||||||
# Function Curl Test 1 - Test User Domain Whitelist
|
echo "${bold}${green}---------------------------------------"
|
||||||
# *************************************************
|
echo "${bold}${green}Activating Users whitelist-domains.conf"
|
||||||
|
echo "${bold}${green}---------------------------------------"
|
||||||
|
printf "\n\n"
|
||||||
|
sudo cp ${TRAVIS_BUILD_DIR}/.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:9000 -e http://www.myowndomain.com 2>&1 | grep -i 'Welcome'; then
|
||||||
|
@ -65,11 +66,6 @@ else
|
||||||
#exit 1
|
#exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
run_curltest1
|
|
||||||
|
|
||||||
# *************************************************
|
|
||||||
# Function Curl Test 2 - Test User Domain Whitelist
|
|
||||||
# *************************************************
|
|
||||||
|
|
||||||
run_curltest2 () {
|
run_curltest2 () {
|
||||||
if curl http://localhost:9000 -e http://www.myotherdomain.com 2>&1 | grep -i 'Welcome'; then
|
if curl http://localhost:9000 -e http://www.myotherdomain.com 2>&1 | grep -i 'Welcome'; then
|
||||||
|
@ -79,6 +75,30 @@ else
|
||||||
#exit 1
|
#exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# -----------
|
||||||
|
# Start Tests
|
||||||
|
# -----------
|
||||||
|
|
||||||
|
echo "${bold}${green}-------------------------------"
|
||||||
|
echo "${bold}${green}Whitelist Domains Test Starting"
|
||||||
|
echo "${bold}${green}-------------------------------"
|
||||||
|
printf "\n\n"
|
||||||
|
|
||||||
|
whitelistOwnDomain
|
||||||
|
reloadNginX
|
||||||
|
waitforReload
|
||||||
|
|
||||||
|
# *************************************************
|
||||||
|
# Function Curl Test 1 - Test User Domain Whitelist
|
||||||
|
# *************************************************
|
||||||
|
|
||||||
|
run_curltest1
|
||||||
|
|
||||||
|
# *************************************************
|
||||||
|
# Function Curl Test 2 - Test User Domain Whitelist
|
||||||
|
# *************************************************
|
||||||
|
|
||||||
run_curltest2
|
run_curltest2
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue