From 5d0e80204119d7292f8133e14fbddc27385c3335 Mon Sep 17 00:00:00 2001 From: BugKing Date: Thu, 16 Jul 2020 16:00:16 +0800 Subject: [PATCH 1/6] =?UTF-8?q?docs:=20=E5=9C=A8=20readme=20=E4=B8=AD?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index d1f25726d0..3992f40dee 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,21 @@ curl -sSL https://github.com/metersphere/metersphere/releases/latest/download/qu - [完整文档](https://metersphere.io/docs/) - [演示视频](http://video.fit2cloud.com/%E3%80%90%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91%E3%80%91202006%20MeterSphere%20v1.0%20%E5%8A%9F%E8%83%BD%E6%BC%94%E7%A4%BA.mp4) +## 版本说明 + +MeterSphere 版本号命名规则为:v大版本.功能版本.Bug修复版本。比如: + +``` +v1.0.1 是 v1.0.0 之后的Bug修复版本; +v1.1.0 是 v1.0.0 之后的功能版本。 +``` +像其它优秀开源项目一样,MeterSphere 将每月发布一个功能版本,并同时维护 3 个功能版本。比如: + +``` +在 v1.3 发布前,我们会同时维护 v1.0、v1.1、v1.2; +在 v1.3 发布后,我们会同时维护 v1.1、v1.2、v1.3;v1.0 会停止维护。 +``` + ## 技术优势 - 全生命周期: 能够覆盖从测试计划到测试执行、测试报告分析的不同阶段; From 04e27d27c8e8369e313dba27e324c2d7e0466adf Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 16 Jul 2020 16:57:33 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/components/ApiEnvironmentConfig.vue | 29 ++++++++++++++----- .../environment/EnvironmentEdit.vue | 19 +++++++----- .../common/components/MsAsideItem.vue | 8 ++--- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue b/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue index f7a735befa..033d279310 100644 --- a/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue +++ b/frontend/src/business/components/api/test/components/ApiEnvironmentConfig.vue @@ -50,19 +50,34 @@ this.getEnvironments(); }, deleteEnvironment(environment) { - this.result = this.$get('/api/environment/delete/' + environment.id, response => { - this.$success(this.$t('commons.delete_success')); - this.getEnvironments(); - }); + if (environment.id) { + this.result = this.$get('/api/environment/delete/' + environment.id, () => { + this.$success(this.$t('commons.delete_success')); + this.getEnvironments(); + }); + } }, copyEnvironment(environment) { let newEnvironment = {}; Object.assign(newEnvironment, environment); newEnvironment.id = null; + newEnvironment.name = this.getNoRepeatName(newEnvironment.name); + this.$refs.environmentEdit._save(newEnvironment); this.environments.push(newEnvironment); + this.$refs.environmentItems.itemSelected(this.environments.length -1 , newEnvironment); + }, + getNoRepeatName(name) { + for (let i in this.environments) { + if (this.environments[i].name === name) { + return this.getNoRepeatName(name + ' copy'); + } + } + return name; }, addEnvironment() { - this.environments.push(this.getDefaultEnvironment()); + let newEnvironment = this.getDefaultEnvironment(); + this.environments.push(newEnvironment); + this.$refs.environmentItems.itemSelected(this.environments.length -1 , newEnvironment); }, environmentSelected(environment) { this.getEnvironment(environment); @@ -97,6 +112,7 @@ close() { this.$emit('close'); this.visible = false; + this.$refs.environmentEdit.clearValidate(); } } } @@ -116,7 +132,4 @@ height: 100%; position: absolute; } - - - diff --git a/frontend/src/business/components/api/test/components/environment/EnvironmentEdit.vue b/frontend/src/business/components/api/test/components/environment/EnvironmentEdit.vue index d34077a6db..3b3380c425 100644 --- a/frontend/src/business/components/api/test/components/environment/EnvironmentEdit.vue +++ b/frontend/src/business/components/api/test/components/environment/EnvironmentEdit.vue @@ -78,30 +78,30 @@ save() { this.$refs['from'].validate((valid) => { if (valid) { - this._save(); + this._save(this.environment); } else { return false; } }); }, - _save() { - let param = this.buildParam(); + _save(environment) { + let param = this.buildParam(environment); let url = '/api/environment/add'; if (param.id) { url = '/api/environment/update'; } this.result = this.$post(url, param, response => { if (!param.id) { - this.environment.id = response.data; + environment.id = response.data; } this.$success(this.$t('commons.save_success')); }); }, - buildParam() { + buildParam(environment) { let param = {}; - Object.assign(param, this.environment); - param.variables = JSON.stringify(this.environment.variables); - param.headers = JSON.stringify(this.environment.headers); + Object.assign(param, environment); + param.variables = JSON.stringify(environment.variables); + param.headers = JSON.stringify(environment.headers); return param; }, validateSocket(socket) { @@ -135,6 +135,9 @@ }, cancel() { this.$emit('close'); + }, + clearValidate() { + this.$refs["from"].clearValidate(); } }, } diff --git a/frontend/src/business/components/common/components/MsAsideItem.vue b/frontend/src/business/components/common/components/MsAsideItem.vue index 48b0f33edb..2f37bbe9c7 100644 --- a/frontend/src/business/components/common/components/MsAsideItem.vue +++ b/frontend/src/business/components/common/components/MsAsideItem.vue @@ -10,14 +10,10 @@ -
- - - - + - +
From dc25e0fe63fc8a5d1f82926df39fedb6c763363a Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 16 Jul 2020 17:26:23 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/components/ApiScenarioForm.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/business/components/api/test/components/ApiScenarioForm.vue b/frontend/src/business/components/api/test/components/ApiScenarioForm.vue index 383a82e190..deb002d984 100644 --- a/frontend/src/business/components/api/test/components/ApiScenarioForm.vue +++ b/frontend/src/business/components/api/test/components/ApiScenarioForm.vue @@ -16,10 +16,6 @@ - - - - @@ -86,6 +82,7 @@ for (let i in this.environments) { if (this.environments[i].id === this.scenario.environmentId) { this.scenario.environment = this.environments[i]; + this.setRequestEnvironments(); hasEnvironment = true; break; } @@ -104,9 +101,7 @@ for (let i in this.environments) { if (this.environments[i].id === value) { this.scenario.environment = this.environments[i]; - this.scenario.requests.forEach(request => { - request.environment = this.environments[i]; - }); + this.setRequestEnvironments(); break; } } @@ -126,6 +121,11 @@ }, environmentConfigClose() { this.getEnvironments(); + }, + setRequestEnvironments() { + this.scenario.requests.forEach(request => { + request.environment = this.scenario.environment; + }); } } } From c16f60e87dbabeebc68fff4cb55c45d5f33ea43a Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 16 Jul 2020 18:04:11 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20=E4=BF=9D=E5=AD=98=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/service/ApiTestEnvironmentService.java | 2 +- frontend/src/business/components/api/test/ApiTestConfig.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 e2e485ae2a..acaa4e3551 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java @@ -34,7 +34,7 @@ public class ApiTestEnvironmentService { } public void update(ApiTestEnvironmentWithBLOBs apiTestEnvironment) { - apiTestEnvironmentMapper.updateByPrimaryKeySelective(apiTestEnvironment); + apiTestEnvironmentMapper.updateByPrimaryKey(apiTestEnvironment); } public String add(ApiTestEnvironmentWithBLOBs apiTestEnvironmentWithBLOBs) { diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index 080c03aecb..0d27df2b79 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -255,7 +255,7 @@ return this.test.isValid() && !this.change; }, isDisabled() { - return !(this.test.isValid()) + return !(this.test.isValid()) && !this.change; } }, From b29a4f91090b1693ae4e3f6ab4f136b68c85c5cb Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 16 Jul 2020 18:50:45 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E5=AF=BC=E5=85=A5=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8D=E6=A0=A1=E9=AA=8C=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/service/APITestService.java | 15 ++------------- .../components/api/test/ApiTestConfig.vue | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 7f49463951..a41addfd2e 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.List; @@ -39,8 +40,6 @@ import java.util.Random; import java.util.UUID; import java.util.stream.Collectors; -import javax.annotation.Resource; - @Service @Transactional(rollbackFor = Exception.class) public class APITestService { @@ -76,6 +75,7 @@ public class APITestService { if (files == null || files.isEmpty()) { throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); } + checkNameExist(request); ApiTest test = createTest(request); saveFile(test.getId(), files); } @@ -173,12 +173,6 @@ public class APITestService { } } - private Boolean isNameExist(SaveAPITestRequest request) { - ApiTestExample example = new ApiTestExample(); - example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId()); - return apiTestMapper.countByExample(example) > 0; - } - private ApiTest updateTest(SaveAPITestRequest request) { checkNameExist(request); final ApiTest test = new ApiTest(); @@ -193,7 +187,6 @@ public class APITestService { } private ApiTest createTest(SaveAPITestRequest request) { - checkNameExist(request); final ApiTest test = new ApiTest(); test.setId(request.getId()); test.setName(request.getName()); @@ -290,10 +283,6 @@ public class APITestService { request.setName(name.substring(0, name.length() - suffix.length())); } } - - if (isNameExist(request)) { - request.setName(request.getName() + "_" + request.getId().substring(0, 5)); - } return request; } } diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index 0d27df2b79..5d474723c5 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -255,7 +255,7 @@ return this.test.isValid() && !this.change; }, isDisabled() { - return !(this.test.isValid()) && !this.change; + return !(this.test.isValid() && this.change); } }, From d830cc85db51874b821f76cd6b58f0c633a74fec Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 17 Jul 2020 09:34:39 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20postman=20=E5=AF=BC=E5=85=A5body?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/parse/PostmanParser.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/parse/PostmanParser.java b/backend/src/main/java/io/metersphere/api/parse/PostmanParser.java index ed270d27b9..8f3988fb3a 100644 --- a/backend/src/main/java/io/metersphere/api/parse/PostmanParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/PostmanParser.java @@ -14,10 +14,23 @@ import org.apache.commons.lang3.StringUtils; import java.io.InputStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class PostmanParser extends ApiImportAbstractParser { + private static Map postmanBodyRowMap; + + static { + postmanBodyRowMap = new HashMap<>(); + postmanBodyRowMap.put("json", "application/json"); + postmanBodyRowMap.put("text", "text/plain"); + postmanBodyRowMap.put("html", "text/html"); + postmanBodyRowMap.put("xml", "text/xml"); + postmanBodyRowMap.put("javascript", "application/x-javascript"); + } + @Override public ApiImport parse(InputStream source) { String testStr = getApiTestStr(source); @@ -69,7 +82,7 @@ public class PostmanParser extends ApiImportAbstractParser { if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.RAW.value())) { body.setRaw(postmanBody.getString(bodyMode)); body.setType(MsRequestBodyType.RAW.value()); - String contentType = postmanBody.getJSONObject("options").getJSONObject("raw").getString("language"); + String contentType = postmanBodyRowMap.get(postmanBody.getJSONObject("options").getJSONObject("raw").getString("language")); addContentType(request, contentType); } else if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.FORM_DATA.value()) || StringUtils.equals(bodyMode, PostmanRequestBodyMode.URLENCODED.value())) { List postmanKeyValues = JSON.parseArray(postmanBody.getString(bodyMode), PostmanKeyValue.class);