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