fix: add content-type header for koreader-sync auth (#1016)

* test: add content-type assertion for user auth

* fix: specify JSON content type in authorizeUser method

Set content type to JSON for user authorization response.
This commit is contained in:
Iván Ruiz Gázquez
2025-08-29 10:31:45 -06:00
committed by GitHub
parent addf7c0c17
commit 3e64d35957
2 changed files with 5 additions and 2 deletions
@@ -22,7 +22,9 @@ public class KoreaderController {
@GetMapping("/users/auth")
public ResponseEntity<Map<String, String>> authorizeUser() {
return koreaderService.authorizeUser();
return koreaderService
.authorizeUser()
.contentType(MediaType.APPLICATION_JSON);
}
@PostMapping("/users/create")
@@ -44,4 +46,4 @@ public class KoreaderController {
koreaderService.saveProgress(koreaderProgress.getDocument(), koreaderProgress);
return ResponseEntity.ok(Map.of("status", "progress updated"));
}
}
}
@@ -36,6 +36,7 @@ class KoreaderControllerTest {
when(koreaderService.authorizeUser()).thenReturn(ResponseEntity.ok(expected));
ResponseEntity<Map<String, String>> resp = controller.authorizeUser();
assertEquals(HttpStatus.OK, resp.getStatusCode());
assertEquals(MediaType.APPLICATION_JSON, resp.getHeaders().getContentType());
assertEquals(expected, resp.getBody());
}