From cd33380763ded9fe8121f803c5881b38fd58691c Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 28 Jan 2021 16:17:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9C=BA=E6=99=AF=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E8=AE=A4=E8=AF=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/sampler/MsHTTPSamplerProxy.java | 7 +++++++ .../scenario/component/ApiComponent.vue | 9 +++++++++ .../scenario/component/ComponentConfig.vue | 4 +++- .../definition/components/auth/ApiAuthConfig.vue | 16 ++++++++++------ 4 files changed, 29 insertions(+), 7 deletions(-) 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 b1a5ff5701..22c78ad384 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONType; import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.ParameterConfig; +import io.metersphere.api.dto.definition.request.auth.MsAuthManager; import io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager; import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.KeyValue; @@ -87,6 +88,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { @JSONField(ordinal = 35) private Object requestResult; + @JSONField(ordinal = 36) + private MsAuthManager authManager; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { @@ -223,6 +227,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { el.toHashTree(httpSamplerTree, el.getHashTree(), config); } } + if (this.authManager != null) { + this.authManager.toHashTree(tree, hashTree, config); + } } private boolean isVariable(String path, String value) { diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 433d9ef3f8..5fae058169 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -107,6 +107,15 @@ this.request.url = undefined; } } + // 历史数据 auth 处理 + if (this.request.hashTree) { + for (let index in this.request.hashTree) { + if (this.request.hashTree[index].type == 'AuthManager') { + this.request.authManager = this.request.hashTree[index]; + this.request.hashTree.splice(index, 1); + } + } + } } }, computed: { diff --git a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue index 8e9a5cd98e..59e4c6c13c 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -70,6 +70,8 @@ case ELEMENT_TYPE.scenario: name = "MsApiScenarioComponent"; break; + case "AuthManager": + break; default: name = "MsApiComponent"; break; @@ -107,7 +109,7 @@ suggestClick(node) { this.$emit('suggestClick', node); }, - refReload(){ + refReload() { this.$emit('refReload'); } } diff --git a/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue b/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue index 2fc2b7136b..0f9fa7a651 100644 --- a/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue +++ b/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue @@ -3,7 +3,7 @@ - + @@ -50,9 +50,7 @@ - - @@ -66,11 +64,17 @@ request: {}, }, created() { - for (let index in this.request.hashTree) { - if (this.request.hashTree[index].type == 'AuthManager') { - this.authConfig = this.request.hashTree[index]; + if (this.request.hashTree) { + for (let index in this.request.hashTree) { + if (this.request.hashTree[index].type == 'AuthManager') { + this.request.authManager = this.request.hashTree[index]; + this.request.hashTree.splice(index, 1); + } } } + if (this.request.authManager) { + this.authConfig = this.request.authManager; + } }, data() { return {