Skip to content

Commit 8a39b95

Browse files
committed
Merge branch 'add-api-to-route' into 'initial-setup'
Add Laravel's api prefix and middleware group to our route See merge request it/soldel-packages/sns-handler!1
2 parents 569bd90 + 2fed78a commit 8a39b95

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
.idea
66
.php_cs.cache
7+
.phpunit.result.cache

routes/api.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
use Illuminate\Support\Facades\Route;
33
use MiamiOH\SnsHandler\Controllers\SnsMessageController;
44

5-
Route::post('/sns/message', [SnsMessageController::class, 'handle']);
5+
Route::group(['prefix' => 'api', 'middleware' => 'api'], function() {
6+
Route::post('/sns/message', [SnsMessageController::class, 'handle']);
7+
});

tests/Feature/SnsHandlerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testReturnsNotFoundForUnknownTopicArn(): void
4040
'Type' => SnsMessage::NOTIFICATION_TYPE,
4141
'TopicArn' => 'arn:aws:sns:us-west-2:123456789012:Unknown',
4242
]);
43-
$response = $this->postJson('/sns/message', $data);
43+
$response = $this->postJson('/api/sns/message', $data);
4444

4545
$this->assertEquals(404, $response->status());
4646
}
@@ -55,7 +55,7 @@ public function testConfirmsSubscriptionForKnownTopicArn(): void
5555
'SubscribeURL' => 'https://aws.amazon.com/sns/register/abc123'
5656
]);
5757

58-
$this->postJson('/sns/message', $data);
58+
$this->postJson('/api/sns/message', $data);
5959

6060
Http::assertSent(function (Request $request) {
6161
return $request->url() === 'https://aws.amazon.com/sns/register/abc123';
@@ -72,7 +72,7 @@ public function testRespondsWithOkAfterConfirmsSubscription(): void
7272
'SubscribeURL' => 'https://aws.amazon.com/sns/register/abc123'
7373
]);
7474

75-
$response = $this->postJson('/sns/message', $data);
75+
$response = $this->postJson('/api/sns/message', $data);
7676

7777
$this->assertEquals(200, $response->status());
7878
}
@@ -89,7 +89,7 @@ public function testReturnsBadGatewayResponseIfConfirmationFails(): void
8989
'SubscribeURL' => 'https://aws.amazon.com/sns/register/abc123'
9090
]);
9191

92-
$response = $this->postJson('/sns/message', $data);
92+
$response = $this->postJson('/api/sns/message', $data);
9393

9494
$this->assertEquals(502, $response->status());
9595
}
@@ -106,7 +106,7 @@ public function testSendsMessageToRegisteredHandler(): void
106106
$this->assertEquals('Test message', $message->message());
107107
});
108108

109-
$response = $this->postJson('/sns/message', $data);
109+
$response = $this->postJson('/api/sns/message', $data);
110110

111111
$this->assertEquals(200, $response->status());
112112
}

0 commit comments

Comments
 (0)