-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4152a7e
commit 698cbae
Showing
10 changed files
with
204 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
tests/server/test_geo_blocked_ip/change_config_remove_geo_blocked_ips.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"success": true, | ||
"serviceId": 1, | ||
"heartbeatIntervalInMS": 600000, | ||
"endpoints": [], | ||
"blockedUserIds": [], | ||
"allowedIPAddresses": [], | ||
"blockedIPAddresses": [], | ||
"receivedAnyStats": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"AIKIDO_BLOCK": "1", | ||
"AIKIDO_LOCALHOST_ALLOWED_BY_DEFAULT": "0", | ||
"AIKIDO_FEATURE_COLLECT_API_SCHEMA": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
$_SERVER['REMOTE_ADDR'] = '5.8.19.22'; | ||
|
||
if (extension_loaded('aikido')) { | ||
$decision = \aikido\should_block_request(); | ||
|
||
if ($decision->block && $decision->type == "blocked" && $decision->trigger == "geoip") { | ||
http_response_code(403); | ||
echo "Your IP address is blocked due to geo restrictions. (Your IP: {$decision->ip})"; | ||
exit(); | ||
} | ||
} | ||
|
||
echo "Something"; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"success": true, | ||
"serviceId": 1, | ||
"heartbeatIntervalInMS": 600000, | ||
"endpoints": [], | ||
"blockedUserIds": [], | ||
"allowedIPAddresses": [], | ||
"receivedAnyStats": true, | ||
"blockedIPAddresses": [ | ||
{ | ||
"source": "geoip", | ||
"description": "geo restrictions", | ||
"ips": [ | ||
"64:ff9b:1::/48", | ||
"1.2.9.0/24", | ||
"1.4.9.0/24", | ||
"1.173.94.92/30", | ||
"2.16.20.0/23", | ||
"2.16.53.0/24", | ||
"2.16.103.0/24", | ||
"2.16.154.0/24", | ||
"2.17.144.0/23", | ||
"2.17.146.0/24", | ||
"2.19.181.0/24", | ||
"2.19.204.0/23", | ||
"2.20.254.0/23", | ||
"2.22.237.0/24", | ||
"2.23.167.0/24", | ||
"2.56.26.0/23", | ||
"2.56.88.0/23", | ||
"2.56.138.0/24", | ||
"2.56.178.0/24", | ||
"2.56.180.0/22", | ||
"2.56.228.0/22", | ||
"2.56.240.0/23", | ||
"2.56.242.0/24", | ||
"2.57.0.0/24", | ||
"2.57.37.0/24", | ||
"2.57.38.0/24", | ||
"2.57.52.0/22", | ||
"2.57.80.0/22", | ||
"2.57.112.0/22", | ||
"2.57.184.0/22", | ||
"2.58.68.0/22", | ||
"2.58.96.0/23", | ||
"2.58.98.0/24", | ||
"2.58.124.0/22", | ||
"2.59.40.0/22", | ||
"2.59.48.0/23", | ||
"2.59.50.0/24", | ||
"2.59.51.0/24", | ||
"2.59.76.0/22", | ||
"2.59.80.0/22", | ||
"2.59.160.0/23", | ||
"2.59.176.0/22", | ||
"2.59.213.0/24", | ||
"2.59.214.0/23", | ||
"2.59.216.0/22", | ||
"2.59.240.0/22", | ||
"2.60.0.0/15", | ||
"2.62.0.0/16", | ||
"2.63.0.0/17", | ||
"2.63.128.0/20", | ||
"2.63.160.0/20", | ||
"2.63.192.0/19", | ||
"2.63.240.0/20", | ||
"2.92.0.0/14", | ||
"5.1.41.0/24", | ||
"5.1.47.0/24", | ||
"5.1.48.0/21", | ||
"5.2.32.0/19", | ||
"5.3.0.0/16", | ||
"5.8.8.0/21", | ||
"5.8.16.0/23", | ||
"5.8.19.0/24" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import requests | ||
import time | ||
import sys | ||
from testlib import * | ||
|
||
''' | ||
1. Sets up the allowed IP address config for route '/test'. Checks that requests are blocked. | ||
2. Changes the config to remote the allowed IP address. Checks that requests are passing. | ||
3. Changes the config again to enable allowed IP address. Checks that requests are blocked. | ||
''' | ||
|
||
|
||
def run_test(): | ||
response = php_server_get("/test") | ||
assert_response_code_is(response, 403) | ||
assert_response_header_contains(response, "Content-Type", "text") | ||
assert_response_body_contains(response, "Your IP address is blocked due to geo restrictions. (Your IP: ") | ||
|
||
apply_config("change_config_remove_geo_blocked_ips.json") | ||
|
||
response = php_server_get("/test") | ||
assert_response_code_is(response, 200) | ||
assert_response_body_contains(response, "Something") | ||
|
||
apply_config("start_config.json") | ||
|
||
response = php_server_get("/test") | ||
assert_response_code_is(response, 403) | ||
assert_response_header_contains(response, "Content-Type", "text") | ||
assert_response_body_contains(response, "Your IP address is blocked due to geo restrictions. (Your IP: ") | ||
|
||
|
||
if __name__ == "__main__": | ||
load_test_args() | ||
run_test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters