From 40dd0e9898bf2a88e51d497c46d826ea8f7326f4 Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期四, 20 八月 2026 09:37:15 +0800
Subject: [PATCH] fix: connect premium merchants and restrict approval PDFs
---
talent-card-server/src/test/java/com/talentcard/server/upload/ImageUploadServiceTests.java | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/talent-card-server/src/test/java/com/talentcard/server/upload/ImageUploadServiceTests.java b/talent-card-server/src/test/java/com/talentcard/server/upload/ImageUploadServiceTests.java
index 87acf42..84285cf 100644
--- a/talent-card-server/src/test/java/com/talentcard/server/upload/ImageUploadServiceTests.java
+++ b/talent-card-server/src/test/java/com/talentcard/server/upload/ImageUploadServiceTests.java
@@ -40,4 +40,27 @@
.isInstanceOf(BusinessException.class)
.hasMessageContaining("Only JPG, PNG, and WEBP");
}
+
+ @Test
+ void savesPdfWithGeneratedFilename() throws Exception {
+ ImageUploadService service = new ImageUploadService(temporaryDirectory);
+ MockMultipartFile pdf = new MockMultipartFile("file", "window.pdf", "application/pdf", "%PDF-1.7".getBytes());
+
+ ImageUploadResult result = service.uploadPdf(pdf);
+
+ assertThat(result.url()).matches("/uploads/[0-9a-f-]+\\.pdf");
+ try (Stream<Path> files = Files.list(temporaryDirectory)) {
+ assertThat(files).hasSize(1);
+ }
+ }
+
+ @Test
+ void rejectsNonPdfUploads() {
+ ImageUploadService service = new ImageUploadService(temporaryDirectory);
+ MockMultipartFile image = new MockMultipartFile("file", "window.pdf", "application/pdf", "not a pdf".getBytes());
+
+ assertThatThrownBy(() -> service.uploadPdf(image))
+ .isInstanceOf(BusinessException.class)
+ .hasMessageContaining("仅支持 PDF");
+ }
}
--
Gitblit v1.7.1