fix(接口测试): 修复用例附件被直接删除漏洞
This commit is contained in:
parent
ec7282fc18
commit
b5b4c510c6
|
@ -333,10 +333,14 @@ public class ApiTestCaseService {
|
||||||
extApiDefinitionExecResultMapper.deleteByResourceId(testId);
|
extApiDefinitionExecResultMapper.deleteByResourceId(testId);
|
||||||
apiTestCaseMapper.deleteByPrimaryKey(testId);
|
apiTestCaseMapper.deleteByPrimaryKey(testId);
|
||||||
esbApiParamService.deleteByResourceId(testId);
|
esbApiParamService.deleteByResourceId(testId);
|
||||||
deleteBodyFiles(testId);
|
|
||||||
// 删除附件关系
|
// 删除附件关系
|
||||||
extFileAssociationService.deleteByResourceId(testId);
|
extFileAssociationService.deleteByResourceId(testId);
|
||||||
deleteFollows(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) {
|
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) {
|
public void checkNameExist(SaveApiTestCaseRequest request) {
|
||||||
if (hasSameCase(request)) {
|
if (hasSameCase(request)) {
|
||||||
MSException.throwException(Translator.get("case_name_is_already_exist") + ": " + request.getName());
|
MSException.throwException(Translator.get("case_name_is_already_exist") + ": " + request.getName());
|
||||||
|
|
Loading…
Reference in New Issue