fix(接口测试): auth配置执行不生效
This commit is contained in:
parent
42eb1a827c
commit
1fb923d2af
|
@ -96,7 +96,7 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
|
||||||
HTTPAuthConfig authConfig = msHTTPElement.getAuthConfig();
|
HTTPAuthConfig authConfig = msHTTPElement.getAuthConfig();
|
||||||
|
|
||||||
// 处理认证信息
|
// 处理认证信息
|
||||||
AuthManager authManager = getAuthManager(sampler, authConfig);
|
AuthManager authManager = getAuthManager(authConfig);
|
||||||
if (authManager != null) {
|
if (authManager != null) {
|
||||||
httpTree.add(authManager);
|
httpTree.add(authManager);
|
||||||
}
|
}
|
||||||
|
@ -136,17 +136,16 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取认证配置
|
* 获取认证配置
|
||||||
* @param sampler
|
|
||||||
* @param authConfig
|
* @param authConfig
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private AuthManager getAuthManager(HTTPSamplerProxy sampler, HTTPAuthConfig authConfig) {
|
private AuthManager getAuthManager(HTTPAuthConfig authConfig) {
|
||||||
if (authConfig == null || !authConfig.isHTTPAuthValid()) {
|
if (authConfig == null || !authConfig.isHTTPAuthValid()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Authorization auth = new Authorization();
|
Authorization auth = new Authorization();
|
||||||
auth.setURL(sampler.getPath());
|
auth.setURL(StringUtils.EMPTY);
|
||||||
auth.setMechanism(mechanismMap.get(authConfig.getAuthType()));
|
auth.setMechanism(mechanismMap.get(authConfig.getAuthType()));
|
||||||
authHanlerMap.get(authConfig.getAuthType()).accept(auth, authConfig);
|
authHanlerMap.get(authConfig.getAuthType()).accept(auth, authConfig);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,10 @@ public class MsFormDataBodyConverter extends MsBodyConverter<FormDataBody> {
|
||||||
if (CollectionUtils.isEmpty(formValues)) {
|
if (CollectionUtils.isEmpty(formValues)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<FormDataKV> validFormValues = formValues.stream().filter(FormDataKV::isValid).collect(Collectors.toList());
|
List<FormDataKV> validFormValues = formValues.stream()
|
||||||
|
.filter(FormDataKV::getEnable)
|
||||||
|
.filter(FormDataKV::isValid)
|
||||||
|
.collect(Collectors.toList());
|
||||||
List<FormDataKV> fileFormValues = validFormValues.stream().filter(FormDataKV::isFile).collect(Collectors.toList());
|
List<FormDataKV> fileFormValues = validFormValues.stream().filter(FormDataKV::isFile).collect(Collectors.toList());
|
||||||
List<FormDataKV> textFormValues = validFormValues.stream().filter(kv -> !kv.isFile()).collect(Collectors.toList());
|
List<FormDataKV> textFormValues = validFormValues.stream().filter(kv -> !kv.isFile()).collect(Collectors.toList());
|
||||||
sampler.setHTTPFiles(getHttpFileArg(fileFormValues));
|
sampler.setHTTPFiles(getHttpFileArg(fileFormValues));
|
||||||
|
|
|
@ -16,7 +16,10 @@ public class MsWWWFormBodyConverter extends MsBodyConverter<WWWFormBody> {
|
||||||
@Override
|
@Override
|
||||||
public void parse(HTTPSamplerProxy sampler, WWWFormBody body, ParameterConfig config) {
|
public void parse(HTTPSamplerProxy sampler, WWWFormBody body, ParameterConfig config) {
|
||||||
List<WWWFormKV> formValues = body.getFormValues();
|
List<WWWFormKV> formValues = body.getFormValues();
|
||||||
List<WWWFormKV> validFormValues = formValues.stream().filter(WWWFormKV::isValid).collect(Collectors.toList());
|
List<WWWFormKV> validFormValues = formValues.stream()
|
||||||
|
.filter(WWWFormKV::getEnable)
|
||||||
|
.filter(WWWFormKV::isValid)
|
||||||
|
.collect(Collectors.toList());
|
||||||
sampler.setArguments(getArguments(validFormValues));
|
sampler.setArguments(getArguments(validFormValues));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue