refactor(系统设置): 优化组织服务集成测试连接接口
--bug=1035416 --user=宋昌昌 【系统设置】组织-服务集成,JIRA编辑状态提示没有权限,在预览界面课程正常测试链接 https://www.tapd.cn/55049933/s/1465706
This commit is contained in:
parent
51c7327727
commit
8bdd2cd2d3
|
@ -33,6 +33,6 @@ public class BugFileDTO {
|
|||
@Schema(description = "创建人")
|
||||
private String createUser;
|
||||
|
||||
@Schema(description = "是否关联")
|
||||
private Boolean associated;
|
||||
@Schema(description = "是否本地文件")
|
||||
private Boolean local;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class BugAttachmentService {
|
|||
if (!CollectionUtils.isEmpty(bugLocalAttachments)) {
|
||||
bugLocalAttachments.forEach(localFile -> {
|
||||
BugFileDTO localFileDTO = BugFileDTO.builder().refId(localFile.getId()).fileId(localFile.getFileId()).fileName(localFile.getFileName()).fileType(getLocalFileType(localFile.getFileName()))
|
||||
.fileSize(localFile.getSize()).createTime(localFile.getCreateTime()).createUser(localFile.getCreateUser()).associated(false).build();
|
||||
.fileSize(localFile.getSize()).createTime(localFile.getCreateTime()).createUser(localFile.getCreateUser()).local(true).build();
|
||||
bugFiles.add(localFileDTO);
|
||||
});
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class BugAttachmentService {
|
|||
FileMetadata associatedFileMetadata = fileMetadataMap.get(associatedFile.getFileId());
|
||||
BugFileDTO associatedFileDTO = BugFileDTO.builder().refId(associatedFile.getId()).fileId(associatedFile.getFileId()).fileName(associatedFileMetadata.getName() + "." + associatedFileMetadata.getType())
|
||||
.fileType(associatedFileMetadata.getType()).fileSize(associatedFileMetadata.getSize()).createTime(associatedFileMetadata.getCreateTime())
|
||||
.createUser(associatedFileMetadata.getCreateUser()).associated(true).build();
|
||||
.createUser(associatedFileMetadata.getCreateUser()).local(false).build();
|
||||
bugFiles.add(associatedFileDTO);
|
||||
});
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ public class BugAttachmentService {
|
|||
List<String> unLinkIds = new ArrayList<>();
|
||||
List<String> deleteLocalIds = new ArrayList<>();
|
||||
deleteMsAttachments.forEach(deleteMsFile -> {
|
||||
if (deleteMsFile.getAssociated()) {
|
||||
if (!deleteMsFile.getLocal()) {
|
||||
unLinkIds.add(deleteMsFile.getRefId());
|
||||
} else {
|
||||
deleteLocalIds.add(deleteMsFile.getRefId());
|
||||
|
|
|
@ -139,7 +139,7 @@ public class BugAttachmentControllerTests extends BaseTest {
|
|||
List<BugFileDTO> files = getBugFiles("default-attachment-bug-id");
|
||||
files.forEach(file -> {
|
||||
request.setFileId(file.getFileId());
|
||||
request.setAssociated(file.getAssociated());
|
||||
request.setAssociated(!file.getLocal());
|
||||
try {
|
||||
this.requestPostDownloadFile(BUG_ATTACHMENT_PREVIEW, null, request);
|
||||
this.requestPostDownloadFile(BUG_ATTACHMENT_DOWNLOAD, null, request);
|
||||
|
@ -161,9 +161,9 @@ public class BugAttachmentControllerTests extends BaseTest {
|
|||
request.setFileId("not-exist-file-id");
|
||||
this.requestPost(BUG_ATTACHMENT_TRANSFER, request).andExpect(status().is5xxServerError());
|
||||
List<BugFileDTO> files = getBugFiles("default-attachment-bug-id");
|
||||
files.stream().filter(file -> !file.getAssociated()).forEach(file -> {
|
||||
files.stream().filter(BugFileDTO::getLocal).forEach(file -> {
|
||||
request.setFileId(file.getFileId());
|
||||
request.setAssociated(file.getAssociated());
|
||||
request.setAssociated(!file.getLocal());
|
||||
try {
|
||||
this.requestPostWithOk(BUG_ATTACHMENT_TRANSFER, request);
|
||||
} catch (Exception e) {
|
||||
|
@ -191,7 +191,7 @@ public class BugAttachmentControllerTests extends BaseTest {
|
|||
}
|
||||
});
|
||||
List<BugFileDTO> tapdFiles = getBugFiles("default-bug-id-tapd");
|
||||
tapdFiles.stream().filter(BugFileDTO::getAssociated).forEach(file -> {
|
||||
tapdFiles.stream().filter(file -> !file.getLocal()).forEach(file -> {
|
||||
try {
|
||||
request.setBugId("default-bug-id-tapd");
|
||||
request.setRefId(file.getRefId());
|
||||
|
@ -212,7 +212,7 @@ public class BugAttachmentControllerTests extends BaseTest {
|
|||
request.setBugId("default-attachment-bug-id");
|
||||
request.setProjectId("default-project-for-attachment");
|
||||
request.setRefId(file.getRefId());
|
||||
request.setAssociated(file.getAssociated());
|
||||
request.setAssociated(!file.getLocal());
|
||||
try {
|
||||
this.requestPostWithOk(BUG_ATTACHMENT_DELETE, request);
|
||||
} catch (Exception e) {
|
||||
|
@ -225,7 +225,7 @@ public class BugAttachmentControllerTests extends BaseTest {
|
|||
request.setBugId("default-bug-id-tapd");
|
||||
request.setProjectId("default-project-for-attachment");
|
||||
request.setRefId(file.getRefId());
|
||||
request.setAssociated(file.getAssociated());
|
||||
request.setAssociated(!file.getLocal());
|
||||
try {
|
||||
this.requestPost(BUG_ATTACHMENT_DELETE, request).andExpect(status().is5xxServerError());
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.domain.ServiceIntegration;
|
||||
import io.metersphere.system.dto.ServiceIntegrationDTO;
|
||||
import io.metersphere.system.dto.request.ServiceIntegrationUpdateRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.service.ServiceIntegrationLogService;
|
||||
import io.metersphere.system.service.ServiceIntegrationService;
|
||||
import io.metersphere.validation.groups.Created;
|
||||
|
@ -65,16 +65,17 @@ public class ServiceIntegrationController {
|
|||
serviceIntegrationService.delete(id);
|
||||
}
|
||||
|
||||
@PostMapping("/validate/{pluginId}")
|
||||
@PostMapping("/validate/{pluginId}/{orgId}")
|
||||
@Operation(summary = "系统设置-组织-服务集成-校验服务集成信息")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_SERVICE_INTEGRATION_UPDATE)
|
||||
public void validate(@PathVariable String pluginId,
|
||||
@PathVariable String orgId,
|
||||
@Validated({Updated.class})
|
||||
@RequestBody
|
||||
@NotEmpty
|
||||
@Schema(description = "配置的表单键值对", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
HashMap<String, String> serviceIntegrationInfo) {
|
||||
serviceIntegrationService.validate(pluginId, serviceIntegrationInfo);
|
||||
serviceIntegrationService.validate(pluginId, orgId, serviceIntegrationInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/validate/{id}")
|
||||
|
|
|
@ -15,7 +15,6 @@ import io.metersphere.system.uid.IDGenerator;
|
|||
import io.metersphere.system.utils.ServiceUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -127,9 +126,9 @@ public class ServiceIntegrationService {
|
|||
}
|
||||
}
|
||||
|
||||
public void validate(String pluginId, Map<String, String> serviceIntegrationInfo) {
|
||||
public void validate(String pluginId, String orgId, Map<String, String> serviceIntegrationInfo) {
|
||||
pluginService.checkResourceExist(pluginId);
|
||||
Platform platform = platformPluginService.getPlatform(pluginId, StringUtils.EMPTY, JSON.toJSONString(serviceIntegrationInfo));
|
||||
Platform platform = platformPluginService.getPlatform(pluginId, orgId, JSON.toJSONString(serviceIntegrationInfo));
|
||||
platform.validateIntegrationConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ import io.metersphere.system.domain.Organization;
|
|||
import io.metersphere.system.domain.Plugin;
|
||||
import io.metersphere.system.domain.ServiceIntegration;
|
||||
import io.metersphere.system.dto.ServiceIntegrationDTO;
|
||||
import io.metersphere.system.dto.request.ServiceIntegrationUpdateRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.PluginMapper;
|
||||
import io.metersphere.system.mapper.ServiceIntegrationMapper;
|
||||
import io.metersphere.system.dto.request.ServiceIntegrationUpdateRequest;
|
||||
import io.metersphere.system.service.OrganizationService;
|
||||
import io.metersphere.system.service.PluginLoadService;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -48,7 +48,7 @@ public class ServiceIntegrationControllerTests extends BaseTest {
|
|||
private static final String BASE_PATH = "/service/integration/";
|
||||
private static final String LIST = "/list/{0}";
|
||||
private static final String VALIDATE_GET = "/validate/{0}";
|
||||
private static final String VALIDATE_POST = "/validate/{0}";
|
||||
private static final String VALIDATE_POST = "/validate/{0}/{1}";
|
||||
private static final String SCRIPT_GET = "/script/{0}";
|
||||
private static ServiceIntegration addServiceIntegration;
|
||||
private static Organization defaultOrg;
|
||||
|
@ -250,22 +250,22 @@ public class ServiceIntegrationControllerTests extends BaseTest {
|
|||
integrationConfig.setAddress(String.format("http://%s:%s", mockServerHost, mockServerHostPort));
|
||||
Map<String, Object> integrationConfigMap = JSON.parseMap(JSON.toJSONString(integrationConfig));
|
||||
// @@请求成功
|
||||
this.requestPostWithOk(VALIDATE_POST, integrationConfigMap, plugin.getId());
|
||||
this.requestPostWithOk(VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId());
|
||||
|
||||
// @@校验插件禁用
|
||||
setPluginEnable(addServiceIntegration.getPluginId(), false);
|
||||
assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId()), PLUGIN_ENABLE);
|
||||
assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId()), PLUGIN_ENABLE);
|
||||
setPluginEnable(addServiceIntegration.getPluginId(), true);
|
||||
|
||||
// @@校验权限
|
||||
setPluginGlobal(addServiceIntegration.getPluginId(), false);
|
||||
assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId()), PLUGIN_PERMISSION);
|
||||
assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId()), PLUGIN_PERMISSION);
|
||||
setPluginGlobal(addServiceIntegration.getPluginId(), true);
|
||||
|
||||
// @@校验 NOT_FOUND 异常
|
||||
assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, "1111"), NOT_FOUND);
|
||||
assertErrorCode(this.requestPost(VALIDATE_POST, integrationConfigMap, "1111", defaultOrg.getId()), NOT_FOUND);
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_SERVICE_INTEGRATION_UPDATE, VALIDATE_POST, integrationConfigMap, plugin.getId());
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_SERVICE_INTEGRATION_UPDATE, VALIDATE_POST, integrationConfigMap, plugin.getId(), defaultOrg.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
const formValue = {
|
||||
...fApi.value.formData(),
|
||||
};
|
||||
await postValidate(formValue, pluginId.value);
|
||||
await postValidate(formValue, `${pluginId.value}/${lastOrganizationId}`);
|
||||
if (!isConfigOrigin.value) isDisabled.value = false;
|
||||
Message.success(t('organization.service.successMessage'));
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue