Merge branch 'dev' of https://github.com/fit2cloudrd/metersphere-server into dev
This commit is contained in:
commit
18b4250dbf
|
@ -85,6 +85,7 @@ public interface ParamConstants {
|
|||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum MAIL {
|
||||
HOST("meter.host", 1),
|
||||
PORT("meter.port", 2),
|
||||
|
|
|
@ -15,13 +15,15 @@ import java.util.List;
|
|||
@RequestMapping(value = "/system")
|
||||
public class SystemParameterController {
|
||||
@Resource
|
||||
private SystemParameterService SystemParameterService;
|
||||
private SystemParameterService SystemParameterService;
|
||||
|
||||
@PostMapping("/edit/email")
|
||||
public void editMail(@RequestBody List<SystemParameter> SystemParameter){
|
||||
SystemParameterService.editMail(SystemParameter);
|
||||
public void editMail(@RequestBody List<SystemParameter> systemParameter) {
|
||||
SystemParameterService.editMail(systemParameter);
|
||||
}
|
||||
|
||||
@PostMapping("/testConnection")
|
||||
public void testConnection(@RequestBody HashMap<String, String> hashMap){
|
||||
public void testConnection(@RequestBody HashMap<String, String> hashMap) {
|
||||
SystemParameterService.testConnection(hashMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.commons.collections.CollectionUtils;
|
|||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
@ -16,7 +17,6 @@ import java.util.Properties;
|
|||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
|
@ -39,7 +39,8 @@ public class SystemParameterService {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
public void editMail(List<SystemParameter> parameters){
|
||||
|
||||
public void editMail(List<SystemParameter> parameters) {
|
||||
List<SystemParameter> paramList = this.getParamList(ParamConstants.Classify.MAIL.getValue());
|
||||
boolean empty = paramList.size() < 2;
|
||||
parameters.forEach(parameter -> {
|
||||
|
@ -54,13 +55,14 @@ public class SystemParameterService {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<SystemParameter> getParamList(String type) {
|
||||
SystemParameterExample example = new SystemParameterExample();
|
||||
example.createCriteria().andParamKeyLike(type + "%");
|
||||
return systemParameterMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public void testConnection(HashMap<String, String> hashMap){
|
||||
public void testConnection(HashMap<String, String> hashMap) {
|
||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
javaMailSender.setHost(hashMap.get(ParamConstants.MAIL.PORT.getKey()));
|
||||
|
|
|
@ -75,9 +75,9 @@
|
|||
|
||||
let parameters = [];
|
||||
let url = new URL(this.addProtocol(this.request.url));
|
||||
url.searchParams.forEach(function (key, value) {
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
parameters.push(new KeyValue({name: key, value: value}));
|
||||
parameters.push(new KeyValue(key, value));
|
||||
}
|
||||
});
|
||||
// 添加一个空的,用于填写
|
||||
|
|
|
@ -279,7 +279,7 @@ export class HTTPSamplerArguments extends Element {
|
|||
let collectionProp = this.collectionProp('Arguments.arguments');
|
||||
this.args.forEach(arg => {
|
||||
let elementProp = collectionProp.elementProp(arg.name, 'HTTPArgument');
|
||||
elementProp.boolProp('HTTPArgument.always_encode', arg.encode || false);
|
||||
elementProp.boolProp('HTTPArgument.always_encode', arg.encode || true);
|
||||
elementProp.boolProp('HTTPArgument.use_equals', arg.equals || true);
|
||||
if (arg.name) {
|
||||
elementProp.stringProp('Argument.name', arg.name);
|
||||
|
|
|
@ -456,7 +456,7 @@ class JMXGenerator {
|
|||
}
|
||||
|
||||
addScenarioVariables(threadGroup, scenario) {
|
||||
let args = scenario.variables.filter(this.filter)
|
||||
let args = this.replaceKV(scenario.variables);
|
||||
if (args.length > 0) {
|
||||
let name = scenario.name + " Variables"
|
||||
threadGroup.put(new Arguments(name, args));
|
||||
|
@ -464,7 +464,7 @@ class JMXGenerator {
|
|||
}
|
||||
|
||||
addScenarioHeaders(threadGroup, scenario) {
|
||||
let headers = scenario.headers.filter(this.filter)
|
||||
let headers = this.replaceKV(scenario.headers);
|
||||
if (headers.length > 0) {
|
||||
let name = scenario.name + " Headers"
|
||||
threadGroup.put(new HeaderManager(name, headers));
|
||||
|
@ -473,14 +473,14 @@ class JMXGenerator {
|
|||
|
||||
addRequestHeader(httpSamplerProxy, request) {
|
||||
let name = request.name + " Headers";
|
||||
let headers = request.headers.filter(this.filter);
|
||||
let headers = this.replaceKV(request.headers);
|
||||
if (headers.length > 0) {
|
||||
httpSamplerProxy.put(new HeaderManager(name, headers));
|
||||
}
|
||||
}
|
||||
|
||||
addRequestArguments(httpSamplerProxy, request) {
|
||||
let args = request.parameters.filter(this.filter)
|
||||
let args = this.replaceKV(request.parameters);
|
||||
if (args.length > 0) {
|
||||
httpSamplerProxy.add(new HTTPSamplerArguments(args));
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ class JMXGenerator {
|
|||
getAssertion(regex) {
|
||||
let name = regex.description;
|
||||
let type = JMX_ASSERTION_CONDITION.CONTAINS; // 固定用Match,自己写正则
|
||||
let value = regex.expression;
|
||||
let value = this.replace(regex.expression);
|
||||
switch (regex.subject) {
|
||||
case ASSERTION_REGEX_SUBJECT.RESPONSE_CODE:
|
||||
return new ResponseCodeAssertion(name, type, value);
|
||||
|
@ -577,6 +577,20 @@ class JMXGenerator {
|
|||
return config.isValid();
|
||||
}
|
||||
|
||||
replace(str) {
|
||||
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """);
|
||||
}
|
||||
|
||||
replaceKV(kvs) {
|
||||
let results = [];
|
||||
kvs.filter(this.filter).forEach(kv => {
|
||||
let name = this.replace(kv.name);
|
||||
let value = this.replace(kv.value);
|
||||
results.push(new KeyValue(name, value));
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
toXML() {
|
||||
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
||||
xml += this.jmeterTestPlan.toXML();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<el-form-item :label="$t('system_parameter_setting.SMTP_host')" prop="host">
|
||||
</el-form-item>
|
||||
<el-input v-model="formInline.host" :placeholder="$t('system_parameter_setting.SMTP_host')"
|
||||
v-on:input="host('host')"></el-input>
|
||||
v-on:input="change()"></el-input>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<el-form-item :label="$t('system_parameter_setting.SMTP_port')" prop="port">
|
||||
</el-form-item>
|
||||
<el-input v-model="formInline.port" :placeholder="$t('system_parameter_setting.SMTP_port')"
|
||||
v-on:input="port('port')"></el-input>
|
||||
v-on:input="change()"></el-input>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
|
@ -28,7 +28,7 @@
|
|||
<el-form-item :label="$t('system_parameter_setting.SMTP_account')" prop="account">
|
||||
</el-form-item>
|
||||
<el-input v-model="formInline.account" :placeholder="$t('system_parameter_setting.SMTP_account')"
|
||||
v-on:input="account('account')"></el-input>
|
||||
v-on:input="change()"></el-input>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
|
@ -94,7 +94,7 @@
|
|||
host: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t('commons.host_cannot_be_empty')
|
||||
message: ''
|
||||
},
|
||||
],
|
||||
port: [
|
||||
|
@ -114,30 +114,8 @@
|
|||
|
||||
|
||||
methods: {
|
||||
host() {
|
||||
let host = this.formInline.host;
|
||||
if (!host) {
|
||||
this.disabledConnection = true;
|
||||
this.disabledSave = true;
|
||||
} else {
|
||||
this.disabledConnection = false;
|
||||
this.disabledSave = false;
|
||||
}
|
||||
},
|
||||
port() {
|
||||
|
||||
let port = this.formInline.port;
|
||||
if (!port) {
|
||||
this.disabledConnection = true;
|
||||
this.disabledSave = true;
|
||||
} else {
|
||||
this.disabledConnection = false;
|
||||
this.disabledSave = false;
|
||||
}
|
||||
},
|
||||
account() {
|
||||
let account = this.formInline.account;
|
||||
if (!account) {
|
||||
change() {
|
||||
if (!this.formInline.host || !this.formInline.port || !this.formInline.account) {
|
||||
this.disabledConnection = true;
|
||||
this.disabledSave = true;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue