优化
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ class QualificationAndOrderFileOpenApiContractTest {
|
||||
assertThat(yaml)
|
||||
.contains("/api/merchant/v1/files/qualifications:")
|
||||
.contains("enum: [LEGAL_PERSON_ID, FREIGHT_FORWARDER_CERTIFICATE, BANK_ACCOUNT_LICENSE]")
|
||||
.contains("merchant:qualification:upload", "maxLength: 5242880")
|
||||
.contains("merchant:qualification:upload", "maxLength: 5242880", "PDF/JPG/PNG/BMP")
|
||||
.contains("name: replace", "requestId:", "traceId:")
|
||||
.doesNotContain("enum: [BUSINESS_LICENSE, LEGAL_PERSON_ID, FREIGHT_FORWARDER_CERTIFICATE, BANK_ACCOUNT_LICENSE]");
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class LocalQualificationStorageTest {
|
||||
Path qualificationRoot = storageRoot.resolve("qualifications");
|
||||
assertTrue(Files.isDirectory(qualificationRoot));
|
||||
try (var files = Files.list(qualificationRoot)) {
|
||||
assertEquals(0, files.count());
|
||||
assertFalse(files.anyMatch(path -> path.getFileName().toString().startsWith(".file-service-probe-")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,47 @@ class LocalQualificationStorageTest {
|
||||
storage.load(10001L, stored.fileName()).getFile().toPath().toAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
void storesBmpQualificationWithEitherStandardMimeTypeAndKeepsTenantOwnership() throws Exception {
|
||||
storage.initialize();
|
||||
byte[] bmp = {0x42, 0x4d, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
for (String contentType : new String[] {"image/bmp", "image/x-ms-bmp"}) {
|
||||
var upload = new MockMultipartFile("file", "license.bmp", contentType, bmp);
|
||||
var stored = storage.store(10001L, upload);
|
||||
|
||||
assertTrue(stored.fileName().endsWith(".bmp"));
|
||||
assertEquals(stored.path().toAbsolutePath(),
|
||||
storage.load(10001L, stored.fileName()).getFile().toPath().toAbsolutePath());
|
||||
BizException crossTenant = assertThrows(BizException.class,
|
||||
() -> storage.load(10002L, stored.fileName()));
|
||||
assertEquals(ResultCode.NOT_FOUND, crossTenant.getResultCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsBmpMimeTypeWhenTheFileSignatureIsNotBmp() {
|
||||
storage.initialize();
|
||||
var upload = new MockMultipartFile("file", "license.bmp", "image/bmp", "not-bmp".getBytes());
|
||||
|
||||
BizException exception = assertThrows(BizException.class,
|
||||
() -> storage.store(10001L, upload));
|
||||
|
||||
assertTrue(exception.getMessage().contains("文件内容与格式不匹配"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deletesBmpQualificationByItsValidatedDocumentUrl() {
|
||||
storage.initialize();
|
||||
byte[] bmp = {0x42, 0x4d, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
var stored = storage.store(10001L,
|
||||
new MockMultipartFile("file", "license.bmp", "image/bmp", bmp));
|
||||
|
||||
storage.deleteByDocumentUrl(10001L, stored.documentUrl());
|
||||
|
||||
assertFalse(Files.exists(stored.path()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsQualificationFilesLargerThanTheClientFiveMegabyteLimit() {
|
||||
storage.initialize();
|
||||
|
||||
Reference in New Issue
Block a user