This commit is contained in:
chenjianxing 2021-01-12 16:28:54 +08:00
commit 7f49a1b8ef
57 changed files with 1754 additions and 222 deletions

View File

@ -58,6 +58,8 @@ public class MsScenario extends MsTestElement {
if (!this.isEnable()) {
return;
}
config.setStep(this.name);
config.setEnableCookieShare(enableCookieShare);
if (StringUtils.isNotEmpty(environmentId)) {
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);

View File

@ -14,5 +14,9 @@ public class ParameterConfig {
private List<ScenarioVariable> variables;
// 公共Cookie
private boolean enableCookieShare;
// 步骤
private String step;
private final String stepType = "STEP_GROUP";
}

View File

@ -15,6 +15,7 @@ import io.metersphere.api.dto.scenario.KeyValue;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
@ -64,7 +65,7 @@ public class MsDubboSampler extends MsTestElement {
this.getRefElement(this);
}
final HashTree testPlanTree = tree.add(dubboSample());
final HashTree testPlanTree = tree.add(dubboSample(config));
if (CollectionUtils.isNotEmpty(hashTree)) {
hashTree.forEach(el -> {
el.toHashTree(testPlanTree, el.getHashTree(), config);
@ -72,9 +73,12 @@ public class MsDubboSampler extends MsTestElement {
}
}
private DubboSample dubboSample() {
private DubboSample dubboSample(ParameterConfig config) {
DubboSample sampler = new DubboSample();
sampler.setName(this.getName());
if (config != null && StringUtils.isNotEmpty(config.getStep())) {
sampler.setName(this.getName() + "<->" + config.getStep());
}
sampler.setProperty(TestElement.TEST_CLASS, DubboSample.class.getName());
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboSampleGui"));
@ -97,19 +101,6 @@ public class MsDubboSampler extends MsTestElement {
return sampler;
}
private ConfigTestElement dubboConfig() {
ConfigTestElement configTestElement = new ConfigTestElement();
configTestElement.setEnabled(true);
configTestElement.setName(this.getName());
configTestElement.setProperty(TestElement.TEST_CLASS, ConfigTestElement.class.getName());
configTestElement.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboDefaultConfigGui"));
configTestElement.addConfigElement(configCenter(this.getConfigCenter()));
configTestElement.addConfigElement(registryCenter(this.getRegistryCenter()));
configTestElement.addConfigElement(consumerAndService(this.getConsumerAndService()));
return configTestElement;
}
private ConfigTestElement configCenter(MsConfigCenter configCenter) {
ConfigTestElement configTestElement = new ConfigTestElement();
if (configCenter != null && configCenter.getProtocol() != null && configCenter.getUsername() != null && configCenter.getPassword() != null) {

View File

@ -96,6 +96,10 @@ public class MsHTTPSamplerProxy extends MsTestElement {
HTTPSamplerProxy sampler = new HTTPSamplerProxy();
sampler.setEnabled(true);
sampler.setName(this.getName());
if (config != null && StringUtils.isNotEmpty(config.getStep())) {
sampler.setName(this.getName() + "<->" + config.getStep());
}
sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName());
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui"));
sampler.setMethod(this.getMethod());

View File

@ -64,7 +64,7 @@ public class MsJDBCSampler extends MsTestElement {
if (this.dataSource == null) {
MSException.throwException("数据源为空无法执行");
}
final HashTree samplerHashTree = tree.add(jdbcSampler());
final HashTree samplerHashTree = tree.add(jdbcSampler(config));
tree.add(jdbcDataSource());
tree.add(arguments(this.getName() + " Variables", this.getVariables()));
if (CollectionUtils.isNotEmpty(hashTree)) {
@ -102,9 +102,12 @@ public class MsJDBCSampler extends MsTestElement {
return arguments;
}
private JDBCSampler jdbcSampler() {
private JDBCSampler jdbcSampler(ParameterConfig config) {
JDBCSampler sampler = new JDBCSampler();
sampler.setName(this.getName());
if (config != null && StringUtils.isNotEmpty(config.getStep())) {
sampler.setName(this.getName() + "<->" + config.getStep());
}
sampler.setProperty(TestElement.TEST_CLASS, JDBCSampler.class.getName());
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
// request.getDataSource() 是ID需要转换为Name

View File

@ -1,15 +1,11 @@
package io.metersphere.api.dto.definition.request.sampler;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import io.metersphere.api.dto.definition.request.MsTestElement;
import io.metersphere.api.dto.definition.request.ParameterConfig;
import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
import io.metersphere.api.service.ApiTestEnvironmentService;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.commons.utils.CommonBeanFactory;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils;
@ -75,7 +71,7 @@ public class MsTCPSampler extends MsTestElement {
parseEnvironment(config.getConfig());
final HashTree samplerHashTree = new ListedHashTree();
samplerHashTree.add(tcpConfig());
tree.set(tcpSampler(), samplerHashTree);
tree.set(tcpSampler(config), samplerHashTree);
if (CollectionUtils.isNotEmpty(hashTree)) {
hashTree.forEach(el -> {
el.toHashTree(samplerHashTree, el.getHashTree(), config);
@ -90,9 +86,13 @@ public class MsTCPSampler extends MsTestElement {
}
}
private TCPSampler tcpSampler() {
private TCPSampler tcpSampler(ParameterConfig config) {
TCPSampler tcpSampler = new TCPSampler();
tcpSampler.setName(this.getName());
if (config != null && StringUtils.isNotEmpty(config.getStep())) {
tcpSampler.setName(this.getName() + "<->" + config.getStep());
}
tcpSampler.setProperty(TestElement.TEST_CLASS, TCPSampler.class.getName());
tcpSampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TCPSamplerGui"));
tcpSampler.setClassname(this.getClassname());

View File

@ -22,7 +22,7 @@ public class ScenarioResult {
private int passAssertions = 0;
private final List<RequestResult> requestResults = new ArrayList<>();
private List<RequestResult> requestResults = new ArrayList<>();
public void addResponseTime(long time) {
this.responseTime += time;

View File

@ -1,9 +1,11 @@
package io.metersphere.api.jmeter;
import io.metersphere.commons.utils.BeanUtils;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Data
public class TestResult {
@ -38,5 +40,39 @@ public class TestResult {
this.passAssertions += count;
}
private static final String separator = "<->";
public void addScenario(ScenarioResult result) {
Map<String, List<RequestResult>> requestResultMap = new LinkedHashMap<>();
if (result != null && CollectionUtils.isNotEmpty(result.getRequestResults())) {
result.getRequestResults().forEach(item -> {
if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf(separator) != -1) {
String array[] = item.getName().split(separator);
String scenarioName = array[array.length - 1];
item.setName(item.getName().replace(separator + scenarioName, ""));
if (requestResultMap.containsKey(scenarioName)) {
requestResultMap.get(scenarioName).add(item);
} else {
List<RequestResult> requestResults = new LinkedList<>();
requestResults.add(item);
requestResultMap.put(scenarioName, requestResults);
}
item.getSubRequestResults().forEach(subItem -> {
subItem.setName(item.getName());
});
}
});
}
if (!requestResultMap.isEmpty()) {
requestResultMap.forEach((k, v) -> {
ScenarioResult scenarioResult = new ScenarioResult();
BeanUtils.copyBean(scenarioResult, result);
scenarioResult.setName(k);
scenarioResult.setRequestResults(v);
scenarios.add(scenarioResult);
});
} else {
scenarios.add(result);
}
}
}

View File

@ -368,14 +368,12 @@ public class ApiAutomationService {
// 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
new TypeReference<LinkedList<MsTestElement>>() {
});
new TypeReference<LinkedList<MsTestElement>>() {});
scenario.setHashTree(elements);
}
if (StringUtils.isNotEmpty(element.getString("variables"))) {
LinkedList<ScenarioVariable> variables = mapper.readValue(element.getString("variables"),
new TypeReference<LinkedList<ScenarioVariable>>() {
});
new TypeReference<LinkedList<ScenarioVariable>>() {});
scenario.setVariables(variables);
}
group.setEnableCookieShare(scenario.isEnableCookieShare());
@ -443,6 +441,7 @@ public class ApiAutomationService {
ParameterConfig config = new ParameterConfig();
config.setConfig(envConfig);
HashTree hashTree = request.getTestElement().generateHashTree(config);
// 调用执行方法
createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
SessionUtils.getUserId());

View File

@ -24,7 +24,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.apache.commons.collections.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
@ -214,9 +214,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
request.setUpdateTime(System.currentTimeMillis());
checkApiModuleExist(request);
List<ApiDefinitionResult> apiDefinitionResults = queryByModuleIds(request.getNodeIds());
if (CollectionUtils.isNotEmpty(apiDefinitionResults)) {
apiDefinitionResults.forEach(apiDefinition -> {
if (StringUtils.isNotBlank(apiDefinition.getModulePath())) {
if (apiDefinition != null && StringUtils.isNotBlank(apiDefinition.getModulePath())) {
StringBuilder path = new StringBuilder(apiDefinition.getModulePath());
List<String> pathLists = Arrays.asList(path.toString().split("/"));
pathLists.set(request.getLevel(), request.getName());
@ -227,9 +227,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
apiDefinition.setModulePath(path.toString());
}
});
batchUpdateApiDefinition(apiDefinitionResults);
}
return apiModuleMapper.updateByPrimaryKeySelective(request);
}

View File

@ -3,7 +3,9 @@ package io.metersphere.api.service;
import com.alibaba.fastjson.JSON;
import io.metersphere.api.dto.DeleteAPIReportRequest;
import io.metersphere.api.dto.QueryAPIReportRequest;
import io.metersphere.api.dto.automation.*;
import io.metersphere.api.dto.automation.APIScenarioReportResult;
import io.metersphere.api.dto.automation.ExecuteType;
import io.metersphere.api.dto.automation.ScenarioStatus;
import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.jmeter.ScenarioResult;
import io.metersphere.api.jmeter.TestResult;
@ -26,7 +28,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -136,10 +137,12 @@ public class ApiScenarioReportService {
// 报告详情内容
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
TestResult newResult = createTestResult(result.getTestId(), scenarioResult);
List<ScenarioResult> scenarioResults = new ArrayList();
scenarioResult.setName(report.getScenarioName());
scenarioResults.add(scenarioResult);
newResult.setScenarios(scenarioResults);
// List<ScenarioResult> scenarioResults = new ArrayList();
// scenarioResult.setName(report.getScenarioName());
// scenarioResults.add(scenarioResult);
// newResult.setScenarios(scenarioResults);
newResult.addScenario(scenarioResult);
detail.setContent(JSON.toJSONString(newResult).getBytes(StandardCharsets.UTF_8));
detail.setReportId(report.getId());
detail.setProjectId(report.getProjectId());
@ -158,10 +161,11 @@ public class ApiScenarioReportService {
// 报告详情内容
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
TestResult newResult = createTestResult(result.getTestId(), item);
List<ScenarioResult> scenarioResults = new ArrayList();
item.setName(report.getScenarioName());
scenarioResults.add(item);
newResult.setScenarios(scenarioResults);
// List<ScenarioResult> scenarioResults = new ArrayList();
// item.setName(report.getScenarioName());
// scenarioResults.add(item);
// newResult.setScenarios(scenarioResults);
newResult.addScenario(item);
detail.setContent(JSON.toJSONString(newResult).getBytes(StandardCharsets.UTF_8));
detail.setReportId(report.getId());
detail.setProjectId(report.getProjectId());

View File

@ -0,0 +1,26 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class AuthSource implements Serializable {
private String id;
private String status;
private Long createTime;
private Long updateTime;
private String description;
private String name;
private String type;
private String configuration;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,670 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class AuthSourceExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public AuthSourceExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andDescriptionIsNull() {
addCriterion("description is null");
return (Criteria) this;
}
public Criteria andDescriptionIsNotNull() {
addCriterion("description is not null");
return (Criteria) this;
}
public Criteria andDescriptionEqualTo(String value) {
addCriterion("description =", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotEqualTo(String value) {
addCriterion("description <>", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThan(String value) {
addCriterion("description >", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThanOrEqualTo(String value) {
addCriterion("description >=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThan(String value) {
addCriterion("description <", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThanOrEqualTo(String value) {
addCriterion("description <=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLike(String value) {
addCriterion("description like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotLike(String value) {
addCriterion("description not like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionIn(List<String> values) {
addCriterion("description in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotIn(List<String> values) {
addCriterion("description not in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionBetween(String value1, String value2) {
addCriterion("description between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotBetween(String value1, String value2) {
addCriterion("description not between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -23,5 +23,7 @@ public class LoadTest implements Serializable {
private String userId;
private Integer num;
private static final long serialVersionUID = 1L;
}

View File

@ -713,6 +713,66 @@ public class LoadTestExample {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andNumIsNull() {
addCriterion("num is null");
return (Criteria) this;
}
public Criteria andNumIsNotNull() {
addCriterion("num is not null");
return (Criteria) this;
}
public Criteria andNumEqualTo(Integer value) {
addCriterion("num =", value, "num");
return (Criteria) this;
}
public Criteria andNumNotEqualTo(Integer value) {
addCriterion("num <>", value, "num");
return (Criteria) this;
}
public Criteria andNumGreaterThan(Integer value) {
addCriterion("num >", value, "num");
return (Criteria) this;
}
public Criteria andNumGreaterThanOrEqualTo(Integer value) {
addCriterion("num >=", value, "num");
return (Criteria) this;
}
public Criteria andNumLessThan(Integer value) {
addCriterion("num <", value, "num");
return (Criteria) this;
}
public Criteria andNumLessThanOrEqualTo(Integer value) {
addCriterion("num <=", value, "num");
return (Criteria) this;
}
public Criteria andNumIn(List<Integer> values) {
addCriterion("num in", values, "num");
return (Criteria) this;
}
public Criteria andNumNotIn(List<Integer> values) {
addCriterion("num not in", values, "num");
return (Criteria) this;
}
public Criteria andNumBetween(Integer value1, Integer value2) {
addCriterion("num between", value1, value2, "num");
return (Criteria) this;
}
public Criteria andNumNotBetween(Integer value1, Integer value2) {
addCriterion("num not between", value1, value2, "num");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -13,5 +13,7 @@ public class LoadTestWithBLOBs extends LoadTest implements Serializable {
private String advancedConfiguration;
private String schedule;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,37 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.AuthSource;
import io.metersphere.base.domain.AuthSourceExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface AuthSourceMapper {
long countByExample(AuthSourceExample example);
int deleteByExample(AuthSourceExample example);
int deleteByPrimaryKey(String id);
int insert(AuthSource record);
int insertSelective(AuthSource record);
List<AuthSource> selectByExampleWithBLOBs(AuthSourceExample example);
List<AuthSource> selectByExample(AuthSourceExample example);
AuthSource selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") AuthSource record, @Param("example") AuthSourceExample example);
int updateByExampleWithBLOBs(@Param("record") AuthSource record, @Param("example") AuthSourceExample example);
int updateByExample(@Param("record") AuthSource record, @Param("example") AuthSourceExample example);
int updateByPrimaryKeySelective(AuthSource record);
int updateByPrimaryKeyWithBLOBs(AuthSource record);
int updateByPrimaryKey(AuthSource record);
}

View File

@ -0,0 +1,304 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.AuthSourceMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.AuthSource">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="type" jdbcType="VARCHAR" property="type" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.AuthSource">
<result column="configuration" jdbcType="LONGVARCHAR" property="configuration" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `status`, create_time, update_time, description, `name`, `type`
</sql>
<sql id="Blob_Column_List">
configuration
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.AuthSourceExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from auth_source
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.AuthSourceExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from auth_source
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from auth_source
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from auth_source
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.AuthSourceExample">
delete from auth_source
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.AuthSource">
insert into auth_source (id, `status`, create_time,
update_time, description, `name`,
`type`, configuration)
values (#{id,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{description,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{configuration,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.AuthSource">
insert into auth_source
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="status != null">
`status`,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="description != null">
description,
</if>
<if test="name != null">
`name`,
</if>
<if test="type != null">
`type`,
</if>
<if test="configuration != null">
configuration,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="configuration != null">
#{configuration,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.AuthSourceExample" resultType="java.lang.Long">
select count(*) from auth_source
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update auth_source
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.configuration != null">
configuration = #{record.configuration,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update auth_source
set id = #{record.id,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
description = #{record.description,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
configuration = #{record.configuration,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update auth_source
set id = #{record.id,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
description = #{record.description,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.AuthSource">
update auth_source
<set>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="configuration != null">
configuration = #{configuration,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.AuthSource">
update auth_source
set `status` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
description = #{description,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
configuration = #{configuration,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.AuthSource">
update auth_source
set `status` = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
description = #{description,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -11,10 +11,12 @@
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="test_resource_pool_id" jdbcType="VARCHAR" property="testResourcePoolId" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="num" jdbcType="INTEGER" property="num" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestWithBLOBs">
<result column="load_configuration" jdbcType="LONGVARCHAR" property="loadConfiguration" />
<result column="advanced_configuration" jdbcType="LONGVARCHAR" property="advancedConfiguration" />
<result column="schedule" jdbcType="LONGVARCHAR" property="schedule" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -76,10 +78,10 @@
</sql>
<sql id="Base_Column_List">
id, project_id, `name`, description, create_time, update_time, `status`, test_resource_pool_id,
user_id
user_id, num
</sql>
<sql id="Blob_Column_List">
load_configuration, advanced_configuration
load_configuration, advanced_configuration, schedule
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestExample" resultMap="ResultMapWithBLOBs">
select
@ -133,13 +135,13 @@
insert into load_test (id, project_id, `name`,
description, create_time, update_time,
`status`, test_resource_pool_id, user_id,
load_configuration, advanced_configuration
)
num, load_configuration, advanced_configuration,
schedule)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{status,jdbcType=VARCHAR}, #{testResourcePoolId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR},
#{loadConfiguration,jdbcType=LONGVARCHAR}, #{advancedConfiguration,jdbcType=LONGVARCHAR}
)
#{num,jdbcType=INTEGER}, #{loadConfiguration,jdbcType=LONGVARCHAR}, #{advancedConfiguration,jdbcType=LONGVARCHAR},
#{schedule,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestWithBLOBs">
insert into load_test
@ -171,12 +173,18 @@
<if test="userId != null">
user_id,
</if>
<if test="num != null">
num,
</if>
<if test="loadConfiguration != null">
load_configuration,
</if>
<if test="advancedConfiguration != null">
advanced_configuration,
</if>
<if test="schedule != null">
schedule,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -206,12 +214,18 @@
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="num != null">
#{num,jdbcType=INTEGER},
</if>
<if test="loadConfiguration != null">
#{loadConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="advancedConfiguration != null">
#{advancedConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="schedule != null">
#{schedule,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.LoadTestExample" resultType="java.lang.Long">
@ -250,12 +264,18 @@
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.num != null">
num = #{record.num,jdbcType=INTEGER},
</if>
<if test="record.loadConfiguration != null">
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="record.advancedConfiguration != null">
advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="record.schedule != null">
schedule = #{record.schedule,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -272,8 +292,10 @@
`status` = #{record.status,jdbcType=VARCHAR},
test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER},
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR},
advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR}
advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR},
schedule = #{record.schedule,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -288,7 +310,8 @@
update_time = #{record.updateTime,jdbcType=BIGINT},
`status` = #{record.status,jdbcType=VARCHAR},
test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR}
user_id = #{record.userId,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -320,12 +343,18 @@
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="num != null">
num = #{num,jdbcType=INTEGER},
</if>
<if test="loadConfiguration != null">
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="advancedConfiguration != null">
advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR},
</if>
<if test="schedule != null">
schedule = #{schedule,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -339,8 +368,10 @@
`status` = #{status,jdbcType=VARCHAR},
test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER},
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR},
advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR}
advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR},
schedule = #{schedule,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.LoadTest">
@ -352,7 +383,8 @@
update_time = #{updateTime,jdbcType=BIGINT},
`status` = #{status,jdbcType=VARCHAR},
test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR}
user_id = #{userId,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -14,4 +14,6 @@ public interface ExtLoadTestMapper {
List<LoadTest> getLoadTestByProjectId(String projectId);
int checkLoadTestOwner(@Param("testId") String testId, @Param("workspaceIds") Set<String> workspaceIds);
LoadTest getNextNum(@Param("projectId") String projectId);
}

View File

@ -128,4 +128,7 @@
</if>
</where>
</select>
<select id="getNextNum" resultType="io.metersphere.base.domain.LoadTest">
select * from load_test lt where lt.project_id = #{projectId} ORDER BY num DESC LIMIT 1;
</select>
</mapper>

View File

@ -18,6 +18,7 @@
tplc.test_plan_id,
tplc.load_case_id,
lt.status,
lt.num,
tplc.status as caseStatus,
lt.name as caseName,
tplc.load_report_id,

View File

@ -0,0 +1,24 @@
package io.metersphere.commons.user;
import org.apache.shiro.authc.UsernamePasswordToken;
public class MsUserToken extends UsernamePasswordToken {
private String loginType;
public MsUserToken() {
}
public MsUserToken(final String username, final String password, final String loginType) {
super(username, password);
this.loginType = loginType;
}
public String getLoginType() {
return loginType;
}
public void setLoginType(String loginType) {
this.loginType = loginType;
}
}

View File

@ -0,0 +1,47 @@
package io.metersphere.commons.user;
import io.metersphere.commons.exception.MSException;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.pam.ModularRealmAuthenticator;
import org.apache.shiro.realm.Realm;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class UserModularRealmAuthenticator extends ModularRealmAuthenticator {
@Override
protected AuthenticationInfo doAuthenticate(AuthenticationToken authenticationToken)
throws AuthenticationException {
// 判断getRealms()是否返回为空
assertRealmsConfigured();
// 强制转换回自定义的CustomizedToken
MsUserToken userToken = (MsUserToken) authenticationToken;
// 登录类型
String loginType = userToken.getLoginType();
// 所有Realm
Collection<Realm> realms = getRealms();
// 登录类型对应的所有Realm
List<Realm> typeRealms = new ArrayList<>();
// 默认使用本地验证
for (Realm realm : realms) {
if (realm.getName().contains(loginType)) {
typeRealms.add(realm);
}
}
if (typeRealms.size() == 0) {
MSException.throwException("No realm");
}
// 判断是单Realm还是多Realm
if (typeRealms.size() == 1) {
return doSingleRealmAuthentication(typeRealms.get(0), userToken);
} else {
return doMultiRealmAuthentication(typeRealms, userToken);
}
}
}

View File

@ -1,9 +1,14 @@
package io.metersphere.config;
import io.metersphere.commons.user.UserModularRealmAuthenticator;
import io.metersphere.commons.utils.ShiroUtils;
import io.metersphere.security.ApiKeyFilter;
import io.metersphere.security.LdapRealm;
import io.metersphere.security.ShiroDBRealm;
import org.apache.shiro.authc.pam.FirstSuccessfulStrategy;
import org.apache.shiro.authc.pam.ModularRealmAuthenticator;
import org.apache.shiro.cache.MemoryConstrainedCacheManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
@ -23,9 +28,7 @@ import org.springframework.core.env.Environment;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import java.util.EnumSet;
import java.util.Map;
import java.util.Objects;
import java.util.*;
@Configuration
@ConditionalOnProperty(prefix = "sso", name = "mode", havingValue = "local", matchIfMissing = true)
@ -74,15 +77,22 @@ public class ShiroConfig implements EnvironmentAware {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setSessionManager(sessionManager);
dwsm.setCacheManager(memoryConstrainedCacheManager);
dwsm.setAuthenticator(modularRealmAuthenticator());
return dwsm;
}
@Bean(name = "shiroDBRealm")
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public ShiroDBRealm getShiroDBRealm() {
public ShiroDBRealm shiroDBRealm() {
return new ShiroDBRealm();
}
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public LdapRealm ldapRealm() {
return new LdapRealm();
}
@Bean(name = "lifecycleBeanPostProcessor")
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
@ -95,6 +105,14 @@ public class ShiroConfig implements EnvironmentAware {
return daap;
}
@Bean
public ModularRealmAuthenticator modularRealmAuthenticator() {
//自己重写的ModularRealmAuthenticator
UserModularRealmAuthenticator modularRealmAuthenticator = new UserModularRealmAuthenticator();
modularRealmAuthenticator.setAuthenticationStrategy(new FirstSuccessfulStrategy());
return modularRealmAuthenticator;
}
@Bean
public AuthorizationAttributeSourceAdvisor getAuthorizationAttributeSourceAdvisor(DefaultWebSecurityManager sessionManager) {
AuthorizationAttributeSourceAdvisor aasa = new AuthorizationAttributeSourceAdvisor();
@ -114,8 +132,13 @@ public class ShiroConfig implements EnvironmentAware {
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
ApplicationContext context = event.getApplicationContext();
ShiroDBRealm shiroDBRealm = (ShiroDBRealm) context.getBean("shiroDBRealm");
((DefaultWebSecurityManager) context.getBean("securityManager")).setRealm(shiroDBRealm);
List<Realm> realmList = new ArrayList<>();
ShiroDBRealm shiroDBRealm = context.getBean(ShiroDBRealm.class);
LdapRealm ldapRealm = context.getBean(LdapRealm.class);
// 基本realm
realmList.add(shiroDBRealm);
realmList.add(ldapRealm);
context.getBean(DefaultWebSecurityManager.class).setRealms(realmList);
}
@Override

View File

@ -1,7 +1,9 @@
package io.metersphere.controller;
import io.metersphere.base.domain.Role;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.service.RoleService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@ -23,6 +25,7 @@ public class RoleController {
}
@GetMapping("/all")
@RequiresRoles(RoleConstants.ADMIN)
public List<Role> getAllRole() {
return roleService.getAllRole();
}

View File

@ -160,6 +160,7 @@ public class PerformanceTestService {
loadTest.setLoadConfiguration(request.getLoadConfiguration());
loadTest.setAdvancedConfiguration(request.getAdvancedConfiguration());
loadTest.setStatus(PerformanceTestStatus.Saved.name());
loadTest.setNum(getNextNum(request.getProjectId()));
loadTestMapper.insert(loadTest);
return loadTest;
}
@ -396,6 +397,7 @@ public class PerformanceTestService {
copy.setUpdateTime(System.currentTimeMillis());
copy.setStatus(APITestStatus.Saved.name());
copy.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
copy.setNum(getNextNum(copy.getProjectId()));
loadTestMapper.insert(copy);
// copy test file
LoadTestFileExample loadTestFileExample = new LoadTestFileExample();
@ -499,4 +501,13 @@ public class PerformanceTestService {
List<LoadTest> loadTests = loadTestMapper.selectByExample(loadTestExample);
return Optional.ofNullable(loadTests).orElse(new ArrayList<>());
}
private int getNextNum(String projectId) {
LoadTest loadTest = extLoadTestMapper.getNextNum(projectId);
if (loadTest == null) {
return 100001;
} else {
return Optional.of(loadTest.getNum() + 1).orElse(100001);
}
}
}

View File

@ -1,9 +1,9 @@
package io.metersphere.security;
import io.metersphere.commons.user.MsUserToken;
import io.metersphere.commons.utils.LogUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.web.filter.authc.AnonymousFilter;
import org.apache.shiro.web.util.WebUtils;
@ -22,12 +22,12 @@ public class ApiKeyFilter extends AnonymousFilter {
if (LogUtil.getLogger().isDebugEnabled()) {
LogUtil.getLogger().debug("user auth: " + userId);
}
SecurityUtils.getSubject().login(new UsernamePasswordToken(userId, ApiKeySessionHandler.random));
SecurityUtils.getSubject().login(new MsUserToken(userId, ApiKeySessionHandler.random, "APIKEY"));
}
} else {
if (ApiKeyHandler.isApiKeyCall(WebUtils.toHttp(request))) {
String userId = ApiKeyHandler.getUser(WebUtils.toHttp(request));
SecurityUtils.getSubject().login(new UsernamePasswordToken(userId, ApiKeySessionHandler.random));
SecurityUtils.getSubject().login(new MsUserToken(userId, ApiKeySessionHandler.random, "APIKEY"));
}
}

View File

@ -0,0 +1,102 @@
package io.metersphere.security;
import io.metersphere.base.domain.Role;
import io.metersphere.commons.constants.UserSource;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.UserDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 自定义Realm 注入service 可能会导致在 service的aop 失效例如@Transactional,
* 解决方法
* <p>
* 1. 这里改成注入mapper这样mapper 中的事务失效<br/>
* 2. 这里仍然注入service在配置ShiroConfig 的时候不去set realm, 等到spring 初始化完成之后
* set realm
* </p>
*/
public class LdapRealm extends AuthorizingRealm {
private Logger logger = LoggerFactory.getLogger(LdapRealm.class);
@Resource
private UserService userService;
@Override
public String getName() {
return "LDAP";
}
/**
* 权限认证
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
String userId = (String) principals.getPrimaryPrincipal();
return getAuthorizationInfo(userId, userService);
}
public static AuthorizationInfo getAuthorizationInfo(String userId, UserService userService) {
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
// roles 内容填充
UserDTO userDTO = userService.getUserDTO(userId);
Set<String> roles = userDTO.getRoles().stream().map(Role::getId).collect(Collectors.toSet());
authorizationInfo.setRoles(roles);
return authorizationInfo;
}
/**
* 登录认证
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
String userId = token.getUsername();
String password = String.valueOf(token.getPassword());
return loginLdapMode(userId, password);
}
private AuthenticationInfo loginLdapMode(String userId, String password) {
// userId email 有一个相同就返回User
String email = (String) SecurityUtils.getSubject().getSession().getAttribute("email");
UserDTO user = userService.getLoginUser(userId, Arrays.asList(UserSource.LDAP.name(), UserSource.LOCAL.name()));
String msg;
if (user == null) {
user = userService.getUserDTOByEmail(email, UserSource.LDAP.name(), UserSource.LOCAL.name());
if (user == null) {
msg = "The user does not exist: " + userId;
logger.warn(msg);
throw new UnknownAccountException(Translator.get("user_not_exist") + userId);
}
userId = user.getId();
}
SessionUser sessionUser = SessionUser.fromUser(user);
SessionUtils.putUser(sessionUser);
return new SimpleAuthenticationInfo(userId, password, getName());
}
@Override
public boolean isPermitted(PrincipalCollection principals, String permission) {
return true;
}
}

View File

@ -20,7 +20,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
@ -44,6 +43,11 @@ public class ShiroDBRealm extends AuthorizingRealm {
@Value("${run.mode:release}")
private String runMode;
@Override
public String getName() {
return "LOCAL";
}
/**
* 权限认证
*/
@ -85,10 +89,6 @@ public class ShiroDBRealm extends AuthorizingRealm {
return loginLocalMode(userId, password);
}
if (StringUtils.equals(login, UserSource.LDAP.name())) {
return loginLdapMode(userId, password);
}
UserDTO user = getUserWithOutAuthenticate(userId);
userId = user.getId();
SessionUser sessionUser = SessionUser.fromUser(user);
@ -111,28 +111,6 @@ public class ShiroDBRealm extends AuthorizingRealm {
return user;
}
private AuthenticationInfo loginLdapMode(String userId, String password) {
// userId email 有一个相同就返回User
String email = (String) SecurityUtils.getSubject().getSession().getAttribute("email");
UserDTO user = userService.getLoginUser(userId, Arrays.asList(UserSource.LDAP.name(), UserSource.LOCAL.name()));
String msg;
if (user == null) {
user = userService.getUserDTOByEmail(email, UserSource.LDAP.name(), UserSource.LOCAL.name());
if (user == null) {
msg = "The user does not exist: " + userId;
logger.warn(msg);
throw new UnknownAccountException(Translator.get("user_not_exist") + userId);
}
userId = user.getId();
}
SessionUser sessionUser = SessionUser.fromUser(user);
SessionUtils.putUser(sessionUser);
return new SimpleAuthenticationInfo(userId, password, getName());
}
private AuthenticationInfo loginLocalMode(String userId, String password) {
UserDTO user = userService.getLoginUser(userId, Collections.singletonList(UserSource.LOCAL.name()));
String msg;

View File

@ -2,6 +2,7 @@ package io.metersphere.service;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.track.dto.TreeNodeDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
@ -203,6 +204,8 @@ public class NodeTreeService<T extends TreeNodeDTO> {
*/
public void sort(List<String> ids) {
// 获取相邻节点 id
if (CollectionUtils.isEmpty(ids))
return;
String before = ids.get(0);
String id = ids.get(1);
String after = ids.get(2);

View File

@ -8,6 +8,7 @@ import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.constants.UserSource;
import io.metersphere.commons.constants.UserStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.MsUserToken;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.commons.utils.SessionUtils;
@ -558,14 +559,16 @@ public class UserService {
String login = (String) SecurityUtils.getSubject().getSession().getAttribute("authenticate");
String username = StringUtils.trim(request.getUsername());
String password = "";
String loginType = UserSource.LDAP.name();
if (!StringUtils.equals(login, UserSource.LDAP.name())) {
loginType = UserSource.LOCAL.name();
password = StringUtils.trim(request.getPassword());
if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
return ResultHolder.error("user or password can't be null");
}
}
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
MsUserToken token = new MsUserToken(username, password, loginType);
Subject subject = SecurityUtils.getSubject();
try {
subject.login(token);

View File

@ -11,4 +11,5 @@ public class TestPlanLoadCaseDTO extends TestPlanLoadCase {
private String caseName;
private String projectName;
private String caseStatus;
private String num;
}

View File

@ -39,7 +39,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@ -119,7 +119,7 @@ public class TestCaseService {
return testCaseMapper.updateByPrimaryKeySelective(testCase);
}
private void checkTestCaseExist(TestCaseWithBLOBs testCase) {
public TestCaseWithBLOBs checkTestCaseExist(TestCaseWithBLOBs testCase) {
// 全部字段值相同才判断为用例存在
if (testCase != null) {
@ -152,17 +152,22 @@ public class TestCaseService {
List<TestCaseWithBLOBs> caseList = testCaseMapper.selectByExampleWithBLOBs(example);
// 如果上边字段全部相同去检查 steps remark
boolean isExt = false;
if (!CollectionUtils.isEmpty(caseList)) {
caseList.forEach(tc -> {
for (TestCaseWithBLOBs tc : caseList) {
String steps = tc.getSteps();
String remark = tc.getRemark();
if (StringUtils.equals(steps, testCase.getSteps()) && StringUtils.equals(remark, testCase.getRemark())) {
MSException.throwException(Translator.get("test_case_already_exists"));
// MSException.throwException(Translator.get("test_case_already_exists"));
isExt = true;
}
});
}
}
if (isExt) {
return caseList.get(0);
}
}
return null;
}
public int deleteTestCase(String testCaseId) {
@ -260,7 +265,9 @@ public class TestCaseService {
try {
XmindCaseParser xmindParser = new XmindCaseParser(this, userId, projectId, testCaseNames);
errList = xmindParser.parse(multipartFile);
if (xmindParser.getNodePaths().isEmpty() && xmindParser.getTestCase().isEmpty()) {
if (CollectionUtils.isEmpty(xmindParser.getNodePaths())
&& CollectionUtils.isEmpty(xmindParser.getTestCase())
&& CollectionUtils.isEmpty(xmindParser.getUpdateTestCase())) {
if (errList == null) {
errList = new ArrayList<>();
}
@ -269,15 +276,18 @@ public class TestCaseService {
excelResponse.setErrList(errList);
}
if (errList.isEmpty()) {
if (!xmindParser.getNodePaths().isEmpty()) {
if (CollectionUtils.isNotEmpty(xmindParser.getNodePaths())) {
testCaseNodeService.createNodes(xmindParser.getNodePaths(), projectId);
}
if (!xmindParser.getTestCase().isEmpty()) {
if (CollectionUtils.isNotEmpty(xmindParser.getTestCase())) {
Collections.reverse(xmindParser.getTestCase());
this.saveImportData(xmindParser.getTestCase(), projectId);
}
if (CollectionUtils.isNotEmpty(xmindParser.getUpdateTestCase())) {
this.updateImportData(xmindParser.getUpdateTestCase(), projectId);
}
}
xmindParser.clear();
}
}
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
MSException.throwException(e.getMessage());
@ -313,7 +323,6 @@ public class TestCaseService {
}
public void saveImportData(List<TestCaseWithBLOBs> testCases, String projectId) {
Map<String, String> nodePathMap = testCaseNodeService.createNodeByTestCases(testCases, projectId);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);
@ -335,6 +344,27 @@ public class TestCaseService {
sqlSession.flushStatements();
}
public void updateImportData(List<TestCaseWithBLOBs> testCases, String projectId) {
Map<String, String> nodePathMap = testCaseNodeService.createNodeByTestCases(testCases, projectId);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);
if (!testCases.isEmpty()) {
AtomicInteger sort = new AtomicInteger();
AtomicInteger num = new AtomicInteger();
num.set(getNextNum(projectId) + testCases.size());
testCases.forEach(testcase -> {
testcase.setUpdateTime(System.currentTimeMillis());
testcase.setNodeId(nodePathMap.get(testcase.getNodePath()));
testcase.setSort(sort.getAndIncrement());
testcase.setNum(num.decrementAndGet());
testcase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
mapper.updateByPrimaryKeySelective(testcase);
});
}
sqlSession.flushStatements();
}
public void testCaseTemplateExport(HttpServletResponse response) {
try {
EasyExcelExporter easyExcelExporter = new EasyExcelExporter(new TestCaseExcelDataFactory().getExcelDataByLocal());
@ -572,7 +602,9 @@ public class TestCaseService {
public boolean exist(TestCaseWithBLOBs testCaseWithBLOBs) {
try {
checkTestCaseExist(testCaseWithBLOBs);
TestCaseWithBLOBs caseWithBLOBs = checkTestCaseExist(testCaseWithBLOBs);
if (caseWithBLOBs != null)
return true;
} catch (MSException e) {
return true;
}

View File

@ -44,6 +44,11 @@ public class XmindCaseParser {
* 转换后的案例信息
*/
private List<TestCaseWithBLOBs> testCases;
/**
* 需要更新的用例
*/
private List<TestCaseWithBLOBs> updateTestCases;
/**
* 案例详情重写了hashCode方法去重用
*/
@ -59,6 +64,7 @@ public class XmindCaseParser {
this.projectId = projectId;
this.testCaseNames = testCaseNames;
testCases = new LinkedList<>();
updateTestCases = new LinkedList<>();
compartDatas = new ArrayList<>();
process = new DetailUtil();
nodePaths = new ArrayList<>();
@ -71,6 +77,7 @@ public class XmindCaseParser {
public void clear() {
compartDatas.clear();
testCases.clear();
updateTestCases.clear();
testCaseNames.clear();
nodePaths.clear();
}
@ -79,6 +86,10 @@ public class XmindCaseParser {
return this.testCases;
}
public List<TestCaseWithBLOBs> getUpdateTestCase() {
return this.updateTestCases;
}
public List<String> getNodePaths() {
return this.nodePaths;
}
@ -112,7 +123,7 @@ public class XmindCaseParser {
/**
* 验证用例的合规性
*/
private void validate(TestCaseWithBLOBs data) {
private boolean validate(TestCaseWithBLOBs data) {
String nodePath = data.getNodePath();
if (!nodePath.startsWith("/")) {
nodePath = "/" + nodePath;
@ -149,9 +160,13 @@ public class XmindCaseParser {
}
if (testCaseNames.contains(data.getName())) {
boolean dbExist = testCaseService.exist(data);
if (dbExist) {
process.add(Translator.get("test_case_already_exists_excel"), nodePath + "/" + data.getName());
TestCaseWithBLOBs bloBs = testCaseService.checkTestCaseExist(data);
if (bloBs != null) {
// process.add(Translator.get("test_case_already_exists_excel"), nodePath + "/" + data.getName());
// 记录需要变更的用例
BeanUtils.copyBean(bloBs, data, "id");
updateTestCases.add(bloBs);
return false;
}
} else {
testCaseNames.add(data.getName());
@ -172,6 +187,7 @@ public class XmindCaseParser {
process.add(Translator.get("test_case_already_exists_excel"), nodePath + "/" + compartData.getName());
}
compartDatas.add(compartData);
return true;
}
/**
@ -299,9 +315,10 @@ public class XmindCaseParser {
}
testCase.setRemark(rc.toString());
testCase.setSteps(this.getSteps(steps));
testCases.add(testCase);
// 校验合规性
validate(testCase);
if (validate(testCase)) {
testCases.add(testCase);
}
}
/**

@ -1 +1 @@
Subproject commit 068127ce59ea8b016434ed52a9de4a7a4b13bdb4
Subproject commit 8d5b1ebeabf5ebaee9ca186087ac8a34cf888518

View File

@ -0,0 +1,14 @@
CREATE TABLE IF NOT EXISTS `auth_source` (
`id` varchar(50) NOT NULL,
`configuration` text NOT NULL,
`status` varchar(64) NOT NULL,
`create_time` bigint(13) NOT NULL,
`update_time` bigint(13) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`name` varchar(60) DEFAULT NULL,
`type` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;

View File

@ -0,0 +1,51 @@
alter table load_test add num int null;
DROP PROCEDURE IF EXISTS test_cursor;
DELIMITER //
CREATE PROCEDURE test_cursor()
BEGIN
DECLARE projectId VARCHAR(64);
DECLARE loadTestId VARCHAR(64);
DECLARE num INT;
DECLARE done INT DEFAULT 0;
DECLARE cursor1 CURSOR FOR (SELECT DISTINCT project_id
FROM load_test
WHERE num IS NULL);
DECLARE cursor2 CURSOR FOR (SELECT id
FROM load_test
WHERE project_id = projectId
ORDER BY create_time);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cursor1;
outer_loop:
LOOP
FETCH cursor1 INTO projectId;
IF done
THEN
LEAVE outer_loop;
END IF;
SET num = 100001;
OPEN cursor2;
inner_loop:
LOOP
FETCH cursor2 INTO loadTestId;
IF done
THEN
LEAVE inner_loop;
END IF;
UPDATE load_test
SET num = num
WHERE id = loadTestId;
SET num = num + 1;
END LOOP;
SET done = 0;
CLOSE cursor2;
END LOOP;
CLOSE cursor1;
END //
DELIMITER ;
CALL test_cursor();
DROP PROCEDURE IF EXISTS test_cursor;

View File

@ -64,7 +64,7 @@
<!--要生成的数据库表 -->
<table tableName="test_case"/>
<table tableName="auth_source"/>
<!--<table tableName="test_plan_api_scenario"/>-->
<!--<table tableName="test_plan"/>-->
<!--<table tableName="api_scenario_report"/>-->

View File

@ -178,5 +178,8 @@ message_task_already_exists=Task recipient already exists
#automation
automation_name_already_exists=the scenario already exists in the project and the module
automation_exec_info=There are no test steps to execute
#authsource
authsource_name_already_exists=Authentication source name already exists
authsource_name_is_null=Authentication source name cannot be empty
authsource_configuration_is_null=Authentication source configuration cannot be empty

View File

@ -179,3 +179,7 @@ message_task_already_exists=任务接收人已经存在
#automation
automation_name_already_exists=同一个项目和模块下,场景名称不能重复
automation_exec_info=没有测试步骤,无法执行
#authsource
authsource_name_already_exists=认证源名称已经存在
authsource_name_is_null=认证源名称不能为空
authsource_configuration_is_null=认证源配置不能为空

View File

@ -180,3 +180,7 @@ message_task_already_exists=任務接收人已經存在
#automation
automation_name_already_exists=同一個項目和模塊下,場景名稱不能重複
automation_exec_info=沒有測試步驟,無法執行
#authsource
authsource_name_already_exists=認證源名稱已經存在
authsource_name_is_null=認證源名稱不能為空
authsource_configuration_is_null=認證源配置不能為空

View File

@ -9,14 +9,21 @@
<main v-if="this.isNotRunning">
<ms-metric-chart :content="content" :totalTime="totalTime"/>
<div>
<!--<ms-scenario-results :scenarios="content.scenarios" v-on:requestResult="requestResult"/>-->
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :label="$t('api_report.total')" name="total">
<ms-scenario-results :scenarios="content.scenarios" v-on:requestResult="requestResult"/>
</el-tab-pane>
<el-tab-pane name="fail">
<template slot="label">
<span class="fail">{{ $t('api_report.fail') }}</span>
</template>
<ms-scenario-results v-on:requestResult="requestResult" :scenarios="fails"/>
</el-tab-pane>
</el-tabs>
</div>
<!--<el-collapse-transition>-->
<!--<div v-show="isActive" style="width: 99%">-->
<!--<ms-request-result-tail v-if="isRequestResult" :request-type="requestType" :request="request"-->
<!--:scenario-name="scenarioName"/>-->
<!--</div>-->
<!--</el-collapse-transition>-->
<ms-api-report-export v-if="reportExportVisible" id="apiTestReport" :title="report.testName"
:content="content" :total-time="totalTime"/>
</main>

View File

@ -1,5 +1,5 @@
<template>
<div class="scenario-result">
<div class="scenario-result" v-if="scenario && scenario.requestResults && scenario.requestResults.length>0">
<div @click="active">
<el-row :gutter="10" type="flex" align="middle" class="info">

View File

@ -1,5 +1,5 @@
<template>
<div style="min-width: 1200px;margin-bottom: 20px">
<div style="margin-bottom: 20px">
<span class="kv-description" v-if="description">
{{ description }}
</span>

View File

@ -28,18 +28,15 @@
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<div style="min-width: 1200px;" v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<ms-api-variable :is-read-only="isReadOnly"
:parameters="body.kvs"
:isShowEnable="isShowEnable"
type="body"
v-if="body.type == 'Form Data'"/>
:isShowEnable="isShowEnable" type="body" v-if="body.type == 'Form Data'"/>
<ms-api-from-url-variable :is-read-only="isReadOnly"
:parameters="body.kvs"
type="body"
v-if="body.type == 'WWW_FORM'"/>
type="body" v-if="body.type == 'WWW_FORM'"/>
</div>
<div v-if="body.type == 'JSON'">
<div style="padding: 10px">
<el-switch active-text="JSON-SCHEMA" v-model="body.format" active-value="JSON-SCHEMA"/>

View File

@ -62,7 +62,6 @@ export default {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
console.log(this.basisData)
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
@ -73,6 +72,9 @@ export default {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('runTest', this.basisData);
}
},

View File

@ -71,6 +71,10 @@ export default {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
this.basisData.method = this.basisData.protocol;
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('runTest', this.basisData);
}
},

View File

@ -3,7 +3,7 @@
<el-row>
<el-col :span="21" style="padding-bottom: 20px">
<div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100% ;margin: 10px">
<el-form class="tcp" :model="request" :rules="rules" ref="request" label-width="auto" :disabled="isReadOnly" style="margin: 20px">
<el-form class="tcp" :model="request" :rules="rules" ref="request" :disabled="isReadOnly" style="margin: 20px">
<el-tabs v-model="activeName" class="request-tabs">

View File

@ -3,12 +3,12 @@
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :label="$t('organization.message.template')" name="apiTemplate">
<el-button type="primary" size="mini" style="margin-left: 10px" @click="openOneClickOperation">导入</el-button>
<div style="min-height: 400px">
<div style="min-height: 200px">
<json-schema-editor class="schema" :value="schema" lang="zh_CN" custom/>
</div>
</el-tab-pane>
<el-tab-pane :label="$t('schema.preview')" name="preview">
<div style="min-height: 400px">
<div style="min-height: 200px">
<pre>{{this.preview}}</pre>
</div>
</el-tab-pane>

View File

@ -13,6 +13,12 @@
@filter-change="filter"
@row-click="link"
>
<el-table-column
prop="num"
label="ID"
width="100"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="name"
:label="$t('commons.name')"

View File

@ -14,6 +14,9 @@
<el-tab-pane v-if="hasLicense()" :label="$t('display.title')" name="display">
<ms-display/>
</el-tab-pane>
<el-tab-pane v-if="hasLicense()" :label="'认证设置'" name="auth">
<ms-auth/>
</el-tab-pane>
</el-tabs>
</el-card>
</template>
@ -26,6 +29,7 @@ import {hasLicense} from '@/common/js/utils';
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const display = requireComponent.keys().length > 0 ? requireComponent("./display/Display.vue") : {};
const auth = requireComponent.keys().length > 0 ? requireComponent("./auth/Auth.vue") : {};
export default {
name: "SystemParameterSetting",
@ -33,7 +37,8 @@ export default {
BaseSetting,
EmailSetting,
LdapSetting,
"MsDisplay": display.default
"MsDisplay": display.default,
"MsAuth": auth.default,
},
data() {
return {

View File

@ -24,7 +24,7 @@
</template>
</el-table-column>
<!-- <el-table-column prop="num" label="ID" show-overflow-tooltip/>-->
<el-table-column prop="num" label="ID" show-overflow-tooltip/>
<el-table-column
prop="caseName"
:label="$t('commons.name')"
@ -83,7 +83,9 @@
show-overflow-tooltip>
<template v-slot:default="scope">
<div v-loading="loading === scope.row.id">
<el-link type="info" @click="getReport(scope.row)" v-if="scope.row.loadReportId">{{ $t('test_track.plan.load_case.view_report') }}</el-link>
<el-link type="info" @click="getReport(scope.row)" v-if="scope.row.loadReportId">
{{ $t('test_track.plan.load_case.view_report') }}
</el-link>
<span v-else> - </span>
</div>
</template>

@ -1 +1 @@
Subproject commit 7d43154a7c19732407a8e9ace8a7d1ea13c91f36
Subproject commit 3d96d7c61bc50f32f18311d23f447663e02d7d44

View File

@ -1461,6 +1461,8 @@ export default {
add_file: "Add file",
delimiter: "Delimiter",
format: "Output format",
},
auth_source: {
delete_prompt:'This operation will delete the authentication source, do you want to continue? '
}
};

View File

@ -1461,5 +1461,8 @@ export default {
add_file: "添加文件",
delimiter: "分隔符",
format: "输出格式",
},
auth_source: {
delete_prompt: '此操作会删除认证源,是否继续?'
}
};

View File

@ -1461,5 +1461,8 @@ export default {
add_file: "添加文件",
delimiter: "分隔符",
format: "輸出格式",
},
auth_source: {
delete_prompt: '此操作會刪除認證源,是否繼續? '
}
};