fix(配额管理): 修复接口测试没有验证配额的问题
--bug=1008092 --user=刘瑞斌 【系统设置】配额管理,接口测试数量没限制住 https://www.tapd.cn/55049933/s/1070718
This commit is contained in:
parent
737f3d7819
commit
bf128be591
|
@ -97,7 +97,6 @@ public class APITestService {
|
|||
if (file == null) {
|
||||
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
|
||||
}
|
||||
checkQuota();
|
||||
request.setBodyUploadIds(null);
|
||||
ApiTest test = createTest(request);
|
||||
saveFile(test, file);
|
||||
|
@ -140,7 +139,6 @@ public class APITestService {
|
|||
}
|
||||
|
||||
public void copy(SaveAPITestRequest request) {
|
||||
checkQuota();
|
||||
|
||||
ApiTestExample example = new ApiTestExample();
|
||||
example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId());
|
||||
|
@ -452,13 +450,6 @@ public class APITestService {
|
|||
return reportId;
|
||||
}
|
||||
|
||||
private void checkQuota() {
|
||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||
if (quotaService != null) {
|
||||
quotaService.checkAPITestQuota();
|
||||
}
|
||||
}
|
||||
|
||||
public void mergeCreate(SaveAPITestRequest request, MultipartFile file, List<String> selectIds) {
|
||||
ApiTest test = createTest(request, file);
|
||||
selectIds.forEach(sourceId -> {
|
||||
|
|
|
@ -46,6 +46,7 @@ import io.metersphere.log.vo.DetailColumn;
|
|||
import io.metersphere.log.vo.OperatingLogDetails;
|
||||
import io.metersphere.log.vo.api.AutomationReference;
|
||||
import io.metersphere.plugin.core.MsTestElement;
|
||||
import io.metersphere.service.QuotaService;
|
||||
import io.metersphere.service.RelationshipEdgeService;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
|
@ -295,6 +296,7 @@ public class ApiAutomationService {
|
|||
}
|
||||
|
||||
public ApiScenario create(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles, List<MultipartFile> scenarioFiles) {
|
||||
checkQuota();
|
||||
request.setId(UUID.randomUUID().toString());
|
||||
checkNameExist(request);
|
||||
int nextNum = getNextNum(request.getProjectId());
|
||||
|
@ -326,6 +328,13 @@ public class ApiAutomationService {
|
|||
return scenario;
|
||||
}
|
||||
|
||||
private void checkQuota() {
|
||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||
if (quotaService != null) {
|
||||
quotaService.checkAPIAutomationQuota();
|
||||
}
|
||||
}
|
||||
|
||||
private void uploadFiles(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles, List<MultipartFile> scenarioFiles) {
|
||||
FileUtils.createBodyFiles(request.getScenarioFileIds(), scenarioFiles);
|
||||
List<String> bodyFileRequestIds = request.getBodyFileRequestIds();
|
||||
|
@ -394,6 +403,7 @@ public class ApiAutomationService {
|
|||
}
|
||||
|
||||
public ApiScenario update(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles, List<MultipartFile> scenarioFiles) {
|
||||
checkQuota();
|
||||
checkNameExist(request);
|
||||
checkScenarioNum(request);
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@ import io.metersphere.log.vo.StatusReference;
|
|||
import io.metersphere.log.vo.api.DefinitionReference;
|
||||
import io.metersphere.notice.sender.NoticeModel;
|
||||
import io.metersphere.notice.service.NoticeSendService;
|
||||
import io.metersphere.service.FileService;
|
||||
import io.metersphere.service.RelationshipEdgeService;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.service.*;
|
||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import io.metersphere.track.service.TestPlanService;
|
||||
|
@ -269,6 +266,7 @@ public class ApiDefinitionService {
|
|||
}
|
||||
|
||||
public ApiDefinitionWithBLOBs create(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
checkQuota();
|
||||
if (StringUtils.equals(request.getProtocol(), "DUBBO")) {
|
||||
request.setMethod("dubbo://");
|
||||
}
|
||||
|
@ -278,6 +276,7 @@ public class ApiDefinitionService {
|
|||
}
|
||||
|
||||
public ApiDefinitionWithBLOBs update(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
checkQuota();
|
||||
if (request.getRequest() != null) {
|
||||
deleteFileByTestId(request.getRequest().getId());
|
||||
}
|
||||
|
@ -292,6 +291,13 @@ public class ApiDefinitionService {
|
|||
return returnModel;
|
||||
}
|
||||
|
||||
private void checkQuota() {
|
||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||
if (quotaService != null) {
|
||||
quotaService.checkAPIDefinitionQuota();
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String apiId) {
|
||||
apiTestCaseService.deleteTestCase(apiId);
|
||||
deleteFileByTestId(apiId);
|
||||
|
@ -1748,7 +1754,7 @@ public class ApiDefinitionService {
|
|||
String format = body.getString("format");
|
||||
if (StringUtils.equals(format, "JSON-SCHEMA") && StringUtils.isNotEmpty(body.getString("jsonSchema"))) {
|
||||
elements = JSONSchemaToDocumentUtils.getDocument(body.getString("jsonSchema"));
|
||||
}else {
|
||||
} else {
|
||||
elements = JSONToDocumentUtils.getDocument(raw, dataType);
|
||||
}
|
||||
} else if (StringUtils.equals(dataType, "XML")) {
|
||||
|
|
|
@ -231,13 +231,6 @@ public class ApiTestCaseService {
|
|||
return test;
|
||||
}
|
||||
|
||||
private void checkQuota() {
|
||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||
if (quotaService != null) {
|
||||
quotaService.checkAPITestQuota();
|
||||
}
|
||||
}
|
||||
|
||||
public ApiTestCase update(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
|
||||
deleteFileByTestId(request.getId());
|
||||
request.setBodyUploadIds(null);
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.util.Set;
|
|||
|
||||
public interface QuotaService {
|
||||
|
||||
void checkAPITestQuota();
|
||||
void checkAPIDefinitionQuota();
|
||||
|
||||
void checkAPIAutomationQuota();
|
||||
|
||||
void checkLoadTestQuota(TestPlanRequest request, boolean checkPerformance);
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9a24f644b842d930da6019383fc70e11b8973af2
|
||||
Subproject commit 1a1a00814f367d827975b524781771b74a7e7938
|
Loading…
Reference in New Issue