去掉component_asset表,使用明确的 DTO 和参数校验,统一 connectableTargets 格式。区分编辑版本与几何修订,普通信息修改不会让组件端口失效;过期版本返回 409。上传时校验会话和文件大小,采用流式处理,绑定失败自动清理本次上传对象。修复并发重名创建、分页参数、HTTP 状态码及失败操作日志。
This commit is contained in:
+30
-5
@@ -12,6 +12,10 @@ import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.util.ServletRequestPathUtils;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
|
||||
/** Multipart size failures can occur before an MVC interceptor is invoked. */
|
||||
@Slf4j
|
||||
@@ -35,16 +39,15 @@ public class EarlyFailureAuditFilter extends OncePerRequestFilter {
|
||||
chain.doFilter(request, response);
|
||||
} finally {
|
||||
if (response.getStatus() >= 400 && request.getAttribute(OperationAuditInterceptor.CONTEXT) == null
|
||||
&& request.getRequestURI().startsWith("/admin-api/")) {
|
||||
&& request.getRequestURI().startsWith(request.getContextPath() + "/admin-api/")) {
|
||||
try {
|
||||
// DispatcherServlet clears its parsed path before returning to filters.
|
||||
org.springframework.web.util.ServletRequestPathUtils.parseAndCache(request);
|
||||
var handler = mappings.getHandler(request);
|
||||
var handler = resolveWriteHandler(request);
|
||||
if (handler != null) {
|
||||
audit.preHandle(request, response, handler.getHandler());
|
||||
audit.preHandle(request, response, handler);
|
||||
if (request.getAttribute(OperationAuditInterceptor.CONTEXT) instanceof OperationAuditInterceptor.Context context) {
|
||||
request.setAttribute(OperationAuditInterceptor.CONTEXT, new OperationAuditInterceptor.Context(context.event(), started));
|
||||
audit.afterCompletion(request, response, handler.getHandler(), null);
|
||||
audit.afterCompletion(request, response, handler, null);
|
||||
}
|
||||
}
|
||||
} catch (Exception failure) {
|
||||
@@ -53,4 +56,26 @@ public class EarlyFailureAuditFilter extends OncePerRequestFilter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private HandlerMethod resolveWriteHandler(HttpServletRequest request) {
|
||||
ServletRequestPathUtils.parseAndCache(request);
|
||||
HandlerMethod best = null;
|
||||
PathPattern bestPattern = null;
|
||||
for (var entry : mappings.getHandlerMethods().entrySet()) {
|
||||
if (!entry.getValue().hasMethodAnnotation(AuditOperation.class)
|
||||
|| entry.getKey().getMethodsCondition().getMatchingCondition(request) == null) continue;
|
||||
var paths = entry.getKey().getPathPatternsCondition().getMatchingCondition(request);
|
||||
if (paths == null) continue;
|
||||
PathPattern pattern = paths.getFirstPattern();
|
||||
if (bestPattern == null || pattern.compareTo(bestPattern) < 0) {
|
||||
best = entry.getValue();
|
||||
bestPattern = pattern;
|
||||
}
|
||||
}
|
||||
if (bestPattern != null) {
|
||||
var match = bestPattern.matchAndExtract(ServletRequestPathUtils.getParsedRequestPath(request).pathWithinApplication());
|
||||
if (match != null) request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, match.getUriVariables());
|
||||
}
|
||||
return best;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -41,11 +41,13 @@ public class ComponentAssetController {
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void upload(
|
||||
@RequestParam String objectKey,
|
||||
@RequestHeader(ComponentUploadSupport.UPLOAD_TOKEN_HEADER) String uploadSessionToken,
|
||||
@RequestHeader(value = HttpHeaders.CONTENT_TYPE, required = false) String contentType,
|
||||
HttpServletRequest request
|
||||
) throws IOException {
|
||||
componentUploadSupport.uploadObject(
|
||||
operatorProvider.userId(),
|
||||
uploadSessionToken,
|
||||
objectKey,
|
||||
contentType,
|
||||
request.getInputStream(),
|
||||
|
||||
+5
-2
@@ -23,7 +23,9 @@ import com.linkerbot.cadworld.service.ComponentCoverImageUploadService;
|
||||
import com.linkerbot.cadworld.service.ComponentService;
|
||||
import com.linkerbot.cadworld.service.ComponentUrdfUploadService;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -37,6 +39,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/components")
|
||||
@RequiredArgsConstructor
|
||||
@Validated
|
||||
public class ComponentController {
|
||||
|
||||
private final com.linkerbot.cadworld.service.AdminOperatorProvider operatorProvider;
|
||||
@@ -109,8 +112,8 @@ public class ComponentController {
|
||||
@ApiRequestLog("查询组件列表")
|
||||
@GetMapping
|
||||
public ApiResponse<PageResponse<ComponentListItemResponse>> list(
|
||||
@RequestParam(defaultValue = "1") long page,
|
||||
@RequestParam(defaultValue = "20") long size,
|
||||
@RequestParam(defaultValue = "1") @Min(1) long page,
|
||||
@RequestParam(defaultValue = "20") @Min(1) long size,
|
||||
@RequestParam(required = false) String keyword
|
||||
) {
|
||||
return ApiResponse.success(componentService.listComponents(page, Math.min(size, 100), keyword));
|
||||
|
||||
+41
-37
@@ -1,66 +1,70 @@
|
||||
package com.linkerbot.cadworld.controller;
|
||||
|
||||
import com.linkerbot.cadworld.logging.ApiRequestLog;
|
||||
|
||||
import com.linkerbot.cadworld.audit.AuditOperation;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.linkerbot.cadworld.audit.AuditOperation;
|
||||
import com.linkerbot.cadworld.common.api.ApiResponse;
|
||||
import com.linkerbot.cadworld.common.api.PageResponse;
|
||||
import com.linkerbot.cadworld.dto.common.SuccessResponse;
|
||||
import com.linkerbot.cadworld.dto.interfaces.SaveInterfaceDefinitionRequest;
|
||||
import com.linkerbot.cadworld.logging.ApiRequestLog;
|
||||
import com.linkerbot.cadworld.service.InterfaceAssetService;
|
||||
import com.linkerbot.cadworld.service.InterfaceDefinitionService;
|
||||
import com.linkerbot.cadworld.service.client.ObjectStorageClient;
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/interfaces")
|
||||
@RequiredArgsConstructor
|
||||
@Validated
|
||||
public class InterfaceDefinitionController {
|
||||
private final InterfaceDefinitionService service;
|
||||
private final ObjectStorageClient objectStorageClient;
|
||||
private final InterfaceAssetService assets;
|
||||
|
||||
@ApiRequestLog("查询接口列表")
|
||||
@GetMapping public ApiResponse<List<JsonNode>> list(@RequestParam(required = false) String keyword) { return ApiResponse.success(service.list(keyword)); }
|
||||
@GetMapping
|
||||
public ApiResponse<List<JsonNode>> list(@RequestParam(required = false) String keyword) {
|
||||
return ApiResponse.success(service.list(keyword));
|
||||
}
|
||||
|
||||
@ApiRequestLog("查询接口详情")
|
||||
@GetMapping("/{id}") public ApiResponse<JsonNode> get(@PathVariable String id) { return ApiResponse.success(service.get(id)); }
|
||||
@GetMapping("/{id}")
|
||||
public ApiResponse<JsonNode> get(@PathVariable String id) {
|
||||
return ApiResponse.success(service.get(id));
|
||||
}
|
||||
|
||||
@AuditOperation(module = "INTERFACE", action = "CREATE")
|
||||
@ApiRequestLog("新增接口定义")
|
||||
@PostMapping public ApiResponse<JsonNode> create(@RequestBody JsonNode request) { return ApiResponse.success(service.create(request)); }
|
||||
@PostMapping
|
||||
public ApiResponse<JsonNode> create(@Valid @RequestBody SaveInterfaceDefinitionRequest request) {
|
||||
return ApiResponse.success(service.create(request));
|
||||
}
|
||||
|
||||
@AuditOperation(module = "INTERFACE", action = "UPDATE")
|
||||
@ApiRequestLog("修改接口定义")
|
||||
@PutMapping("/{id}") public ApiResponse<JsonNode> update(@PathVariable String id, @RequestBody JsonNode request) { return ApiResponse.success(service.update(id, request)); }
|
||||
@PutMapping("/{id}")
|
||||
public ApiResponse<JsonNode> update(@PathVariable String id, @Valid @RequestBody SaveInterfaceDefinitionRequest request) {
|
||||
return ApiResponse.success(service.update(id, request));
|
||||
}
|
||||
|
||||
@AuditOperation(module = "INTERFACE", action = "DELETE")
|
||||
@ApiRequestLog("删除接口定义")
|
||||
@DeleteMapping("/{id}") public ApiResponse<SuccessResponse> delete(@PathVariable String id) { service.delete(id); return ApiResponse.success(SuccessResponse.ok()); }
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResponse<SuccessResponse> delete(@PathVariable String id) {
|
||||
service.delete(id);
|
||||
return ApiResponse.success(SuccessResponse.ok());
|
||||
}
|
||||
|
||||
@AuditOperation(module = "INTERFACE", action = "UPLOAD")
|
||||
@ApiRequestLog("上传接口源文件")
|
||||
@PostMapping("/{id}/assets")
|
||||
@PostMapping(value = "/{id}/assets", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ApiResponse<String> uploadAsset(@PathVariable String id,
|
||||
@RequestParam int geometryRevision,
|
||||
@RequestPart("file") MultipartFile file) throws IOException {
|
||||
if (file == null || file.isEmpty()) throw new IllegalArgumentException("接口源文件不能为空");
|
||||
String name = file.getOriginalFilename() == null ? "source.step" : file.getOriginalFilename().replace('\\', '/');
|
||||
name = name.substring(name.lastIndexOf('/') + 1).replaceAll("[^A-Za-z0-9._-]", "_");
|
||||
if(service.get(id).path("geometryRevision").asInt()!=geometryRevision)throw new IllegalArgumentException("接口已修订,请刷新");
|
||||
String key;
|
||||
{
|
||||
try {
|
||||
byte[] bytes = file.getBytes();
|
||||
String hash = java.util.HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(bytes));
|
||||
key = "interfaces/" + java.util.HexFormat.of().formatHex(id.getBytes(java.nio.charset.StandardCharsets.UTF_8)) + "/" + geometryRevision + "/" + hash + "/" + name;
|
||||
objectStorageClient.putObject(key, file.getContentType(), new java.io.ByteArrayInputStream(bytes), bytes.length);
|
||||
service.attachAsset(id, geometryRevision, key, "sha256:" + hash);
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 不可用", exception);
|
||||
}
|
||||
}
|
||||
return ApiResponse.success(key);
|
||||
@RequestParam @Min(1) int geometryRevision,
|
||||
@RequestPart("file") MultipartFile file) {
|
||||
return ApiResponse.success(assets.upload(id, geometryRevision, file));
|
||||
}
|
||||
}
|
||||
|
||||
+35
-38
@@ -1,60 +1,57 @@
|
||||
package com.linkerbot.cadworld.controller;
|
||||
|
||||
import com.linkerbot.cadworld.logging.ApiRequestLog;
|
||||
|
||||
import static com.linkerbot.cadworld.mechanicalinterface.InterfaceGeometry.*;
|
||||
import com.linkerbot.cadworld.common.api.ApiResponse;
|
||||
import com.linkerbot.cadworld.mechanicalinterface.MechanicalInterfaceSolver;
|
||||
import com.linkerbot.cadworld.service.InterfaceDefinitionService;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.linkerbot.cadworld.common.api.ApiResponse;
|
||||
import com.linkerbot.cadworld.logging.ApiRequestLog;
|
||||
import com.linkerbot.cadworld.mechanicalinterface.InterfaceGeometry.CandidateSet;
|
||||
import com.linkerbot.cadworld.mechanicalinterface.InterfaceGeometry.Port;
|
||||
import com.linkerbot.cadworld.mechanicalinterface.InterfaceGeometry.PoseRequest;
|
||||
import com.linkerbot.cadworld.mechanicalinterface.MechanicalInterfaceSolver;
|
||||
import com.linkerbot.cadworld.service.InterfaceDefinitionService;
|
||||
import java.io.IOException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController @RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/admin-api/interfaces/{id}")
|
||||
public class InterfacePoseController {
|
||||
private final InterfaceDefinitionService definitions;
|
||||
private final MechanicalInterfaceSolver solver;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@ApiRequestLog("计算接口姿态候选")
|
||||
@PostMapping("/pose-candidates")
|
||||
public ApiResponse<CandidateSet> candidates(@PathVariable String id,@RequestBody JsonNode body){
|
||||
PoseRequest request=read(body,PoseRequest.class);
|
||||
return ApiResponse.success(solver.enumeratePortPoses(definitions.geometryDefinition(id,request.definitionRevision()),request));
|
||||
public ApiResponse<CandidateSet> candidates(@PathVariable String id, @RequestBody JsonNode body) {
|
||||
PoseRequest request = read(body, PoseRequest.class);
|
||||
var definition = definitions.geometryDefinition(id, request.definitionRevision());
|
||||
return ApiResponse.success(solver.enumeratePortPoses(definition, request));
|
||||
}
|
||||
|
||||
@ApiRequestLog("确认组件端口姿态")
|
||||
@PostMapping("/confirm-port")
|
||||
public ApiResponse<Port> confirm(@PathVariable String id,@RequestBody JsonNode body){
|
||||
Port request=read(body,Port.class);
|
||||
if(!id.equals(request.definitionId()))throw new IllegalArgumentException("URL 与端口定义不一致");
|
||||
return ApiResponse.success(solver.confirmPortPose(definitions.geometryDefinition(id,request.definitionRevision()),request));
|
||||
}
|
||||
private <T> T read(JsonNode body,Class<T> type){
|
||||
try{return objectMapper.readerFor(type).with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).readValue(normalizePortBody(body));}
|
||||
catch(java.io.IOException | IllegalArgumentException e){throw new IllegalArgumentException("不支持的接口数据结构:"+rootMessage(e),e);}
|
||||
}
|
||||
private JsonNode normalizePortBody(JsonNode body){
|
||||
if(body==null||!body.isObject())return body;
|
||||
ObjectNode copy=body.deepCopy();JsonNode targets=copy.get("connectableTargets");
|
||||
if(targets!=null&&!targets.isNull()){
|
||||
ArrayNode normalized=objectMapper.createArrayNode();flattenTargets(targets,normalized);copy.set("connectableTargets",normalized);
|
||||
public ApiResponse<Port> confirm(@PathVariable String id, @RequestBody JsonNode body) {
|
||||
Port request = read(body, Port.class);
|
||||
if (!id.equals(request.definitionId())) {
|
||||
throw new IllegalArgumentException("URL 与端口定义不一致");
|
||||
}
|
||||
return copy;
|
||||
var definition = definitions.geometryDefinition(id, request.definitionRevision());
|
||||
return ApiResponse.success(solver.confirmPortPose(definition, request));
|
||||
}
|
||||
private void flattenTargets(JsonNode node,ArrayNode output){
|
||||
if(node==null||node.isNull())return;
|
||||
if(node.isArray()){
|
||||
boolean path=true;StringBuilder joined=new StringBuilder();
|
||||
for(JsonNode child:node){if(!child.isTextual()){path=false;break;}if(joined.length()>0)joined.append('/');joined.append(child.asText());}
|
||||
if(path){String value=joined.toString().trim();if(!value.isEmpty()&&!containsTarget(output,value))output.add(value);return;}
|
||||
node.forEach(child->flattenTargets(child,output));return;
|
||||
|
||||
private <T> T read(JsonNode body, Class<T> type) {
|
||||
try {
|
||||
return objectMapper.readerFor(type).with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).readValue(body);
|
||||
} catch (IOException | IllegalArgumentException exception) {
|
||||
throw new IllegalArgumentException("不支持的接口数据结构:" + rootMessage(exception), exception);
|
||||
}
|
||||
String value=node.asText("").trim();if(!value.isEmpty()&&!containsTarget(output,value))output.add(value);
|
||||
}
|
||||
private boolean containsTarget(ArrayNode output,String value){for(JsonNode item:output)if(value.equals(item.asText()))return true;return false;}
|
||||
private String rootMessage(Throwable error){Throwable current=error;while(current.getCause()!=null)current=current.getCause();return current.getMessage()==null?"字段格式错误":current.getMessage();}
|
||||
|
||||
private String rootMessage(Throwable error) {
|
||||
Throwable current = error;
|
||||
while (current.getCause() != null) current = current.getCause();
|
||||
return current.getMessage() == null ? "字段格式错误" : current.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ app:
|
||||
public-base-url: ${APP_STORAGE_PUBLIC_BASE_URL:http://127.0.0.1:${SERVER_PORT:8992}/admin-api/component-assets}
|
||||
local-root: ${APP_STORAGE_LOCAL_ROOT:./data/assets}
|
||||
upload-session-ttl: PT30M
|
||||
max-upload-bytes: ${APP_STORAGE_MAX_UPLOAD_BYTES:104857600}
|
||||
minio:
|
||||
endpoint: ${APP_MINIO_ENDPOINT:}
|
||||
access-key: ${APP_MINIO_ACCESS_KEY:}
|
||||
|
||||
@@ -40,7 +40,8 @@ class AdminApiTest {
|
||||
|
||||
@BeforeEach
|
||||
void clean() {
|
||||
for (String table : new String[]{"component_asset", "component", "interface_definition_revision", "interface_definition_v2", "sys_user", "sys_operation_log"}) {
|
||||
TestSchemaSupport.prepare(jdbc);
|
||||
for (String table : new String[]{"component", "interface_definition_revision", "interface_definition_v2", "sys_user", "sys_operation_log"}) {
|
||||
jdbc.update("DELETE FROM " + table);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +144,9 @@ class AdminApiTest {
|
||||
JsonNode result = send("/admin-api/components", component("sample"));
|
||||
long id = result.path("data").path("id").asLong();
|
||||
assertThat(result.path("data").path("sourceUrl").asText()).contains("/admin-api/component-assets/");
|
||||
mvc.perform(put("/admin-api/components/{id}", id).contentType(MediaType.APPLICATION_JSON).content(json.writeValueAsString(component("renamed"))))
|
||||
var update = json.valueToTree(component("renamed"));
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) update).set("componentJson", result.path("data").path("componentJson"));
|
||||
mvc.perform(put("/admin-api/components/{id}", id).contentType(MediaType.APPLICATION_JSON).content(update.toString()))
|
||||
.andExpect(status().isOk());
|
||||
mvc.perform(get("/admin-api/components")).andExpect(status().isOk());
|
||||
mvc.perform(get("/admin-api/components/{id}", id)).andExpect(status().isOk());
|
||||
@@ -173,16 +176,17 @@ class AdminApiTest {
|
||||
JsonNode created = send("/admin-api/interfaces", request).path("data");
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) created).put("name", "新版");
|
||||
mvc.perform(put("/admin-api/interfaces/mount").contentType(MediaType.APPLICATION_JSON).content(created.toString()))
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.data.geometryRevision").value(2));
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.data.geometryRevision").value(1))
|
||||
.andExpect(jsonPath("$.data.editRevision").value(2));
|
||||
mvc.perform(put("/admin-api/interfaces/mount").contentType(MediaType.APPLICATION_JSON).content(created.toString()))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM interface_definition_revision", Long.class)).isEqualTo(2);
|
||||
.andExpect(status().isConflict());
|
||||
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM interface_definition_revision", Long.class)).isEqualTo(1);
|
||||
mvc.perform(get("/admin-api/interfaces")).andExpect(status().isOk());
|
||||
mvc.perform(delete("/admin-api/interfaces/mount")).andExpect(status().isOk());
|
||||
assertThat(logCount()).isEqualTo(4);
|
||||
// Historical revisions survive deletion and still prohibit ID reuse.
|
||||
mvc.perform(post("/admin-api/interfaces").contentType(MediaType.APPLICATION_JSON).content(request.toString()))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
.andExpect(status().isConflict());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -193,7 +197,9 @@ class AdminApiTest {
|
||||
Map.of("uploadSessionToken", token, "objectPath", "cover.png", "contentType", "image/png")).path("data");
|
||||
assertThat(upload.path("uploadUrl").asText()).contains("/admin-api/component-assets/upload");
|
||||
String key = upload.path("objectKey").asText();
|
||||
mvc.perform(put("/admin-api/component-assets/upload").param("objectKey", key).contentType("image/png").content(new byte[]{1, 2, 3}))
|
||||
assertThat(upload.path("uploadHeaders").path("X-Upload-Session-Token").asText()).isEqualTo(token);
|
||||
mvc.perform(put("/admin-api/component-assets/upload").param("objectKey", key)
|
||||
.header("X-Upload-Session-Token", token).contentType("image/png").content(new byte[]{1, 2, 3}))
|
||||
.andExpect(status().isNoContent());
|
||||
send("/admin-api/components/cover-image-upload-sessions/complete", Map.of("uploadSessionToken", token, "objectKeys", new String[]{key}));
|
||||
mvc.perform(get("/admin-api/component-assets/" + key)).andExpect(status().isOk()).andExpect(content().bytes(new byte[]{1, 2, 3}));
|
||||
@@ -201,6 +207,33 @@ class AdminApiTest {
|
||||
assertThat(jdbc.queryForList("SELECT * FROM sys_operation_log").toString()).doesNotContain(token);
|
||||
}
|
||||
|
||||
@Test
|
||||
void sourceUploadBindsHashAndRetriesWithoutChangingGeometryOrLeakingNewKeys() throws Exception {
|
||||
send("/admin-api/interfaces", interfaceRequest("source-upload"));
|
||||
byte[] bytes = {1, 2, 3};
|
||||
var file = new org.springframework.mock.web.MockMultipartFile("file", "plate.step", "application/octet-stream", bytes);
|
||||
var response = mvc.perform(multipart("/admin-api/interfaces/source-upload/assets")
|
||||
.file(file).param("geometryRevision", "1")).andExpect(status().isOk()).andReturn();
|
||||
String key = json.readTree(response.getResponse().getContentAsString()).path("data").asText();
|
||||
mvc.perform(get("/admin-api/interfaces/source-upload"))
|
||||
.andExpect(jsonPath("$.data.geometryRevision").value(1))
|
||||
.andExpect(jsonPath("$.data.editRevision").value(2))
|
||||
.andExpect(jsonPath("$.data.sourceAssetKey").value(key))
|
||||
.andExpect(jsonPath("$.data.sourceGeometryHash").value(
|
||||
"sha256:039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81"));
|
||||
mvc.perform(multipart("/admin-api/interfaces/source-upload/assets").file(file).param("geometryRevision", "1"))
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.data").value(key));
|
||||
mvc.perform(get("/admin-api/interfaces/source-upload")).andExpect(jsonPath("$.data.editRevision").value(2));
|
||||
mvc.perform(multipart("/admin-api/interfaces/source-upload/assets")
|
||||
.file(new org.springframework.mock.web.MockMultipartFile("file", "plate.step", "application/octet-stream", new byte[]{9}))
|
||||
.param("geometryRevision", "1"))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
mvc.perform(multipart("/admin-api/interfaces/source-upload/assets").file(file).param("geometryRevision", "2"))
|
||||
.andExpect(status().isConflict());
|
||||
mvc.perform(get("/admin-api/component-assets/" + key)).andExpect(status().isOk()).andExpect(content().bytes(bytes));
|
||||
assertThat(logCount()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void requiresNewLogSurvivesOuterRollbackAndOldRoutesAreAbsent() throws Exception {
|
||||
transactions.executeWithoutResult(tx -> {
|
||||
@@ -229,6 +262,144 @@ class AdminApiTest {
|
||||
assertThat(logCount()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void staleAndConcurrentComponentUpdatesCannotOverwriteEachOther() throws Exception {
|
||||
JsonNode created = send("/admin-api/components", component("concurrent")).path("data");
|
||||
long id = created.path("id").asLong();
|
||||
var body = (com.fasterxml.jackson.databind.node.ObjectNode) json.valueToTree(component("editor"));
|
||||
body.set("componentJson", created.get("componentJson"));
|
||||
var gate = new java.util.concurrent.CountDownLatch(1);
|
||||
try (var workers = java.util.concurrent.Executors.newFixedThreadPool(2)) {
|
||||
java.util.concurrent.Callable<Integer> update = () -> {
|
||||
gate.await();
|
||||
return mvc.perform(put("/admin-api/components/{id}", id).contentType(MediaType.APPLICATION_JSON)
|
||||
.content(body.toString())).andReturn().getResponse().getStatus();
|
||||
};
|
||||
var first = workers.submit(update);
|
||||
var second = workers.submit(update);
|
||||
gate.countDown();
|
||||
assertThat(java.util.List.of(first.get(10, java.util.concurrent.TimeUnit.SECONDS), second.get(10, java.util.concurrent.TimeUnit.SECONDS)))
|
||||
.containsExactlyInAnyOrder(200, 409);
|
||||
}
|
||||
mvc.perform(get("/admin-api/components/{id}", id)).andExpect(jsonPath("$.data.componentJson.componentRevision").value(2));
|
||||
assertThat(logCount()).isEqualTo(3);
|
||||
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM sys_operation_log WHERE success=FALSE", Long.class)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void concurrentComponentCreationHasDatabaseNameUniqueness() throws Exception {
|
||||
var gate = new java.util.concurrent.CountDownLatch(1);
|
||||
String body = json.writeValueAsString(component("same-name"));
|
||||
try (var workers = java.util.concurrent.Executors.newFixedThreadPool(2)) {
|
||||
java.util.concurrent.Callable<Integer> create = () -> {
|
||||
gate.await();
|
||||
return mvc.perform(post("/admin-api/components").contentType(MediaType.APPLICATION_JSON)
|
||||
.content(body)).andReturn().getResponse().getStatus();
|
||||
};
|
||||
var first = workers.submit(create);
|
||||
var second = workers.submit(create);
|
||||
gate.countDown();
|
||||
assertThat(java.util.List.of(first.get(10, java.util.concurrent.TimeUnit.SECONDS), second.get(10, java.util.concurrent.TimeUnit.SECONDS)))
|
||||
.containsExactlyInAnyOrder(200, 409);
|
||||
}
|
||||
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM component", Long.class)).isEqualTo(1);
|
||||
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM information_schema.tables WHERE LOWER(table_name)='component_asset'", Long.class)).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void componentUpdatesRequireClientRevisionAndPaginationRejectsNonPositiveValues() throws Exception {
|
||||
long id = send("/admin-api/components", component("revision-required")).path("data").path("id").asLong();
|
||||
mvc.perform(put("/admin-api/components/{id}", id).contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json.writeValueAsString(component("new")))).andExpect(status().isUnprocessableEntity());
|
||||
for (String value : new String[]{"0", "-1"}) {
|
||||
mvc.perform(get("/admin-api/components").param("page", value)).andExpect(status().isUnprocessableEntity());
|
||||
mvc.perform(get("/admin-api/components").param("size", value)).andExpect(status().isUnprocessableEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void interfaceFieldLengthsFailBeforeDatabaseAndHttpErrorsHaveCorrectStatus() throws Exception {
|
||||
var body = interfaceRequest("invalid-length");
|
||||
body.put("name", "x".repeat(129));
|
||||
mvc.perform(post("/admin-api/interfaces").contentType(MediaType.APPLICATION_JSON).content(body.toString()))
|
||||
.andExpect(status().isUnprocessableEntity()).andExpect(jsonPath("$.message", org.hamcrest.Matchers.containsString("name")));
|
||||
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM interface_definition_v2", Long.class)).isZero();
|
||||
body.put("name", "valid").put("unsupportedField", "must not be silently ignored");
|
||||
mvc.perform(post("/admin-api/interfaces").contentType(MediaType.APPLICATION_JSON).content(body.toString()))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
body.remove("unsupportedField");
|
||||
body.putArray("connectableTargets").add(123);
|
||||
mvc.perform(post("/admin-api/interfaces").contentType(MediaType.APPLICATION_JSON).content(body.toString()))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
mvc.perform(patch("/admin-api/interfaces").contentType(MediaType.APPLICATION_JSON).content("{}"))
|
||||
.andExpect(status().isMethodNotAllowed()).andExpect(header().exists("Allow"));
|
||||
mvc.perform(post("/admin-api/interfaces").contentType(MediaType.TEXT_PLAIN).content("{}"))
|
||||
.andExpect(status().isUnsupportedMediaType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void flatTargetArraysSurvivePoseConfirmationAndRoundTrip() throws Exception {
|
||||
var request = interfaceRequest("roundtrip");
|
||||
request.putArray("connectableTargets").add("A").add("B");
|
||||
JsonNode definition = send("/admin-api/interfaces", request).path("data");
|
||||
var pose = json.createObjectNode().put("definitionRevision", 1).put("linkName", "base").put("sourceGeometryHash", "hash");
|
||||
pose.set("geometryInLink", definition.get("geometry"));
|
||||
JsonNode candidates = send("/admin-api/interfaces/roundtrip/pose-candidates", pose).path("data");
|
||||
var port = json.createObjectNode().put("id", "port").put("linkName", "base")
|
||||
.put("definitionId", "roundtrip").put("definitionRevision", 1).put("sourceGeometryHash", "hash")
|
||||
.put("solverVersion", candidates.path("solverVersion").asText());
|
||||
port.set("geometryInLink", definition.get("geometry"));
|
||||
port.putObject("selectedPose").put("id", candidates.path("candidates").get(0).path("id").asText());
|
||||
port.set("connectableTargets", definition.get("connectableTargets"));
|
||||
JsonNode confirmed = send("/admin-api/interfaces/roundtrip/confirm-port", port).path("data");
|
||||
assertThat(confirmed.path("connectableTargets").toString()).isEqualTo("[\"A\",\"B\"]");
|
||||
assertThat(send("/admin-api/interfaces/roundtrip/confirm-port", confirmed).path("data").path("connectableTargets"))
|
||||
.isEqualTo(confirmed.get("connectableTargets"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void actualUploadRejectsMissingForgedExpiredAndCrossSessionTokens() throws Exception {
|
||||
JsonNode session = send("/admin-api/components/cover-image-upload-sessions", null).path("data");
|
||||
String key = session.path("keyPrefix").asText() + "cover.png";
|
||||
mvc.perform(put("/admin-api/component-assets/upload").param("objectKey", key).content(new byte[]{1}))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
mvc.perform(put("/admin-api/component-assets/upload").param("objectKey", key)
|
||||
.header("X-Upload-Session-Token", "forged-token").content(new byte[]{1}))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
String expired = uploadTokens
|
||||
.generateToken(0L, com.linkerbot.cadworld.enums.ComponentUploadType.COVER_IMAGE,
|
||||
session.path("keyPrefix").asText(), java.time.Instant.now().minusSeconds(30));
|
||||
mvc.perform(put("/admin-api/component-assets/upload").param("objectKey", key)
|
||||
.header("X-Upload-Session-Token", expired).content(new byte[]{1}))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
mvc.perform(put("/admin-api/component-assets/upload").param("objectKey", "components/cover-images/0/other/cover.png")
|
||||
.header("X-Upload-Session-Token", session.path("uploadSessionToken").asText()).content(new byte[]{1}))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
assertThat(logCount()).isEqualTo(5);
|
||||
assertThat(jdbc.queryForList("SELECT * FROM sys_operation_log").toString()).doesNotContain(expired, "forged-token", session.path("uploadSessionToken").asText());
|
||||
}
|
||||
|
||||
@Autowired com.linkerbot.cadworld.service.support.ComponentUploadSessionTokenProvider uploadTokens;
|
||||
|
||||
private com.fasterxml.jackson.databind.node.ObjectNode interfaceRequest(String id) throws Exception {
|
||||
return (com.fasterxml.jackson.databind.node.ObjectNode) json.readTree("""
|
||||
{"id":"%s","name":"安装接口","geometry":{"plane":{"pointM":[0,0,0],"outwardNormal":[0,0,1]},
|
||||
"holes":[{"id":"a","pointOnPlaneM":[-0.02,0,0],"axis":[0,0,1],"diameterM":0.004},
|
||||
{"id":"b","pointOnPlaneM":[0.02,0,0],"axis":[0,0,1],"diameterM":0.004}]},
|
||||
"tolerances":{"positionM":0.0002,"axisAngleRad":0.0174533,"planeAngleRad":0.0174533}}
|
||||
""".formatted(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sourceUploadUnsupportedMediaTypeStillHasExactlyOneFailedAudit() throws Exception {
|
||||
mvc.perform(post("/admin-api/interfaces/missing/assets").param("geometryRevision", "1")
|
||||
.contentType(MediaType.APPLICATION_JSON).content("{}"))
|
||||
.andExpect(status().isUnsupportedMediaType());
|
||||
assertThat(logCount()).isEqualTo(1);
|
||||
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM sys_operation_log WHERE module='INTERFACE' AND action='UPLOAD' AND success=FALSE AND target_id='missing' AND http_status=415", Long.class))
|
||||
.isEqualTo(1);
|
||||
}
|
||||
|
||||
private JsonNode send(String path, Object body) throws Exception {
|
||||
var request = post(path);
|
||||
if (body != null) request.contentType(MediaType.APPLICATION_JSON).content(json.writeValueAsString(body));
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package com.linkerbot.cadworld;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.DriverManager;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.jdbc.datasource.init.ScriptUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
@@ -20,6 +26,27 @@ import static org.assertj.core.api.Assertions.*;
|
||||
"app.minio.bucket=cadworld-verification", "logging.file.path=target/integration-logs"
|
||||
})
|
||||
class ExternalServicesIT extends AdminApiTest {
|
||||
@Autowired com.linkerbot.cadworld.service.client.ObjectStorageClient storage;
|
||||
|
||||
@Test
|
||||
void minioStreamLimitPreservesExistingObjectAndMapsTo413() throws Exception {
|
||||
String key = "limit-verification/" + java.util.UUID.randomUUID() + "/model.rfs";
|
||||
try {
|
||||
storage.putObject(key, "application/octet-stream", new java.io.ByteArrayInputStream(new byte[]{1, 2}), 2);
|
||||
var bounded = com.linkerbot.cadworld.service.support.UploadLimits.bounded(
|
||||
new java.io.ByteArrayInputStream(new byte[9]), 8);
|
||||
assertThatThrownBy(() -> storage.putObject(key, "application/octet-stream", bounded, -1))
|
||||
.isInstanceOf(com.linkerbot.cadworld.common.exception.BizException.class)
|
||||
.extracting("httpStatus").isEqualTo(413);
|
||||
var downloaded = new java.io.ByteArrayOutputStream();
|
||||
storage.writeObjectTo(key, downloaded);
|
||||
assertThat(downloaded.toByteArray()).containsExactly((byte) 1, (byte) 2);
|
||||
} finally {
|
||||
storage.deleteObject(key);
|
||||
}
|
||||
assertThat(storage.objectExists(key)).isFalse();
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void prepareAndVerifySql() throws Exception {
|
||||
String url = System.getProperty("cadworld.it.db-url", "jdbc:mysql://127.0.0.1:13306/cadworld_verification?serverTimezone=Asia/Shanghai");
|
||||
@@ -46,6 +73,22 @@ class ExternalServicesIT extends AdminApiTest {
|
||||
try (var result = statement.executeQuery("SELECT COUNT(*) FROM sys_user WHERE nickname='sentinel' AND deleted=0")) {
|
||||
result.next(); assertThat(result.getInt(1)).isEqualTo(1);
|
||||
}
|
||||
String readme = Files.readString(db.getParent().resolve("README.md"));
|
||||
var supplement = Pattern.compile("<!-- schema-refactor -->\\s*```sql\\s*(.*?)```", Pattern.DOTALL)
|
||||
.matcher(readme);
|
||||
assertThat(supplement.find()).as("README must provide the schema supplement").isTrue();
|
||||
var sql = new ByteArrayResource(supplement.group(1).getBytes(StandardCharsets.UTF_8));
|
||||
ScriptUtils.executeSqlScript(connection, sql);
|
||||
ScriptUtils.executeSqlScript(connection, sql);
|
||||
try (var result = statement.executeQuery("SELECT COUNT(*) FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='interface_definition_v2' AND column_name='edit_revision'")) {
|
||||
result.next(); assertThat(result.getInt(1)).isEqualTo(1);
|
||||
}
|
||||
try (var result = statement.executeQuery("SELECT COUNT(*) FROM information_schema.statistics WHERE table_schema=DATABASE() AND table_name='component' AND index_name='uk_component_name' AND non_unique=0")) {
|
||||
result.next(); assertThat(result.getInt(1)).isEqualTo(1);
|
||||
}
|
||||
try (var result = statement.executeQuery("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name='component_asset'")) {
|
||||
result.next(); assertThat(result.getInt(1)).isZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.linkerbot.cadworld;
|
||||
|
||||
import java.sql.Connection;
|
||||
import org.springframework.jdbc.core.ConnectionCallback;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
/** Applies the separately delivered schema changes to disposable test databases only. */
|
||||
final class TestSchemaSupport {
|
||||
private TestSchemaSupport() { }
|
||||
|
||||
static void prepare(JdbcTemplate jdbc) {
|
||||
jdbc.execute((ConnectionCallback<Void>) connection -> {
|
||||
if (!"H2".equals(connection.getMetaData().getDatabaseProductName())
|
||||
&& !"cadworld_verification".equals(connection.getCatalog())) {
|
||||
throw new IllegalStateException("Schema preparation requires a disposable test database");
|
||||
}
|
||||
try (var statement = connection.createStatement()) {
|
||||
boolean hasRevision = false;
|
||||
String componentTable = "component";
|
||||
try (var columns = connection.getMetaData().getColumns(connection.getCatalog(), null, "%", "%")) {
|
||||
while (columns.next()) {
|
||||
if ("interface_definition_v2".equalsIgnoreCase(columns.getString("TABLE_NAME"))
|
||||
&& "edit_revision".equalsIgnoreCase(columns.getString("COLUMN_NAME"))) hasRevision = true;
|
||||
if ("component".equalsIgnoreCase(columns.getString("TABLE_NAME"))) componentTable = columns.getString("TABLE_NAME");
|
||||
}
|
||||
}
|
||||
if (!hasRevision) statement.execute("ALTER TABLE interface_definition_v2 ADD COLUMN edit_revision BIGINT NOT NULL DEFAULT 1 COMMENT '编辑版本号,每次修改递增,用于防止旧数据覆盖'");
|
||||
boolean hasNameIndex = false;
|
||||
try (var indexes = connection.getMetaData().getIndexInfo(connection.getCatalog(), null, componentTable, false, false)) {
|
||||
while (indexes.next()) {
|
||||
if ("uk_component_name".equalsIgnoreCase(indexes.getString("INDEX_NAME"))) hasNameIndex = true;
|
||||
}
|
||||
}
|
||||
if (!hasNameIndex) statement.execute("CREATE UNIQUE INDEX uk_component_name ON component(component_name)");
|
||||
statement.execute("DROP TABLE IF EXISTS component_asset");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
"spring.datasource.driver-class-name=org.h2.Driver", "spring.datasource.username=sa", "spring.datasource.password=",
|
||||
"spring.sql.init.mode=always", "spring.sql.init.schema-locations=classpath:test-schema.sql",
|
||||
"spring.servlet.multipart.max-file-size=1KB", "spring.servlet.multipart.max-request-size=2KB",
|
||||
"app.storage.max-upload-bytes=1024",
|
||||
"app.storage.provider=local", "app.storage.local-root=target/test-http-assets", "logging.file.path=target/test-logs"
|
||||
})
|
||||
@ActiveProfiles("verification")
|
||||
@@ -27,6 +28,28 @@ class UploadHttpTest {
|
||||
@Autowired TestRestTemplate http;
|
||||
@Autowired JdbcTemplate jdbc;
|
||||
|
||||
@Test
|
||||
void realChunkedPutCannotBypassUploadLimit() throws Exception {
|
||||
var session = http.postForObject("/admin-api/components/cover-image-upload-sessions", null,
|
||||
com.fasterxml.jackson.databind.JsonNode.class).path("data");
|
||||
String objectKey = session.path("keyPrefix").asText() + "chunked.png";
|
||||
var uri = org.springframework.web.util.UriComponentsBuilder.fromUriString(http.getRootUri())
|
||||
.path("/admin-api/component-assets/upload").queryParam("objectKey", objectKey)
|
||||
.build().encode().toUri();
|
||||
var request = java.net.http.HttpRequest.newBuilder(uri)
|
||||
.header("X-Upload-Session-Token", session.path("uploadSessionToken").asText())
|
||||
.header("Content-Type", "image/png")
|
||||
.PUT(java.net.http.HttpRequest.BodyPublishers.ofInputStream(
|
||||
() -> new java.io.ByteArrayInputStream(new byte[1025]))).build();
|
||||
try (var client = java.net.http.HttpClient.newHttpClient()) {
|
||||
var response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString());
|
||||
assertThat(response.statusCode()).isEqualTo(413);
|
||||
assertThat(response.body()).contains("UPLOAD_TOO_LARGE");
|
||||
}
|
||||
assertThat(http.getForEntity("/admin-api/component-assets/" + objectKey, String.class).getStatusCode())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
void realServletMultipartSizeFailureReturns413AndPersistsAudit() {
|
||||
var body = new LinkedMultiValueMap<String, Object>();
|
||||
|
||||
+5
-1
@@ -20,7 +20,11 @@ class OperationAuditInterceptorTest {
|
||||
var request = new MockHttpServletRequest("POST", "/admin-api/components");
|
||||
var response = new MockHttpServletResponse();
|
||||
var handler = new HandlerMethod(this, getClass().getDeclaredMethod("operation"));
|
||||
when(mappings.getHandler(request)).thenReturn(new org.springframework.web.servlet.HandlerExecutionChain(handler));
|
||||
var options = new org.springframework.web.servlet.mvc.method.RequestMappingInfo.BuilderConfiguration();
|
||||
options.setPatternParser(new org.springframework.web.util.pattern.PathPatternParser());
|
||||
var mapping = org.springframework.web.servlet.mvc.method.RequestMappingInfo.paths("/admin-api/components")
|
||||
.methods(org.springframework.web.bind.annotation.RequestMethod.POST).options(options).build();
|
||||
when(mappings.getHandlerMethods()).thenReturn(java.util.Map.of(mapping, handler));
|
||||
var filter = new EarlyFailureAuditFilter(mappings, audit);
|
||||
filter.doFilter(request, response, (req, res) -> ((jakarta.servlet.http.HttpServletResponse) res).setStatus(413));
|
||||
var captured = org.mockito.ArgumentCaptor.forClass(com.linkerbot.cadworld.entity.OperationLog.class);
|
||||
|
||||
Reference in New Issue
Block a user