Skip to content

Commit

Permalink
Close #125 - Improve alerts Integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Hamon committed Jan 17, 2017
1 parent 0394b59 commit 19cc068
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions tests/2_Integration/05-Results/ApiAlertsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,40 @@ class ApiAlertsTest extends CommonTestCase
*/
public function POSTrequests()
{
$this->insertOrUpdateAlert(2, 1483605762, "Pdf.Dropper.Agent-1507034", "4C4C4544-0033-4A10-8051-FFFFFFFFFFFF");
$this->insertOrUpdateAlert(3, 1483605770, "Pdf.Dropper.Agent-1507034", "4C4C4544-0033-4A10-8051-BBBBBBBBBBBB");
$this->insertOrUpdateAlert(3, 1483605777, "Win.Trojan.Elpapok-1", "4C4C4544-0033-4A10-8051-BBBBBBBBBBBB");
$json_alerts = '{ "alerts" :';
$json_alerts .= $this->getJsonForAlert(2, 1483605762, "Pdf.Dropper.Agent-1507034", "4C4C4544-0033-4A10-8051-FFFFFFFFFFFF");
$json_alerts .= $this->getJsonForAlert(3, 1483605770, "Pdf.Dropper.Agent-1507034", "4C4C4544-0033-4A10-8051-BBBBBBBBBBBB");
$json_alerts .= $this->getJsonForAlert(3, 1483605777, "Win.Trojan.Elpapok-1", "4C4C4544-0033-4A10-8051-BBBBBBBBBBBB");
$json_alerts = rtrim($json_alerts, ",");
$json_alerts .= '}';

$this->insertAlerts($json_alerts);
}

protected function insertOrUpdateAlert($agentid, $detection_time, $malware_type, $uuid)
protected function getJsonForAlert($agentid, $detection_time, $malware_type, $uuid)
{
$json_alert = '{
"job_id": 1,
"name" : "'.$malware_type.'",
"filepath" : "/home/malwares/X",
"action" : "cleaned",
"detection_time" : '.$detection_time.'
}';
return '{
"job_id": 1,
"name" : "'.$malware_type.'",
"filepath" : "/home/malwares/X",
"action" : "cleaned",
"detection_time" : '.$detection_time.'
},';
}

protected function insertAlerts($json_alerts)
{
$json = '{
"task": {"obj": '.$json_alert.',
"name":"Alerts",
"antivirus": {
"name":"Armadito",
"version":"0.10.2"
}
},
"agent_version":"2.3.18",
"agent_id":'.$agentid.',
"uuid": "'.$uuid.'"}';

"task": {"obj": '.$json_alerts.',
"name":"Alerts",
"antivirus": {
"name":"Armadito",
"version":"0.10.2"
}
},
"agent_version":"2.3.18",
"agent_id":'.$agentid.',
"uuid": "'.$uuid.'"}';

PluginArmaditoAlert::manageApiRequest($json);
}
Expand Down

0 comments on commit 19cc068

Please sign in to comment.