feat(项目管理): 增加环境设置
This commit is contained in:
parent
cd108b14be
commit
803a852676
|
@ -1,25 +0,0 @@
|
|||
package io.metersphere.sdk.dto.environment;
|
||||
|
||||
|
||||
import io.metersphere.sdk.constants.StorageType;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Data
|
||||
public class BodyFile {
|
||||
private String id;
|
||||
private String name;
|
||||
// LOCAL 和 引用(FILE_REF) / GIT
|
||||
private String storage;
|
||||
private String fileId;
|
||||
private String projectId;
|
||||
private String fileType;
|
||||
// 正常/已删除
|
||||
private String status;
|
||||
// 调试附件处理
|
||||
private String refResourceId;
|
||||
|
||||
public boolean isRef() {
|
||||
return StringUtils.equals(storage, StorageType.FILE_REF.name()) && StringUtils.isNotEmpty(fileId);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package io.metersphere.sdk.dto.environment.script;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApiScript {
|
||||
@Schema(description = "环境级")
|
||||
private ScriptContent envJSR223PostScript;
|
||||
@Schema(description = "场景级")
|
||||
private ScenarioPostScript scenarioJSR223PostScript;
|
||||
@Schema(description = "步骤级")
|
||||
private StepPostScript stepJSR223PostScript;
|
||||
|
||||
|
||||
}
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
class ScenarioPostScript extends ScriptContent {
|
||||
|
||||
@Schema(description = "关联场景结果 true: 是/false: 否")
|
||||
private Boolean associateScenarioResults = false;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
class StepPostScript extends ScriptContent{
|
||||
|
||||
@Schema(description = "忽略请求")
|
||||
private List<String> filterRequestPostScript;
|
||||
@Schema(description = "脚本执行顺序 true:先执行 false:后执行")
|
||||
private Boolean preScriptExecBefore = true;
|
||||
@Schema(description = "脚本内容")
|
||||
private ScriptContent scriptContent;
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package io.metersphere.sdk.dto.environment.script;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ScriptContent {
|
||||
|
||||
@Schema(description = "脚本内容")
|
||||
private String script;
|
||||
@Schema(description = "脚本语言")
|
||||
private String scriptLanguage;
|
||||
@Schema(description = "是否是jsr223")
|
||||
private Boolean jsrEnable;
|
||||
|
||||
}
|
|
@ -450,4 +450,5 @@ template.functional_default=Default
|
|||
|
||||
global_parameters_already_exist=Global parameters already exist
|
||||
global_parameters_is_not_exist=Global parameters is not exist
|
||||
api_test_environment_not_exist=Environment is not exist
|
||||
|
||||
|
|
|
@ -447,4 +447,5 @@ custom_field.functional_priority=优先级
|
|||
template.functional_default=默认模板
|
||||
|
||||
global_parameters_already_exist=全局参数已存在
|
||||
global_parameters_is_not_exist=全局参数不存在
|
||||
global_parameters_is_not_exist=全局参数不存在
|
||||
api_test_environment_not_exist=环境不存在
|
|
@ -447,3 +447,4 @@ template.functional_default=默認模板
|
|||
|
||||
global_parameters_already_exist=全局參數已存在
|
||||
global_parameters_is_not_exist=全局參數不存在
|
||||
api_test_environment_not_exist=環境不存在
|
|
@ -129,3 +129,11 @@ permission.project_application_api.read=API test read
|
|||
permission.project_application_api.update=API test update
|
||||
permission.project_base_info.name=Project base info
|
||||
permission.project_log.name=Operation log
|
||||
|
||||
#environment datasource
|
||||
environment_datasource.id.not_blank=ID is required
|
||||
environment_datasource.driver.not_blank=Driver is required
|
||||
environment_datasource.driverId.not_blank=Driver ID is required
|
||||
environment_datasource.dbUrl.not_blank=Db Url is required
|
||||
environment_name_is_null=Environment name is required
|
||||
environment_config_is_null=Environment config is required
|
||||
|
|
|
@ -129,3 +129,11 @@ permission.project_application_api.read=接口测试-查询
|
|||
permission.project_application_api.update=接口测试-编辑
|
||||
permission.project_base_info.name=基本信息
|
||||
permission.project_log.name=日志
|
||||
|
||||
#environment datasource
|
||||
environment_datasource.id.not_blank=ID不能为空
|
||||
environment_datasource.driver.not_blank=驱动不能为空
|
||||
environment_datasource.driverId.not_blank=驱动ID不能为空
|
||||
environment_datasource.dbUrl.not_blank=数据库连接不能为空
|
||||
environment_name_is_null=环境名称不能为空
|
||||
environment_config_is_null=环境配置不能为空
|
||||
|
|
|
@ -128,4 +128,12 @@ permission.project_application_performance_test.update=性能測試-編輯
|
|||
permission.project_application_api.read=接口測試-查詢
|
||||
permission.project_application_api.update=接口測試-編輯
|
||||
permission.project_base_info.name=基本信息
|
||||
permission.project_log.name=日誌
|
||||
permission.project_log.name=日誌
|
||||
|
||||
#environment datasource
|
||||
environment_datasource.id.not_blank=ID不能為空
|
||||
environment_datasource.driver.not_blank=驅動不能為空
|
||||
environment_datasource.driverId.not_blank=驅動ID不能為空
|
||||
environment_datasource.dbUrl.not_blank=數據庫地址不能為空
|
||||
environment_name_is_null=環境名稱不能為空
|
||||
environment_config_is_null=環境配置不能為空
|
|
@ -1,21 +1,29 @@
|
|||
package io.metersphere.system.controller.environment;
|
||||
package io.metersphere.project.controller;
|
||||
|
||||
import io.metersphere.project.dto.environment.EnvironmentRequest;
|
||||
import io.metersphere.project.dto.environment.datasource.DataSource;
|
||||
import io.metersphere.project.dto.environment.ssl.KeyStoreEntry;
|
||||
import io.metersphere.project.service.CommandService;
|
||||
import io.metersphere.project.service.EnvironmentLogService;
|
||||
import io.metersphere.project.service.EnvironmentService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.environment.EnvironmentConfigRequest;
|
||||
import io.metersphere.sdk.dto.environment.dataSource.DataSource;
|
||||
import io.metersphere.system.service.environment.EnvironmentService;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
@ -25,6 +33,8 @@ public class EnvironmentController {
|
|||
|
||||
@Resource
|
||||
private EnvironmentService environmentService;
|
||||
@Resource
|
||||
private CommandService commandService;
|
||||
|
||||
@GetMapping("/list/{projectId}")
|
||||
@Operation(summary = "项目管理-环境-环境目录-列表")
|
||||
|
@ -36,7 +46,7 @@ public class EnvironmentController {
|
|||
@GetMapping("/get/{environmentId}")
|
||||
@Operation(summary = "项目管理-环境-环境目录-详情")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ)
|
||||
public EnvironmentConfigRequest get(@PathVariable String environmentId) {
|
||||
public EnvironmentRequest get(@PathVariable String environmentId) {
|
||||
return environmentService.get(environmentId);
|
||||
}
|
||||
|
||||
|
@ -44,35 +54,39 @@ public class EnvironmentController {
|
|||
@PostMapping("/add")
|
||||
@Operation(summary = "项目管理-环境-环境目录-新增")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_ADD)
|
||||
public EnvironmentConfigRequest add(@Validated({Created.class}) @RequestBody EnvironmentConfigRequest environmentConfigRequest,
|
||||
@RequestPart(value = "files", required = false) List<MultipartFile> sslFiles) {
|
||||
return environmentService.add(environmentConfigRequest, SessionUtils.getUserId(), sslFiles);
|
||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = EnvironmentLogService.class)
|
||||
public EnvironmentRequest add(@Validated({Created.class}) @RequestPart(value = "request") EnvironmentRequest request,
|
||||
@RequestPart(value = "file", required = false) List<MultipartFile> sslFiles) {
|
||||
return environmentService.add(request, SessionUtils.getUserId(), sslFiles);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_UPDATE)
|
||||
@Operation(summary = "项目管理-环境-环境目录-修改")
|
||||
public void update() {
|
||||
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = EnvironmentLogService.class)
|
||||
public EnvironmentRequest update(@Validated({Updated.class}) @RequestPart("request") EnvironmentRequest request,
|
||||
@RequestPart(value = "file", required = false) List<MultipartFile> sslFiles) {
|
||||
return environmentService.update(request, SessionUtils.getUserId(), sslFiles);
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
@GetMapping("/delete/{id}")
|
||||
@Operation(summary = "项目管理-环境-环境目录-删除")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_DELETE)
|
||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#id)", msClass = EnvironmentLogService.class)
|
||||
public void delete(@PathVariable String id) {
|
||||
environmentService.delete(id);
|
||||
}
|
||||
|
||||
@PostMapping("/database/validate")
|
||||
@Operation(summary = "项目管理-环境-数据库配置-校验")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ)
|
||||
public void validate(@RequestBody DataSource databaseConfig) {
|
||||
@RequiresPermissions(value = {PermissionConstants.PROJECT_ENVIRONMENT_READ, PermissionConstants.PROJECT_ENVIRONMENT_READ_ADD, PermissionConstants.PROJECT_ENVIRONMENT_READ_UPDATE}, logical = Logical.OR)
|
||||
public void validate(@Validated @RequestBody DataSource databaseConfig) {
|
||||
environmentService.validateDataSource(databaseConfig);
|
||||
}
|
||||
|
||||
@GetMapping("/database/driver-options/{organizationId}")
|
||||
@Operation(summary = "项目管理-环境-数据库配置-数据库驱动选项")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ)
|
||||
@RequiresPermissions(value = {PermissionConstants.PROJECT_ENVIRONMENT_READ, PermissionConstants.PROJECT_ENVIRONMENT_READ_ADD, PermissionConstants.PROJECT_ENVIRONMENT_READ_UPDATE}, logical = Logical.OR)
|
||||
public List<OptionDTO> driverOptions(@PathVariable String organizationId) {
|
||||
return environmentService.getDriverOptions(organizationId);
|
||||
}
|
||||
|
@ -87,8 +101,14 @@ public class EnvironmentController {
|
|||
@PostMapping("/export")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_EXPORT)
|
||||
@Operation(summary = "项目管理-环境-环境目录-导出")
|
||||
public List<EnvironmentConfigRequest> export(@RequestBody List<String> environmentIds) {
|
||||
public String export(@RequestBody List<String> environmentIds) {
|
||||
return environmentService.export(environmentIds);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/get/entry")
|
||||
@RequiresPermissions(value = {PermissionConstants.PROJECT_ENVIRONMENT_READ_ADD, PermissionConstants.PROJECT_ENVIRONMENT_READ_UPDATE}, logical = Logical.OR)
|
||||
public List<KeyStoreEntry> getEntry(@RequestPart("request") String password, @RequestPart(value = "file") MultipartFile sslFiles) {
|
||||
return commandService.getEntry(password, sslFiles);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,13 @@
|
|||
package io.metersphere.system.controller.environment;
|
||||
package io.metersphere.project.controller;
|
||||
|
||||
import io.metersphere.project.dto.environment.GlobalParamsRequest;
|
||||
import io.metersphere.project.service.GlobalParamsLogService;
|
||||
import io.metersphere.project.service.GlobalParamsService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.environment.GlobalParamsRequest;
|
||||
import io.metersphere.system.service.environment.GlobalParamsService;
|
||||
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -24,15 +28,17 @@ public class GlobalParamsController {
|
|||
@PostMapping("/add")
|
||||
@Operation(summary = "项目管理-环境-全局参数-新增")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_ADD)
|
||||
public GlobalParamsRequest add(@Validated({Created.class}) @RequestBody GlobalParamsRequest globalParamsRequest) {
|
||||
return globalParamsService.add(globalParamsRequest, SessionUtils.getUserId());
|
||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = GlobalParamsLogService.class)
|
||||
public GlobalParamsRequest add(@Validated({Created.class}) @RequestBody GlobalParamsRequest request) {
|
||||
return globalParamsService.add(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "项目管理-环境-全局参数-修改")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_UPDATE)
|
||||
public GlobalParamsRequest update(@Validated({Updated.class}) @RequestBody GlobalParamsRequest globalParamsRequest) {
|
||||
return globalParamsService.update(globalParamsRequest, SessionUtils.getUserId());
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = GlobalParamsLogService.class)
|
||||
public GlobalParamsRequest update(@Validated({Updated.class}) @RequestBody GlobalParamsRequest request) {
|
||||
return globalParamsService.update(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/get/{projectId}")
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.project.dto.environment;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BodyFile {
|
||||
private String id;
|
||||
private String name;
|
||||
private String fileId;
|
||||
private String projectId;
|
||||
private String fileType;
|
||||
// 正常/已删除
|
||||
private String status;
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
package io.metersphere.sdk.dto.environment;
|
||||
package io.metersphere.project.dto.environment;
|
||||
|
||||
import io.metersphere.sdk.dto.environment.assertions.EnvironmentAssertions;
|
||||
import io.metersphere.sdk.dto.environment.authConfig.AuthConfig;
|
||||
import io.metersphere.sdk.dto.environment.common.CommonParams;
|
||||
import io.metersphere.sdk.dto.environment.dataSource.DataSource;
|
||||
import io.metersphere.sdk.dto.environment.hostConfig.HostConfig;
|
||||
import io.metersphere.sdk.dto.environment.httpConfig.HttpConfig;
|
||||
import io.metersphere.sdk.dto.environment.script.post.EnvironmentPostScript;
|
||||
import io.metersphere.sdk.dto.environment.script.pre.EnvironmentPreScript;
|
||||
import io.metersphere.sdk.dto.environment.ssl.KeyStoreConfig;
|
||||
import io.metersphere.sdk.dto.environment.tcpConfig.TCPConfig;
|
||||
import io.metersphere.sdk.dto.environment.variables.CommonVariables;
|
||||
import io.metersphere.project.dto.environment.assertions.EnvironmentAssertions;
|
||||
import io.metersphere.project.dto.environment.auth.AuthConfig;
|
||||
import io.metersphere.project.dto.environment.common.CommonParams;
|
||||
import io.metersphere.project.dto.environment.datasource.DataSource;
|
||||
import io.metersphere.project.dto.environment.host.HostConfig;
|
||||
import io.metersphere.project.dto.environment.http.HttpConfig;
|
||||
import io.metersphere.project.dto.environment.script.post.EnvironmentPostScript;
|
||||
import io.metersphere.project.dto.environment.script.pre.EnvironmentPreScript;
|
||||
import io.metersphere.project.dto.environment.ssl.KeyStoreConfig;
|
||||
import io.metersphere.project.dto.environment.tcp.TCPConfig;
|
||||
import io.metersphere.project.dto.environment.variables.CommonVariables;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
package io.metersphere.sdk.dto.environment;
|
||||
package io.metersphere.project.dto.environment;
|
||||
|
||||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -11,7 +12,7 @@ import java.io.Serial;
|
|||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class EnvironmentConfigRequest implements Serializable {
|
||||
public class EnvironmentRequest implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Schema(description = "ID")
|
||||
|
@ -19,14 +20,15 @@ public class EnvironmentConfigRequest implements Serializable {
|
|||
@Size(min = 1, max = 50, message = "{project_parameters.id.length_range}", groups = {Updated.class})
|
||||
private String id;
|
||||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{project_parameters.project_id.not_blank}", groups = {Created.class, Updated.class})
|
||||
@NotBlank(message = "{project_application.project_id.not_blank}", groups = {Created.class, Updated.class})
|
||||
@Size(min = 1, max = 50, message = "{project_parameters.project_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String projectId;
|
||||
@Schema(description = "环境名称")
|
||||
@NotBlank(message = "{project_parameters.project_id.not_blank}", groups = {Created.class, Updated.class})
|
||||
@NotBlank(message = "{environment_name_is_null}", groups = {Created.class, Updated.class})
|
||||
private String name;
|
||||
|
||||
@Schema(description = "环境配置")
|
||||
@NotNull(message = "{environment_config_is_null}", groups = {Created.class, Updated.class})
|
||||
private EnvironmentConfig config;
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package io.metersphere.sdk.dto.environment;
|
||||
package io.metersphere.project.dto.environment;
|
||||
|
||||
import io.metersphere.sdk.dto.environment.variables.CommonVariables;
|
||||
import io.metersphere.project.dto.environment.variables.CommonVariables;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GlobalParamsDTO implements Serializable {
|
||||
public class GlobalParams implements Serializable {
|
||||
|
||||
@Schema(description = "请求头")
|
||||
private List<KeyValue> headers;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment;
|
||||
package io.metersphere.project.dto.environment;
|
||||
|
||||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
|
@ -24,7 +24,7 @@ public class GlobalParamsRequest implements Serializable {
|
|||
private String projectId;
|
||||
|
||||
@Schema(description = "全局参数")
|
||||
private GlobalParamsDTO globalParams;
|
||||
private GlobalParams globalParams;
|
||||
|
||||
|
||||
@Serial
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment;
|
||||
package io.metersphere.project.dto.environment;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions;
|
||||
package io.metersphere.project.dto.environment.assertions;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions;
|
||||
package io.metersphere.project.dto.environment.assertions;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions;
|
||||
package io.metersphere.project.dto.environment.assertions;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions;
|
||||
package io.metersphere.project.dto.environment.assertions;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions;
|
||||
package io.metersphere.project.dto.environment.assertions;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions;
|
||||
package io.metersphere.project.dto.environment.assertions;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions;
|
||||
package io.metersphere.project.dto.environment.assertions;
|
||||
|
||||
import io.metersphere.sdk.dto.environment.assertions.document.MsAssertionDocument;
|
||||
import io.metersphere.sdk.dto.environment.httpConfig.ApplicationModule;
|
||||
import io.metersphere.project.dto.environment.assertions.document.MsAssertionDocument;
|
||||
import io.metersphere.project.dto.environment.http.ApplicationModule;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions.document;
|
||||
package io.metersphere.project.dto.environment.assertions.document;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions.document;
|
||||
package io.metersphere.project.dto.environment.assertions.document;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.assertions.document;
|
||||
package io.metersphere.project.dto.environment.assertions.document;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.authConfig;
|
||||
package io.metersphere.project.dto.environment.auth;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
@ -13,7 +13,7 @@ public class AuthConfig implements Serializable {
|
|||
@Schema(description = "密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "认证方式 No Auth、Basic Auth、Digest Auth")
|
||||
@Schema(description = "认证方式 No Auth、Basic Auth、Digest Auth、ssl")
|
||||
private String verification;
|
||||
|
||||
@Serial
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.common;
|
||||
package io.metersphere.project.dto.environment.common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.sdk.dto.environment.dataSource;
|
||||
package io.metersphere.project.dto.environment.datasource;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
|
@ -8,15 +9,20 @@ import java.io.Serializable;
|
|||
|
||||
@Data
|
||||
public class DataSource implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Schema(description = "id")
|
||||
private String id;
|
||||
@Schema(description = "数据源名称")
|
||||
private String dataSource;
|
||||
@Schema(description = "数据驱动")
|
||||
@NotBlank(message = "{environment_datasource.driver.not_blank}")
|
||||
private String driver;
|
||||
@Schema(description = "数据驱动id")
|
||||
@NotBlank(message = "{environment_datasource.driverId.not_blank}")
|
||||
private String driverId;
|
||||
@Schema(description = "数据库连接url")
|
||||
@NotBlank(message = "{environment_datasource.dbUrl.not_blank}")
|
||||
private String dbUrl;
|
||||
@Schema(description = "用户名")
|
||||
private String username;
|
||||
|
@ -26,6 +32,4 @@ public class DataSource implements Serializable {
|
|||
private Long poolMax;
|
||||
@Schema(description = "超时时间")
|
||||
private Long timeout;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.hostConfig;
|
||||
package io.metersphere.project.dto.environment.host;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,8 +1,7 @@
|
|||
package io.metersphere.sdk.dto.environment.hostConfig;
|
||||
package io.metersphere.project.dto.environment.host;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.apache.hc.core5.net.Host;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.httpConfig;
|
||||
package io.metersphere.project.dto.environment.http;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.sdk.dto.environment.httpConfig;
|
||||
package io.metersphere.project.dto.environment.http;
|
||||
|
||||
|
||||
import io.metersphere.sdk.dto.environment.KeyValue;
|
||||
import io.metersphere.project.dto.environment.KeyValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package io.metersphere.project.dto.environment.script;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ScriptContent {
|
||||
|
||||
@Schema(description = "脚本内容")
|
||||
private String script;
|
||||
@Schema(description = "脚本语言")
|
||||
private String scriptLanguage;
|
||||
@Schema(description = "是否是jsr223")
|
||||
private Boolean jsrEnable;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ScenarioPostScript extends ScriptContent {
|
||||
|
||||
@Schema(description = "关联场景结果 true: 是/false: 否")
|
||||
private Boolean associateScenarioResults = false;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class StepPostScript extends ScriptContent {
|
||||
|
||||
@Schema(description = "忽略请求")
|
||||
private List<String> filterRequestPostScript;
|
||||
@Schema(description = "脚本执行顺序 true:先执行 false:后执行")
|
||||
private Boolean preScriptExecBefore = true;
|
||||
@Schema(description = "脚本内容")
|
||||
private ScriptContent scriptContent;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ApiScript {
|
||||
@Schema(description = "测试计划级")
|
||||
private ScriptContent envJSR223PostScript;
|
||||
@Schema(description = "场景级")
|
||||
private ScenarioPostScript scenarioJSR223PostScript;
|
||||
@Schema(description = "步骤级")
|
||||
private StepPostScript stepJSR223PostScript;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package io.metersphere.sdk.dto.environment.script.post;
|
||||
package io.metersphere.project.dto.environment.script.post;
|
||||
|
||||
|
||||
import io.metersphere.sdk.dto.environment.script.ApiScript;
|
||||
import io.metersphere.project.dto.environment.script.ScriptContent;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EnvironmentPostScript {
|
||||
@Schema(description = "接口测试")
|
||||
private ApiScript apiPostScript;
|
||||
private ScriptContent.ApiScript apiPostScript;
|
||||
@Schema(description = "UI测试")
|
||||
private UiPostScript uiPostScript;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.script.post;
|
||||
package io.metersphere.project.dto.environment.script.post;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,14 +1,14 @@
|
|||
package io.metersphere.sdk.dto.environment.script.pre;
|
||||
package io.metersphere.project.dto.environment.script.pre;
|
||||
|
||||
|
||||
import io.metersphere.sdk.dto.environment.script.ApiScript;
|
||||
import io.metersphere.project.dto.environment.script.ScriptContent;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EnvironmentPreScript {
|
||||
@Schema(description = "接口测试")
|
||||
private ApiScript apiPreScript;
|
||||
private ScriptContent.ApiScript apiPreScript;
|
||||
@Schema(description = "UI测试")
|
||||
private UiPreScript uiPreScript;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.script.pre;
|
||||
package io.metersphere.project.dto.environment.script.pre;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.ssl;
|
||||
package io.metersphere.project.dto.environment.ssl;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.ssl;
|
||||
package io.metersphere.project.dto.environment.ssl;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.sdk.dto.environment.ssl;
|
||||
package io.metersphere.project.dto.environment.ssl;
|
||||
|
||||
|
||||
import io.metersphere.sdk.dto.environment.BodyFile;
|
||||
import io.metersphere.project.dto.environment.BodyFile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.ssl;
|
||||
package io.metersphere.project.dto.environment.ssl;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.tcpConfig;
|
||||
package io.metersphere.project.dto.environment.tcp;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.sdk.dto.environment.variables;
|
||||
package io.metersphere.project.dto.environment.variables;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
@ -0,0 +1,217 @@
|
|||
package io.metersphere.project.service;
|
||||
|
||||
|
||||
import io.metersphere.project.dto.environment.ssl.KeyStoreEntry;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.util.FileUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CommandService {
|
||||
|
||||
public static final String BODY_FILE_DIR = "/opt/metersphere/data/body/";
|
||||
public static String createFile(MultipartFile bodyFile) {
|
||||
validateFileName(bodyFile.getOriginalFilename());
|
||||
String dir = BODY_FILE_DIR;
|
||||
File fileDir = new File(dir);
|
||||
if (!fileDir.exists()) {
|
||||
fileDir.mkdirs();
|
||||
}
|
||||
File file = new File(dir + UUID.randomUUID().toString() + "_" + bodyFile.getOriginalFilename());
|
||||
try (InputStream in = bodyFile.getInputStream(); OutputStream out = new FileOutputStream(file)) {
|
||||
file.createNewFile();
|
||||
FileUtil.copyStream(in, out);
|
||||
} catch (IOException e) {
|
||||
LogUtils.error(e);
|
||||
throw new MSException(Translator.get("upload_fail"));
|
||||
}
|
||||
return file.getPath();
|
||||
}
|
||||
|
||||
public static void deleteFile(String path) {
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static void validateFileName(String... fileNames) {
|
||||
if (fileNames != null) {
|
||||
for (String fileName : fileNames) {
|
||||
if (StringUtils.isNotEmpty(fileName) && StringUtils.contains(fileName, "." + File.separator)) {
|
||||
throw new MSException(Translator.get("invalid_parameter"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<KeyStoreEntry> getEntry(String password, MultipartFile file) {
|
||||
try {
|
||||
String path = createFile(file);
|
||||
// 执行验证指令
|
||||
if (StringUtils.isNotEmpty(password)) {
|
||||
password = JSON.parseObject(password, String.class);
|
||||
}
|
||||
String[] args = {"keytool", "-rfc", "-list", "-keystore", path, "-storepass", password};
|
||||
Process p = new ProcessBuilder(args).start();
|
||||
List<KeyStoreEntry> dtoList = new LinkedList<>();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
|
||||
String line = null;
|
||||
KeyStoreEntry dto = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.contains("keystore password was incorrect")) {
|
||||
throw new MSException(Translator.get("ssl_password_error"));
|
||||
}
|
||||
if (line.startsWith("别名") || line.startsWith("Alias name")) {
|
||||
if (dto != null) {
|
||||
dtoList.add(dto);
|
||||
}
|
||||
dto = new KeyStoreEntry();
|
||||
dto.setOriginalAsName(line.split(":")[1]);
|
||||
}
|
||||
if (line.startsWith("条目类型") || line.startsWith("Entry type")) {
|
||||
dto.setType(line.split(":")[1]);
|
||||
}
|
||||
}
|
||||
if (dto != null) {
|
||||
dtoList.add(dto);
|
||||
}
|
||||
}
|
||||
deleteFile(path);
|
||||
return dtoList;
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* public void createKeyStore(String alias, String path) {
|
||||
try {
|
||||
File f = new File(path);
|
||||
if (f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
List<String> arguments = new ArrayList();
|
||||
arguments.add("keytool");
|
||||
arguments.add("-genkeypair");
|
||||
arguments.add("-alias");
|
||||
arguments.add(alias);
|
||||
arguments.add("-dname");
|
||||
arguments.add("CN=localhost,OU=cn,O=cn,L=cn,ST=cn,C=cn");
|
||||
arguments.add("-keyalg");
|
||||
arguments.add("RSA");
|
||||
arguments.add("-keystore");
|
||||
arguments.add(f.getName());
|
||||
arguments.add("-storepass");
|
||||
arguments.add("ms123...");
|
||||
arguments.add("-keypass");
|
||||
arguments.add("ms123...");
|
||||
arguments.add("-validity");
|
||||
arguments.add(Integer.toString(1024));
|
||||
SystemCommand nativeCommand = new SystemCommand(f.getParentFile(), (Map) null);
|
||||
nativeCommand.run(arguments);
|
||||
} catch (Exception e) {
|
||||
throw new MSException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void mergeKeyStore(String newKeyStore, KeyStoreConfig sslConfig) {
|
||||
try {
|
||||
// 创建零时keyStore
|
||||
this.createKeyStore("ms-run", newKeyStore);
|
||||
// 修改别名
|
||||
Map<String, List<KeyStoreEntry>> entryMap = new HashMap<>();
|
||||
if (sslConfig != null && CollectionUtils.isNotEmpty(sslConfig.getEntry())) {
|
||||
sslConfig.getEntry().forEach(item -> {
|
||||
if (entryMap.containsKey(item.getSourceId())) {
|
||||
entryMap.get(item.getSourceId()).add(item);
|
||||
} else {
|
||||
List<KeyStoreEntry> list = new ArrayList<>();
|
||||
list.add(item);
|
||||
entryMap.put(item.getSourceId(), list);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (sslConfig != null && CollectionUtils.isNotEmpty(sslConfig.getFiles())) {
|
||||
sslConfig.getFiles().forEach(item -> {
|
||||
List<KeyStoreEntry> entries = entryMap.get(item.getId());
|
||||
if (CollectionUtils.isNotEmpty(entries)) {
|
||||
entries.forEach(entry -> {
|
||||
File srcFile = new File(BODY_FILE_DIR + "/ssl/" + item.getId() + "_" + item.getName());
|
||||
try {
|
||||
// 开始合并
|
||||
File destFile = new File(newKeyStore);
|
||||
List<String> arguments = new ArrayList();
|
||||
arguments.add("keytool");
|
||||
arguments.add("-importkeystore");
|
||||
arguments.add("-srckeystore");
|
||||
arguments.add(srcFile.getName());
|
||||
arguments.add("-srcstorepass");
|
||||
arguments.add(item.getPassword());
|
||||
arguments.add("-srcalias");
|
||||
arguments.add(entry.getOriginalAsName().trim());
|
||||
arguments.add("-srckeypass");
|
||||
arguments.add(entry.getPassword());
|
||||
|
||||
arguments.add("-destkeystore");
|
||||
arguments.add(destFile.getName());
|
||||
arguments.add("-deststorepass");
|
||||
arguments.add("ms123...");
|
||||
arguments.add("-destalias");
|
||||
arguments.add(StringUtils.isNotEmpty(entry.getNewAsName()) ? entry.getNewAsName().trim() : entry.getOriginalAsName().trim());
|
||||
arguments.add("-destkeypass");
|
||||
arguments.add("ms123...");
|
||||
|
||||
LogUtils.info("证书合并命令:", String.join(StringUtils.SPACE, arguments));
|
||||
SystemCommand nativeCommand = new SystemCommand(destFile.getParentFile(), (Map) null);
|
||||
int exitVal = nativeCommand.run(arguments);
|
||||
if (exitVal > 0) {
|
||||
throw new MSException("合并条目:【" + entry.getOriginalAsName() + " 】失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
throw new MSException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkKeyStore(String password, String path) {
|
||||
try {
|
||||
String keytoolArgs[] = {"keytool", "-rfc", "-list", "-keystore", path, "-storepass", password};
|
||||
Process p = new ProcessBuilder(keytoolArgs).start();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.contains("keystore password was incorrect")) {
|
||||
throw new MSException(Translator.get("ssl_password_error"));
|
||||
}
|
||||
if (line.contains("Exception")) {
|
||||
throw new MSException(Translator.get("ssl_file_error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
throw new MSException(e.getMessage());
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package io.metersphere.project.service;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.dto.environment.EnvironmentConfig;
|
||||
import io.metersphere.project.dto.environment.EnvironmentRequest;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.domain.EnvironmentBlob;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
|
||||
import io.metersphere.sdk.mapper.EnvironmentBlobMapper;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class EnvironmentLogService {
|
||||
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private EnvironmentMapper environmentMapper;
|
||||
@Resource
|
||||
private EnvironmentBlobMapper environmentBlobMapper;
|
||||
|
||||
public LogDTO addLog(EnvironmentRequest request) {
|
||||
Project project = getProject(request.getProjectId());
|
||||
LogDTO dto = new LogDTO(
|
||||
request.getProjectId(),
|
||||
project.getOrganizationId(),
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT_ENVIRONMENT,
|
||||
request.getName());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(request));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
public LogDTO updateLog(EnvironmentRequest request) {
|
||||
Project project = getProject(request.getProjectId());
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT_ENVIRONMENT,
|
||||
request.getName());
|
||||
Environment environment = environmentMapper.selectByPrimaryKey(request.getId());
|
||||
EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(request.getId());
|
||||
EnvironmentRequest before = new EnvironmentRequest();
|
||||
before.setName(environment.getName());
|
||||
before.setConfig(JSON.parseObject(new String(environmentBlob.getConfig()), EnvironmentConfig.class));
|
||||
dto.setOriginalValue(JSON.toJSONBytes(before));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request));
|
||||
return dto;
|
||||
}
|
||||
|
||||
public LogDTO deleteLog(String id) {
|
||||
Environment environment = environmentMapper.selectByPrimaryKey(id);
|
||||
Project project = getProject(environment.getProjectId());
|
||||
return new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
id,
|
||||
null,
|
||||
OperationLogType.DELETE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT_ENVIRONMENT,
|
||||
environment.getName());
|
||||
}
|
||||
|
||||
|
||||
private Project getProject(String id) {
|
||||
return projectMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
}
|
|
@ -1,36 +1,35 @@
|
|||
package io.metersphere.system.service.environment;
|
||||
package io.metersphere.project.service;
|
||||
|
||||
|
||||
import io.metersphere.project.dto.environment.EnvironmentConfig;
|
||||
import io.metersphere.project.dto.environment.EnvironmentRequest;
|
||||
import io.metersphere.project.dto.environment.datasource.DataSource;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.domain.EnvironmentBlob;
|
||||
import io.metersphere.sdk.domain.EnvironmentBlobExample;
|
||||
import io.metersphere.sdk.domain.EnvironmentExample;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.environment.EnvironmentConfig;
|
||||
import io.metersphere.sdk.dto.environment.EnvironmentConfigRequest;
|
||||
import io.metersphere.sdk.dto.environment.dataSource.DataSource;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.file.FileRequest;
|
||||
import io.metersphere.sdk.file.MinioRepository;
|
||||
import io.metersphere.sdk.mapper.EnvironmentBlobMapper;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.system.service.JdbcDriverPluginService;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.service.JdbcDriverPluginService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class EnvironmentService {
|
||||
|
@ -43,59 +42,77 @@ public class EnvironmentService {
|
|||
@Resource
|
||||
private JdbcDriverPluginService jdbcDriverPluginService;
|
||||
|
||||
private static final String DIR_PATH = "/project-management/environment/";
|
||||
private static final String USERNAME = "user";
|
||||
private static final String PASSWORD = "password";
|
||||
|
||||
|
||||
public List<OptionDTO> getDriverOptions(String organizationId) {
|
||||
return jdbcDriverPluginService.getJdbcDriverOption(organizationId);
|
||||
}
|
||||
|
||||
public void validateDataSource(DataSource databaseConfig) {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(databaseConfig.getDriverId())) {
|
||||
Driver driver = jdbcDriverPluginService.getDriverByOptionId(databaseConfig.getDriverId());
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("user", databaseConfig.getUsername());
|
||||
properties.setProperty("password", databaseConfig.getPassword());
|
||||
driver.connect(databaseConfig.getDbUrl(), properties);
|
||||
} else {
|
||||
DriverManager.getConnection(databaseConfig.getDbUrl(), databaseConfig.getUsername(), databaseConfig.getPassword());
|
||||
}
|
||||
Driver driver = jdbcDriverPluginService.getDriverByOptionId(databaseConfig.getDriverId());
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(USERNAME, databaseConfig.getUsername());
|
||||
properties.setProperty(PASSWORD, databaseConfig.getPassword());
|
||||
driver.connect(databaseConfig.getDbUrl(), properties);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
Environment environment = environmentMapper.selectByPrimaryKey(id);
|
||||
if (environment == null) {
|
||||
throw new MSException(Translator.get("api_test_environment_not_exist"));
|
||||
}
|
||||
//删除环境的ssl文件
|
||||
FileRequest fileRequest = new FileRequest();
|
||||
fileRequest.setProjectId(StringUtils.join(DIR_PATH, environment.getProjectId()));
|
||||
fileRequest.setResourceId(id);
|
||||
try {
|
||||
minioRepository.deleteFolder(fileRequest);
|
||||
} catch (Exception e) {
|
||||
LogUtils.info("删除ssl文件失败: 文件名称:" + environment.getName(), e);
|
||||
}
|
||||
environmentMapper.deleteByPrimaryKey(id);
|
||||
environmentBlobMapper.deleteByPrimaryKey(id);
|
||||
|
||||
}
|
||||
|
||||
public EnvironmentConfigRequest add(EnvironmentConfigRequest environmentConfigRequest, String userId, List<MultipartFile> sslFiles) {
|
||||
public EnvironmentRequest add(EnvironmentRequest request, String userId, List<MultipartFile> sslFiles) {
|
||||
Environment environment = new Environment();
|
||||
environment.setId(UUID.randomUUID().toString());
|
||||
environment.setCreateUser(userId);
|
||||
environment.setName(environmentConfigRequest.getName());
|
||||
environment.setName(request.getName());
|
||||
environment.setProjectId(request.getProjectId());
|
||||
checkEnvironmentExist(environment);
|
||||
environment.setCreateTime(System.currentTimeMillis());
|
||||
environment.setProjectId(environmentConfigRequest.getProjectId());
|
||||
environment.setUpdateUser(userId);
|
||||
environment.setUpdateTime(System.currentTimeMillis());
|
||||
environmentMapper.insert(environment);
|
||||
request.setId(environment.getId());
|
||||
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
||||
environmentBlob.setId(environment.getId());
|
||||
String config = JSON.toJSONString(environmentConfigRequest.getConfig());
|
||||
environmentBlob.setConfig(config.getBytes());
|
||||
environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
|
||||
environmentBlobMapper.insert(environmentBlob);
|
||||
if (CollectionUtils.isNotEmpty(sslFiles)) {
|
||||
sslFiles.forEach(sslFile -> {
|
||||
FileRequest fileRequest = new FileRequest();
|
||||
fileRequest.setFileName(sslFile.getOriginalFilename());
|
||||
fileRequest.setProjectId(environment.getProjectId());
|
||||
fileRequest.setProjectId(StringUtils.join(DIR_PATH, environment.getProjectId()));
|
||||
fileRequest.setResourceId(environment.getId());
|
||||
try {
|
||||
minioRepository.saveFile(sslFile, fileRequest);
|
||||
} catch (Exception e) {
|
||||
LogUtils.info("上传ssl文件失败: 文件名称:" + sslFile.getOriginalFilename(), e);
|
||||
LogUtils.info("上传ssl文件失败: 文件名称:" + sslFile.getName(), e);
|
||||
throw new MSException(Translator.get("api_test_environment_ssl_file_upload_failed"));
|
||||
}
|
||||
});
|
||||
}
|
||||
return environmentConfigRequest;
|
||||
return request;
|
||||
}
|
||||
|
||||
public List<Environment> list(String projectId) {
|
||||
|
@ -105,21 +122,21 @@ public class EnvironmentService {
|
|||
return environmentMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public EnvironmentConfigRequest get(String environmentId) {
|
||||
EnvironmentConfigRequest environmentConfigRequest = new EnvironmentConfigRequest();
|
||||
public EnvironmentRequest get(String environmentId) {
|
||||
EnvironmentRequest environmentRequest = new EnvironmentRequest();
|
||||
Environment environment = environmentMapper.selectByPrimaryKey(environmentId);
|
||||
EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(environmentId);
|
||||
environmentConfigRequest.setProjectId(environment.getProjectId());
|
||||
environmentConfigRequest.setName(environment.getName());
|
||||
environmentConfigRequest.setId(environment.getId());
|
||||
if (environmentBlob == null) {
|
||||
return environmentConfigRequest;
|
||||
if (environment == null) {
|
||||
return null;
|
||||
}
|
||||
environmentConfigRequest.setConfig(JSON.parseObject(Arrays.toString(environmentBlob.getConfig()), EnvironmentConfig.class));
|
||||
return environmentConfigRequest;
|
||||
EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(environmentId);
|
||||
environmentRequest.setProjectId(environment.getProjectId());
|
||||
environmentRequest.setName(environment.getName());
|
||||
environmentRequest.setId(environment.getId());
|
||||
environmentRequest.setConfig(JSON.parseObject(new String(environmentBlob.getConfig()), EnvironmentConfig.class));
|
||||
return environmentRequest;
|
||||
}
|
||||
|
||||
public List<EnvironmentConfigRequest> export(List<String> environmentIds) {
|
||||
public String export(List<String> environmentIds) {
|
||||
if (CollectionUtils.isNotEmpty(environmentIds)) {
|
||||
// 查询环境
|
||||
EnvironmentExample environmentExample = new EnvironmentExample();
|
||||
|
@ -130,26 +147,26 @@ public class EnvironmentService {
|
|||
// 查询环境配置
|
||||
EnvironmentBlobExample environmentBlobExample = new EnvironmentBlobExample();
|
||||
environmentBlobExample.createCriteria().andIdIn(environmentIds);
|
||||
List<EnvironmentBlob> environmentBlobs = environmentBlobMapper.selectByExample(environmentBlobExample);
|
||||
List<EnvironmentBlob> environmentBlobs = environmentBlobMapper.selectByExampleWithBLOBs(environmentBlobExample);
|
||||
Map<String, EnvironmentBlob> environmentBlobMap = new HashMap<>();
|
||||
environmentBlobs.forEach(environmentBlob -> environmentBlobMap.put(environmentBlob.getId(), environmentBlob));
|
||||
|
||||
List<EnvironmentConfigRequest> environmentConfigRequests = new ArrayList<>();
|
||||
List<EnvironmentRequest> environmentRequests = new ArrayList<>();
|
||||
environmentIds.forEach(environmentId -> {
|
||||
EnvironmentConfigRequest environmentConfigRequest = new EnvironmentConfigRequest();
|
||||
EnvironmentRequest environmentRequest = new EnvironmentRequest();
|
||||
Environment environment = environmentMap.get(environmentId);
|
||||
EnvironmentBlob environmentBlob = environmentBlobMap.get(environmentId);
|
||||
environmentConfigRequest.setProjectId(environment.getProjectId());
|
||||
environmentConfigRequest.setName(environment.getName());
|
||||
environmentConfigRequest.setId(environment.getId());
|
||||
environmentRequest.setProjectId(environment.getProjectId());
|
||||
environmentRequest.setName(environment.getName());
|
||||
environmentRequest.setId(environment.getId());
|
||||
if (environmentBlob != null) {
|
||||
environmentConfigRequest.setConfig(JSON.parseObject(Arrays.toString(environmentBlob.getConfig()), EnvironmentConfig.class));
|
||||
environmentRequest.setConfig(JSON.parseObject(new String(environmentBlob.getConfig()), EnvironmentConfig.class));
|
||||
}
|
||||
environmentConfigRequests.add(environmentConfigRequest);
|
||||
environmentRequests.add(environmentRequest);
|
||||
});
|
||||
return environmentConfigRequests;
|
||||
return JSON.toJSONString(environmentRequests);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,21 +188,23 @@ public class EnvironmentService {
|
|||
String content = new String(inputStream.readAllBytes());
|
||||
inputStream.close();
|
||||
// 拿到的参数是一个list
|
||||
List<EnvironmentConfigRequest> environmentConfigRequests = JSON.parseArray(content, EnvironmentConfigRequest.class);
|
||||
if (CollectionUtils.isNotEmpty(environmentConfigRequests)) {
|
||||
environmentConfigRequests.forEach(environmentConfigRequest -> {
|
||||
List<EnvironmentRequest> environmentRequests = JSON.parseArray(content, EnvironmentRequest.class);
|
||||
if (CollectionUtils.isNotEmpty(environmentRequests)) {
|
||||
environmentRequests.forEach(environmentRequest -> {
|
||||
Environment environment = new Environment();
|
||||
environment.setId(UUID.randomUUID().toString());
|
||||
environment.setCreateUser(userId);
|
||||
environment.setName(environmentConfigRequest.getName());
|
||||
environment.setName(environmentRequest.getName());
|
||||
environment.setProjectId(currentProjectId);
|
||||
environment.setUpdateUser(userId);
|
||||
environment.setUpdateTime(System.currentTimeMillis());
|
||||
checkEnvironmentExist(environment);
|
||||
environment.setCreateTime(System.currentTimeMillis());
|
||||
environment.setProjectId(currentProjectId);
|
||||
environmentMapper.insert(environment);
|
||||
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
||||
environmentBlob.setId(environment.getId());
|
||||
String config = JSON.toJSONString(environmentConfigRequest.getConfig());
|
||||
environmentBlob.setConfig(config.getBytes());
|
||||
environmentBlob.setConfig(JSON.toJSONBytes(environmentRequest.getConfig()));
|
||||
environmentBlobMapper.insert(environmentBlob);
|
||||
});
|
||||
}
|
||||
|
@ -195,4 +214,34 @@ public class EnvironmentService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EnvironmentRequest update(EnvironmentRequest request, String userId, List<MultipartFile> sslFiles) {
|
||||
Environment environment = new Environment();
|
||||
environment.setId(request.getId());
|
||||
environment.setUpdateUser(userId);
|
||||
environment.setProjectId(request.getProjectId());
|
||||
environment.setName(request.getName());
|
||||
checkEnvironmentExist(environment);
|
||||
environment.setUpdateTime(System.currentTimeMillis());
|
||||
environmentMapper.updateByPrimaryKeySelective(environment);
|
||||
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
||||
environmentBlob.setId(environment.getId());
|
||||
environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
|
||||
environmentBlobMapper.updateByPrimaryKeySelective(environmentBlob);
|
||||
if (CollectionUtils.isNotEmpty(sslFiles)) {
|
||||
sslFiles.forEach(sslFile -> {
|
||||
FileRequest fileRequest = new FileRequest();
|
||||
fileRequest.setFileName(sslFile.getOriginalFilename());
|
||||
fileRequest.setProjectId(StringUtils.join(DIR_PATH, environment.getProjectId()));
|
||||
fileRequest.setResourceId(request.getId());
|
||||
try {
|
||||
minioRepository.saveFile(sslFile, fileRequest);
|
||||
} catch (Exception e) {
|
||||
LogUtils.info("上传ssl文件失败: 文件名称:" + sslFile.getOriginalFilename(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package io.metersphere.project.service;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.dto.environment.GlobalParamsRequest;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.domain.ProjectParameters;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
|
||||
import io.metersphere.sdk.mapper.ProjectParametersMapper;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GlobalParamsLogService {
|
||||
|
||||
@Resource
|
||||
private ProjectParametersMapper projectParametersMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
|
||||
public LogDTO addLog(GlobalParamsRequest request) {
|
||||
Project project = getProject(request.getProjectId());
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT_ENVIRONMENT,
|
||||
null);
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(request.getGlobalParams()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
public LogDTO updateLog(GlobalParamsRequest request) {
|
||||
Project project = getProject(request.getProjectId());
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT_ENVIRONMENT,
|
||||
null);
|
||||
ProjectParameters projectParameters = projectParametersMapper.selectByPrimaryKey(request.getId());
|
||||
dto.setOriginalValue(projectParameters.getParameters());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getGlobalParams()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
private Project getProject(String id) {
|
||||
return projectMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
}
|
|
@ -1,15 +1,16 @@
|
|||
package io.metersphere.system.service.environment;
|
||||
package io.metersphere.project.service;
|
||||
|
||||
import io.metersphere.project.dto.environment.GlobalParams;
|
||||
import io.metersphere.project.dto.environment.GlobalParamsRequest;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.domain.ProjectParameters;
|
||||
import io.metersphere.sdk.domain.ProjectParametersExample;
|
||||
import io.metersphere.sdk.dto.environment.GlobalParamsDTO;
|
||||
import io.metersphere.sdk.dto.environment.GlobalParamsRequest;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.mapper.ProjectParametersMapper;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -37,8 +38,7 @@ public class GlobalParamsService {
|
|||
projectParameters.setUpdateUser(userId);
|
||||
projectParameters.setCreateTime(System.currentTimeMillis());
|
||||
projectParameters.setUpdateTime(System.currentTimeMillis());
|
||||
String params = JSON.toJSONString(globalParamsRequest.getGlobalParams());
|
||||
projectParameters.setParameters(params.getBytes());
|
||||
projectParameters.setParameters(JSON.toJSONBytes(globalParamsRequest.getGlobalParams()));
|
||||
projectParametersMapper.insert(projectParameters);
|
||||
globalParamsRequest.setId(projectParameters.getId());
|
||||
return globalParamsRequest;
|
||||
|
@ -52,8 +52,7 @@ public class GlobalParamsService {
|
|||
projectParameters.setId(globalParamsRequest.getId());
|
||||
projectParameters.setUpdateUser(userId);
|
||||
projectParameters.setUpdateTime(System.currentTimeMillis());
|
||||
String params = JSON.toJSONString(globalParamsRequest.getGlobalParams());
|
||||
projectParameters.setParameters(params.getBytes());
|
||||
projectParameters.setParameters(JSON.toJSONBytes(globalParamsRequest.getGlobalParams()));
|
||||
projectParametersMapper.updateByPrimaryKeySelective(projectParameters);
|
||||
return globalParamsRequest;
|
||||
}
|
||||
|
@ -75,7 +74,7 @@ public class GlobalParamsService {
|
|||
GlobalParamsRequest globalParamsRequest = new GlobalParamsRequest();
|
||||
globalParamsRequest.setProjectId(projectId);
|
||||
globalParamsRequest.setId(projectParametersList.get(0).getId());
|
||||
globalParamsRequest.setGlobalParams(JSON.parseObject(new String(projectParametersList.get(0).getParameters()), GlobalParamsDTO.class));
|
||||
globalParamsRequest.setGlobalParams(JSON.parseObject(new String(projectParametersList.get(0).getParameters()), GlobalParams.class));
|
||||
return globalParamsRequest;
|
||||
} else {
|
||||
return null;
|
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +1,21 @@
|
|||
package io.metersphere.project.controller;
|
||||
|
||||
import io.metersphere.project.dto.environment.GlobalParams;
|
||||
import io.metersphere.project.dto.environment.GlobalParamsRequest;
|
||||
import io.metersphere.project.dto.environment.KeyValue;
|
||||
import io.metersphere.project.dto.environment.variables.CommonVariables;
|
||||
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.constants.VariableTypeConstants;
|
||||
|
||||
import io.metersphere.sdk.domain.ProjectParameters;
|
||||
import io.metersphere.sdk.domain.ProjectParametersExample;
|
||||
import io.metersphere.sdk.dto.environment.GlobalParamsDTO;
|
||||
import io.metersphere.sdk.dto.environment.GlobalParamsRequest;
|
||||
import io.metersphere.sdk.dto.environment.KeyValue;
|
||||
import io.metersphere.sdk.dto.environment.variables.CommonVariables;
|
||||
import io.metersphere.sdk.mapper.ProjectParametersMapper;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
|
@ -126,78 +129,80 @@ public class GlobalParamsControllerTests extends BaseTest {
|
|||
//添加全局参数 有headers 有envVariables
|
||||
GlobalParamsRequest request = new GlobalParamsRequest();
|
||||
request.setProjectId("projectId1");
|
||||
GlobalParamsDTO globalParamsDTO = new GlobalParamsDTO();
|
||||
globalParamsDTO.setHeaders(getHeaders(1));
|
||||
globalParamsDTO.setCommonVariables(getEnvVariables(1));
|
||||
request.setGlobalParams(globalParamsDTO);
|
||||
GlobalParams globalParams = new GlobalParams();
|
||||
globalParams.setHeaders(getHeaders(1));
|
||||
globalParams.setCommonVariables(getEnvVariables(1));
|
||||
request.setGlobalParams(globalParams);
|
||||
MvcResult mvcResult = this.responsePost(add, request);
|
||||
GlobalParamsRequest globalParamsRequest = parseObjectFromMvcResult(mvcResult, GlobalParamsRequest.class);
|
||||
Assertions.assertNotNull(globalParamsRequest);
|
||||
ProjectParameters projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId());
|
||||
Assertions.assertNotNull(projectParameters);
|
||||
Assertions.assertEquals("projectId1", projectParameters.getProjectId());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getHeaders().size());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getCommonVariables().size());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders().size());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getCommonVariables().size());
|
||||
|
||||
//添加全局参数 有headers 无envVariables
|
||||
request = new GlobalParamsRequest();
|
||||
request.setProjectId("projectId2");
|
||||
globalParamsDTO = new GlobalParamsDTO();
|
||||
globalParamsDTO.setHeaders(getHeaders(1));
|
||||
globalParamsDTO.setCommonVariables(new ArrayList<>());
|
||||
request.setGlobalParams(globalParamsDTO);
|
||||
globalParams = new GlobalParams();
|
||||
globalParams.setHeaders(getHeaders(1));
|
||||
globalParams.setCommonVariables(new ArrayList<>());
|
||||
request.setGlobalParams(globalParams);
|
||||
mvcResult = this.responsePost(add, request);
|
||||
globalParamsRequest = parseObjectFromMvcResult(mvcResult, GlobalParamsRequest.class);
|
||||
Assertions.assertNotNull(globalParamsRequest);
|
||||
projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId());
|
||||
Assertions.assertNotNull(projectParameters);
|
||||
Assertions.assertEquals("projectId2", projectParameters.getProjectId());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getHeaders().size());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getCommonVariables().size());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders().size());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getCommonVariables().size());
|
||||
|
||||
//添加全局参数 无headers 有envVariables
|
||||
request = new GlobalParamsRequest();
|
||||
request.setProjectId("projectId3");
|
||||
globalParamsDTO = new GlobalParamsDTO();
|
||||
globalParamsDTO.setHeaders(new ArrayList<>());
|
||||
globalParamsDTO.setCommonVariables(getEnvVariables(1));
|
||||
request.setGlobalParams(globalParamsDTO);
|
||||
globalParams = new GlobalParams();
|
||||
globalParams.setHeaders(new ArrayList<>());
|
||||
globalParams.setCommonVariables(getEnvVariables(1));
|
||||
request.setGlobalParams(globalParams);
|
||||
mvcResult = this.responsePost(add, request);
|
||||
globalParamsRequest = parseObjectFromMvcResult(mvcResult, GlobalParamsRequest.class);
|
||||
Assertions.assertNotNull(globalParamsRequest);
|
||||
projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId());
|
||||
Assertions.assertNotNull(projectParameters);
|
||||
Assertions.assertEquals("projectId3", projectParameters.getProjectId());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getHeaders().size());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getCommonVariables().size());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders().size());
|
||||
Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getCommonVariables().size());
|
||||
|
||||
//添加全局参数 无headers 无envVariables
|
||||
request = new GlobalParamsRequest();
|
||||
request.setProjectId("projectId4");
|
||||
globalParamsDTO = new GlobalParamsDTO();
|
||||
globalParamsDTO.setHeaders(new ArrayList<>());
|
||||
globalParamsDTO.setCommonVariables(new ArrayList<>());
|
||||
request.setGlobalParams(globalParamsDTO);
|
||||
globalParams = new GlobalParams();
|
||||
globalParams.setHeaders(new ArrayList<>());
|
||||
globalParams.setCommonVariables(new ArrayList<>());
|
||||
request.setGlobalParams(globalParams);
|
||||
mvcResult = this.responsePost(add, request);
|
||||
globalParamsRequest = parseObjectFromMvcResult(mvcResult, GlobalParamsRequest.class);
|
||||
Assertions.assertNotNull(globalParamsRequest);
|
||||
projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId());
|
||||
Assertions.assertNotNull(projectParameters);
|
||||
Assertions.assertEquals("projectId4", projectParameters.getProjectId());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getHeaders().size());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getCommonVariables().size());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders().size());
|
||||
Assertions.assertEquals(0, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getCommonVariables().size());
|
||||
|
||||
request = new GlobalParamsRequest();
|
||||
request.setProjectId("projectId5");
|
||||
request.setGlobalParams(new GlobalParamsDTO());
|
||||
request.setGlobalParams(new GlobalParams());
|
||||
mvcResult = this.responsePost(add, request);
|
||||
globalParamsRequest = parseObjectFromMvcResult(mvcResult, GlobalParamsRequest.class);
|
||||
Assertions.assertNotNull(globalParamsRequest);
|
||||
//校验日志
|
||||
checkLog(globalParamsRequest.getId(), OperationLogType.ADD);
|
||||
projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId());
|
||||
Assertions.assertNotNull(projectParameters);
|
||||
Assertions.assertEquals("projectId5", projectParameters.getProjectId());
|
||||
Assertions.assertNull(JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getHeaders());
|
||||
Assertions.assertNull(JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getCommonVariables());
|
||||
Assertions.assertNull(JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders());
|
||||
Assertions.assertNull(JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getCommonVariables());
|
||||
|
||||
//校验权限
|
||||
request = new GlobalParamsRequest();
|
||||
|
@ -234,18 +239,20 @@ public class GlobalParamsControllerTests extends BaseTest {
|
|||
GlobalParamsRequest request = new GlobalParamsRequest();
|
||||
request.setProjectId("projectId1");
|
||||
request.setId(projectParametersList.get(0).getId());
|
||||
GlobalParamsDTO globalParamsDTO = new GlobalParamsDTO();
|
||||
globalParamsDTO.setHeaders(getHeaders(2));
|
||||
globalParamsDTO.setCommonVariables(getEnvVariables(2));
|
||||
request.setGlobalParams(globalParamsDTO);
|
||||
GlobalParams globalParams = new GlobalParams();
|
||||
globalParams.setHeaders(getHeaders(2));
|
||||
globalParams.setCommonVariables(getEnvVariables(2));
|
||||
request.setGlobalParams(globalParams);
|
||||
MvcResult mvcResult = this.responsePost(update, request);
|
||||
GlobalParamsRequest globalParamsRequest = parseObjectFromMvcResult(mvcResult, GlobalParamsRequest.class);
|
||||
Assertions.assertNotNull(globalParamsRequest);
|
||||
//校验日志
|
||||
checkLog(globalParamsRequest.getId(), OperationLogType.UPDATE);
|
||||
ProjectParameters projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId());
|
||||
Assertions.assertNotNull(projectParameters);
|
||||
Assertions.assertEquals("projectId1", projectParameters.getProjectId());
|
||||
Assertions.assertEquals(2, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getHeaders().size());
|
||||
Assertions.assertEquals(2, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParamsDTO.class).getCommonVariables().size());
|
||||
Assertions.assertEquals(2, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders().size());
|
||||
Assertions.assertEquals(2, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getCommonVariables().size());
|
||||
|
||||
//校验权限
|
||||
request = new GlobalParamsRequest();
|
||||
|
|
|
@ -28,3 +28,6 @@ replace INTO user_role_relation (id, user_id, role_id, source_id, organization_i
|
|||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation4','admin1','project_member','projectId2','100001','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation5','admin1','project_member','projectId3','100001','1684747668321','admin');
|
||||
replace INTO user_role_permission(id, role_id, permission_id) VALUES ('user_role_permission1','project_member','PROJECT_BASE_INFO:READ');
|
||||
|
||||
#插入测试数据 环境
|
||||
replace INTO environment (id, name, project_id, create_user, update_user, create_time, update_time) VALUES ('environmentId1', '环境1', 'projectId1', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,601 @@
|
|||
[
|
||||
{
|
||||
"id":"1017615191384064",
|
||||
"projectId":"projectId",
|
||||
"name":"导入环境1",
|
||||
"config":{
|
||||
"commonParams":{
|
||||
"requestTimeout":null,
|
||||
"responseTimeout":null
|
||||
},
|
||||
"commonVariables":[
|
||||
|
||||
],
|
||||
"httpConfig":[
|
||||
|
||||
],
|
||||
"dataSources":[
|
||||
|
||||
],
|
||||
"hostConfig":{
|
||||
"enable":null,
|
||||
"hosts":null
|
||||
},
|
||||
"tcpConfig":{
|
||||
"className":null,
|
||||
"server":null,
|
||||
"port":0,
|
||||
"username":null,
|
||||
"password":null,
|
||||
"connectTimeout":null,
|
||||
"timeout":null,
|
||||
"soLinger":null,
|
||||
"reUseConnection":null,
|
||||
"nodelay":null,
|
||||
"closeConnection":null,
|
||||
"eolByte":null
|
||||
},
|
||||
"authConfig":{
|
||||
"username":null,
|
||||
"password":null,
|
||||
"verification":null
|
||||
},
|
||||
"sslConfig":{
|
||||
"entry":null,
|
||||
"files":null,
|
||||
"defaultAlias":null
|
||||
},
|
||||
"preScript":{
|
||||
"apiPreScript":null,
|
||||
"uiPreScript":null
|
||||
},
|
||||
"postScript":{
|
||||
"apiPostScript":null,
|
||||
"uiPostScript":null
|
||||
},
|
||||
"assertions":{
|
||||
"module":null,
|
||||
"xpathType":null,
|
||||
"regex":null,
|
||||
"jsonPath":null,
|
||||
"jsr223":null,
|
||||
"xpath":null,
|
||||
"duration":null,
|
||||
"document":null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id":"1017615191384065",
|
||||
"projectId":"projectId",
|
||||
"name":"导入环境2",
|
||||
"config":{
|
||||
"commonParams":{
|
||||
"requestTimeout":6000,
|
||||
"responseTimeout":6000
|
||||
},
|
||||
"commonVariables":[
|
||||
|
||||
],
|
||||
"httpConfig":[
|
||||
|
||||
],
|
||||
"dataSources":[
|
||||
|
||||
],
|
||||
"hostConfig":{
|
||||
"enable":null,
|
||||
"hosts":null
|
||||
},
|
||||
"tcpConfig":{
|
||||
"className":null,
|
||||
"server":null,
|
||||
"port":0,
|
||||
"username":null,
|
||||
"password":null,
|
||||
"connectTimeout":null,
|
||||
"timeout":null,
|
||||
"soLinger":null,
|
||||
"reUseConnection":null,
|
||||
"nodelay":null,
|
||||
"closeConnection":null,
|
||||
"eolByte":null
|
||||
},
|
||||
"authConfig":{
|
||||
"username":null,
|
||||
"password":null,
|
||||
"verification":null
|
||||
},
|
||||
"sslConfig":{
|
||||
"entry":null,
|
||||
"files":null,
|
||||
"defaultAlias":null
|
||||
},
|
||||
"preScript":{
|
||||
"apiPreScript":null,
|
||||
"uiPreScript":null
|
||||
},
|
||||
"postScript":{
|
||||
"apiPostScript":null,
|
||||
"uiPostScript":null
|
||||
},
|
||||
"assertions":{
|
||||
"module":null,
|
||||
"xpathType":null,
|
||||
"regex":null,
|
||||
"jsonPath":null,
|
||||
"jsr223":null,
|
||||
"xpath":null,
|
||||
"duration":null,
|
||||
"document":null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id":"1017615191384066",
|
||||
"projectId":"projectId",
|
||||
"name":"导入环境3",
|
||||
"config":{
|
||||
"commonParams":{
|
||||
"requestTimeout":6000,
|
||||
"responseTimeout":6000
|
||||
},
|
||||
"commonVariables":[
|
||||
{
|
||||
"id":null,
|
||||
"name":"key0",
|
||||
"type":"CONSTANT",
|
||||
"value":"value0",
|
||||
"enable":true,
|
||||
"description":"description0"
|
||||
}
|
||||
],
|
||||
"httpConfig":[
|
||||
|
||||
],
|
||||
"dataSources":[
|
||||
|
||||
],
|
||||
"hostConfig":{
|
||||
"enable":null,
|
||||
"hosts":null
|
||||
},
|
||||
"tcpConfig":{
|
||||
"className":null,
|
||||
"server":null,
|
||||
"port":0,
|
||||
"username":null,
|
||||
"password":null,
|
||||
"connectTimeout":null,
|
||||
"timeout":null,
|
||||
"soLinger":null,
|
||||
"reUseConnection":null,
|
||||
"nodelay":null,
|
||||
"closeConnection":null,
|
||||
"eolByte":null
|
||||
},
|
||||
"authConfig":{
|
||||
"username":null,
|
||||
"password":null,
|
||||
"verification":null
|
||||
},
|
||||
"sslConfig":{
|
||||
"entry":null,
|
||||
"files":null,
|
||||
"defaultAlias":null
|
||||
},
|
||||
"preScript":{
|
||||
"apiPreScript":null,
|
||||
"uiPreScript":null
|
||||
},
|
||||
"postScript":{
|
||||
"apiPostScript":null,
|
||||
"uiPostScript":null
|
||||
},
|
||||
"assertions":{
|
||||
"module":null,
|
||||
"xpathType":null,
|
||||
"regex":null,
|
||||
"jsonPath":null,
|
||||
"jsr223":null,
|
||||
"xpath":null,
|
||||
"duration":null,
|
||||
"document":null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id":"1017615191384067",
|
||||
"projectId":"projectId",
|
||||
"name":"导入环境4",
|
||||
"config":{
|
||||
"commonParams":{
|
||||
"requestTimeout":6000,
|
||||
"responseTimeout":6000
|
||||
},
|
||||
"commonVariables":[
|
||||
{
|
||||
"id":null,
|
||||
"name":"key0",
|
||||
"type":"CONSTANT",
|
||||
"value":"value0",
|
||||
"enable":true,
|
||||
"description":"description0"
|
||||
}
|
||||
],
|
||||
"httpConfig":[
|
||||
{
|
||||
"socket":"socket",
|
||||
"domain":"domain",
|
||||
"protocol":"https",
|
||||
"applicationModule":null,
|
||||
"type":null,
|
||||
"details":null,
|
||||
"headers":[
|
||||
{
|
||||
"name":"key",
|
||||
"value":"value",
|
||||
"enable":true
|
||||
}
|
||||
],
|
||||
"browser":null,
|
||||
"description":null
|
||||
}
|
||||
],
|
||||
"dataSources":[
|
||||
|
||||
],
|
||||
"hostConfig":{
|
||||
"enable":null,
|
||||
"hosts":null
|
||||
},
|
||||
"tcpConfig":{
|
||||
"className":null,
|
||||
"server":null,
|
||||
"port":0,
|
||||
"username":null,
|
||||
"password":null,
|
||||
"connectTimeout":null,
|
||||
"timeout":null,
|
||||
"soLinger":null,
|
||||
"reUseConnection":null,
|
||||
"nodelay":null,
|
||||
"closeConnection":null,
|
||||
"eolByte":null
|
||||
},
|
||||
"authConfig":{
|
||||
"username":null,
|
||||
"password":null,
|
||||
"verification":null
|
||||
},
|
||||
"sslConfig":{
|
||||
"entry":null,
|
||||
"files":null,
|
||||
"defaultAlias":null
|
||||
},
|
||||
"preScript":{
|
||||
"apiPreScript":null,
|
||||
"uiPreScript":null
|
||||
},
|
||||
"postScript":{
|
||||
"apiPostScript":null,
|
||||
"uiPostScript":null
|
||||
},
|
||||
"assertions":{
|
||||
"module":null,
|
||||
"xpathType":null,
|
||||
"regex":null,
|
||||
"jsonPath":null,
|
||||
"jsr223":null,
|
||||
"xpath":null,
|
||||
"duration":null,
|
||||
"document":null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id":"1017615191384068",
|
||||
"projectId":"projectId",
|
||||
"name":"导入环境5",
|
||||
"config":{
|
||||
"commonParams":{
|
||||
"requestTimeout":6000,
|
||||
"responseTimeout":6000
|
||||
},
|
||||
"commonVariables":[
|
||||
{
|
||||
"id":null,
|
||||
"name":"key0",
|
||||
"type":"CONSTANT",
|
||||
"value":"value0",
|
||||
"enable":true,
|
||||
"description":"description0"
|
||||
}
|
||||
],
|
||||
"httpConfig":[
|
||||
{
|
||||
"socket":"socket",
|
||||
"domain":"domain",
|
||||
"protocol":"https",
|
||||
"applicationModule":null,
|
||||
"type":null,
|
||||
"details":null,
|
||||
"headers":[
|
||||
{
|
||||
"name":"key",
|
||||
"value":"value",
|
||||
"enable":true
|
||||
}
|
||||
],
|
||||
"browser":null,
|
||||
"description":null
|
||||
}
|
||||
],
|
||||
"dataSources":[
|
||||
{
|
||||
"id":"1",
|
||||
"dataSource":"mysql",
|
||||
"driver":"com.mysql.cj.jdbc.Driver",
|
||||
"driverId":null,
|
||||
"dbUrl":"jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai",
|
||||
"username":"root",
|
||||
"password":"123456",
|
||||
"poolMax":10,
|
||||
"timeout":1000
|
||||
}
|
||||
],
|
||||
"hostConfig":{
|
||||
"enable":null,
|
||||
"hosts":null
|
||||
},
|
||||
"tcpConfig":{
|
||||
"className":null,
|
||||
"server":null,
|
||||
"port":0,
|
||||
"username":null,
|
||||
"password":null,
|
||||
"connectTimeout":null,
|
||||
"timeout":null,
|
||||
"soLinger":null,
|
||||
"reUseConnection":null,
|
||||
"nodelay":null,
|
||||
"closeConnection":null,
|
||||
"eolByte":null
|
||||
},
|
||||
"authConfig":{
|
||||
"username":null,
|
||||
"password":null,
|
||||
"verification":null
|
||||
},
|
||||
"sslConfig":{
|
||||
"entry":null,
|
||||
"files":null,
|
||||
"defaultAlias":null
|
||||
},
|
||||
"preScript":{
|
||||
"apiPreScript":null,
|
||||
"uiPreScript":null
|
||||
},
|
||||
"postScript":{
|
||||
"apiPostScript":null,
|
||||
"uiPostScript":null
|
||||
},
|
||||
"assertions":{
|
||||
"module":null,
|
||||
"xpathType":null,
|
||||
"regex":null,
|
||||
"jsonPath":null,
|
||||
"jsr223":null,
|
||||
"xpath":null,
|
||||
"duration":null,
|
||||
"document":null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id":"1017615191384069",
|
||||
"projectId":"projectId",
|
||||
"name":"导入环境6",
|
||||
"config":{
|
||||
"commonParams":{
|
||||
"requestTimeout":6000,
|
||||
"responseTimeout":6000
|
||||
},
|
||||
"commonVariables":[
|
||||
{
|
||||
"id":null,
|
||||
"name":"key0",
|
||||
"type":"CONSTANT",
|
||||
"value":"value0",
|
||||
"enable":true,
|
||||
"description":"description0"
|
||||
}
|
||||
],
|
||||
"httpConfig":[
|
||||
{
|
||||
"socket":"socket",
|
||||
"domain":"domain",
|
||||
"protocol":"https",
|
||||
"applicationModule":null,
|
||||
"type":null,
|
||||
"details":null,
|
||||
"headers":[
|
||||
{
|
||||
"name":"key",
|
||||
"value":"value",
|
||||
"enable":true
|
||||
}
|
||||
],
|
||||
"browser":null,
|
||||
"description":null
|
||||
}
|
||||
],
|
||||
"dataSources":[
|
||||
{
|
||||
"id":"1",
|
||||
"dataSource":"mysql",
|
||||
"driver":"com.mysql.cj.jdbc.Driver",
|
||||
"driverId":null,
|
||||
"dbUrl":"jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai",
|
||||
"username":"root",
|
||||
"password":"123456",
|
||||
"poolMax":10,
|
||||
"timeout":1000
|
||||
}
|
||||
],
|
||||
"hostConfig":{
|
||||
"enable":null,
|
||||
"hosts":null
|
||||
},
|
||||
"tcpConfig":{
|
||||
"className":"className",
|
||||
"server":"server",
|
||||
"port":8080,
|
||||
"username":"username",
|
||||
"password":"password",
|
||||
"connectTimeout":"connectTimeout",
|
||||
"timeout":"timeout",
|
||||
"soLinger":"soLinger",
|
||||
"reUseConnection":true,
|
||||
"nodelay":true,
|
||||
"closeConnection":true,
|
||||
"eolByte":"eolByte"
|
||||
},
|
||||
"authConfig":{
|
||||
"username":null,
|
||||
"password":null,
|
||||
"verification":null
|
||||
},
|
||||
"sslConfig":{
|
||||
"entry":null,
|
||||
"files":null,
|
||||
"defaultAlias":null
|
||||
},
|
||||
"preScript":{
|
||||
"apiPreScript":null,
|
||||
"uiPreScript":null
|
||||
},
|
||||
"postScript":{
|
||||
"apiPostScript":null,
|
||||
"uiPostScript":null
|
||||
},
|
||||
"assertions":{
|
||||
"module":null,
|
||||
"xpathType":null,
|
||||
"regex":null,
|
||||
"jsonPath":null,
|
||||
"jsr223":null,
|
||||
"xpath":null,
|
||||
"duration":null,
|
||||
"document":null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id":"1017615191384070",
|
||||
"projectId":"projectId",
|
||||
"name":"导入环境7",
|
||||
"config":{
|
||||
"commonParams":{
|
||||
"requestTimeout":6000,
|
||||
"responseTimeout":6000
|
||||
},
|
||||
"commonVariables":[
|
||||
{
|
||||
"id":null,
|
||||
"name":"key0",
|
||||
"type":"CONSTANT",
|
||||
"value":"value0",
|
||||
"enable":true,
|
||||
"description":"description0"
|
||||
}
|
||||
],
|
||||
"httpConfig":[
|
||||
{
|
||||
"socket":"socket",
|
||||
"domain":"domain",
|
||||
"protocol":"https",
|
||||
"applicationModule":null,
|
||||
"type":null,
|
||||
"details":null,
|
||||
"headers":[
|
||||
{
|
||||
"name":"key",
|
||||
"value":"value",
|
||||
"enable":true
|
||||
}
|
||||
],
|
||||
"browser":null,
|
||||
"description":null
|
||||
}
|
||||
],
|
||||
"dataSources":[
|
||||
{
|
||||
"id":"1",
|
||||
"dataSource":"mysql",
|
||||
"driver":"com.mysql.cj.jdbc.Driver",
|
||||
"driverId":null,
|
||||
"dbUrl":"jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai",
|
||||
"username":"root",
|
||||
"password":"123456",
|
||||
"poolMax":10,
|
||||
"timeout":1000
|
||||
}
|
||||
],
|
||||
"hostConfig":{
|
||||
"enable":true,
|
||||
"hosts":[
|
||||
{
|
||||
"ip":"ip",
|
||||
"domain":"domain",
|
||||
"description":"description",
|
||||
"uuid":"uuid"
|
||||
}
|
||||
]
|
||||
},
|
||||
"tcpConfig":{
|
||||
"className":"className",
|
||||
"server":"server",
|
||||
"port":8080,
|
||||
"username":"username",
|
||||
"password":"password",
|
||||
"connectTimeout":"connectTimeout",
|
||||
"timeout":"timeout",
|
||||
"soLinger":"soLinger",
|
||||
"reUseConnection":true,
|
||||
"nodelay":true,
|
||||
"closeConnection":true,
|
||||
"eolByte":"eolByte"
|
||||
},
|
||||
"authConfig":{
|
||||
"username":null,
|
||||
"password":null,
|
||||
"verification":null
|
||||
},
|
||||
"sslConfig":{
|
||||
"entry":null,
|
||||
"files":null,
|
||||
"defaultAlias":null
|
||||
},
|
||||
"preScript":{
|
||||
"apiPreScript":null,
|
||||
"uiPreScript":null
|
||||
},
|
||||
"postScript":{
|
||||
"apiPostScript":null,
|
||||
"uiPostScript":null
|
||||
},
|
||||
"assertions":{
|
||||
"module":null,
|
||||
"xpathType":null,
|
||||
"regex":null,
|
||||
"jsonPath":null,
|
||||
"jsr223":null,
|
||||
"xpath":null,
|
||||
"duration":null,
|
||||
"document":null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
]
|
Binary file not shown.
|
@ -81,6 +81,7 @@ public class OperationLogModule {
|
|||
public static final String PROJECT_MANAGEMENT_PERMISSION = "PROJECT_MANAGEMENT_PERMISSION"; // 项目管理-项目与权限
|
||||
public static final String PROJECT_MANAGEMENT_PERMISSION_MEMBER = "PROJECT_MANAGEMENT_PERMISSION_MEMBER";// 项目管理-项目与权限-成员
|
||||
public static final String PROJECT_MANAGEMENT_PERMISSION_USER_ROLE = "PROJECT_USER_GROUP";// 项目管理-项目与权限-用户组
|
||||
public static final String PROJECT_MANAGEMENT_ENVIRONMENT = "PROJECT_MANAGEMENT_ENVIRONMENT";// 项目管理-环境
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue