Merge branch 'main' into codex/update-usercontroller-for-user-data-retrieval

This commit is contained in:
Tim
2025-07-01 13:24:28 +08:00
committed by GitHub
4 changed files with 81 additions and 62 deletions

View File

@@ -58,6 +58,12 @@ class PublishModeIntegrationTest {
return rest.exchange(url, HttpMethod.POST, new HttpEntity<>(body, h), Map.class);
}
private <T> ResponseEntity<T> get(String url, Class<T> type, String token) {
HttpHeaders h = new HttpHeaders();
if (token != null) h.setBearerAuth(token);
return rest.exchange(url, HttpMethod.GET, new HttpEntity<>(h), type);
}
@Test
void postRequiresApproval() {
String userToken = registerAndLogin("eve", "e@example.com");
@@ -74,7 +80,7 @@ class PublishModeIntegrationTest {
List<?> list = rest.getForObject("/api/posts", List.class);
assertTrue(list.isEmpty(), "Post should not be listed before approval");
List<Map<String, Object>> pending = (List<Map<String, Object>>) rest.getForObject("/api/admin/posts/pending", List.class);
List<Map<String, Object>> pending = get("/api/admin/posts/pending", List.class, adminToken).getBody();
assertEquals(1, pending.size());
assertEquals(postId.intValue(), ((Number)pending.get(0).get("id")).intValue());

View File

@@ -16,6 +16,6 @@ class CosImageUploaderTest {
String url = uploader.upload("data".getBytes(), "img.png").join();
verify(client).putObject(any(PutObjectRequest.class));
assertEquals("http://cos.example.com/img.png", url);
assertTrue(url.matches("http://cos.example.com/[a-f0-9]{32}\\.png"));
}
}