refactor(接口测试): 优化http协议解析url (#13142)
Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
parent
d2ec4963b1
commit
111f8b4fdb
|
@ -34,4 +34,7 @@ public class ApiScenarioRequest extends BaseQueryRequest {
|
|||
* 是否需要查询环境字段
|
||||
*/
|
||||
private boolean selectEnvironment = false;
|
||||
|
||||
//测试计划关联场景过滤掉步骤为0的场景
|
||||
private String stepTotal;
|
||||
}
|
||||
|
|
|
@ -320,6 +320,9 @@
|
|||
where pc.test_plan_id = #{request.planId}
|
||||
)
|
||||
</if>
|
||||
<if test="request.stepTotal !=null">
|
||||
and api_scenario.step_total is not null and api_scenario.step_total > 0
|
||||
</if>
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="api_scenario"/>
|
||||
</include>
|
||||
|
|
|
@ -93,12 +93,21 @@ export default {
|
|||
getURL(urlStr) {
|
||||
try {
|
||||
let url = new URL(urlStr);
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
this.isUrl = true;
|
||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
||||
}
|
||||
});
|
||||
if (url.search && url.search.length > 1) {
|
||||
let params = url.search.substr(1).split("&");
|
||||
params.forEach(param => {
|
||||
if (param) {
|
||||
let keyValues = param.split("=");
|
||||
if (keyValues) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({
|
||||
name: keyValues[0],
|
||||
required: false,
|
||||
value: keyValues[1]
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return url;
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||
|
|
|
@ -498,11 +498,21 @@ export default {
|
|||
getURL(urlStr) {
|
||||
try {
|
||||
let url = new URL(urlStr);
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
||||
}
|
||||
});
|
||||
if (url.search && url.search.length > 1) {
|
||||
let params = url.search.substr(1).split("&");
|
||||
params.forEach(param => {
|
||||
if (param) {
|
||||
let keyValues = param.split("=");
|
||||
if (keyValues) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({
|
||||
name: keyValues[0],
|
||||
required: false,
|
||||
value: keyValues[1]
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return url;
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||
|
|
|
@ -272,11 +272,21 @@ export default {
|
|||
getURL(urlStr) {
|
||||
try {
|
||||
let url = new URL(urlStr);
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
||||
}
|
||||
});
|
||||
if (url.search && url.search.length > 1) {
|
||||
let params = url.search.substr(1).split("&");
|
||||
params.forEach(param => {
|
||||
if (param) {
|
||||
let keyValues = param.split("=");
|
||||
if (keyValues) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({
|
||||
name: keyValues[0],
|
||||
required: false,
|
||||
value: keyValues[1]
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return url;
|
||||
} catch (e) {
|
||||
return urlStr;
|
||||
|
|
|
@ -156,11 +156,21 @@ export default {
|
|||
getURL(urlStr) {
|
||||
try {
|
||||
let url = new URL(urlStr);
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
this.request.parameters.splice(0, 0, new KeyValue({name: key, value: value}));
|
||||
}
|
||||
});
|
||||
if (url.search && url.search.length > 1) {
|
||||
let params = url.search.substr(1).split("&");
|
||||
params.forEach(param => {
|
||||
if (param) {
|
||||
let keyValues = param.split("=");
|
||||
if (keyValues) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({
|
||||
name: keyValues[0],
|
||||
required: false,
|
||||
value: keyValues[1]
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return url;
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||
|
|
|
@ -209,6 +209,7 @@ export default {
|
|||
if (this.planId != null) {
|
||||
this.condition.planId = this.planId;
|
||||
}
|
||||
this.condition.stepTotal = "testPlan";
|
||||
|
||||
let url = "/test/plan/scenario/case/relevance/list/" + this.currentPage + "/" + this.pageSize;
|
||||
this.result = this.$post(url, this.condition, response => {
|
||||
|
|
Loading…
Reference in New Issue