fix(接口测试): 接口调试重命名校验有误
--bug=1037016 --user=陈建星 【接口测试】接口调试-新建请求-当前账号未创建过请求,却报错提示请求已存在 https://www.tapd.cn/55049933/s/1474547
This commit is contained in:
parent
263317e3c4
commit
4053e5c206
|
@ -252,7 +252,7 @@ public class ApiTestCaseController {
|
|||
}
|
||||
|
||||
@GetMapping("/run/{id}/{reportId}")
|
||||
@Operation(summary = "用例执行,获取获取执行结果")
|
||||
@Operation(summary = "用例执行,实时获取执行结果")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_EXECUTE)
|
||||
public TaskRequestDTO run(@PathVariable String id, @PathVariable String reportId) {
|
||||
return apiTestCaseService.run(id, reportId, SessionUtils.getUserId());
|
||||
|
|
|
@ -32,9 +32,4 @@ public class WWWFormKV extends KeyValueEnableParam {
|
|||
* 最大长度
|
||||
*/
|
||||
private Integer maxLength;
|
||||
/**
|
||||
* 是否对参数进行编码
|
||||
* 默认 false
|
||||
*/
|
||||
private Boolean encode = false;
|
||||
}
|
||||
|
|
|
@ -165,6 +165,7 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
|
|||
|
||||
/**
|
||||
* 添加场景和环境变量
|
||||
*
|
||||
* @param msHTTPElement
|
||||
* @param envInfo
|
||||
*/
|
||||
|
|
|
@ -51,7 +51,6 @@ public abstract class MsBodyConverter<T> {
|
|||
value = StringUtils.EMPTY;
|
||||
}
|
||||
HTTPArgument httpArgument = new HTTPArgument(kv.getKey(), value);
|
||||
httpArgument.setAlwaysEncoded(kv.getEncode());
|
||||
arguments.addArgument(httpArgument);
|
||||
if (kv instanceof FormDataKV formDataKV && formDataKV.getContentType() != null) {
|
||||
httpArgument.setContentType(formDataKV.getContentType());
|
||||
|
|
|
@ -97,7 +97,7 @@ public class ApiDebugService extends MoveNodeService {
|
|||
ApiDebug apiDebug = new ApiDebug();
|
||||
BeanUtils.copyBean(apiDebug, request);
|
||||
apiDebug.setCreateUser(createUser);
|
||||
checkAddExist(apiDebug);
|
||||
checkAddExist(apiDebug, createUser);
|
||||
apiDebug.setId(IDGenerator.nextStr());
|
||||
apiDebug.setCreateTime(System.currentTimeMillis());
|
||||
apiDebug.setUpdateTime(System.currentTimeMillis());
|
||||
|
@ -141,7 +141,7 @@ public class ApiDebugService extends MoveNodeService {
|
|||
checkResourceExist(request.getId());
|
||||
ApiDebug apiDebug = BeanUtils.copyBean(new ApiDebug(), request);
|
||||
ApiDebug originApiDebug = apiDebugMapper.selectByPrimaryKey(request.getId());
|
||||
checkUpdateExist(apiDebug, originApiDebug);
|
||||
checkUpdateExist(apiDebug, originApiDebug, updateUser);
|
||||
apiDebug.setUpdateUser(updateUser);
|
||||
apiDebug.setUpdateTime(System.currentTimeMillis());
|
||||
apiDebugMapper.updateByPrimaryKeySelective(apiDebug);
|
||||
|
@ -179,23 +179,25 @@ public class ApiDebugService extends MoveNodeService {
|
|||
apiDebugBlobMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
private void checkAddExist(ApiDebug apiDebug) {
|
||||
private void checkAddExist(ApiDebug apiDebug, String userId) {
|
||||
ApiDebugExample example = new ApiDebugExample();
|
||||
example.createCriteria()
|
||||
.andNameEqualTo(apiDebug.getName())
|
||||
.andCreateUserEqualTo(userId)
|
||||
.andModuleIdEqualTo(apiDebug.getModuleId());
|
||||
if (CollectionUtils.isNotEmpty(apiDebugMapper.selectByExample(example))) {
|
||||
throw new MSException(API_DEBUG_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpdateExist(ApiDebug apiDebug, ApiDebug originApiDebug) {
|
||||
private void checkUpdateExist(ApiDebug apiDebug, ApiDebug originApiDebug, String userId) {
|
||||
if (StringUtils.isBlank(apiDebug.getName())) {
|
||||
return;
|
||||
}
|
||||
ApiDebugExample example = new ApiDebugExample();
|
||||
example.createCriteria()
|
||||
.andIdNotEqualTo(apiDebug.getId())
|
||||
.andCreateUserEqualTo(userId)
|
||||
.andModuleIdEqualTo(apiDebug.getModuleId() == null ? originApiDebug.getModuleId() : apiDebug.getModuleId())
|
||||
.andNameEqualTo(apiDebug.getName());
|
||||
if (CollectionUtils.isNotEmpty(apiDebugMapper.selectByExample(example))) {
|
||||
|
@ -238,7 +240,7 @@ public class ApiDebugService extends MoveNodeService {
|
|||
if (!StringUtils.equals(request.getModuleId(), apiDebug.getModuleId())) {
|
||||
checkModuleExist(request.getModuleId());
|
||||
apiDebug.setModuleId(request.getModuleId());
|
||||
checkUpdateExist(apiDebug, apiDebug);
|
||||
checkUpdateExist(apiDebug, apiDebug, userId);
|
||||
apiDebug.setUpdateUser(userId);
|
||||
apiDebug.setUpdateTime(System.currentTimeMillis());
|
||||
apiDebugMapper.updateByPrimaryKeySelective(apiDebug);
|
||||
|
|
|
@ -205,6 +205,9 @@ public class ApiDebugControllerTests extends BaseTest {
|
|||
assertUploadFile(resultData.getId(), List.of(uploadFileId));
|
||||
assertLinkFile(resultData.getId(), List.of(fileMetadataId));
|
||||
|
||||
// 校验不同用户的重名校验
|
||||
apiDebugService.add(request, "userA");
|
||||
|
||||
// 再插入一条数据,便于修改时重名校验
|
||||
request.setName("test1");
|
||||
request.setUploadFileIds(null);
|
||||
|
@ -251,6 +254,7 @@ public class ApiDebugControllerTests extends BaseTest {
|
|||
request.setUnLinkFileIds(List.of(fileMetadataId));
|
||||
request.setDeleteFileIds(List.of(uploadFileId));
|
||||
this.requestPostWithOk(DEFAULT_UPDATE, request);
|
||||
|
||||
// 校验请求成功数据
|
||||
assertUpdateApiDebug(request, msHttpElement, request.getId());
|
||||
assertUploadFile(addApiDebug.getId(), List.of());
|
||||
|
|
|
@ -15,7 +15,6 @@ import io.metersphere.api.parser.TestElementParserFactory;
|
|||
import io.metersphere.api.utils.ApiDataUtils;
|
||||
import io.metersphere.plugin.api.dto.ParameterConfig;
|
||||
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||
import io.metersphere.project.api.KeyValueEnableParam;
|
||||
import io.metersphere.project.api.KeyValueParam;
|
||||
import io.metersphere.project.api.assertion.*;
|
||||
import io.metersphere.project.api.assertion.body.*;
|
||||
|
@ -61,7 +60,6 @@ public class MsHTTPElementTest {
|
|||
FormDataKV formDataKV = new FormDataKV();
|
||||
formDataKV.setEnable(false);
|
||||
formDataKV.setContentType("text/plain");
|
||||
formDataKV.setEncode(true);
|
||||
formDataKV.setMaxLength(10);
|
||||
formDataKV.setMinLength(8);
|
||||
formDataKV.setDescription("test");
|
||||
|
|
Loading…
Reference in New Issue