Skip to content

Commit

Permalink
add test file
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Sep 12, 2023
1 parent 2e2acbe commit 786f950
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bbot/test/test_step_2/module_tests/test_module_ip2location.py
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"

0 comments on commit 786f950

Please sign in to comment.