Merge branch 'v1.6' of https://github.com/metersphere/metersphere into v1.6
This commit is contained in:
commit
8cf56af2b9
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
name: v1.6.1 问题
|
||||
about: 提交关于 v1.6.1 的缺陷与建议,赢取Lv同款鼠标垫!马克杯!文化衫!
|
||||
title: "[v1.6.1]"
|
||||
labels: v1.6.1
|
||||
name: v1.6反馈
|
||||
about: 提交关于 v1.6的缺陷与建议,赢取Lv同款鼠标垫!马克杯!文化衫!
|
||||
title: "[v1.6]"
|
||||
labels: v1.6
|
||||
assignees: luty2018
|
||||
|
||||
---
|
||||
|
|
|
@ -85,15 +85,15 @@ public class ApiAutomationController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/run")
|
||||
public void run(@RequestBody RunScenarioRequest request) {
|
||||
public String run(@RequestBody RunScenarioRequest request) {
|
||||
request.setExecuteType(ExecuteType.Completed.name());
|
||||
apiAutomationService.run(request);
|
||||
return apiAutomationService.run(request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/run/batch")
|
||||
public void runBatch(@RequestBody RunScenarioRequest request) {
|
||||
public String runBatch(@RequestBody RunScenarioRequest request) {
|
||||
request.setExecuteType(ExecuteType.Saved.name());
|
||||
apiAutomationService.run(request);
|
||||
return apiAutomationService.run(request);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,12 +32,7 @@ public class KeyValue {
|
|||
}
|
||||
|
||||
public KeyValue(String name, String value, String description, String contentType) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.contentType = contentType;
|
||||
this.enable = true;
|
||||
this.required = true;
|
||||
this(name, value, description, contentType, true);
|
||||
}
|
||||
|
||||
public KeyValue(String name, String value, String description, String contentType, boolean required) {
|
||||
|
@ -49,6 +44,10 @@ public class KeyValue {
|
|||
this.required = required;
|
||||
}
|
||||
|
||||
public KeyValue(String name, String value, String description, boolean required) {
|
||||
this(name, value, description, "", required);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(value)) && !StringUtils.equalsIgnoreCase(type, "file");
|
||||
}
|
||||
|
|
|
@ -142,10 +142,10 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
|||
}
|
||||
|
||||
protected void addCookie(List<KeyValue> headers, String key, String value) {
|
||||
addCookie(headers, key, value, "", "", true);
|
||||
addCookie(headers, key, value, "", true);
|
||||
}
|
||||
|
||||
protected void addCookie(List<KeyValue> headers, String key, String value, String description, String contentType, boolean required) {
|
||||
protected void addCookie(List<KeyValue> headers, String key, String value, String description, boolean required) {
|
||||
boolean hasCookie = false;
|
||||
for (KeyValue header : headers) {
|
||||
if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) {
|
||||
|
|
|
@ -166,8 +166,7 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
|||
|
||||
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
||||
CookieParameter cookieParameter = (CookieParameter) parameter;
|
||||
addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription()),
|
||||
"", parameter.getRequired());
|
||||
addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription()), parameter.getRequired());
|
||||
}
|
||||
|
||||
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
||||
|
@ -301,8 +300,7 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
|||
|
||||
private void parseFormDataParameters(FormParameter parameter, Body body) {
|
||||
List<KeyValue> keyValues = Optional.ofNullable(body.getKvs()).orElse(new ArrayList<>());
|
||||
KeyValue kv = new KeyValue(parameter.getName(), "", getDefaultStringValue(parameter.getDescription()),
|
||||
"", parameter.getRequired());
|
||||
KeyValue kv = new KeyValue(parameter.getName(), "", getDefaultStringValue(parameter.getDescription()), parameter.getRequired());
|
||||
if (StringUtils.equals(parameter.getType(), "file")) {
|
||||
kv.setType("file");
|
||||
}
|
||||
|
@ -312,7 +310,6 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
|||
|
||||
private void parseQueryParameters(Parameter parameter, List<KeyValue> arguments) {
|
||||
QueryParameter queryParameter = (QueryParameter) parameter;
|
||||
arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription()),
|
||||
"", queryParameter.getRequired()));
|
||||
arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription()), queryParameter.getRequired()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import io.metersphere.commons.exception.MSException;
|
|||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.XMLUtils;
|
||||
import io.swagger.models.parameters.FormParameter;
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
|
@ -179,12 +178,12 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
|||
|
||||
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
||||
CookieParameter cookieParameter = (CookieParameter) parameter;
|
||||
addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription()), "", true);
|
||||
addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription()), parameter.getRequired());
|
||||
}
|
||||
|
||||
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
||||
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
||||
addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription()), "", true);
|
||||
addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription()), "", parameter.getRequired());
|
||||
}
|
||||
|
||||
private HttpResponse parseResponse(ApiResponses responses) {
|
||||
|
@ -250,9 +249,9 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
|||
}
|
||||
|
||||
Set<String> refSet = new HashSet<>();
|
||||
Map<String, String> binaryKeyMap = new HashMap();
|
||||
Map<String, Schema> infoMap = new HashMap();
|
||||
Schema schema = mediaType.getSchema();
|
||||
Object bodyData = parseSchema(schema, refSet, binaryKeyMap);
|
||||
Object bodyData = parseSchema(schema, refSet, infoMap);
|
||||
|
||||
if (bodyData == null) {
|
||||
return;
|
||||
|
@ -261,7 +260,7 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
|||
body.setType(getBodyType(contentType));
|
||||
|
||||
if (StringUtils.equals(contentType, org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE)) {
|
||||
parseKvBody(schema, body, bodyData, binaryKeyMap);
|
||||
parseKvBody(schema, body, bodyData, infoMap);
|
||||
} else if (StringUtils.equals(contentType, org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE)) {
|
||||
body.setRaw(bodyData.toString());
|
||||
} else if (StringUtils.equals(contentType, org.springframework.http.MediaType.APPLICATION_JSON_VALUE)) {
|
||||
|
@ -269,27 +268,34 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
|||
} else if (StringUtils.equals(contentType, org.springframework.http.MediaType.APPLICATION_XML_VALUE)) {
|
||||
body.setRaw(parseXmlBody(schema, bodyData));
|
||||
} else if (StringUtils.equals(contentType, org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE)) {
|
||||
parseKvBody(schema, body, bodyData, binaryKeyMap);
|
||||
parseKvBody(schema, body, bodyData, infoMap);
|
||||
} else {
|
||||
body.setRaw(bodyData.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void parseKvBody(Schema schema, Body body, Object data, Map<String, String> binaryKeyMap) {
|
||||
private void parseKvBody(Schema schema, Body body, Object data, Map<String, Schema> infoMap) {
|
||||
if (data instanceof JSONObject) {
|
||||
((JSONObject) data).forEach((k, v) -> {
|
||||
KeyValue kv = new KeyValue(k, v.toString());
|
||||
if (binaryKeyMap.keySet().contains(k)) {
|
||||
kv.setDescription(binaryKeyMap.get(k));
|
||||
kv.setType("file");
|
||||
Schema schemaInfo = infoMap.get(k);
|
||||
if (schemaInfo != null) {
|
||||
kv.setDescription(schemaInfo.getDescription());
|
||||
// kv.setRequired(schemaInfo.getRequired());
|
||||
if (schemaInfo instanceof BinarySchema) {
|
||||
kv.setType("file");
|
||||
}
|
||||
}
|
||||
body.getKvs().add(kv);
|
||||
});
|
||||
} else {
|
||||
KeyValue kv = new KeyValue(schema.getName(), data.toString(), schema.getDescription());
|
||||
if (binaryKeyMap.keySet().contains(schema.getName())) {
|
||||
kv.setDescription(binaryKeyMap.get(schema.getDescription()));
|
||||
kv.setType("file");
|
||||
Schema schemaInfo = infoMap.get(schema.getName());
|
||||
if (schemaInfo != null) {
|
||||
kv.setDescription(schemaInfo.getDescription());
|
||||
if (schemaInfo instanceof BinarySchema) {
|
||||
kv.setType("file");
|
||||
}
|
||||
}
|
||||
body.getKvs().add(kv);
|
||||
}
|
||||
|
@ -315,37 +321,37 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
|||
return this.components.getSchemas().get(ref);
|
||||
}
|
||||
|
||||
private Object parseSchema(Schema schema, Set<String> refSet, Map<String, String> binaryKeyMap) {
|
||||
private Object parseSchema(Schema schema, Set<String> refSet, Map<String, Schema> infoMap) {
|
||||
infoMap.put(schema.getName(), schema);
|
||||
if (StringUtils.isNotBlank(schema.get$ref())) {
|
||||
if (refSet.contains(schema.get$ref())) {
|
||||
return new JSONObject();
|
||||
}
|
||||
refSet.add(schema.get$ref());
|
||||
Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, binaryKeyMap);
|
||||
Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, infoMap);
|
||||
return propertiesResult == null ? getDefaultValueByPropertyType(schema) : propertiesResult;
|
||||
} else if (schema instanceof ArraySchema) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
Schema items = ((ArraySchema) schema).getItems();
|
||||
parseSchema(items, refSet, binaryKeyMap);
|
||||
jsonArray.add(parseSchema(items, refSet, binaryKeyMap));
|
||||
parseSchema(items, refSet, infoMap);
|
||||
jsonArray.add(parseSchema(items, refSet, infoMap));
|
||||
return jsonArray;
|
||||
} else if (schema instanceof BinarySchema) {
|
||||
binaryKeyMap.put(schema.getName(), schema.getDescription());
|
||||
return getDefaultValueByPropertyType(schema);
|
||||
} else {
|
||||
Object propertiesResult = parseSchemaProperties(schema, refSet, binaryKeyMap);
|
||||
Object propertiesResult = parseSchemaProperties(schema, refSet, infoMap);
|
||||
return propertiesResult == null ? getDefaultValueByPropertyType(schema) : propertiesResult;
|
||||
}
|
||||
}
|
||||
|
||||
private Object parseSchemaProperties(Schema schema, Set<String> refSet, Map<String, String> binaryKeyMap) {
|
||||
private Object parseSchemaProperties(Schema schema, Set<String> refSet, Map<String, Schema> infoMap) {
|
||||
Map<String, Schema> properties = schema.getProperties();
|
||||
if (MapUtils.isEmpty(properties)) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
properties.forEach((key, value) -> {
|
||||
jsonObject.put(key, parseSchema(value, refSet, binaryKeyMap));
|
||||
jsonObject.put(key, parseSchema(value, refSet, infoMap));
|
||||
});
|
||||
return jsonObject;
|
||||
}
|
||||
|
@ -363,6 +369,6 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
|||
|
||||
private void parseQueryParameters(Parameter parameter, List<KeyValue> arguments) {
|
||||
QueryParameter queryParameter = (QueryParameter) parameter;
|
||||
arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription())));
|
||||
arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription()), parameter.getRequired()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,6 +333,13 @@
|
|||
and project_id= #{request.projectId}
|
||||
</if>
|
||||
</where>
|
||||
UNION ALL
|
||||
select id,name,status,project_id,"scenario" as type from api_scenario
|
||||
<where>
|
||||
<if test="request.projectId!=null">
|
||||
and project_id= #{request.projectId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="listByTestCaseIds" resultType="io.metersphere.track.dto.TestCaseDTO">
|
||||
select test_case.*,api_test.name as apiName,load_test.name AS performName from test_case left join api_test on
|
||||
|
|
|
@ -15,6 +15,8 @@ public interface ExtTestPlanTestCaseMapper {
|
|||
|
||||
List<TestPlanCaseDTO> list(@Param("request") QueryTestPlanCaseRequest request);
|
||||
|
||||
List<TestPlanCaseDTO> listByPlanId(@Param("request") QueryTestPlanCaseRequest request);
|
||||
|
||||
List<TestPlanCaseDTO> listByNode(@Param("request") QueryTestPlanCaseRequest request);
|
||||
|
||||
List<TestPlanCaseDTO> listByNodes(@Param("request") QueryTestPlanCaseRequest request);
|
||||
|
|
|
@ -334,6 +334,34 @@
|
|||
test_plan_test_case
|
||||
where plan_id = #{planId}
|
||||
</select>
|
||||
<select id="listByPlanId" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
|
||||
SELECT test_plan_api_case.api_case_id as id,"definition" as type,api_test_case.name,test_plan_api_case.status
|
||||
from test_plan_api_case left join api_test_case on test_plan_api_case.api_case_id=api_test_case.id
|
||||
<where>
|
||||
<if test="request.planId != null">
|
||||
and test_plan_api_case.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
</where>
|
||||
UNION ALL
|
||||
SELECT test_plan_api_scenario.api_scenario_id as id,"scenario" as type,api_scenario.name,test_plan_api_scenario.status
|
||||
from test_plan_api_scenario left join api_scenario on test_plan_api_scenario.api_scenario_id=api_scenario.id
|
||||
<where>
|
||||
<if test="request.planId != null">
|
||||
and test_plan_api_scenario.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
</where>
|
||||
UNION ALL
|
||||
SELECT test_case.test_id as id,test_case.type as type,test_case.name,test_plan_test_case.status
|
||||
from test_plan_test_case left join test_case on test_plan_test_case.case_id =test_case.id
|
||||
<where>
|
||||
<if test="request.planId != null">
|
||||
and test_plan_test_case.plan_id = #{request.planId}
|
||||
</if>
|
||||
<if test="request.method != null">
|
||||
and test_case.method = #{request.method}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="updateTestCaseStates" parameterType="java.lang.String">
|
||||
update test_plan_test_case
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
public enum ApiRunMode {
|
||||
RUN, DEBUG,DELIMIT,SCENARIO, API_PLAN, SCENARIO_PLAN
|
||||
RUN, DEBUG,DELIMIT,SCENARIO, API_PLAN, SCENARIO_PLAN,API
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TestCaseController {
|
|||
return testCaseService.listTestCase(request);
|
||||
}
|
||||
|
||||
|
||||
/*jenkins项目下所有接口和性能测试用例*/
|
||||
@GetMapping("/list/method/{projectId}")
|
||||
public List<TestCaseDTO> listByMethod(@PathVariable String projectId) {
|
||||
QueryTestCaseRequest request = new QueryTestCaseRequest();
|
||||
|
|
|
@ -30,13 +30,13 @@ public class TestPlanTestCaseController {
|
|||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, testPlanTestCaseService.list(request));
|
||||
}
|
||||
|
||||
/*jenkins测试计划下全部用例*/
|
||||
@GetMapping("/list/{planId}")
|
||||
public List<TestPlanCaseDTO> getTestPlanCaseByPlanId(@PathVariable String planId) {
|
||||
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
|
||||
request.setPlanId(planId);
|
||||
request.setMethod("auto");
|
||||
return testPlanTestCaseService.list(request);
|
||||
return testPlanTestCaseService.listByPlanId(request);
|
||||
}
|
||||
|
||||
@GetMapping("/list/node/{planId}/{nodePaths}")
|
||||
|
|
|
@ -55,6 +55,11 @@ public class TestPlanTestCaseService {
|
|||
});
|
||||
return list;
|
||||
}
|
||||
public List<TestPlanCaseDTO> listByPlanId(QueryTestPlanCaseRequest request) {
|
||||
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.listByPlanId(request);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<TestPlanCaseDTO> listByNode(QueryTestPlanCaseRequest request) {
|
||||
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.listByNode(request);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 068127ce59ea8b016434ed52a9de4a7a4b13bdb4
|
||||
Subproject commit f27d1609d77f7d6c988d37d709466e844d350e17
|
|
@ -1,4 +1,5 @@
|
|||
alter table test_plan add project_id varchar(50) null comment '测试计划所属项目';
|
||||
ALTER TABLE api_test_case MODIFY COLUMN name varchar(255) NOT NULL COMMENT 'Test name';
|
||||
|
||||
DROP PROCEDURE IF EXISTS test_cursor;
|
||||
DELIMITER //
|
||||
|
|
|
@ -307,7 +307,7 @@ export default {
|
|||
rules: {
|
||||
name: [
|
||||
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
|
||||
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
|
||||
{max: 255, message: this.$t('test_track.length_less_than') + '255', trigger: 'blur'}
|
||||
],
|
||||
module: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}],
|
||||
maintainer: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
|
||||
|
|
Loading…
Reference in New Issue