fix(接口自动化): 修复特殊URL执行问题,如url结尾时?执行时 ?丢失
This commit is contained in:
parent
9a52ccc629
commit
102b895943
|
@ -312,7 +312,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
sampler.setPort(urlObject.getPort());
|
sampler.setPort(urlObject.getPort());
|
||||||
}
|
}
|
||||||
sampler.setProtocol(urlObject.getProtocol());
|
sampler.setProtocol(urlObject.getProtocol());
|
||||||
sampler.setPath(URLDecoder.decode(URLEncoder.encode(urlObject.getPath(), "UTF-8"), "UTF-8"));
|
sampler.setPath(URLDecoder.decode(URLEncoder.encode(urlObject.getFile(), "UTF-8"), "UTF-8"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
String envPath = "";
|
String envPath = "";
|
||||||
if (!isCustomizeReqCompleteUrl(this.path)) {
|
if (!isCustomizeReqCompleteUrl(this.path)) {
|
||||||
URL urlObject = new URL(url);
|
URL urlObject = new URL(url);
|
||||||
envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile();
|
||||||
if (StringUtils.isNotBlank(this.getPath())) {
|
if (StringUtils.isNotBlank(this.getPath())) {
|
||||||
envPath += this.getPath();
|
envPath += this.getPath();
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
sampler.setPort(httpConfig.getPort());
|
sampler.setPort(httpConfig.getPort());
|
||||||
} else {
|
} else {
|
||||||
URL urlObject = new URL(this.path);
|
URL urlObject = new URL(this.path);
|
||||||
envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile();
|
||||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
||||||
sampler.setProtocol(urlObject.getProtocol());
|
sampler.setProtocol(urlObject.getProtocol());
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
sampler.setPort(urlObject.getPort());
|
sampler.setPort(urlObject.getPort());
|
||||||
}
|
}
|
||||||
sampler.setProtocol(urlObject.getProtocol());
|
sampler.setProtocol(urlObject.getProtocol());
|
||||||
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
|
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile();
|
||||||
sampler.setPath(envPath);
|
sampler.setPath(envPath);
|
||||||
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
||||||
envPath = getRestParameters(URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8"));
|
envPath = getRestParameters(URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8"));
|
||||||
|
|
|
@ -1040,7 +1040,9 @@ public class ApiAutomationService {
|
||||||
public void run() {
|
public void run() {
|
||||||
List<String> reportIds = new LinkedList<>();
|
List<String> reportIds = new LinkedList<>();
|
||||||
for (APIScenarioReportResult key : map.keySet()) {
|
for (APIScenarioReportResult key : map.keySet()) {
|
||||||
|
if (StringUtils.isNotEmpty(serialReportId)) {
|
||||||
key.setExecuteType(ExecuteType.Marge.name());
|
key.setExecuteType(ExecuteType.Marge.name());
|
||||||
|
}
|
||||||
apiScenarioReportMapper.insert(key);
|
apiScenarioReportMapper.insert(key);
|
||||||
reportIds.add(key.getId());
|
reportIds.add(key.getId());
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -45,6 +45,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
reqOptions: REQ_METHOD,
|
reqOptions: REQ_METHOD,
|
||||||
|
isUrl: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -69,21 +70,26 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
pathChange() {
|
pathChange() {
|
||||||
|
this.isUrl = false;
|
||||||
if (!this.request.path || this.request.path.indexOf('?') === -1) return;
|
if (!this.request.path || this.request.path.indexOf('?') === -1) return;
|
||||||
let url = this.getURL(this.addProtocol(this.request.path));
|
let url = this.getURL(this.addProtocol(this.request.path));
|
||||||
if (url) {
|
if (url && this.isUrl) {
|
||||||
this.request.path = decodeURIComponent(this.request.path.substr(0, this.request.path.indexOf("?")));
|
this.request.path = decodeURIComponent(this.request.path.substr(0, this.request.path.indexOf("?")));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
urlChange() {
|
urlChange() {
|
||||||
|
this.isUrl = false;
|
||||||
if (this.isCustomizeReq) {
|
if (this.isCustomizeReq) {
|
||||||
this.request.path = this.request.url;
|
this.request.path = this.request.url;
|
||||||
}
|
}
|
||||||
if (!this.request.url || this.request.url.indexOf('?') === -1) return;
|
if (!this.request.url || this.request.url.indexOf('?') === -1) return;
|
||||||
let url = this.getURL(this.addProtocol(this.request.url));
|
let url = this.getURL(this.addProtocol(this.request.url));
|
||||||
if (url) {
|
if (url) {
|
||||||
|
let paramUrl = this.request.url.substr(this.request.url.indexOf("?") + 1);
|
||||||
|
if (paramUrl && this.isUrl) {
|
||||||
this.request.url = decodeURIComponent(this.request.url.substr(0, this.request.url.indexOf("?")));
|
this.request.url = decodeURIComponent(this.request.url.substr(0, this.request.url.indexOf("?")));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
addProtocol(url) {
|
addProtocol(url) {
|
||||||
if (url) {
|
if (url) {
|
||||||
|
@ -98,6 +104,7 @@ export default {
|
||||||
let url = new URL(urlStr);
|
let url = new URL(urlStr);
|
||||||
url.searchParams.forEach((value, key) => {
|
url.searchParams.forEach((value, key) => {
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
|
this.isUrl = true;
|
||||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue