|
|
@@ -25,6 +25,7 @@ import com.nju.edu.gitlab.vo.ProjectVO;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.NoArgsConstructor;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
@@ -36,6 +37,7 @@ import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
|
+@Slf4j
|
|
|
public class AuthTools {
|
|
|
private final APITestMapper apiTestMapper;
|
|
|
private final FuncTestCaseMapper funcTestCaseMapper;
|
|
|
@@ -68,6 +70,7 @@ public class AuthTools {
|
|
|
|
|
|
public boolean checkProjOwnershipParam(HttpServletRequest request) {
|
|
|
String projectIdStr = request.getParameter("projectId");
|
|
|
+ log.info("checkProjOwnershipParam verifying projectId: " + projectIdStr);
|
|
|
if (!StringUtils.isNumeric(projectIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -78,12 +81,15 @@ public class AuthTools {
|
|
|
public boolean checkProjOwnership (Integer projectId) {
|
|
|
UserPO userPO = getCurrentUser();
|
|
|
SeecoderGitlabApi seecoderGitlabApi = SpringUtil.getBean(SeecoderGitlabApi.class);
|
|
|
+ log.info("checkProjOwnership verifying projectId: " + projectId);
|
|
|
try {
|
|
|
List<ProjectVO> projects = seecoderGitlabApi.getAllProjectsByUserId(userPO.getId());
|
|
|
if (projects.stream().noneMatch(project -> project.getProjectId().equals(projectId))){
|
|
|
+ log.error("checkProjOwnership projectId none match " + projectId);
|
|
|
return false;
|
|
|
}
|
|
|
} catch (SeecoderGitlabException e) {
|
|
|
+ log.error("checkProjOwnership " + e.getMessage());
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return true;
|
|
|
@@ -91,6 +97,7 @@ public class AuthTools {
|
|
|
|
|
|
public boolean checkTestOwnershipParam(HttpServletRequest request) {
|
|
|
String testIdStr = request.getParameter("testId");
|
|
|
+ log.info("checkTestOwnershipParam verifying testId: " + testIdStr);
|
|
|
if (!StringUtils.isNumeric(testIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -99,6 +106,7 @@ public class AuthTools {
|
|
|
}
|
|
|
|
|
|
public boolean checkTestOwnership (Integer testId) {
|
|
|
+ log.info("checkTestOwnership verifying testId: " + testId);
|
|
|
TestInfo testInfo = apiTestMapper.selectByTestId(testId);
|
|
|
if (testInfo == null) {
|
|
|
return false;
|
|
|
@@ -109,6 +117,7 @@ public class AuthTools {
|
|
|
|
|
|
public boolean checkTestCaseOwnershipParam(HttpServletRequest request) {
|
|
|
String testCaseIdStr = request.getParameter("testCaseId");
|
|
|
+ log.info("checkTestCaseOwnershipParam verifying testCaseId: " + testCaseIdStr);
|
|
|
if (!StringUtils.isNumeric(testCaseIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -117,6 +126,7 @@ public class AuthTools {
|
|
|
}
|
|
|
|
|
|
public boolean checkTestCaseOwnership (Integer testCaseId) {
|
|
|
+ log.info("checkTestCaseOwnership verifying testCaseId: " + testCaseId);
|
|
|
FuncTestCasePO funcTestCasePO = funcTestCaseMapper.selectById(testCaseId);
|
|
|
Integer projectId = funcTestCasePO.getProjectId();
|
|
|
return checkProjOwnership(projectId);
|
|
|
@@ -124,6 +134,7 @@ public class AuthTools {
|
|
|
|
|
|
public boolean checkTestStepOwnershipParam (HttpServletRequest request) {
|
|
|
String testStepIdStr = request.getParameter("testStepId");
|
|
|
+ log.info("checkTestStepOwnershipParam verifying testStepId: " + testStepIdStr);
|
|
|
if (!StringUtils.isNumeric(testStepIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -132,6 +143,7 @@ public class AuthTools {
|
|
|
}
|
|
|
|
|
|
public boolean checkTestStepOwnership (Integer testStepId) {
|
|
|
+ log.info("checkTestStepOwnership verifying testStepId: " + testStepId);
|
|
|
List<FuncTestStepPO> funcTestStepPOS = funcTestStepMapper.selectByTestCaseId(testStepId);
|
|
|
if (funcTestStepPOS == null) {
|
|
|
return false;
|
|
|
@@ -144,11 +156,13 @@ public class AuthTools {
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
|
|
|
TreeNodeUpdateBasicVO treeNodeUpdateBasicVO = mapper.readValue(requestBody, TreeNodeUpdateBasicVO.class);
|
|
|
+ log.info("checkTreeNodeOwnershipBody verifying treeNodeId: " + treeNodeUpdateBasicVO.getId());
|
|
|
return checkTreeNodeOwnership(treeNodeUpdateBasicVO.getId());
|
|
|
}
|
|
|
|
|
|
public boolean checkTreeNodeOwnershipParam (HttpServletRequest request) {
|
|
|
String treeNodeIdStr = request.getParameter("treeId");
|
|
|
+ log.info("checkTreeNodeOwnershipParam verifying treeNodeId: " + treeNodeIdStr);
|
|
|
if (!StringUtils.isNumeric(treeNodeIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -157,6 +171,7 @@ public class AuthTools {
|
|
|
}
|
|
|
|
|
|
public boolean checkTreeNodeOwnership (Integer treeNodeId) {
|
|
|
+ log.info("checkTreeNodeOwnership verifying treeNodeId: " + treeNodeId);
|
|
|
TreeNodePO treeNodeById = treeNodeMapper.getTreeNodeById(treeNodeId);
|
|
|
if (treeNodeById == null) {
|
|
|
return false;
|
|
|
@@ -167,6 +182,7 @@ public class AuthTools {
|
|
|
|
|
|
public boolean checkBugOwnershipParam (HttpServletRequest request) {
|
|
|
String bugIdStr = request.getParameter("bugId");
|
|
|
+ log.info("checkBugOwnershipParam verifying bugId: " + bugIdStr);
|
|
|
if (!StringUtils.isNumeric(bugIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -176,6 +192,7 @@ public class AuthTools {
|
|
|
|
|
|
public boolean checkBugOwnership (Integer bugId) {
|
|
|
BugListPO bugListPO = bugListMapper.selectById(bugId);
|
|
|
+ log.info("checkBugOwnership verifying bugId: " + bugId);
|
|
|
if (bugListPO == null) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -187,12 +204,14 @@ public class AuthTools {
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
String requestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
|
|
|
PipelineUpdateConfigVO pipelineUpdateConfigVO = mapper.readValue(requestBody, PipelineUpdateConfigVO.class);
|
|
|
+ log.info("checkProjPipelineBody verifying projectId: " + pipelineUpdateConfigVO.getProjectId() + " pipelineId: " + pipelineUpdateConfigVO.getPipelineId());
|
|
|
return checkProjPipeline(pipelineUpdateConfigVO.getProjectId(), pipelineUpdateConfigVO.getPipelineId());
|
|
|
}
|
|
|
|
|
|
public boolean checkProjPipelineParam (HttpServletRequest request) {
|
|
|
String projectIdStr = request.getParameter("projectId");
|
|
|
String pipelineIdStr = request.getParameter("pipelineId");
|
|
|
+ log.info("checkProjPipelineParam verifying projectId: " + projectIdStr + " pipelineId: " + pipelineIdStr);
|
|
|
if (!StringUtils.isNumeric(projectIdStr) || !StringUtils.isNumeric(pipelineIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -202,6 +221,7 @@ public class AuthTools {
|
|
|
}
|
|
|
|
|
|
public boolean checkProjPipeline (Integer projectId, Integer pipelineId) {
|
|
|
+ log.info("checkProjPipeline verifying projectId: " + projectId + " pipelineId: " + pipelineId);
|
|
|
// check if pipelineId owned by projectId
|
|
|
PipelinePO pipelinePO = pipelineMapper.selectById(pipelineId);
|
|
|
Integer projectId1 = pipelinePO.getProjectId();
|
|
|
@@ -213,6 +233,7 @@ public class AuthTools {
|
|
|
}
|
|
|
|
|
|
public boolean checkPipelineOwnership (Integer pipelineId) {
|
|
|
+ log.info("checkPipelineOwnership verifying pipelineId: " + pipelineId);
|
|
|
PipelinePO pipelinePO = pipelineMapper.selectById(pipelineId);
|
|
|
if (pipelinePO == null) {
|
|
|
return false;
|
|
|
@@ -223,6 +244,7 @@ public class AuthTools {
|
|
|
|
|
|
public boolean checkPipelineRecordOwnershipParam (HttpServletRequest request) {
|
|
|
String pipelineRecordIdStr = request.getParameter("recordId");
|
|
|
+ log.info("checkPipelineRecordOwnershipParam verifying pipelineRecordId: " + pipelineRecordIdStr);
|
|
|
if (!StringUtils.isNumeric(pipelineRecordIdStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -231,6 +253,7 @@ public class AuthTools {
|
|
|
}
|
|
|
|
|
|
public boolean checkPipelineRecordOwnership (Integer pipelineRecordId) {
|
|
|
+ log.info("checkPipelineRecordOwnershipParam verifying pipelineRecordId: " + pipelineRecordId);
|
|
|
PipelineRecordPO pipelineRecordPO = pipelineRecordMapper.selectById(pipelineRecordId);
|
|
|
if (pipelineRecordPO == null) {
|
|
|
return false;
|