This commit is contained in:
fit2-zhao 2020-10-09 10:40:07 +08:00
commit 7972c91170
35 changed files with 326 additions and 234 deletions

View File

@ -7,9 +7,11 @@ import io.metersphere.api.dto.scenario.request.HttpRequest;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.http.HttpHeader;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -19,7 +21,7 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
protected String getApiTestStr(InputStream source) {
StringBuilder testStr = null;
try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source, StandardCharsets.UTF_8))) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source, StandardCharsets.UTF_8))) {
testStr = new StringBuilder();
String inputStr;
while ((inputStr = bufferedReader.readLine()) != null) {
@ -46,21 +48,21 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
}
protected void addContentType(HttpRequest request, String contentType) {
addHeader(request, HttpHeader.CONTENT_TYPE.toString(), contentType);
addHeader(request, "Content-Type", contentType);
}
protected void addCookie(HttpRequest request, String key, String value) {
List<KeyValue> headers = Optional.ofNullable(request.getHeaders()).orElse(new ArrayList<>());
boolean hasCookie = false;
for (KeyValue header : headers) {
if (StringUtils.equalsIgnoreCase(HttpHeader.COOKIE.name(), header.getName())) {
if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) {
hasCookie = true;
String cookies = Optional.ofNullable(header.getValue()).orElse("");
header.setValue(cookies + key + "=" + value + ";");
}
}
if (!hasCookie) {
addHeader(request, HttpHeader.COOKIE.name(), key + "=" + value + ";");
addHeader(request, "Cookie", key + "=" + value + ";");
}
}

View File

@ -9,7 +9,6 @@ import io.metersphere.api.dto.parse.ApiImport;
import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.commons.constants.MsRequestBodyType;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.http.HttpMethod;
import java.io.InputStream;
@ -62,7 +61,7 @@ public class MsParser extends ApiImportAbstractParser {
Object body = requestObject.get("body");
if (body instanceof JSONArray) {
JSONArray bodies = requestObject.getJSONArray("body");
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodies != null) {
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), "POST") && bodies != null) {
StringBuilder bodyStr = new StringBuilder();
for (int i = 0; i < bodies.size(); i++) {
String tmp = bodies.getString(i);
@ -75,7 +74,7 @@ public class MsParser extends ApiImportAbstractParser {
}
} else if (body instanceof JSONObject) {
JSONObject bodyObj = requestObject.getJSONObject("body");
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodyObj != null) {
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), "POST") && bodyObj != null) {
JSONArray kvs = new JSONArray();
bodyObj.keySet().forEach(key -> {
JSONObject kv = new JSONObject();

View File

@ -12,11 +12,11 @@ public class Notice implements Serializable {
private String testId;
private String name;
private String enable;
private String type;
private String userId;
private static final long serialVersionUID = 1L;
}

View File

@ -314,76 +314,6 @@ public class NoticeExample {
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 andEnableIsNull() {
addCriterion("`ENABLE` is null");
return (Criteria) this;
@ -523,6 +453,76 @@ public class NoticeExample {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(String value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(String value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(String value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(String value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(String value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLike(String value) {
addCriterion("user_id like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotLike(String value) {
addCriterion("user_id not like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<String> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<String> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(String value1, String value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(String value1, String value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -5,9 +5,9 @@
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="EVENT" jdbcType="VARCHAR" property="event" />
<result column="TEST_ID" jdbcType="VARCHAR" property="testId" />
<result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="ENABLE" jdbcType="VARCHAR" property="enable" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -68,7 +68,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, EVENT, TEST_ID, `NAME`, `ENABLE`, `type`
id, EVENT, TEST_ID, `ENABLE`, `type`, user_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.NoticeExample" resultMap="BaseResultMap">
select
@ -102,9 +102,11 @@
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.Notice">
INSERT INTO notice (id, EVENT, TEST_ID,
`NAME`, `ENABLE`, `type`)
`ENABLE`, `type`, user_id
)
VALUES (#{id,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{enable,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR})
#{enable,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.Notice">
insert into notice
@ -118,15 +120,15 @@
<if test="testId != null">
TEST_ID,
</if>
<if test="name != null">
`NAME`,
</if>
<if test="enable != null">
`ENABLE`,
</if>
<if test="type != null">
`type`,
</if>
<if test="userId != null">
user_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -138,15 +140,15 @@
<if test="testId != null">
#{testId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="enable != null">
#{enable,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.NoticeExample" resultType="java.lang.Long">
@ -167,15 +169,15 @@
<if test="record.testId != null">
TEST_ID = #{record.testId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`NAME` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.enable != null">
`ENABLE` = #{record.enable,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -186,9 +188,9 @@
set id = #{record.id,jdbcType=VARCHAR},
EVENT = #{record.event,jdbcType=VARCHAR},
TEST_ID = #{record.testId,jdbcType=VARCHAR},
`NAME` = #{record.name,jdbcType=VARCHAR},
`ENABLE` = #{record.enable,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR}
`type` = #{record.type,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -202,15 +204,15 @@
<if test="testId != null">
TEST_ID = #{testId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`NAME` = #{name,jdbcType=VARCHAR},
</if>
<if test="enable != null">
`ENABLE` = #{enable,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -218,9 +220,9 @@
UPDATE notice
SET EVENT = #{event,jdbcType=VARCHAR},
TEST_ID = #{testId,jdbcType=VARCHAR},
`NAME` = #{name,jdbcType=VARCHAR},
`ENABLE` = #{enable,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR}
`type` = #{type,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR}
WHERE id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -16,8 +16,6 @@ public interface ExtUserMapper {
List<User> searchUser(String condition);
List<String> queryEmails(String[] names);
List<String> queryEmailByIds(List<String> userIds);
}

View File

@ -33,18 +33,6 @@
</where>
order by u.update_time desc
</select>
<!--查询邮箱-->
<select id="queryEmails" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
email
from user
WHERE name IN
<foreach collection="array" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<select id="queryEmailByIds" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
email

View File

@ -1,10 +1,14 @@
package io.metersphere.commons.utils;
import io.metersphere.commons.user.SessionUser;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.DefaultSessionManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.subject.support.DefaultSubjectContext;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
@ -26,6 +30,30 @@ public class SessionUtils {
}
}
private static Session getSessionByUsername(String username) {
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
Collection<Session> sessions = sessionManager.getSessionDAO().getActiveSessions();
for (Session session : sessions) {
if (null != session && StringUtils.equals(String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)), username)) {
return session;
}
}
return null;
}
/**
* 踢除用户
*
* @param username
*/
public static void kickOutUser(String username) {
Session session = getSessionByUsername(username);
if (session != null) {
DefaultSessionManager sessionManager = CommonBeanFactory.getBean(DefaultSessionManager.class);
sessionManager.getSessionDAO().delete(session);
}
}
//
public static void putUser(SessionUser sessionUser) {
SecurityUtils.getSubject().getSession().setAttribute(ATTR_USER, sessionUser);

View File

@ -2,7 +2,6 @@ package io.metersphere.config;
import io.metersphere.commons.utils.ShiroUtils;
import io.metersphere.security.ApiKeyFilter;
import io.metersphere.security.LoginFilter;
import io.metersphere.security.ShiroDBRealm;
import org.apache.shiro.cache.MemoryConstrainedCacheManager;
import org.apache.shiro.session.mgt.SessionManager;
@ -36,7 +35,7 @@ public class ShiroConfig implements EnvironmentAware {
@Bean
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager sessionManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.getFilters().put("authc", new LoginFilter());
// shiroFilterFactoryBean.getFilters().put("authc", new LoginFilter());
shiroFilterFactoryBean.setLoginUrl("/login");
shiroFilterFactoryBean.setSecurityManager(sessionManager);
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
@ -45,7 +44,8 @@ public class ShiroConfig implements EnvironmentAware {
shiroFilterFactoryBean.getFilters().put("apikey", new ApiKeyFilter());
Map<String, String> filterChainDefinitionMap = shiroFilterFactoryBean.getFilterChainDefinitionMap();
ShiroUtils.loadBaseFilterChain(filterChainDefinitionMap);
filterChainDefinitionMap.put("/**", "apikey, authc");
// filterChainDefinitionMap.put("/**", "apikey, authc");
filterChainDefinitionMap.put("/**", "apikey");
return shiroFilterFactoryBean;
}

View File

@ -63,6 +63,8 @@ public class UserController {
@RequiresRoles(RoleConstants.ADMIN)
public void deleteUser(@PathVariable(value = "userId") String userId) {
userService.deleteUser(userId);
// 踢掉在线用户
SessionUtils.kickOutUser(userId);
}
@PostMapping("/special/update")

View File

@ -3,7 +3,10 @@ package io.metersphere.notice.domain;
import io.metersphere.base.domain.Notice;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class NoticeDetail extends Notice {
private String[] names;
private List<String> userIds = new ArrayList<>();
}

View File

@ -42,12 +42,12 @@ public class MailService {
@Resource
private SystemParameterService systemParameterService;
public void sendPerformanceNotification(List<NoticeDetail> noticeList, String status, LoadTestWithBLOBs loadTest) {
public void sendPerformanceNotification(List<NoticeDetail> noticeList, String status, LoadTestWithBLOBs loadTest, String id) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
Map<String, String> context = new HashMap<>();
context.put("title", "Performance" + Translator.get("timing_task_result_notification"));
context.put("testName", loadTest.getName());
context.put("id", loadTest.getId());
context.put("id", id);
context.put("type", "performance");
context.put("url", baseSystemConfigDTO.getUrl());
String performanceTemplate = "";
@ -231,10 +231,10 @@ public class MailService {
if (noticeList.size() > 0) {
for (NoticeDetail n : noticeList) {
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_SUCCESSFUL)) {
successEmailList = userService.queryEmail(n.getNames());
successEmailList = userService.queryEmail(n.getUserIds());
}
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_FAILED)) {
failEmailList = userService.queryEmail(n.getNames());
failEmailList = userService.queryEmail(n.getUserIds());
}
}
} else {

View File

@ -5,6 +5,7 @@ import io.metersphere.base.domain.NoticeExample;
import io.metersphere.base.mapper.NoticeMapper;
import io.metersphere.notice.controller.request.NoticeRequest;
import io.metersphere.notice.domain.NoticeDetail;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -28,14 +29,14 @@ public class NoticeService {
noticeMapper.deleteByExample(example);
}
noticeRequest.getNotices().forEach(n -> {
if (n.getNames().length > 0) {
for (String x : n.getNames()) {
if (CollectionUtils.isNotEmpty(n.getUserIds())) {
for (String x : n.getUserIds()) {
Notice notice = new Notice();
notice.setId(UUID.randomUUID().toString());
notice.setEvent(n.getEvent());
notice.setEnable(n.getEnable());
notice.setTestId(noticeRequest.getTestId());
notice.setName(x);
notice.setUserId(x);
notice.setType(n.getType());
noticeMapper.insert(notice);
}
@ -48,33 +49,29 @@ public class NoticeService {
example.createCriteria().andTestIdEqualTo(id);
List<Notice> notices = noticeMapper.selectByExample(example);
List<NoticeDetail> result = new ArrayList<>();
List<String> success = new ArrayList<>();
List<String> fail = new ArrayList<>();
String[] successArray;
String[] failArray;
List<String> successList = new ArrayList<>();
List<String> failList = new ArrayList<>();
NoticeDetail notice1 = new NoticeDetail();
NoticeDetail notice2 = new NoticeDetail();
if (notices.size() > 0) {
for (Notice n : notices) {
if (n.getEvent().equals(EXECUTE_SUCCESSFUL)) {
success.add(n.getName());
successList.add(n.getUserId());
notice1.setEnable(n.getEnable());
notice1.setTestId(id);
notice1.setType(n.getType());
notice1.setEvent(n.getEvent());
}
if (n.getEvent().equals(EXECUTE_FAILED)) {
fail.add(n.getName());
failList.add(n.getUserId());
notice2.setEnable(n.getEnable());
notice2.setTestId(id);
notice2.setType(n.getType());
notice2.setEvent(n.getEvent());
}
}
successArray = success.toArray(new String[0]);
failArray = fail.toArray(new String[0]);
notice1.setNames(successArray);
notice2.setNames(failArray);
notice1.setUserIds(successList);
notice2.setUserIds(failList);
result.add(notice1);
result.add(notice2);
}

View File

@ -242,7 +242,7 @@ public class PerformanceTestService {
if (request.getTriggerMode().equals("SCHEDULE")) {
try {
noticeList = noticeService.queryNotice(loadTest.getId());
mailService.sendPerformanceNotification(noticeList, PerformanceTestStatus.Completed.name(), loadTest);
mailService.sendPerformanceNotification(noticeList, PerformanceTestStatus.Completed.name(), loadTest, engine.getReportId());
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}
@ -321,7 +321,7 @@ public class PerformanceTestService {
loadTestMapper.updateByPrimaryKeySelective(loadTest);
if (triggerMode.equals("SCHEDULE")) {
noticeList = noticeService.queryNotice(loadTest.getId());
mailService.sendPerformanceNotification(noticeList, loadTest.getStatus(), loadTest);
mailService.sendPerformanceNotification(noticeList, loadTest.getStatus(), loadTest, loadTest.getId());
}
throw e;
}
@ -449,7 +449,7 @@ public class PerformanceTestService {
if (loadTestReport.getTriggerMode().equals("SCHEDULE")) {
try {
noticeList = noticeService.queryNotice(loadTest.getId());
mailService.sendPerformanceNotification(noticeList, loadTestReport.getStatus(), loadTest);
mailService.sendPerformanceNotification(noticeList, loadTestReport.getStatus(), loadTest, loadTestReport.getId());
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}

View File

@ -34,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@ -62,8 +61,8 @@ public class UserService {
@Resource
private WorkspaceService workspaceService;
public List<String> queryEmail(String[] names) {
return extUserMapper.queryEmails(names);
public List<String> queryEmail(List<String> userIds) {
return extUserMapper.queryEmailByIds(userIds);
}
public List<String> queryEmailByIds(List<String> userIds) {

View File

@ -25,6 +25,7 @@ import java.util.List;
@RequestMapping("/test/case/review")
@RestController
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public class TestCaseReviewController {
@Resource
@ -33,7 +34,6 @@ public class TestCaseReviewController {
TestReviewProjectService testReviewProjectService;
@PostMapping("/list/{goPage}/{pageSize}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public Pager<List<TestCaseReviewDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryCaseReviewRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewService.listCaseReview(request));
@ -46,19 +46,16 @@ public class TestCaseReviewController {
}
@PostMapping("/project")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public List<Project> getProjectByReviewId(@RequestBody TestCaseReview request) {
return testCaseReviewService.getProjectByReviewId(request);
}
@PostMapping("/reviewer")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public List<User> getUserByReviewId(@RequestBody TestCaseReview request) {
return testCaseReviewService.getUserByReviewId(request);
}
@GetMapping("/recent/{count}")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public List<TestCaseReviewDTO> recentTestPlans(@PathVariable int count) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
PageHelper.startPage(1, count, true);

View File

@ -82,7 +82,8 @@ public class XmindCaseParser {
for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
process.append(Translator.get("module_not_null") + "; ");
break;
} else if (nodes[i].trim().length() > 30) {
process.append(nodes[i].trim() + "" + Translator.get("test_track.length_less_than") + "30 ;");
}
}
});
@ -236,6 +237,9 @@ public class XmindCaseParser {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
stringBuilder.append(Translator.get("module_not_null") + "; ");
break;
} else if (nodes[i].trim().length() > 30) {
stringBuilder.append(nodes[i].trim() + "" + Translator.get("test_track.length_less_than") + "30 ;");
break;
}
}
}
@ -275,7 +279,6 @@ public class XmindCaseParser {
} else {
item.setPath(item.getTitle());
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
item.setPath(item.getTitle());
recursion(processBuffer, item, 1, item.getChildren().getAttached());
}
}
@ -285,7 +288,7 @@ public class XmindCaseParser {
} catch (Exception ex) {
processBuffer.append(Translator.get("incorrect_format"));
LogUtil.error(ex.getMessage());
return ex.getMessage();
return "xmind "+Translator.get("incorrect_format");
}
return process.toString();
}

View File

@ -0,0 +1,10 @@
ALTER TABLE notice
ADD user_id VARCHAR(50) NULL;
UPDATE notice
SET notice.user_id = (
SELECT id
FROM user
WHERE notice.NAME = user.name
);
ALTER TABLE notice
DROP COLUMN name;

View File

@ -157,3 +157,4 @@ import_xmind_not_found=Test case not found
license_valid_license_error=Authorization authentication failed
timing_task_result_notification=Timing task result notification
test_review_task_notice=Test review task notice
test_track.length_less_than=The title is too long, the length must be less than

View File

@ -157,5 +157,5 @@ license_valid_license_error=授权认证失败
import_xmind_not_found=未找到测试用例
timing_task_result_notification=定时任务结果通知
test_review_task_notice=测试评审任务通知
test_track.length_less_than=标题过长,字数必须小于

View File

@ -158,3 +158,4 @@ import_xmind_count_error=思維導圖導入用例數量不能超過 500 條
import_xmind_not_found=未找到测试用例
timing_task_result_notification=定時任務結果通知
test_review_task_notice=測試評審任務通知
test_track.length_less_than=標題過長,字數必須小於

View File

@ -2,7 +2,7 @@
<div class="text-container">
<div @click="active" class="collapse">
<i class="icon el-icon-arrow-right" :class="{'is-active': isActive}"/>
{{$t('api_report.response')}}
{{ $t('api_report.response') }}
</div>
<el-collapse-transition>
<el-tabs v-model="activeName" v-show="isActive">
@ -10,7 +10,7 @@
<ms-code-edit :mode="mode" :read-only="true" :data="response.body" :modes="modes" ref="codeEdit"/>
</el-tab-pane>
<el-tab-pane label="Headers" name="headers" class="pane">
<pre>{{response.headers}}</pre>
<pre>{{ response.headers }}</pre>
</el-tab-pane>
<el-tab-pane :label="$t('api_report.assertions')" name="assertions" class="pane assertions">
<ms-assertion-results :assertions="response.assertions"/>
@ -18,7 +18,7 @@
<el-tab-pane v-if="activeName == 'body'" :disabled="true" name="mode" class="pane assertions">
<template v-slot:label>
<ms-dropdown :commands="modes" @command="modeChange"/>
<ms-dropdown :commands="modes" :default-command="mode" @command="modeChange"/>
</template>
</el-tab-pane>
@ -32,73 +32,83 @@
</template>
<script>
import MsAssertionResults from "./AssertionResults";
import MsCodeEdit from "../../../common/components/MsCodeEdit";
import MsDropdown from "../../../common/components/MsDropdown";
import {BODY_FORMAT} from "../../test/model/ScenarioModel";
import MsAssertionResults from "./AssertionResults";
import MsCodeEdit from "../../../common/components/MsCodeEdit";
import MsDropdown from "../../../common/components/MsDropdown";
import {BODY_FORMAT} from "../../test/model/ScenarioModel";
export default {
name: "MsResponseText",
export default {
name: "MsResponseText",
components: {
MsDropdown,
MsCodeEdit,
MsAssertionResults,
components: {
MsDropdown,
MsCodeEdit,
MsAssertionResults,
},
props: {
response: Object
},
data() {
return {
isActive: true,
activeName: "body",
modes: ['text', 'json', 'xml', 'html'],
mode: BODY_FORMAT.TEXT
}
},
methods: {
active() {
this.isActive = !this.isActive;
},
modeChange(mode) {
this.mode = mode;
}
},
props: {
response: Object
},
data() {
return {
isActive: true,
activeName: "body",
modes: ['text', 'json', 'xml', 'html'],
mode: BODY_FORMAT.TEXT
}
},
methods: {
active() {
this.isActive = !this.isActive;
},
modeChange(mode) {
this.mode = mode;
}
},
mounted() {
console.log(this.response.headers);
if (!this.response.headers) {
return;
}
if (this.response.headers.indexOf("Content-Type: application/json") > 0) {
this.mode = BODY_FORMAT.JSON;
}
}
}
</script>
<style scoped>
.text-container .icon {
padding: 5px;
}
.text-container .icon {
padding: 5px;
}
.text-container .collapse {
cursor: pointer;
}
.text-container .collapse {
cursor: pointer;
}
.text-container .collapse:hover {
opacity: 0.8;
}
.text-container .collapse:hover {
opacity: 0.8;
}
.text-container .icon.is-active {
transform: rotate(90deg);
}
.text-container .icon.is-active {
transform: rotate(90deg);
}
.text-container .pane {
background-color: #F5F5F5;
padding: 0 10px;
height: 250px;
overflow-y: auto;
}
.text-container .pane {
background-color: #F5F5F5;
padding: 0 10px;
height: 250px;
overflow-y: auto;
}
.text-container .pane.assertions {
padding: 0;
}
.text-container .pane.assertions {
padding: 0;
}
pre {
margin: 0;
}
pre {
margin: 0;
}
</style>

View File

@ -38,7 +38,15 @@
},
{
title: this.$t('api_test.request.processor.code_template_set_variable'),
value: 'vars.put("variable_name", "variable_value");',
value: 'vars.put("variable_name", "variable_value")',
},
{
title: this.$t('api_test.request.processor.code_template_get_global_variable'),
value: '${__P("variable_name")}',
},
{
title: this.$t('api_test.request.processor.code_template_set_global_variable'),
value: '${__setProperty("variable_name","variable_value",)}',
},
{
title: this.$t('api_test.request.processor.code_template_get_response_header'),

View File

@ -50,14 +50,14 @@
width="240"
>
<template v-slot:default="{row}">
<el-select v-model="row.names" filterable multiple
<el-select v-model="row.userIds" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="userList()" style="width: 100%;">
<el-option
v-for="item in options"
:key="item.id"
:label="item.name"
:value="item.name">
:value="item.id">
</el-option>
</el-select>
</template>
@ -154,13 +154,13 @@ export default {
{
event: "EXECUTE_SUCCESSFUL",
type: "EMAIL",
names: [],
userIds: [],
enable: false
},
{
event: "EXECUTE_FAILED",
type: "EMAIL",
names: [],
userIds: [],
enable: false
}
],
@ -190,8 +190,8 @@ export default {
this.tableData[1].event = "EXECUTE_FAILED"
this.tableData[1].type = "EMAIL"
} else {
this.tableData[0].names = []
this.tableData[1].names = []
this.tableData[0].userIds = []
this.tableData[1].userIds = []
}
})
}

View File

@ -6,7 +6,7 @@
<el-col>
<el-form-item :label="$t('system_config.base.url')" prop="url">
<el-input v-model="formInline.url" :placeholder="$t('system_config.base.url_tip')"/>
<i>(示例:https://rdmetersphere.fit2cloud.com)</i>
<i>({{$t('commons.examples')}}:https://rdmetersphere.fit2cloud.com)</i>
</el-form-item>
</el-col>
</el-row>

View File

@ -1,11 +1,11 @@
<template>
<home-base-component title="我的评审" v-loading>
<home-base-component :title="$t('test_track.review.my_review')" v-loading>
<template slot="header-area">
<div style="float: right">
<ms-table-button :is-tester-permission="true" v-if="!showMyCreator" icon="el-icon-view"
content="我创建的评审" @click="searchMyCreator"/>
:content="$t('test_track.review.my_create')" @click="searchMyCreator"/>
<ms-table-button :is-tester-permission="true" v-if="showMyCreator" icon="el-icon-view"
content="待我评审" @click="searchMyCreator"/>
:content="$t('test_track.review.reviewed_by_me')" @click="searchMyCreator"/>
</div>
</template>
@ -24,13 +24,13 @@
<el-table-column
prop="creator"
fixed
label="创建人"
:label="$t('test_track.review.creator')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="reviewerName"
fixed
label="评审人"
:label="$t('test_track.review.reviewer')"
show-overflow-tooltip>
</el-table-column>
@ -45,7 +45,7 @@
<el-table-column
prop="projectName"
label="已评用例"
:label="$t('test_track.review.done')"
show-overflow-tooltip>
<template v-slot:default="scope">
{{scope.row.reviewed}}/{{scope.row.total}}

View File

@ -0,0 +1,2 @@
import Vue from 'vue';
export const hub = new Vue();

View File

@ -359,6 +359,8 @@ export default {
handleClose() {
removeGoBackListener(this.handleClose);
this.showDialog = false;
this.searchParam.status = null;
this.$emit('update:search-param', this.searchParam);
},
cancel() {
this.handleClose();

View File

@ -196,7 +196,7 @@
<test-plan-test-case-edit
ref="testPlanTestCaseEdit"
:search-param="condition"
:search-param.sync="condition"
@refresh="initTableData"
:is-read-only="isReadOnly"
@refreshTable="search"/>
@ -233,6 +233,7 @@
import ShowMoreBtn from "../../../case/components/ShowMoreBtn";
import BatchEdit from "../../../case/components/BatchEdit";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import {hub} from "@/business/components/track/plan/event-bus";
export default {
name: "TestPlanTestCaseList",
@ -336,9 +337,17 @@
}
},
mounted() {
hub.$on("openFailureTestCase", row => {
this.isReadOnly = true;
this.condition.status = 'Failure';
this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row);
});
this.refreshTableAndPlan();
this.isTestManagerOrTestUser = checkoutTestManagerOrTestUser();
},
beforeDestroy() {
hub.$off("openFailureTestCase");
},
methods: {
initTableData() {
if (this.planId) {

View File

@ -4,6 +4,7 @@
<template>
<el-table
row-key="id"
@row-click="goFailureTestCase"
:data="failureTestCases">
<el-table-column
prop="num"
@ -91,6 +92,7 @@
import TypeTableItem from "../../../../../common/tableItems/planview/TypeTableItem";
import MethodTableItem from "../../../../../common/tableItems/planview/MethodTableItem";
import StatusTableItem from "../../../../../common/tableItems/planview/StatusTableItem";
import {hub} from "@/business/components/track/plan/event-bus";
export default {
name: "FailureResultComponent",
components: {StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem, CommonComponent},
@ -122,6 +124,11 @@
]
}
}
},
methods: {
goFailureTestCase(row) {
hub.$emit("openFailureTestCase", row);
}
}
}
</script>

View File

@ -6,7 +6,7 @@
:show-create="false" :tip="$t('commons.search_by_name_or_id')">
<template v-slot:title>
<node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="refresh"
:title="$t('test_track.review_view.all_review')"/>
:title="$t('test_track.review_view.all_case')"/>
</template>
<template v-slot:button>
<ms-table-button :is-tester-permission="true" icon="el-icon-video-play"

@ -1 +1 @@
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9

View File

@ -1,5 +1,6 @@
export default {
commons: {
examples: 'examples',
help_documentation: 'Help documentation',
delete_cancelled: 'Delete cancelled',
workspace: 'Workspace',
@ -537,11 +538,13 @@ export default {
post_exec_script: "PostProcessor",
code_template: "Code template",
bean_shell_processor_tip: "Currently only BeanShell scripts are supported",
code_template_get_variable: "Get variable",
code_template_set_variable: "Set variable",
code_template_get_response_header: "Get response header",
code_template_get_response_code: "Get response code",
code_template_get_response_result: "Get response result"
code_template_get_variable: "Get Variable",
code_template_set_variable: "Set Variable",
code_template_get_global_variable: "Get Global Variable",
code_template_set_global_variable: "Set Global variable",
code_template_get_response_header: "Get Response Header",
code_template_get_response_code: "Get Response Code",
code_template_get_response_result: "Get Response Result"
},
dubbo: {
protocol: "protocol",
@ -758,6 +761,11 @@ export default {
pass: "pass",
un_pass: "UnPass",
comment: "Comment",
my_review: "My Review",
my_create: "My Create",
reviewed_by_me: "Review By Me",
creator: "Creator",
done: "Commented use cases"
},
comment: {
no_comment: "No Comment",
@ -768,7 +776,7 @@ export default {
},
review_view: {
review: "Review",
all_review: "All Review",
all_case: "All case",
start_review: "Start Review",
relevance_case: "Relevance Case",
execute_result: "Result",

View File

@ -1,5 +1,6 @@
export default {
commons: {
examples: '示例',
help_documentation: '帮助文档',
delete_cancelled: '已取消删除',
workspace: '工作空间',
@ -540,6 +541,8 @@ export default {
bean_shell_processor_tip: "仅支持 BeanShell 脚本",
code_template_get_variable: "获取变量",
code_template_set_variable: "设置变量",
code_template_get_global_variable: "获取全局变量",
code_template_set_global_variable: "设置全局变量",
code_template_get_response_header: "获取响应头",
code_template_get_response_code: "获取响应码",
code_template_get_response_result: "获取响应结果"
@ -764,6 +767,11 @@ export default {
pass: "通过",
un_pass: "未通过",
comment: "评论",
my_review: "我的评审",
my_create: "我创建的评审",
reviewed_by_me: "待我评审",
creator: "创建人",
done: "已评用例"
},
comment: {
no_comment: "暂无评论",
@ -774,7 +782,7 @@ export default {
},
review_view: {
review: "评审",
all_review: "全部评审",
all_case: "全部用例",
start_review: "开始评审",
relevance_case: "关联用例",
execute_result: "执行结果",

View File

@ -1,5 +1,6 @@
export default {
commons: {
examples: '示例',
help_documentation: '幫助文檔',
delete_cancelled: '已取消刪除',
workspace: '工作空間',
@ -540,6 +541,8 @@ export default {
bean_shell_processor_tip: "僅支持 BeanShell 腳本",
code_template_get_variable: "獲取變量",
code_template_set_variable: "設置變量",
code_template_get_global_variable: "獲取全局變量",
code_template_set_global_variable: "設置全局變量",
code_template_get_response_header: "獲取響應頭",
code_template_get_response_code: "獲取響應碼",
code_template_get_response_result: "獲取響應結果"
@ -760,6 +763,11 @@ export default {
pass: "通過",
un_pass: "未通過",
comment: "評論",
my_review: "我的評審",
my_create: "我創建的評審",
reviewed_by_me: "待我評審",
creator: "創建人",
done: "已評用例"
},
comment: {
no_comment: "暫無評論",
@ -770,7 +778,7 @@ export default {
},
review_view: {
review: "評審",
all_review: "全部評審",
all_case: "全部用例",
start_review: "開始評審",
relevance_case: "關聯用例",
execute_result: "執行結果",