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 05f8596f..106eae24 100644 --- a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt @@ -7,13 +7,21 @@ import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import dev.usbharu.hideout.plugins.configureRouting import dev.usbharu.hideout.plugins.configureSerialization +import dev.usbharu.hideout.plugins.configureStatusPages +import dev.usbharu.hideout.service.activitypub.ActivityPubService +import dev.usbharu.hideout.service.activitypub.ActivityPubUserService +import dev.usbharu.hideout.service.impl.UserService +import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.server.config.* import io.ktor.server.testing.* +import junit.framework.TestCase.assertEquals import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import org.mockito.kotlin.any +import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock class InboxRoutingKtTest { @@ -30,4 +38,25 @@ class InboxRoutingKtTest { Assertions.assertEquals(HttpStatusCode.MethodNotAllowed, it.status) } } + + @Test + fun `sharedInboxに空のリクエストボディでPOSTしたら400が帰ってくる`() = testApplication { + environment { + config = ApplicationConfig("empty.conf") + } + val httpSignatureVerifyService = mock{ + on { verify(any()) } doReturn true + } + val activityPubService = mock() + val userService = mock() + val activityPubUserService = mock() + application { + configureStatusPages() + configureSerialization() + configureRouting(httpSignatureVerifyService, activityPubService, userService, activityPubUserService) + } + client.post("/inbox").let { + Assertions.assertEquals(HttpStatusCode.BadRequest, it.status) + } + } }