From ff6da7174bb8a48ca9f5e0df3d5ced004faf7335 Mon Sep 17 00:00:00 2001 From: usbharu Date: Tue, 25 Feb 2025 11:13:54 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wellknown/NodeinfoControllerTest.kt | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 hideout/hideout-activitypub/src/test/kotlin/wellknown/NodeinfoControllerTest.kt diff --git a/hideout/hideout-activitypub/src/test/kotlin/wellknown/NodeinfoControllerTest.kt b/hideout/hideout-activitypub/src/test/kotlin/wellknown/NodeinfoControllerTest.kt new file mode 100644 index 00000000..4c440e57 --- /dev/null +++ b/hideout/hideout-activitypub/src/test/kotlin/wellknown/NodeinfoControllerTest.kt @@ -0,0 +1,69 @@ +package wellknown + +import dev.usbharu.hideout.SpringApplication +import org.flywaydb.core.Flyway +import org.junit.jupiter.api.AfterAll +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.MediaType +import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity +import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.get +import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder +import org.springframework.test.web.servlet.setup.MockMvcBuilders +import org.springframework.web.context.WebApplicationContext + +@SpringBootTest(classes = [SpringApplication::class]) +@AutoConfigureMockMvc +class NodeinfoControllerTest { + + @Autowired + private lateinit var context: WebApplicationContext + + private lateinit var mockMvc: MockMvc + + @BeforeEach + fun setUp() { + mockMvc = MockMvcBuilders.webAppContextSetup(context) + .apply(springSecurity()) + .build() + } + + @Test + fun nodeinfo() { + mockMvc.get("/.well-known/nodeinfo") + .andDo { print() } + .andExpect { status { isOk() } } + .andExpect { content { contentType(MediaType.APPLICATION_JSON) } } + } + + @Test + fun nodeinfo2_0() { + mockMvc.get("/nodeinfo/2.0") + .asyncDispatch() + .andDo { print() } + .andExpect { status { isOk() } } + .andExpect { content { contentType(MediaType.APPLICATION_JSON) } } + } + + @Test + fun nodeinfo2_1() { + mockMvc.get("/nodeinfo/2.1") + .asyncDispatch() + .andDo { print() } + .andExpect { status { isOk() } } + .andExpect { content { contentType(MediaType.APPLICATION_JSON) } } + } + + companion object { + @JvmStatic + @AfterAll + fun dropDatabase(@Autowired flyway: Flyway) { + flyway.clean() + flyway.migrate() + } + } +} \ No newline at end of file