Fixed notices on empty webhook requests

This commit is contained in:
z38 2015-09-13 20:01:16 +02:00
parent 230fdd43ae
commit 1f555c2f27
2 changed files with 9 additions and 0 deletions

View File

@ -85,6 +85,9 @@ class Mailgun{
if(is_null($postData)) {
$postData = $_POST;
}
if(!isset($postData['timestamp']) || !isset($postData['token']) || !isset($postData['signature'])) {
return false;
}
$hmac = hash_hmac('sha256', "{$postData["timestamp"]}{$postData["token"]}", $this->apiKey);
$sig = $postData['signature'];
if(function_exists('hash_equals')) {

View File

@ -33,4 +33,10 @@ class MailgunTest extends \Mailgun\Tests\MailgunTestCase
);
assert(!$client->verifyWebhookSignature($postData));
}
public function testVerifyWebhookEmptyRequest() {
$client = new Mailgun('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
$postData = array();
assert(!$client->verifyWebhookSignature($postData));
}
}