refactor(接口测试): 优化http协议解析url (#13142)

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-04-27 17:39:27 +08:00 committed by GitHub
parent d2ec4963b1
commit 111f8b4fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 21 deletions

View File

@ -34,4 +34,7 @@ public class ApiScenarioRequest extends BaseQueryRequest {
* 是否需要查询环境字段
*/
private boolean selectEnvironment = false;
//测试计划关联场景过滤掉步骤为0的场景
private String stepTotal;
}

View File

@ -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 &gt; 0
</if>
<include refid="queryVersionCondition">
<property name="versionTable" value="api_scenario"/>
</include>

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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 => {