mirror of https://github.com/usbharu/Hideout.git
test: sharedInboxにPOSTしたときのテストを追加
This commit is contained in:
parent
e46dbb7b9b
commit
e4dc17f3b4
|
@ -7,13 +7,21 @@ import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import dev.usbharu.hideout.plugins.configureRouting
|
import dev.usbharu.hideout.plugins.configureRouting
|
||||||
import dev.usbharu.hideout.plugins.configureSerialization
|
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.request.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.config.*
|
import io.ktor.server.config.*
|
||||||
import io.ktor.server.testing.*
|
import io.ktor.server.testing.*
|
||||||
|
import junit.framework.TestCase.assertEquals
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.mockito.kotlin.any
|
||||||
|
import org.mockito.kotlin.doReturn
|
||||||
import org.mockito.kotlin.mock
|
import org.mockito.kotlin.mock
|
||||||
|
|
||||||
class InboxRoutingKtTest {
|
class InboxRoutingKtTest {
|
||||||
|
@ -30,4 +38,25 @@ class InboxRoutingKtTest {
|
||||||
Assertions.assertEquals(HttpStatusCode.MethodNotAllowed, it.status)
|
Assertions.assertEquals(HttpStatusCode.MethodNotAllowed, it.status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `sharedInboxに空のリクエストボディでPOSTしたら400が帰ってくる`() = testApplication {
|
||||||
|
environment {
|
||||||
|
config = ApplicationConfig("empty.conf")
|
||||||
|
}
|
||||||
|
val httpSignatureVerifyService = mock<HttpSignatureVerifyService>{
|
||||||
|
on { verify(any()) } doReturn true
|
||||||
|
}
|
||||||
|
val activityPubService = mock<ActivityPubService>()
|
||||||
|
val userService = mock<UserService>()
|
||||||
|
val activityPubUserService = mock<ActivityPubUserService>()
|
||||||
|
application {
|
||||||
|
configureStatusPages()
|
||||||
|
configureSerialization()
|
||||||
|
configureRouting(httpSignatureVerifyService, activityPubService, userService, activityPubUserService)
|
||||||
|
}
|
||||||
|
client.post("/inbox").let {
|
||||||
|
Assertions.assertEquals(HttpStatusCode.BadRequest, it.status)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue