mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-04 04:59:48 +08:00
fix(项目管理): 修复上传jar文件且开启启用时没有成功启用jar文件的缺陷
【【文件管理】-上传jar文件,开启启用开关,上传完成后,文件状态为禁用】 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001035154
This commit is contained in:
parent
29fc604d6b
commit
2a9b9d3e59
@ -130,7 +130,7 @@ CREATE TABLE IF NOT EXISTS file_module
|
|||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
||||||
`name` VARCHAR(64) NOT NULL COMMENT '模块名称',
|
`name` VARCHAR(255) NOT NULL COMMENT '模块名称',
|
||||||
`parent_id` VARCHAR(50) COMMENT '父级ID',
|
`parent_id` VARCHAR(50) COMMENT '父级ID',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#commons
|
#commons
|
||||||
error_lang_invalid=语言参数错误
|
error_lang_invalid=语言参数错误
|
||||||
file_cannot_be_null=文件不能为空!
|
file_cannot_be_null=文件不能为空!
|
||||||
|
length.too.large=长度过长
|
||||||
cannot_be_null=不能为空
|
cannot_be_null=不能为空
|
||||||
number=第
|
number=第
|
||||||
row=行
|
row=行
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#commons
|
#commons
|
||||||
error_lang_invalid=Invalid language parameter
|
error_lang_invalid=Invalid language parameter
|
||||||
file_cannot_be_null=File cannot be empty!
|
file_cannot_be_null=File cannot be empty!
|
||||||
|
length.too.large=too large
|
||||||
cannot_be_null=\tCannot be empty
|
cannot_be_null=\tCannot be empty
|
||||||
number=Number
|
number=Number
|
||||||
row=row
|
row=row
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#commons
|
#commons
|
||||||
error_lang_invalid=语言参数错误
|
error_lang_invalid=语言参数错误
|
||||||
file_cannot_be_null=文件不能为空!
|
file_cannot_be_null=文件不能为空!
|
||||||
|
length.too.large=长度过长
|
||||||
cannot_be_null=不能为空
|
cannot_be_null=不能为空
|
||||||
number=第
|
number=第
|
||||||
row=行
|
row=行
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#commons
|
#commons
|
||||||
error_lang_invalid=語言參數錯誤
|
error_lang_invalid=語言參數錯誤
|
||||||
file_cannot_be_null=文件不能為空!
|
file_cannot_be_null=文件不能為空!
|
||||||
|
length.too.large=長度過長
|
||||||
cannot_be_null=不能為空
|
cannot_be_null=不能為空
|
||||||
number=第
|
number=第
|
||||||
row=行
|
row=行
|
||||||
|
@ -23,6 +23,7 @@ public class FileRepositoryCreateRequest {
|
|||||||
|
|
||||||
@Schema(description = "存储库地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "存储库地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{file_repository.url.not_blank}")
|
@NotBlank(message = "{file_repository.url.not_blank}")
|
||||||
|
@Size(min = 1, max = 255, message = "Url " + "{length.too.large}")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Schema(description = "存储库token", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "存储库token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ -176,7 +176,7 @@ public class FileMetadataService {
|
|||||||
fileMetadata.setPath(filePath);
|
fileMetadata.setPath(filePath);
|
||||||
fileMetadata.setLatest(true);
|
fileMetadata.setLatest(true);
|
||||||
fileMetadata.setRefId(fileMetadata.getId());
|
fileMetadata.setRefId(fileMetadata.getId());
|
||||||
fileMetadata.setEnable(false);
|
fileMetadata.setEnable(enable);
|
||||||
return fileMetadata;
|
return fileMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,6 +503,9 @@ public class FileManagementControllerTests extends BaseTest {
|
|||||||
LOG_CHECK_LIST.add(
|
LOG_CHECK_LIST.add(
|
||||||
new CheckLogModel(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD)
|
new CheckLogModel(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD)
|
||||||
);
|
);
|
||||||
|
//判断数据库里启用状态是否正确
|
||||||
|
FileMetadata jarFileMeta = fileMetadataMapper.selectByPrimaryKey(returnId);
|
||||||
|
Assertions.assertEquals(jarFileMeta.getEnable(), fileUploadRequest.isEnable());
|
||||||
FILE_ID_PATH.put(returnId, filePath);
|
FILE_ID_PATH.put(returnId, filePath);
|
||||||
jarFileId = returnId;
|
jarFileId = returnId;
|
||||||
uploadedFileTypes.add("jar");
|
uploadedFileTypes.add("jar");
|
||||||
@ -519,6 +522,9 @@ public class FileManagementControllerTests extends BaseTest {
|
|||||||
LOG_CHECK_LIST.add(
|
LOG_CHECK_LIST.add(
|
||||||
new CheckLogModel(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD)
|
new CheckLogModel(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD)
|
||||||
);
|
);
|
||||||
|
//判断数据库里启用状态是否正确
|
||||||
|
jarFileMeta = fileMetadataMapper.selectByPrimaryKey(returnId);
|
||||||
|
Assertions.assertEquals(jarFileMeta.getEnable(), fileUploadRequest.isEnable());
|
||||||
FILE_ID_PATH.put(returnId, filePath);
|
FILE_ID_PATH.put(returnId, filePath);
|
||||||
fileUploadRequest.setEnable(false);
|
fileUploadRequest.setEnable(false);
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
|
import org.springframework.test.web.servlet.ResultActions;
|
||||||
import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils;
|
import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -156,10 +157,31 @@ public class FileRepositoryControllerTest extends BaseTest {
|
|||||||
FileRepositoryCreateRequest createRequest = new FileRepositoryCreateRequest();
|
FileRepositoryCreateRequest createRequest = new FileRepositoryCreateRequest();
|
||||||
createRequest.setProjectId(project.getId());
|
createRequest.setProjectId(project.getId());
|
||||||
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEA);
|
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEA);
|
||||||
createRequest.setUrl(GITEA_URL);
|
|
||||||
createRequest.setToken(GITEA_TOKEN);
|
createRequest.setToken(GITEA_TOKEN);
|
||||||
createRequest.setName("GITEA存储库");
|
createRequest.setUrl(GITEA_URL);
|
||||||
|
//先测试名称长度过长 和 url过长
|
||||||
|
StringBuilder repositoryName = new StringBuilder();
|
||||||
|
while (repositoryName.length() < 256) {
|
||||||
|
repositoryName.append("t");
|
||||||
|
}
|
||||||
|
createRequest.setName(repositoryName.toString());
|
||||||
|
ResultActions badRequestAction = this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest);
|
||||||
|
badRequestAction.andExpect(status().isBadRequest());
|
||||||
|
ResultHolder badRequestHolder = JSON.parseObject(badRequestAction.andReturn().getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class);
|
||||||
|
Assertions.assertFalse(StringUtils.contains(badRequestHolder.getMessage(), "Exception"));
|
||||||
|
|
||||||
|
StringBuilder repositoryTestUrl = new StringBuilder();
|
||||||
|
while (repositoryTestUrl.length() < 256) {
|
||||||
|
repositoryTestUrl.append("t");
|
||||||
|
}
|
||||||
|
createRequest.setName("GITEA存储库");
|
||||||
|
createRequest.setUrl(repositoryTestUrl.toString());
|
||||||
|
badRequestAction = this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest);
|
||||||
|
badRequestHolder = JSON.parseObject(badRequestAction.andReturn().getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class);
|
||||||
|
Assertions.assertFalse(StringUtils.contains(badRequestHolder.getMessage(), "Exception"));
|
||||||
|
|
||||||
|
createRequest.setName("GITEA存储库");
|
||||||
|
createRequest.setUrl(GITEA_URL);
|
||||||
MvcResult result = this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest);
|
MvcResult result = this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest);
|
||||||
String returnStr = result.getResponse().getContentAsString();
|
String returnStr = result.getResponse().getContentAsString();
|
||||||
ResultHolder rh = JSON.parseObject(returnStr, ResultHolder.class);
|
ResultHolder rh = JSON.parseObject(returnStr, ResultHolder.class);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package io.metersphere.system.config.interceptor;
|
package io.metersphere.system.config.interceptor;
|
||||||
|
|
||||||
import io.metersphere.project.domain.CustomFunctionBlob;
|
import io.metersphere.project.domain.CustomFunctionBlob;
|
||||||
import io.metersphere.project.domain.FileMetadataRepository;
|
import io.metersphere.project.domain.FileModuleRepository;
|
||||||
import io.metersphere.sdk.util.CompressUtils;
|
import io.metersphere.sdk.util.CompressUtils;
|
||||||
|
import io.metersphere.sdk.util.EncryptUtils;
|
||||||
import io.metersphere.system.utils.MybatisInterceptorConfig;
|
import io.metersphere.system.utils.MybatisInterceptorConfig;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -16,7 +17,7 @@ public class ProjectInterceptor {
|
|||||||
public List<MybatisInterceptorConfig> projectCompressConfigs() {
|
public List<MybatisInterceptorConfig> projectCompressConfigs() {
|
||||||
List<MybatisInterceptorConfig> configList = new ArrayList<>();
|
List<MybatisInterceptorConfig> configList = new ArrayList<>();
|
||||||
|
|
||||||
configList.add(new MybatisInterceptorConfig(FileMetadataRepository.class, "gitInfo", CompressUtils.class, "zip", "unzip"));
|
configList.add(new MybatisInterceptorConfig(FileModuleRepository.class, "token", EncryptUtils.class, "aesEncrypt", "aesDecrypt"));
|
||||||
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "script", CompressUtils.class, "zip", "unzip"));
|
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "script", CompressUtils.class, "zip", "unzip"));
|
||||||
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "result", CompressUtils.class, "zip", "unzip"));
|
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "result", CompressUtils.class, "zip", "unzip"));
|
||||||
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "params", CompressUtils.class, "zip", "unzip"));
|
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "params", CompressUtils.class, "zip", "unzip"));
|
||||||
|
Loading…
Reference in New Issue
Block a user