From a683bb27ffd50a4a4348092d4e5f41853b24afd9 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 30 Dec 2020 11:25:26 +0800 Subject: [PATCH] =?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=8Dhttp=E7=8E=AF=E5=A2=83=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=B4=E5=85=AC=E5=85=B1=E5=8F=82=E6=95=B0=E6=97=A0?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsScenario.java | 6 ++++++ .../api/dto/definition/request/MsTestElement.java | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 19097a14bf..ae76ff73db 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -109,6 +109,12 @@ public class MsScenario extends MsTestElement { arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); } + if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null + && CollectionUtils.isNotEmpty(config.getConfig().getHttpConfig().getHeaders())) { + config.getConfig().getHttpConfig().getHeaders().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> + arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") + ); + } return arguments; } } 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 5c60342d6d..b54ffdff16 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 @@ -138,9 +138,9 @@ public abstract class MsTestElement { } public Arguments addArguments(ParameterConfig config) { + Arguments arguments = new Arguments(); if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null && CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) { - Arguments arguments = new Arguments(); arguments.setEnabled(true); arguments.setName(name + "Variables"); arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName()); @@ -148,9 +148,18 @@ public abstract class MsTestElement { config.getConfig().getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); - return arguments; } - return null; + if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null + && CollectionUtils.isNotEmpty(config.getConfig().getHttpConfig().getHeaders())) { + arguments.setEnabled(true); + arguments.setName(name + "Variables"); + arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName()); + arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel")); + config.getConfig().getHttpConfig().getHeaders().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> + arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") + ); + } + return arguments; } }