From 35be71ed7438d59a542cbf27317d1a50e5d8ab01 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Thu, 10 Nov 2022 17:21:53 +0800 Subject: [PATCH] test: add OAuth2 REST API tests --- .../api/rest/OAuth2ControllerTest.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/OAuth2ControllerTest.kt diff --git a/komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/OAuth2ControllerTest.kt b/komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/OAuth2ControllerTest.kt new file mode 100644 index 00000000..cbad3238 --- /dev/null +++ b/komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/OAuth2ControllerTest.kt @@ -0,0 +1,30 @@ +package org.gotson.komga.interfaces.api.rest + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +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.security.test.context.support.WithAnonymousUser +import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.junit.jupiter.SpringExtension +import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.get + +@ExtendWith(SpringExtension::class) +@SpringBootTest +@AutoConfigureMockMvc(printOnlyOnFailure = false) +@ActiveProfiles("test") +class OAuth2ControllerTest( + @Autowired private val mockMvc: MockMvc, +) { + + @Test + @WithAnonymousUser + fun `given anonymous user when getting oauth2 providers then returns OK`() { + mockMvc.get("/api/v1/oauth2/providers") + .andExpect { + status { isOk() } + } + } +}