diff --git a/.dev-tools/test-blocker-false-positives.sh b/.dev-tools/test-blocker-false-positives.sh index 5fa971585..44794be72 100755 --- a/.dev-tools/test-blocker-false-positives.sh +++ b/.dev-tools/test-blocker-false-positives.sh @@ -77,6 +77,23 @@ UAmustnotmatch[2]="SNutch" UAmustnotmatch[3]="Bing" UAmustnotmatch[4]="bing" +# --------------------------- +# REFERRER ARRAY - MUST MATCH +# --------------------------- + +REFmustmatch[0]="zx6.ru" +REFmustmatch[1]="100dollars-seo.com" +REFmustmatch[2]="googglet.com" + +# --------------------------------- +# USER-AGENT ARRAY - MUST NOT MATCH +# --------------------------------- + +REFmustnotmatch[0]="zx6.russia" +REFmustnotmatch[1]="100dollars-seo.community" +REFmustnotmatch[2]="googglet.co" +REFmustnotmatch[3]="google.com" + # --------- # FUNCTIONS # --------- @@ -127,6 +144,36 @@ do done } +# ----------------------------- +# REFERRER FALSE POSITIVE TESTS +# ----------------------------- + +REFtest_mustmatch () { +for mustmatch in "${REFmustmatch[@]}" +do + if + curl -I http://localhost:9000 -e "${mustmatch}" 2>&1 | grep -i '(52)'; then + echo "${bold}${green}PASSED - ${red}${mustmatch} was ${bold}${red}BLOCKED" + else + echo "${bold}${red}FAILED - ${red}${mustmatch} was ${bold}${red}NOT BLOCKED" + exit 1 + fi +done +} + +REFtest_mustnotmatch () { +for mustnotmatch in "${REFmustnotmatch[@]}" +do + if + curl -I http://localhost:9000 -e "${mustnotmatch}" 2>&1 | grep -i '(52)'; then + echo "${bold}${red}FAILED (FALSE POSITIVE DETECTED) - ${bold}${red}${mustnotmatch}" + exit 1 + else + echo "${bold}${green}PASSED (FALSE POSITIVE NOT DETECTED) - ${bold}${red}${mustnotmatch}" + fi +done +} + # ------------------------- # Trigger Functions / Tests # -------------------------