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;
|
private boolean selectEnvironment = false;
|
||||||
|
|
||||||
|
//测试计划关联场景过滤掉步骤为0的场景
|
||||||
|
private String stepTotal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,6 +320,9 @@
|
||||||
where pc.test_plan_id = #{request.planId}
|
where pc.test_plan_id = #{request.planId}
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
<if test="request.stepTotal !=null">
|
||||||
|
and api_scenario.step_total is not null and api_scenario.step_total > 0
|
||||||
|
</if>
|
||||||
<include refid="queryVersionCondition">
|
<include refid="queryVersionCondition">
|
||||||
<property name="versionTable" value="api_scenario"/>
|
<property name="versionTable" value="api_scenario"/>
|
||||||
</include>
|
</include>
|
||||||
|
|
|
@ -93,12 +93,21 @@ export default {
|
||||||
getURL(urlStr) {
|
getURL(urlStr) {
|
||||||
try {
|
try {
|
||||||
let url = new URL(urlStr);
|
let url = new URL(urlStr);
|
||||||
url.searchParams.forEach((value, key) => {
|
if (url.search && url.search.length > 1) {
|
||||||
if (key && value) {
|
let params = url.search.substr(1).split("&");
|
||||||
this.isUrl = true;
|
params.forEach(param => {
|
||||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
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;
|
return url;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||||
|
|
|
@ -498,11 +498,21 @@ export default {
|
||||||
getURL(urlStr) {
|
getURL(urlStr) {
|
||||||
try {
|
try {
|
||||||
let url = new URL(urlStr);
|
let url = new URL(urlStr);
|
||||||
url.searchParams.forEach((value, key) => {
|
if (url.search && url.search.length > 1) {
|
||||||
if (key) {
|
let params = url.search.substr(1).split("&");
|
||||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
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;
|
return url;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||||
|
|
|
@ -272,11 +272,21 @@ export default {
|
||||||
getURL(urlStr) {
|
getURL(urlStr) {
|
||||||
try {
|
try {
|
||||||
let url = new URL(urlStr);
|
let url = new URL(urlStr);
|
||||||
url.searchParams.forEach((value, key) => {
|
if (url.search && url.search.length > 1) {
|
||||||
if (key && value) {
|
let params = url.search.substr(1).split("&");
|
||||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
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;
|
return url;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return urlStr;
|
return urlStr;
|
||||||
|
|
|
@ -156,11 +156,21 @@ export default {
|
||||||
getURL(urlStr) {
|
getURL(urlStr) {
|
||||||
try {
|
try {
|
||||||
let url = new URL(urlStr);
|
let url = new URL(urlStr);
|
||||||
url.searchParams.forEach((value, key) => {
|
if (url.search && url.search.length > 1) {
|
||||||
if (key && value) {
|
let params = url.search.substr(1).split("&");
|
||||||
this.request.parameters.splice(0, 0, new KeyValue({name: key, value: value}));
|
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;
|
return url;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||||
|
|
|
@ -209,6 +209,7 @@ export default {
|
||||||
if (this.planId != null) {
|
if (this.planId != null) {
|
||||||
this.condition.planId = this.planId;
|
this.condition.planId = this.planId;
|
||||||
}
|
}
|
||||||
|
this.condition.stepTotal = "testPlan";
|
||||||
|
|
||||||
let url = "/test/plan/scenario/case/relevance/list/" + this.currentPage + "/" + this.pageSize;
|
let url = "/test/plan/scenario/case/relevance/list/" + this.currentPage + "/" + this.pageSize;
|
||||||
this.result = this.$post(url, this.condition, response => {
|
this.result = this.$post(url, this.condition, response => {
|
||||||
|
|
Loading…
Reference in New Issue