From 150cb57836abe617e1abddfae520ddf5ff0085ec Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Mar 2021 18:19:42 +0800 Subject: [PATCH 01/10] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=20csv=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/dto/definition/request/MsTestElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 5fa9333809..a7563bf58a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -213,7 +213,7 @@ public abstract class MsTestElement { csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName()); csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding()); if (CollectionUtils.isNotEmpty(item.getFiles())) { - if (!config.isOperating() && new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) { + if (!config.isOperating() && !new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) { MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ CSV文件不存在 ]"); } csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()); From a8b54c9d74901918fae6e0720031f354f4076122 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Thu, 25 Mar 2021 18:33:03 +0800 Subject: [PATCH 02/10] =?UTF-8?q?refactor:=20=E6=89=93=E5=BC=80=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E9=85=8D=E7=BD=AE=E6=97=B6=E9=BB=98=E8=AE=A4=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E5=BD=93=E5=89=8D=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/automation/scenario/EnvSelect.vue | 8 ++++---- .../components/case/MsEnvironmentSelect.vue | 2 +- .../environment/ApiEnvironmentConfig.vue | 17 ++++++++++++++--- .../test/components/ApiEnvironmentConfig.vue | 17 ++++++++++++++--- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue index c9eda69790..87c62495f0 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue @@ -5,12 +5,12 @@ - + {{ $t('api_test.environment.environment_config') }} @@ -42,6 +42,7 @@ v-model="threadGroup.threadNumber" @change="calculateTotalChart(threadGroup)" :min="resourcePoolResourceLength" + :max="maxThreadNumbers" size="mini"/>
@@ -219,7 +220,8 @@ export default { resourcePools: [], activeNames: ["0"], threadGroups: [], - resourcePoolResourceLength: 1 + resourcePoolResourceLength: 1, + maxThreadNumbers: 5000, } }, mounted() { @@ -336,6 +338,22 @@ export default { }); } }, + resourcePoolChange() { + let result = this.resourcePools.filter(p => p.id === this.resourcePool); + if (result.length === 1) { + let threadNumber = 0; + result[0].resources.forEach(resource => { + threadNumber += JSON.parse(resource.configuration).maxConcurrency; + }) + this.maxThreadNumbers = threadNumber; + this.threadGroups.forEach(tg => { + if (tg.threadNumber > threadNumber) { + this.$set(tg, "threadNumber", threadNumber); + } + }) + this.calculateTotalChart(); + } + }, calculateTotalChart() { let handler = this; if (handler.duration < handler.rampUpTime) { @@ -344,6 +362,11 @@ export default { if (handler.rampUpTime < handler.step) { handler.step = handler.rampUpTime; } + // 线程数不能小于资源池节点的数量 + let resourcePool = this.resourcePools.filter(v => v.id === this.resourcePool)[0]; + if (resourcePool) { + this.resourcePoolResourceLength = resourcePool.resources.length; + } let color = ['#60acfc', '#32d3eb', '#5bc49f', '#feb64d', '#ff7c7c', '#9287e7', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3']; handler.options = { color: color, @@ -649,7 +672,7 @@ export default { border-bottom: 1px solid #DCDFE6; } -/deep/ .el-collapse-item__content{ +/deep/ .el-collapse-item__content { padding-left: 10px; padding-bottom: 5px; border-left-width: 8px; From ef6c7ae83cafa33344b8c3cc60e36d8475b80230 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 25 Mar 2021 19:26:42 +0800 Subject: [PATCH 05/10] chore: sync --- frontend/src/business/components/xpack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 07951ba17a..2115bd28a9 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd +Subproject commit 2115bd28a90854d2b6276a90878934715498c584 From 767faf9dfe9032ede1ccb89d57f3696a91eb1c39 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 26 Mar 2021 09:52:03 +0800 Subject: [PATCH 06/10] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=A1=A8=E6=A0=BC=E5=9B=BA=E5=AE=9A=E5=88=97=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/automation/scenario/ApiScenarioList.vue | 2 +- .../api/definition/components/list/ApiCaseSimpleList.vue | 2 +- .../components/api/definition/components/list/ApiList.vue | 2 +- .../business/components/track/case/components/TestCaseList.vue | 2 +- .../plan/view/comonents/functional/FunctionalTestCaseList.vue | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index d71c832f56..7334643973 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -433,7 +433,7 @@ this.result.loading = false; this.unSelection = data.listObject.map(s => s.id); if (this.$refs.scenarioTable) { - setTimeout(this.$refs.scenarioTable.doLayout,500) + setTimeout(this.$refs.scenarioTable.doLayout, 200) } }); } diff --git a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue index 48f4e2e212..6437c94123 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue @@ -340,7 +340,7 @@ export default { } }) if (this.$refs.caseTable) { - setTimeout(this.$refs.caseTable.doLayout,500) + setTimeout(this.$refs.caseTable.doLayout, 200) } }); } diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index 46ffe54bea..7ec2982c49 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -464,7 +464,7 @@ } }) if (this.$refs.apiDefinitionTable) { - setTimeout(this.$refs.apiDefinitionTable.doLayout, 500) + setTimeout(this.$refs.apiDefinitionTable.doLayout, 200) } }); diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 2b0ec84d70..8a6220194d 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -399,7 +399,7 @@ export default { item.tags = JSON.parse(item.tags); }) if (this.$refs.table) { - setTimeout(this.$refs.table.doLayout,500) + setTimeout(this.$refs.table.doLayout, 200) } }); diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue index b3682c0801..5117b039af 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue @@ -477,7 +477,7 @@ export default { } this.selectRows.clear(); if (this.$refs.table) { - setTimeout(this.$refs.table.doLayout,500) + setTimeout(this.$refs.table.doLayout, 200) } }); } From ba76c828510a330d56a622a1ffd330734b932775 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 26 Mar 2021 11:21:38 +0800 Subject: [PATCH 07/10] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=A4=8D=E5=88=B6=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=EF=BC=8C=E5=9C=BA=E6=99=AF=E5=8F=98=E9=87=8F=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E7=BC=96=E8=BE=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/automation/scenario/EditApiScenario.vue | 2 +- .../api/automation/scenario/component/StepExtendBtns.vue | 2 +- .../api/automation/scenario/maximize/MaximizeScenario.vue | 2 +- frontend/src/business/components/xpack | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index d5c143a998..bab76c1216 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -577,7 +577,7 @@ recursiveSorting(arr, scenarioProjectId) { for (let i in arr) { arr[i].index = Number(i) + 1; - if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].hashTree && arr[i].hashTree.length > 1) { + if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) { arr[i].countController.proceed = true; } if (!arr[i].projectId) { diff --git a/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue b/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue index d028acef6b..76222ef456 100644 --- a/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue +++ b/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue @@ -45,7 +45,7 @@ this.$emit('remove'); break; case "scenarioVar": - this.$refs.scenarioParameters.open(this.data.variables, this.data.headers, true); + this.$refs.scenarioParameters.open(this.data.variables, this.data.headers, this.data.referenced === 'REF'); break; case "openScenario": this.getScenario(); diff --git a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue index 65559c659d..4b2911fb5f 100644 --- a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue @@ -493,7 +493,7 @@ recursiveSorting(arr, scenarioProjectId) { for (let i in arr) { arr[i].index = Number(i) + 1; - if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].hashTree && arr[i].hashTree.length > 1) { + if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) { arr[i].countController.proceed = true; } if (!arr[i].projectId) { diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 2115bd28a9..07951ba17a 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 2115bd28a90854d2b6276a90878934715498c584 +Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd From 6fcc8536d0f935ec82e67b0f46d0820e2a9aa0a6 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 26 Mar 2021 14:00:34 +0800 Subject: [PATCH 08/10] chore: sync --- frontend/src/business/components/xpack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 07951ba17a..2115bd28a9 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd +Subproject commit 2115bd28a90854d2b6276a90878934715498c584 From f5796eb602ec7ddf65740db4df76aed89675e3cd Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 26 Mar 2021 14:14:40 +0800 Subject: [PATCH 09/10] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA)?= =?UTF-8?q?:=20=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtTestCaseMapper.xml | 2 +- .../track/case/components/TestCaseList.vue | 22 ++++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index b23321eba5..6930ce6025 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -274,7 +274,7 @@ #{value} - + and test_case.review_status in #{value} diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 8a6220194d..353891d7b0 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -303,20 +303,12 @@ export default { }, created: function () { this.$emit('setCondition', this.condition); - if (this.trashEnable) { - this.condition.filters = {status: ["Trash"]}; - } else { - this.condition.filters = {status: ["Prepare", "Pass", "UnPass"]}; - } + this.condition.filters = {reviewStatus: ["Prepare", "Pass", "UnPass"]}; this.initTableData(); getSystemLabel(this, this.type) }, activated() { - if (this.trashEnable) { - this.condition.filters = {status: ["Trash"]}; - } else { - this.condition.filters = {status: ["Prepare", "Pass", "UnPass"]}; - } + this.condition.filters = {reviewStatus: ["Prepare", "Pass", "UnPass"]}; this.initTableData(); }, watch: { @@ -372,15 +364,15 @@ export default { case 'coverage': this.condition.caseCoverage = 'coverage'; break; - /* case 'Prepare': - this.condition.filters.status = [this.selectDataRange]; + case 'Prepare': + this.condition.filters.reviewStatus = [this.selectDataRange]; break; case 'Pass': - this.condition.filters.status = [this.selectDataRange]; + this.condition.filters.reviewStatus = [this.selectDataRange]; break; case 'UnPass': - this.condition.filters.status = [this.selectDataRange]; - break;*/ + this.condition.filters.reviewStatus = [this.selectDataRange]; + break; } if (this.projectId) { this.condition.projectId = this.projectId; From dda1217c1aa0fe7dd52a2251723aad1b941e5aa0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 26 Mar 2021 16:29:18 +0800 Subject: [PATCH 10/10] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E6=AD=A5=E9=AA=A4=E8=AF=B7=E6=B1=82=20ip=20=E5=92=8C?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=20=E6=98=AF=E5=8F=98=E9=87=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/automation/parse/MsJmeterParser.java | 69 +++++++++++++++++-- .../request/sampler/MsHTTPSamplerProxy.java | 34 ++++++--- .../automation/scenario/EditApiScenario.vue | 2 +- 3 files changed, 87 insertions(+), 18 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java index 7cb52c524c..852b3b9755 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java @@ -75,6 +75,8 @@ import org.apache.jorphan.collections.HashTree; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.lang.reflect.Field; +import java.net.MalformedURLException; +import java.net.URL; import java.util.*; public class MsJmeterParser extends ApiImportAbstractParser { @@ -132,12 +134,66 @@ public class MsJmeterParser extends ApiImportAbstractParser { return (HashTree) field.get(scriptWrapper); } + public boolean isProtocolDefaultPort(HTTPSamplerProxy source) { + String portAsString = source.getPropertyAsString("HTTPSampler.port"); + if (portAsString != null && !portAsString.isEmpty()) { + return false; + } else { + return true; + } + } + + public String url(String protocol, String host, String port, String file) { + protocol = protocol.toLowerCase(); + if (StringUtils.isNotEmpty(file) && !file.startsWith("/")) { + file += "/"; + } + return protocol + "://" + host + ":" + port + file; + } + + public String getUrl(HTTPSamplerProxy source) throws MalformedURLException { + String path = source.getPath(); + if (!path.startsWith("http://") && !path.startsWith("https://")) { + String domain = source.getDomain(); + String protocol = source.getProtocol(); + String method = source.getMethod(); + StringBuilder pathAndQuery = new StringBuilder(100); + if ("file".equalsIgnoreCase(protocol)) { + domain = null; + } else if (!path.startsWith("/")) { + pathAndQuery.append('/'); + } + + pathAndQuery.append(path); + if ("GET".equals(method) || "DELETE".equals(method) || "OPTIONS".equals(method)) { + String queryString = source.getQueryString(source.getContentEncoding()); + if (queryString.length() > 0) { + if (path.contains("?")) { + pathAndQuery.append("&"); + } else { + pathAndQuery.append("?"); + } + + pathAndQuery.append(queryString); + } + } + String portAsString = source.getPropertyAsString("HTTPSampler.port"); + return this.isProtocolDefaultPort(source) ? new URL(protocol, domain, pathAndQuery.toString()).toExternalForm() : this.url(protocol, domain, portAsString, pathAndQuery.toString()); + } else { + return new URL(path).toExternalForm(); + } + } + private void convertHttpSampler(MsHTTPSamplerProxy samplerProxy, Object key) { try { HTTPSamplerProxy source = (HTTPSamplerProxy) key; BeanUtils.copyBean(samplerProxy, source); - samplerProxy.setRest(new ArrayList(){{this.add(new KeyValue());}}); - samplerProxy.setArguments(new ArrayList(){{this.add(new KeyValue());}}); + samplerProxy.setRest(new ArrayList() {{ + this.add(new KeyValue()); + }}); + samplerProxy.setArguments(new ArrayList() {{ + this.add(new KeyValue()); + }}); if (source != null && source.getHTTPFiles().length > 0) { samplerProxy.getBody().initBinary(); samplerProxy.getBody().setType(Body.FORM_DATA); @@ -158,7 +214,8 @@ public class MsJmeterParser extends ApiImportAbstractParser { samplerProxy.getBody().setKvs(keyValues); } samplerProxy.setProtocol(RequestType.HTTP); - samplerProxy.setPort(source.getPort() + ""); + samplerProxy.setPort(source.getPropertyAsString("HTTPSampler.port")); + samplerProxy.setDomain(source.getDomain()); if (source.getArguments() != null) { if (source.getPostBodyRaw()) { samplerProxy.getBody().setType(Body.RAW); @@ -178,10 +235,10 @@ public class MsJmeterParser extends ApiImportAbstractParser { } samplerProxy.getBody().initBinary(); } - samplerProxy.setPath(""); + // samplerProxy.setPath(source.getPath()); samplerProxy.setMethod(source.getMethod()); - if (source.getUrl() != null) { - samplerProxy.setUrl(source.getUrl().toString()); + if (this.getUrl(source) != null) { + samplerProxy.setUrl(this.getUrl(source)); } samplerProxy.setId(UUID.randomUUID().toString()); samplerProxy.setType("HTTPSamplerProxy"); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 907e0170fb..ecf3e2b261 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -91,6 +91,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { @JSONField(ordinal = 36) private MsAuthManager authManager; + @JSONField(ordinal = 37) + private boolean urlOrPath; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { // 非导出操作,且不是启用状态则跳过执行 @@ -140,23 +143,26 @@ public class MsHTTPSamplerProxy extends MsTestElement { url = this.getUrl(); isUrl = true; } - URL urlObject = new URL(url); if (isUrl) { + if (StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) { + url.replaceAll(this.getPort(), "10990"); + } + URL urlObject = new URL(url); sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8")); - if (urlObject.getPort() > 0) { + if (urlObject.getPort() > 0 && urlObject.getPort() != 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) { sampler.setPort(urlObject.getPort()); + } else { + sampler.setProperty("HTTPSampler.port", this.getPort()); } sampler.setProtocol(urlObject.getProtocol()); + sampler.setPath(urlObject.getPath()); } else { sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain()); sampler.setPort(config.getConfig().get(this.getProjectId()).getHttpConfig().getPort()); sampler.setProtocol(config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol()); + sampler.setPath(this.getPath()); } - String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath(); - if (StringUtils.isNotBlank(this.getPath()) && !isUrl) { - envPath += this.getPath(); - sampler.setPath(envPath); - } + String envPath = sampler.getPath(); if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) { envPath = getRestParameters(URLDecoder.decode(envPath, "UTF-8")); sampler.setPath(envPath); @@ -327,10 +333,16 @@ public class MsHTTPSamplerProxy extends MsTestElement { } public boolean isURL(String str) { - //转换为小写 try { - new URL(str); - return true; + String regex = "^((https|http|ftp|rtsp|mms)?://)" + + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" + + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" + "|" + "([0-9a-z_!~*'()-]+\\.)*" + + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\." + + "[a-z]{2,6})" + + "(:[0-9]{1,5})?" + + "((/?)|" + + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; + return str.matches(regex) || (str.matches("^(http|https|ftp)://.*$") && str.matches(".*://\\$\\{.*$")); } catch (Exception e) { return false; } @@ -339,5 +351,5 @@ public class MsHTTPSamplerProxy extends MsTestElement { private boolean isRest() { return this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).toArray().length > 0; } - } + diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index bab76c1216..4ebeeea4c4 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -926,7 +926,7 @@ return bodyUploadFiles; }, editScenario() { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败 this.$refs['currentScenario'].validate((valid) => { if (valid) {