diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncController.kt index 8057cd0e..fcec13fd 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncController.kt @@ -14,6 +14,7 @@ import org.gotson.komga.infrastructure.security.KomgaPrincipal import org.gotson.komga.interfaces.api.kosync.dto.DocumentProgressDto import org.gotson.komga.interfaces.api.kosync.dto.UserAuthenticationDto import org.springframework.http.HttpStatus +import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.security.core.annotation.AuthenticationPrincipal import org.springframework.web.bind.annotation.GetMapping @@ -29,7 +30,7 @@ import java.time.ZonedDateTime private val logger = KotlinLogging.logger {} @RestController -@RequestMapping("/koreader", produces = ["application/vnd.koreader.v1+json"]) +@RequestMapping("/koreader", produces = [MediaType.APPLICATION_JSON_VALUE, "application/vnd.koreader.v1+json"]) class KoreaderSyncController( private val bookRepository: BookRepository, private val mediaRepository: MediaRepository, diff --git a/komga/src/test/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncControllerTest.kt b/komga/src/test/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncControllerTest.kt index a1e8521f..16011c5b 100644 --- a/komga/src/test/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncControllerTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/interfaces/api/kosync/KoreaderSyncControllerTest.kt @@ -7,9 +7,13 @@ import org.gotson.komga.domain.service.KomgaUserLifecycle import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource 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.HttpHeaders +import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.get import org.springframework.test.web.servlet.post @@ -68,4 +72,17 @@ class KoreaderSyncControllerTest( jsonPath("authorized") { value("OK") } } } + + @ParameterizedTest + @ValueSource(strings = [MediaType.APPLICATION_JSON_VALUE, "application/vnd.koreader.v1+json"]) + fun `given accept header when calling API user then returns OK`(acceptHeader: String) { + mockMvc + .get("/koreader/users/auth") { + header("x-auth-user", apiKey) + header(HttpHeaders.ACCEPT, acceptHeader) + }.andExpect { + status { isOk() } + jsonPath("authorized") { value("OK") } + } + } }