fix(接口测试): 修复 github#10601 认证No Auth导致执行报错问题
--bug=1010304 --user=赵勇 [接口自动化] github#10601接口测试或者自动化测试中,认证设置如果误选了“No Auth”,会导致接口运行报错 https://www.tapd.cn/55049933/s/1104807
This commit is contained in:
parent
3d9d9dffe8
commit
3009e27a1a
|
@ -57,6 +57,7 @@ public class MsAuthManager extends MsTestElement {
|
|||
if (!this.isEnable()) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.equals(this.getVerification(), "Basic Auth")) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
AuthManager authManager = new AuthManager();
|
||||
authManager.setEnabled(true);
|
||||
|
@ -80,6 +81,7 @@ public class MsAuthManager extends MsTestElement {
|
|||
authManager.addAuth(auth);
|
||||
tree.add(authManager);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAuth(HashTree tree, MsAuthManager msAuthManager, HTTPSamplerProxy samplerProxy) {
|
||||
try {
|
||||
|
|
|
@ -224,7 +224,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
MsDNSCacheManager.addEnvironmentDNS(httpSamplerTree, this.getName(), config.getConfig().get(this.getProjectId()), httpConfig);
|
||||
}
|
||||
|
||||
if (this.authManager != null) {
|
||||
if (this.authManager != null && StringUtils.equals(this.authManager.getVerification(), "Basic Auth")) {
|
||||
this.authManager.setAuth(httpSamplerTree, this.authManager, sampler);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,6 @@ export default {
|
|||
if (this.request.hashTree == undefined) {
|
||||
this.request.hashTree = [];
|
||||
}
|
||||
this.request.hashTree.push(authManager);
|
||||
// 这里做个判断,如果原来有值则不覆盖
|
||||
if (this.authConfig.username == undefined && this.authConfig.password == undefined) {
|
||||
this.authConfig = authManager;
|
||||
|
@ -107,7 +106,6 @@ export default {
|
|||
if (this.request.hashTree == undefined) {
|
||||
this.request.hashTree = [];
|
||||
}
|
||||
this.request.hashTree.push(authManager);
|
||||
this.authConfig = authManager;
|
||||
this.request.authManager = this.authConfig;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue