diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java index 6523f1636f..b84be7e3f6 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java @@ -86,10 +86,27 @@ public class ApiTestEnvironmentService { request.setCreateUser(SessionUtils.getUserId()); checkEnvironmentExist(request); FileUtils.createFiles(request.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl"); + //检查Config,判断isMock参数是否给True + request = this.updateConfig(request,false); apiTestEnvironmentMapper.insert(request); return request.getId(); } + private ApiTestEnvironmentDTO updateConfig(ApiTestEnvironmentDTO request, boolean isMock) { + if(StringUtils.isNotEmpty(request.getConfig())){ + try{ + JSONObject configObj = JSONObject.parseObject(request.getConfig()); + if(configObj.containsKey("httpConfig")){ + JSONObject httpObj = configObj.getJSONObject("httpConfig"); + httpObj.put("isMock",isMock); + } + request.setConfig(configObj.toJSONString()); + }catch (Exception e){ + } + } + return request; + } + public void update(ApiTestEnvironmentDTO apiTestEnvironment,List sslFiles) { checkEnvironmentExist(apiTestEnvironment); FileUtils.createFiles(apiTestEnvironment.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl"); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 8b1cea2371..98ed99af03 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -110,7 +110,7 @@ {{ currentScenario.name === undefined || '' ? $t('api_test.scenario.name') : currentScenario.name }} diff --git a/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue b/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue index bf681eacbb..401cad8585 100644 --- a/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue +++ b/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue @@ -70,6 +70,8 @@ } }, copyEnvironment(environment) { + //点击复制的时候先选择改行,否则会出现解析错误 + this.environmentSelected(environment); this.currentEnvironment = environment; if (!environment.id) { this.$warning(this.$t('commons.please_save'));