diff --git a/tests/Http/Controllers/GitHubGateControllerTest.php b/tests/Http/Controllers/GitHubGateControllerTest.php --- a/tests/Http/Controllers/GitHubGateControllerTest.php +++ b/tests/Http/Controllers/GitHubGateControllerTest.php @@ -27,7 +27,7 @@ public function testPost () { $payload = file_get_contents(__DIR__ . '/../../data/GitHubPingPayload.json'); $this->sendPayload( - '/gate/GitHub/Quux', + '/gate/GitHub/Quux', // A gate not existing in data/credentials.json $payload, 'POST', [ diff --git a/tests/Http/PayloadFullTest.php b/tests/Http/PayloadFullTest.php --- a/tests/Http/PayloadFullTest.php +++ b/tests/Http/PayloadFullTest.php @@ -1,6 +1,7 @@ <?php namespace Nasqueron\Notifications\Tests; +use Storage; class PayloadFullTest extends TestCase { @@ -16,20 +17,38 @@ public function testPost () { $payload = file_get_contents(__DIR__ . '/../data/GitHubPingPayload.json'); $this->sendPayload( - '/gate/GitHub/Quux', + '/gate/GitHub/Acme', // A gate existing in data/credentials.json $payload, 'POST', [ 'X-Github-Event' => 'ping', - 'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c' + 'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c', + 'X-Hub-Signature' => 'sha1=25f6cbd17ea4c6c69958b95fb88c879de4b66dcc', ] - ) - ->seeJson([ + )->seeJson([ 'gate' => 'GitHub', - 'door' => 'Quux', + 'door' => 'Acme', 'action' => 'AMQPAction' ]); $this->assertResponseOk(); } + + /** + * Tests a GitHub gate payload. + */ + public function testInvalidSignature () { + $payload = file_get_contents(__DIR__ . '/../data/GitHubPingPayload.json'); + $this->sendPayload( + '/gate/GitHub/Acme', // A gate existing in data/credentials.json + $payload, + 'POST', + [ + 'X-Github-Event' => 'ping', + 'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c', + 'X-Hub-Signature' => 'sha1=somethingwrong', + ] + ); + $this->assertResponseStatus(403); + } }