mirror of https://github.com/MISP/MISP
new: [test] Test more endpoints in sync test
parent
748f74a072
commit
f50b7440af
168
tests/event.json
168
tests/event.json
|
@ -1317,21 +1317,19 @@
|
|||
"name": "CIRCL",
|
||||
"uuid": "55f6ea5e-2c60-40e5-964f-47a8950d210f"
|
||||
},
|
||||
"Event": [
|
||||
{
|
||||
"id": "2006",
|
||||
"date": "2015-08-27",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - Regin: Top-tier espionage tool enables stealthy surveillance by Symantec",
|
||||
"published": true,
|
||||
"uuid": "55df7369-7d68-428b-aa03-4f5d950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1440752388",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
]
|
||||
"Event": {
|
||||
"id": "2006",
|
||||
"date": "2015-08-27",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - Regin: Top-tier espionage tool enables stealthy surveillance by Symantec",
|
||||
"published": true,
|
||||
"uuid": "55df7369-7d68-428b-aa03-4f5d950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1440752388",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Org": {
|
||||
|
@ -1344,21 +1342,19 @@
|
|||
"name": "CIRCL",
|
||||
"uuid": "55f6ea5e-2c60-40e5-964f-47a8950d210f"
|
||||
},
|
||||
"Event": [
|
||||
{
|
||||
"id": "833",
|
||||
"date": "2015-01-22",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - An analysis of Regin's Hopscotch and Legspin",
|
||||
"published": true,
|
||||
"uuid": "54c0ce92-9d00-42b7-8cfc-f03f950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1422266910",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
]
|
||||
"Event": {
|
||||
"id": "833",
|
||||
"date": "2015-01-22",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - An analysis of Regin's Hopscotch and Legspin",
|
||||
"published": true,
|
||||
"uuid": "54c0ce92-9d00-42b7-8cfc-f03f950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1422266910",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Org": {
|
||||
|
@ -1371,21 +1367,19 @@
|
|||
"name": "CIRCL",
|
||||
"uuid": "55f6ea5e-2c60-40e5-964f-47a8950d210f"
|
||||
},
|
||||
"Event": [
|
||||
{
|
||||
"id": "697",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - Regin: Top-tier espionage tool enables stealthy surveillance",
|
||||
"published": true,
|
||||
"uuid": "5472cdc5-3e3c-47c9-a3b1-47be950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1416818985",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
]
|
||||
"Event": {
|
||||
"id": "697",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - Regin: Top-tier espionage tool enables stealthy surveillance",
|
||||
"published": true,
|
||||
"uuid": "5472cdc5-3e3c-47c9-a3b1-47be950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1416818985",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Org": {
|
||||
|
@ -1398,21 +1392,19 @@
|
|||
"name": "CIRCL",
|
||||
"uuid": "55f6ea5e-2c60-40e5-964f-47a8950d210f"
|
||||
},
|
||||
"Event": [
|
||||
{
|
||||
"id": "699",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - The Regin Espionage Toolkit",
|
||||
"published": true,
|
||||
"uuid": "5472fbd1-1a38-484a-b3f4-4502950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1416821880",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
]
|
||||
"Event": {
|
||||
"id": "699",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - The Regin Espionage Toolkit",
|
||||
"published": true,
|
||||
"uuid": "5472fbd1-1a38-484a-b3f4-4502950d210b",
|
||||
"analysis": "2",
|
||||
"timestamp": "1416821880",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Org": {
|
||||
|
@ -1425,21 +1417,19 @@
|
|||
"name": "CIRCL",
|
||||
"uuid": "55f6ea5e-2c60-40e5-964f-47a8950d210f"
|
||||
},
|
||||
"Event": [
|
||||
{
|
||||
"id": "700",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "Regin Yara rules",
|
||||
"published": true,
|
||||
"uuid": "5473051e-2db8-4467-b6d5-4b1d950d210b",
|
||||
"analysis": "1",
|
||||
"timestamp": "1417157341",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
]
|
||||
"Event": {
|
||||
"id": "700",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "Regin Yara rules",
|
||||
"published": true,
|
||||
"uuid": "5473051e-2db8-4467-b6d5-4b1d950d210b",
|
||||
"analysis": "1",
|
||||
"timestamp": "1417157341",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Org": {
|
||||
|
@ -1452,21 +1442,19 @@
|
|||
"name": "CIRCL",
|
||||
"uuid": "55f6ea5e-2c60-40e5-964f-47a8950d210f"
|
||||
},
|
||||
"Event": [
|
||||
{
|
||||
"id": "709",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - Regin: Nation-state ownage of GSM networks",
|
||||
"published": true,
|
||||
"uuid": "5473429a-bc10-498d-a195-46e2950d2109",
|
||||
"analysis": "2",
|
||||
"timestamp": "1416843113",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
]
|
||||
"Event": {
|
||||
"id": "709",
|
||||
"date": "2014-11-24",
|
||||
"threat_level_id": "1",
|
||||
"info": "OSINT - Regin: Nation-state ownage of GSM networks",
|
||||
"published": true,
|
||||
"uuid": "5473429a-bc10-498d-a195-46e2950d2109",
|
||||
"analysis": "2",
|
||||
"timestamp": "1416843113",
|
||||
"distribution": "3",
|
||||
"org_id": "2",
|
||||
"orgc_id": "2"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Tag": [
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
from pymisp import PyMISP
|
||||
from pymisp import PyMISP, MISPEvent
|
||||
|
||||
|
||||
def check_response(response):
|
||||
|
@ -18,8 +18,10 @@ pymisp.global_pythonify = True
|
|||
remote_server = pymisp.add_server({
|
||||
"pull": True,
|
||||
"pull_galaxy_clusters": True,
|
||||
"push_galaxy_clusters": True,
|
||||
"push": True,
|
||||
"push_sightings": True,
|
||||
"caching_enabled": True,
|
||||
"remote_org_id": 1,
|
||||
"name": "Localhost",
|
||||
"url": url,
|
||||
|
@ -41,17 +43,47 @@ assert remote_user["Sync flag"] == "Yes"
|
|||
assert remote_user["Role name"] == "admin"
|
||||
assert remote_user["User"] == "admin@admin.test"
|
||||
|
||||
# Create testing event
|
||||
event = MISPEvent()
|
||||
event.load_file(os.path.dirname(os.path.realpath(__file__)) + "/event.json")
|
||||
pymisp.delete_event_blocklist(event)
|
||||
event = pymisp.add_event(event, metadata=True)
|
||||
check_response(event)
|
||||
|
||||
# Publish that event
|
||||
check_response(pymisp.publish(event))
|
||||
|
||||
# Preview event
|
||||
url = f'servers/previewEvent/{remote_server["id"]}/{event.uuid}'
|
||||
event_preview = pymisp._check_json_response(pymisp._prepare_request('GET', url))
|
||||
check_response(event_preview)
|
||||
assert event_preview["Event"]["uuid"] == event.uuid
|
||||
|
||||
# Test pull
|
||||
url = f'servers/pull/{remote_server["id"]}/disable_background_processing:1'
|
||||
pull_response = pymisp._check_json_response(pymisp._prepare_request('GET', url))
|
||||
check_response(pull_response)
|
||||
assert "Pull completed. 0 events pulled, 0 events could not be pulled, 0 proposals pulled, 0 sightings pulled, 0 clusters pulled." == pull_response["message"], pull_response["message"]
|
||||
|
||||
# Test pull background
|
||||
check_response(pymisp.server_pull(remote_server))
|
||||
|
||||
# Test push
|
||||
url = f'servers/push/{remote_server["id"]}/full/disable_background_processing:1'
|
||||
push_response = pymisp._check_json_response(pymisp._prepare_request('GET', url))
|
||||
check_response(push_response)
|
||||
assert "Push complete. 0 events pushed, 0 events could not be pushed." == push_response["message"], push_response["message"]
|
||||
|
||||
# Delete server
|
||||
# Test push background
|
||||
check_response(pymisp.server_push(remote_server))
|
||||
|
||||
# Test caching
|
||||
url = f'servers/cache/{remote_server["id"]}/disable_background_processing:1'
|
||||
cache_response = pymisp._check_json_response(pymisp._prepare_request('GET', url))
|
||||
check_response(cache_response)
|
||||
assert "Caching the servers has successfully completed." == cache_response["message"], cache_response["message"]
|
||||
|
||||
# Delete server and test event
|
||||
check_response(pymisp.delete_server(remote_server))
|
||||
check_response(pymisp.delete_event(event))
|
||||
check_response(pymisp.delete_event_blocklist(event))
|
||||
|
|
Loading…
Reference in New Issue