fix(接口自动化): 修复通用请求头问题
This commit is contained in:
parent
a683bb27ff
commit
56d0a24fd8
|
@ -109,12 +109,6 @@ public class MsScenario extends MsTestElement {
|
||||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
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;
|
return arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,16 +149,6 @@ public abstract class MsTestElement {
|
||||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
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;
|
return arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,9 +189,15 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashTree httpSamplerTree = tree.add(sampler);
|
final HashTree httpSamplerTree = tree.add(sampler);
|
||||||
if (CollectionUtils.isNotEmpty(this.headers)) {
|
// 通用请求Headers
|
||||||
setHeader(httpSamplerTree);
|
if (config != null && config.getConfig() != null && config.getConfig().getHttpConfig() != null
|
||||||
|
&& CollectionUtils.isNotEmpty(config.getConfig().getHttpConfig().getHeaders())) {
|
||||||
|
setHeader(httpSamplerTree, config.getConfig().getHttpConfig().getHeaders());
|
||||||
}
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(this.headers)) {
|
||||||
|
setHeader(httpSamplerTree, this.headers);
|
||||||
|
}
|
||||||
|
|
||||||
//判断是否要开启DNS
|
//判断是否要开启DNS
|
||||||
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
||||||
&& config.getConfig().getCommonConfig().isEnableHost()) {
|
&& config.getConfig().getCommonConfig().isEnableHost()) {
|
||||||
|
@ -266,7 +272,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeader(HashTree tree) {
|
public void setHeader(HashTree tree, List<KeyValue> headers) {
|
||||||
HeaderManager headerManager = new HeaderManager();
|
HeaderManager headerManager = new HeaderManager();
|
||||||
headerManager.setEnabled(true);
|
headerManager.setEnabled(true);
|
||||||
headerManager.setName(this.getName() + "Headers");
|
headerManager.setName(this.getName() + "Headers");
|
||||||
|
|
Loading…
Reference in New Issue