fix(接口测试): 修复用例附件被直接删除漏洞

This commit is contained in:
fit2-zhao 2022-12-07 22:51:27 +08:00 committed by fit2-zhao
parent ec7282fc18
commit b5b4c510c6
1 changed files with 5 additions and 9 deletions

View File

@ -333,10 +333,14 @@ public class ApiTestCaseService {
extApiDefinitionExecResultMapper.deleteByResourceId(testId);
apiTestCaseMapper.deleteByPrimaryKey(testId);
esbApiParamService.deleteByResourceId(testId);
deleteBodyFiles(testId);
// 删除附件关系
extFileAssociationService.deleteByResourceId(testId);
deleteFollows(testId);
ApiTestCase apiTestCase = apiTestCaseMapper.selectByPrimaryKey(testId);
if (apiTestCase != null) {
String filePath = StringUtils.join(BODY_FILE_DIR, File.separator, apiTestCase.getId());
FileUtil.deleteContents(new File(filePath));
}
}
private void deleteFollows(String testId) {
@ -362,14 +366,6 @@ public class ApiTestCaseService {
}
}
public void deleteBodyFiles(String testId) {
File file = new File(BODY_FILE_DIR + "/" + testId);
FileUtil.deleteContents(file);
if (file.exists()) {
file.delete();
}
}
public void checkNameExist(SaveApiTestCaseRequest request) {
if (hasSameCase(request)) {
MSException.throwException(Translator.get("case_name_is_already_exist") + ": " + request.getName());