mirror of https://github.com/MISP/misp-dashboard
update: Reversed logic with errorFlag + Added it to test_geo
parent
84f495bba8
commit
7f30131497
|
@ -23,11 +23,12 @@ def wipeRedis():
|
||||||
serv_redis_db.flushall()
|
serv_redis_db.flushall()
|
||||||
|
|
||||||
def errorExit():
|
def errorExit():
|
||||||
wipeRedis()
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
|
flag_error = False
|
||||||
today = datetime.datetime.now()
|
today = datetime.datetime.now()
|
||||||
|
|
||||||
# IP -> Coord
|
# IP -> Coord
|
||||||
supposed_ip = '8.8.8.8'
|
supposed_ip = '8.8.8.8'
|
||||||
geo_helper.getCoordFromIpAndPublish(supposed_ip, categ)
|
geo_helper.getCoordFromIpAndPublish(supposed_ip, categ)
|
||||||
|
@ -35,27 +36,27 @@ def test():
|
||||||
excpected_result = [['{"lat": 37.751, "lon": -97.822}', 1.0]]
|
excpected_result = [['{"lat": 37.751, "lon": -97.822}', 1.0]]
|
||||||
if rep != excpected_result:
|
if rep != excpected_result:
|
||||||
print('ip to coord result not matching')
|
print('ip to coord result not matching')
|
||||||
errorExit()
|
flag_error = True
|
||||||
|
|
||||||
# gethitmap
|
# gethitmap
|
||||||
rep = geo_helper.getHitMap(today)
|
rep = geo_helper.getHitMap(today)
|
||||||
excpected_result = [['US', 1.0]]
|
excpected_result = [['US', 1.0]]
|
||||||
if rep != excpected_result:
|
if rep != excpected_result:
|
||||||
print('getHitMap result not matching')
|
print('getHitMap result not matching')
|
||||||
errorExit()
|
flag_error = True
|
||||||
|
|
||||||
# getCoordsByRadius
|
# getCoordsByRadius
|
||||||
rep = geo_helper.getCoordsByRadius(today, today, 0.000, 0.000, '1')
|
rep = geo_helper.getCoordsByRadius(today, today, 0.000, 0.000, '1')
|
||||||
excpected_result = []
|
excpected_result = []
|
||||||
if rep != excpected_result:
|
if rep != excpected_result:
|
||||||
print('getCoordsByRadius result not matching')
|
print('getCoordsByRadius result not matching')
|
||||||
errorExit()
|
flag_error = True
|
||||||
|
|
||||||
rep = geo_helper.getCoordsByRadius(today, today, 37.750, -97.821, '10')
|
rep = geo_helper.getCoordsByRadius(today, today, 37.750, -97.821, '10')
|
||||||
excpected_result = [[['{"categ": "Network Activity", "value": "8.8.8.8"}'], [-97.82200008630753, 37.75100012475438]]]
|
excpected_result = [[['{"categ": "Network Activity", "value": "8.8.8.8"}'], [-97.82200008630753, 37.75100012475438]]]
|
||||||
if rep != excpected_result:
|
if rep != excpected_result:
|
||||||
print('getCoordsByRadius result not matching')
|
print('getCoordsByRadius result not matching')
|
||||||
errorExit()
|
flag_error = True
|
||||||
|
|
||||||
wipeRedis()
|
wipeRedis()
|
||||||
|
|
||||||
|
@ -67,9 +68,12 @@ def test():
|
||||||
excpected_result = ['{"lat": "49.7500", "lon": "6.1667"}', 1.0]
|
excpected_result = ['{"lat": "49.7500", "lon": "6.1667"}', 1.0]
|
||||||
if rep != excpected_result:
|
if rep != excpected_result:
|
||||||
print('Phone to coord result not matching')
|
print('Phone to coord result not matching')
|
||||||
errorExit()
|
flag_error = True
|
||||||
|
|
||||||
|
|
||||||
test()
|
|
||||||
wipeRedis()
|
wipeRedis()
|
||||||
print('Tests succeeded')
|
if test():
|
||||||
|
wipeRedis()
|
||||||
|
errorExit()
|
||||||
|
else:
|
||||||
|
wipeRedis()
|
||||||
|
print('Geo tests succeeded')
|
||||||
|
|
|
@ -25,7 +25,7 @@ def errorExit():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
flag_error = True
|
flag_error = False
|
||||||
today = datetime.datetime.now()
|
today = datetime.datetime.now()
|
||||||
now = time.time
|
now = time.time
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ def test():
|
||||||
rep = trendings_helper.getTrendingEvents(today, today)
|
rep = trendings_helper.getTrendingEvents(today, today)
|
||||||
if rep[0][1] != expected_result[0][1]: #ignore timestamps
|
if rep[0][1] != expected_result[0][1]: #ignore timestamps
|
||||||
print('getTrendingEvents result not matching')
|
print('getTrendingEvents result not matching')
|
||||||
flag_error = False
|
flag_error = True
|
||||||
|
|
||||||
# Tags
|
# Tags
|
||||||
tag1 = {'id': 'tag1', 'colour': 'blue', 'name': 'tag1Name'}
|
tag1 = {'id': 'tag1', 'colour': 'blue', 'name': 'tag1Name'}
|
||||||
|
@ -51,7 +51,7 @@ def test():
|
||||||
rep = trendings_helper.getTrendingTags(today, today)
|
rep = trendings_helper.getTrendingTags(today, today)
|
||||||
if rep[0][1] != expected_result[0][1]: #ignore timestamps
|
if rep[0][1] != expected_result[0][1]: #ignore timestamps
|
||||||
print('getTrendingTags result not matching')
|
print('getTrendingTags result not matching')
|
||||||
flag_error = False
|
flag_error = True
|
||||||
|
|
||||||
# Sightings
|
# Sightings
|
||||||
trendings_helper.addSightings(now())
|
trendings_helper.addSightings(now())
|
||||||
|
@ -61,14 +61,14 @@ def test():
|
||||||
rep = trendings_helper.getTrendingSightings(today, today)
|
rep = trendings_helper.getTrendingSightings(today, today)
|
||||||
if rep[0][1] != expected_result[0][1]: #ignore timestamps
|
if rep[0][1] != expected_result[0][1]: #ignore timestamps
|
||||||
print('getTrendingSightings result not matching')
|
print('getTrendingSightings result not matching')
|
||||||
flag_error = False
|
flag_error = True
|
||||||
|
|
||||||
return flag_error
|
return flag_error
|
||||||
|
|
||||||
wipeRedis()
|
wipeRedis()
|
||||||
if test():
|
if test():
|
||||||
wipeRedis()
|
wipeRedis()
|
||||||
print('Trendings tests succeeded')
|
errorExit()
|
||||||
else:
|
else:
|
||||||
wipeRedis()
|
wipeRedis()
|
||||||
errorExit()
|
print('Trendings tests succeeded')
|
||||||
|
|
Loading…
Reference in New Issue