mirror of https://github.com/MISP/MISP
new: [test] Alert email generating
parent
634810d856
commit
3f12e95571
|
@ -480,11 +480,8 @@ class EventShell extends AppShell
|
|||
{
|
||||
list($eventId, $userId) = $this->args;
|
||||
|
||||
$user = $this->User->getUserById($userId);
|
||||
if (empty($user)) {
|
||||
$this->error("User with ID $userId not found.");
|
||||
}
|
||||
$eventForUser = $this->Event->fetchEvent($this->User->rearrangeToAuthForm($user), [
|
||||
$user = $this->getUser($userId);
|
||||
$eventForUser = $this->Event->fetchEvent($user, [
|
||||
'eventid' => $eventId,
|
||||
'includeAllTags' => true,
|
||||
'includeEventCorrelations' => true,
|
||||
|
@ -496,13 +493,13 @@ class EventShell extends AppShell
|
|||
$this->error("Event with ID $eventId not exists or given user don't have permission to access it.");
|
||||
}
|
||||
|
||||
$emailTemplate = $this->Event->prepareAlertEmail($eventForUser[0], $this->User->rearrangeToAuthForm($user));
|
||||
$emailTemplate = $this->Event->prepareAlertEmail($eventForUser[0], $user);
|
||||
|
||||
App::uses('SendEmail', 'Tools');
|
||||
App::uses('GpgTool', 'Tools');
|
||||
$sendEmail = new SendEmail(GpgTool::initializeGpg());
|
||||
$sendEmail->setTransport('Debug');
|
||||
$result = $sendEmail->sendToUser($user, null, $emailTemplate);
|
||||
$result = $sendEmail->sendToUser(['User' => $user], null, $emailTemplate);
|
||||
|
||||
echo $result['contents']['headers'] . "\n\n" . $result['contents']['message'] . "\n";
|
||||
}
|
||||
|
|
|
@ -6,9 +6,12 @@ set -x
|
|||
AUTH="$1"
|
||||
HOST="$2"
|
||||
|
||||
curl -i -H "Accept: application/json" -H "content-type: application/json" -H "Authorization: $AUTH" --data "@event.json" -X POST http://${HOST}/events
|
||||
curl -i -H "Accept: application/json" -H "content-type: application/json" -H "Authorization: $AUTH" --data "@event.json" -X POST http://${HOST}/events > /dev/null
|
||||
curl -H "Authorization: $AUTH" -X GET http://${HOST}/events/csv/download/1/ignore:1 | sed -e 's/^M//g' | cut -d, -f2 --complement | sort > 1.csv
|
||||
cat 1.csv
|
||||
cut -d, -f2 --complement event.csv | sort > compare.csv
|
||||
diff compare.csv 1.csv
|
||||
# Test alert email generating
|
||||
sudo -E su $USER -c '../app/Console/cake Event testEventNotificationEmail 1 1' > /dev/null
|
||||
# Delete created event
|
||||
curl -i -H "Accept: application/json" -H "content-type: application/json" -H "Authorization: $AUTH" -X POST http://${HOST}/events/delete/1
|
||||
|
|
Loading…
Reference in New Issue