test: 認証関係を修正2

This commit is contained in:
usbharu 2023-05-18 15:45:37 +09:00
parent 7c55f5c8c3
commit da183caca0
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
1 changed files with 17 additions and 21 deletions

View File

@ -1,7 +1,6 @@
package dev.usbharu.hideout.routing.activitypub
import dev.usbharu.hideout.exception.JsonParseException
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
@ -11,6 +10,7 @@ import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.server.config.*
import io.ktor.server.routing.*
import io.ktor.server.testing.*
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@ -27,7 +27,9 @@ class InboxRoutingKtTest {
}
application {
configureSerialization()
configureRouting(mock(), mock(), mock(), mock(), mock())
routing {
inbox(mock(), mock())
}
}
client.get("/inbox").let {
Assertions.assertEquals(HttpStatusCode.MethodNotAllowed, it.status)
@ -45,18 +47,14 @@ class InboxRoutingKtTest {
val activityPubService = mock<ActivityPubService> {
on { parseActivity(any()) } doThrow JsonParseException()
}
val userService = mock<IUserService>()
val activityPubUserService = mock<ActivityPubUserService>()
mock<IUserService>()
mock<ActivityPubUserService>()
application {
configureStatusPages()
configureSerialization()
configureRouting(
httpSignatureVerifyService,
activityPubService,
userService,
activityPubUserService,
mock()
)
routing {
inbox(httpSignatureVerifyService, activityPubService)
}
}
client.post("/inbox").let {
Assertions.assertEquals(HttpStatusCode.BadRequest, it.status)
@ -70,7 +68,9 @@ class InboxRoutingKtTest {
}
application {
configureSerialization()
configureRouting(mock(), mock(), mock(), mock(), mock())
routing {
inbox(mock(), mock())
}
}
client.get("/users/test/inbox").let {
Assertions.assertEquals(HttpStatusCode.MethodNotAllowed, it.status)
@ -88,18 +88,14 @@ class InboxRoutingKtTest {
val activityPubService = mock<ActivityPubService> {
on { parseActivity(any()) } doThrow JsonParseException()
}
val userService = mock<IUserService>()
val activityPubUserService = mock<ActivityPubUserService>()
mock<IUserService>()
mock<ActivityPubUserService>()
application {
configureStatusPages()
configureSerialization()
configureRouting(
httpSignatureVerifyService,
activityPubService,
userService,
activityPubUserService,
mock()
)
routing {
inbox(httpSignatureVerifyService, activityPubService)
}
}
client.post("/users/test/inbox").let {
Assertions.assertEquals(HttpStatusCode.BadRequest, it.status)