-
Notifications
You must be signed in to change notification settings - Fork 561
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
2e2acbe
commit 786f950
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
bbot/test/test_step_2/module_tests/test_module_ip2location.py
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,31 @@ | ||
from .base import ModuleTestBase | ||
|
||
|
||
class TestIP2Location(ModuleTestBase): | ||
targets = ["8.8.8.8"] | ||
config_overrides = {"modules": {"ip2location": {"api_key": "asdf"}}} | ||
|
||
async def setup_before_prep(self, module_test): | ||
module_test.httpx_mock.add_response( | ||
url="http://api.ip2location.io/?key=asdf&ip=8.8.8.8&format=json&source=bbot", | ||
json={ | ||
"ip": "8.8.8.8", | ||
"country_code": "US", | ||
"country_name": "United States of America", | ||
"region_name": "California", | ||
"city_name": "Mountain View", | ||
"latitude": 37.405992, | ||
"longitude": -122.078515, | ||
"zip_code": "94043", | ||
"time_zone": "-07:00", | ||
"asn": "15169", | ||
"as": "Google LLC", | ||
"is_proxy": False, | ||
}, | ||
) | ||
|
||
def check(self, module_test, events): | ||
assert any( | ||
e.type == "GEOLOCATION" and e.data["ip"] == "8.8.8.8" and e.data["city_name"] == "Mountain View" | ||
for e in events | ||
), "Failed to geolocate IP" |