From 2a3db9dddcc3638dbfca02a76166364ab7b1c560 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:07:56 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AEinbox=E3=81=AEPOST=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routing/activitypub/InboxRoutingKtTest.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt index 1e545605..c4de8bfb 100644 --- a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt @@ -70,4 +70,27 @@ class InboxRoutingKtTest { Assertions.assertEquals(HttpStatusCode.MethodNotAllowed, it.status) } } + + @Test + fun `ユーザーのinboxに空のリクエストボディでPOSTしたら400が帰ってくる`() = testApplication { + environment { + config = ApplicationConfig("empty.conf") + } + val httpSignatureVerifyService = mock{ + on { verify(any()) } doReturn true + } + val activityPubService = mock{ + on { parseActivity(any()) } doThrow JsonParseException() + } + val userService = mock() + val activityPubUserService = mock() + application { + configureStatusPages() + configureSerialization() + configureRouting(httpSignatureVerifyService, activityPubService, userService, activityPubUserService) + } + client.post("/users/test/inbox").let { + Assertions.assertEquals(HttpStatusCode.BadRequest, it.status) + } + } }