fix(firstleg): allow customs uploads up to 50MB
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
package com.baiyue.firstleg.customs.container;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ContainerCustomsMultipartConfigurationContractTest {
|
||||
private static final String FILE_LIMIT = "${FIRSTLEG_MULTIPART_MAX_FILE_SIZE:50MB}";
|
||||
private static final String REQUEST_LIMIT = "${FIRSTLEG_MULTIPART_MAX_REQUEST_SIZE:52MB}";
|
||||
|
||||
@Test void applicationAndEnvironmentConfigsPermitFiftyMegabyteCustomsFiles() throws Exception {
|
||||
assertLimits(read("firstleg/src/main/resources/application.yml"));
|
||||
assertLimits(read("config/nacos/cn/firstleg-service.yml"));
|
||||
assertLimits(read("config/nacos/local/firstleg-service.yml"));
|
||||
}
|
||||
|
||||
@Test void customsOpenApiPublishesFileAndMultipartRequestLimits() throws Exception {
|
||||
assertThat(read("firstleg/src/main/resources/openapi/customs-v1.yaml"))
|
||||
.contains("任意格式且最大50MB", "multipart整请求上限52MB");
|
||||
}
|
||||
|
||||
private static void assertLimits(String yaml) {
|
||||
assertThat(yaml).contains("max-file-size: " + FILE_LIMIT, "max-request-size: " + REQUEST_LIMIT);
|
||||
}
|
||||
|
||||
private static String read(String repositoryPath) throws Exception {
|
||||
Path direct = Path.of(repositoryPath);
|
||||
Path path = Files.exists(direct) ? direct : Path.of("..").resolve(repositoryPath).normalize();
|
||||
return Files.readString(path, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user