Skip to content

Commit

Permalink
Merge pull request #270 from SonicCloudOrg/dev/2.0.0-rc
Browse files Browse the repository at this point in the history
feat: rc
  • Loading branch information
ZhouYixun authored Oct 28, 2022
2 parents 82acf45 + c4818c4 commit f323ee3
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ LDAP_BASE_DN=ou=users
LDAP_BASE=ou=system
LDAP_USERNAME=uid=admin,ou=system
LDAP_PASSWORD=sonic
LDAP_URL=ldap://192.168.1.1:10389
LDAP_URL=ldap://192.168.1.1:10389
LDAP_OBJECT_CLASS=person
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ services:
- LDAP_USERNAME
- LDAP_PASSWORD
- LDAP_URL
- LDAP_OBJECT_CLASS
networks:
- sonic-network
volumes:
Expand Down
1 change: 1 addition & 0 deletions docker-compose2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ services:
- LDAP_USERNAME
- LDAP_PASSWORD
- LDAP_URL
- LDAP_OBJECT_CLASS
networks:
- sonic-network
volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sonic:
enable: ${LDAP_USER_ENABLE:true}
userId: ${LDAP_USER_ID:cn}
userBaseDN: ${LDAP_BASE_DN:ou=users}
objectClass: ${LDAP_OBJECT_CLASS:person}
permission:
enable: ${PERMISSION_ENABLE:true}
superAdmin: ${PERMISSION_SUPER_ADMIN:sonic}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public CommentPage<ElementsDTO> findAll(int projectId, String type, List<String>
case "normal" -> lambdaQuery.and(
l -> l.ne(Elements::getEleType, "point").ne(Elements::getEleType, "image").ne(Elements::getEleType, "poco")
);
case "poco" -> lambdaQuery.eq(Elements::getEleType, "poco");
case "poco" -> lambdaQuery.eq(Elements::getEleType, "poco").or().eq(Elements::getEleType, "xpath").or().eq(Elements::getEleType, "cssSelector");
case "point" -> lambdaQuery.eq(Elements::getEleType, "point");
case "image" -> lambdaQuery.eq(Elements::getEleType, "image");
}
Expand All @@ -83,7 +83,7 @@ public CommentPage<ElementsDTO> findAll(int projectId, String type, List<String>
//写入对应模块信息
Page<Elements> page = lambdaQuery.page(pageable);
List<ElementsDTO> elementsDTOS = page.getRecords()
.stream().map(e->findEleDetail(e)).collect(Collectors.toList());
.stream().map(e -> findEleDetail(e)).collect(Collectors.toList());

return CommentPage.convertFrom(page, elementsDTOS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ public void copyPublicSetpsIds(int id) {

//统计需要和公共步骤关联的步骤,
int n = 1; // n 用来保持搜索map时候 caseId 和 key中setCaseId一致
LambdaQueryWrapper<Steps> lqw = new LambdaQueryWrapper<>();

List<Steps> stepsList = stepsMapper.selectList(lqw.orderByDesc(Steps::getSort));
List<Integer> publicStepsStpesId = new ArrayList<>();
List<Integer> publicStepsStepsId = new ArrayList<>();

for (StepsDTO steps : needAllCopySteps) {
Steps step = steps.convertTo();
Expand All @@ -214,7 +212,7 @@ public void copyPublicSetpsIds(int id) {
idIndex = stepsIdDTO.getIndex();
}
}
step.setId(null).setParentId(fatherIdIndex).setCaseId(0).setSort(stepsList.get(0).getSort() + n);
step.setId(null).setParentId(fatherIdIndex).setCaseId(0).setSort(stepsMapper.findMaxSort() + n);
stepsMapper.insert(step.setCaseId(0));
//修改父步骤Id
step.setParentId(step.getId() - (fatherIdIndex - idIndex));
Expand All @@ -227,18 +225,18 @@ public void copyPublicSetpsIds(int id) {
continue;
}

step.setId(null).setCaseId(0).setSort(stepsList.get(0).getSort() + n);
step.setId(null).setCaseId(0).setSort(stepsMapper.findMaxSort() + n);
stepsMapper.insert(step);
//关联steps和elId
if (steps.getElements() != null) {
elementsService.newStepBeLinkedEle(steps,step);
}
//插入的stepId 记录到需要关联步骤的list种
publicStepsStpesId.add(step.getId());
publicStepsStepsId.add(step.getId());
n++;
}
//查询新增step的步骤list 来遍历id 此时不包括子步骤
for (Integer stepsId : publicStepsStpesId) {
for (Integer stepsId : publicStepsStepsId) {
// 保存 public_step 与 最外层step 映射关系
publicStepsStepsMapper.insert(
new PublicStepsSteps()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ public Boolean copyStepsIdByCase(Integer stepId) {
Steps steps = stepsMapper.selectById(stepId);
StepsDTO stepsCopyDTO = stepsService.handleStep(steps.convertTo());

LambdaQueryWrapper<Steps> sort = new LambdaQueryWrapper<>();
List<Steps> stepsList = stepsMapper.selectList(sort.orderByDesc(Steps::getSort));
save(steps.setId(null).setSort(stepsList.size()+1));
save(steps.setId(null).setSort(stepsMapper.findMaxSort() + 1));
//关联ele
if (stepsCopyDTO.getElements() != null) {
elementsService.newStepBeLinkedEle(stepsCopyDTO,steps);
Expand All @@ -317,9 +315,6 @@ public Boolean copyStepsIdByCase(Integer stepId) {
List<PublicStepsAndStepsIdDTO> oldStepDto = stepAndIndex(needAllCopySteps);
//统计需要和公共步骤关联的步骤,
int n = 1;
LambdaQueryWrapper<Steps> lqw = new LambdaQueryWrapper<>();

List<Steps> stepsList1 = stepsMapper.selectList(lqw.orderByDesc(Steps::getSort));

for (StepsDTO steps1 : needAllCopySteps) {
Steps step = steps1.convertTo();
Expand All @@ -337,7 +332,8 @@ public Boolean copyStepsIdByCase(Integer stepId) {
idIndex = stepsIdDTO.getIndex();
}
}
step.setId(null).setParentId(fatherIdIndex).setSort(stepsList1.size() + n);

step.setId(null).setParentId(fatherIdIndex).setSort(stepsMapper.findMaxSort() + n);

stepsMapper.insert(step);

Expand All @@ -352,7 +348,7 @@ public Boolean copyStepsIdByCase(Integer stepId) {
continue;
}

step.setId(null).setSort(stepsList.size() + n);
step.setId(null).setSort(stepsMapper.findMaxSort() + n);
stepsMapper.insert(step);
//关联steps和elId
if (steps1.getElements() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ public boolean copyTestById(int oldId) {
List<PublicStepsAndStepsIdDTO> needCopySteps = stepsService.stepAndIndex(stepsCopyDTOS);

//插入新的步骤
LambdaQueryWrapper<Steps> sort = new LambdaQueryWrapper<>();
List<Steps> stepsList = stepsMapper.selectList(sort.orderByDesc(Steps::getSort));
int n = 1;
for (StepsDTO steps : stepsCopyDTOS) {
Steps step = steps.convertTo();
Expand All @@ -243,7 +241,7 @@ public boolean copyTestById(int oldId) {
idIndex = stepsIdDTO.getIndex();
}
}
step.setId(null).setParentId(fatherIdIndex).setCaseId(oldTestCases.getId()).setSort(stepsList.size() + n);
step.setId(null).setParentId(fatherIdIndex).setCaseId(oldTestCases.getId()).setSort(stepsMapper.findMaxSort() + n);
stepsMapper.insert(step.setCaseId(oldTestCases.getId()));
//修改父步骤Id
step.setParentId(step.getId() - (fatherIdIndex - idIndex));
Expand All @@ -255,7 +253,7 @@ public boolean copyTestById(int oldId) {
}
continue;
}
step.setId(null).setCaseId(oldTestCases.getId()).setSort(stepsList.size() + n);
step.setId(null).setCaseId(oldTestCases.getId()).setSort(stepsMapper.findMaxSort() + n);
stepsMapper.insert(step);
//关联steps和elId
if (steps.getElements() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public class UsersServiceImpl extends SonicServiceImpl<UsersMapper, Users> imple
@Value("${sonic.user.ldap.userBaseDN}")
private String userBaseDN;

@Value("${sonic.user.ldap.objectClass}")
private String objectClass;

@Autowired
@Lazy
private LdapTemplate ldapTemplate;
Expand Down Expand Up @@ -143,10 +146,10 @@ private boolean checkLdapAuthenticate(UserInfo userInfo, boolean create) {
String password = userInfo.getPassword();
logger.info("login check content username {}", username);
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter(userId, username));
filter.and(new EqualsFilter("objectclass", objectClass)).and(new EqualsFilter(userId, username));
try {
boolean authResult = ldapTemplate.authenticate(userBaseDN, filter.toString(), password);
if (create) {
if (create && authResult) {
save(buildUser(userInfo));
}
return authResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void sendDayReportMessage(String token, String secret, int projectId, Str
"> ###### 异常数:" + warnColorString + " \n" +
"> ###### 失败数:" + failColorString + " \n" +
"> ###### 测试通过率:" + (total > 0 ?
new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() * 100 : 0) + "% \n" +
new BigDecimal(((float) passCount / total) * 100).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" +
"> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")");
markdown.put("title", "Sonic云真机测试平台日报");
jsonObject.put("msgtype", "markdown");
Expand Down Expand Up @@ -296,7 +296,7 @@ public void sendDayReportMessage(String token, String secret, int projectId, Str
"> ###### 异常数:" + warnColorString + " \n" +
"> ###### 失败数:" + failColorString + " \n" +
"> ###### 测试通过率:" + (total > 0 ?
new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() * 100 : 0) + "% \n" +
new BigDecimal(((float) passCount / total) * 100).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" +
"> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")");
jsonObject.put("markdown", markdown);
}
Expand All @@ -317,7 +317,7 @@ public void sendDayReportMessage(String token, String secret, int projectId, Str
"异常数:" + warnCount + " \n" +
"失败数:" + failCount + " \n" +
"测试通过率:" + (total > 0 ?
new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() * 100 : 0) + "% \n" +
new BigDecimal(((float) passCount / total) * 100).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" +
"详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")");
elementList.add(element);
card.put("elements", elementList);
Expand Down Expand Up @@ -413,7 +413,7 @@ public void sendWeekReportMessage(String token, String secret, int projectId, St
"> ###### 异常数:" + warnColorString + " \n" +
"> ###### 失败数:" + failColorString + " \n" +
"> ###### 测试通过率:" + (total > 0 ?
new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() * 100 : 0) + "% \n" +
new BigDecimal(((float) passCount / total) * 100).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" +
"> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")");
markdown.put("title", "Sonic云真机测试平台周报");
jsonObject.put("msgtype", "markdown");
Expand Down Expand Up @@ -443,7 +443,7 @@ public void sendWeekReportMessage(String token, String secret, int projectId, St
"> ###### 异常数:" + warnColorString + " \n" +
"> ###### 失败数:" + failColorString + " \n" +
"> ###### 测试通过率:" + (total > 0 ?
new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() * 100 : 0) + "% \n" +
new BigDecimal(((float) passCount / total) * 100).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" +
"> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")");
jsonObject.put("markdown", markdown);
}
Expand All @@ -466,7 +466,7 @@ public void sendWeekReportMessage(String token, String secret, int projectId, St
"异常数:" + warnCount + " \n" +
"失败数:" + failCount + " \n" +
"测试通过率:" + (total > 0 ?
new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() * 100 : 0) + "% \n" +
new BigDecimal(((float) passCount / total) * 100).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" +
"详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")");
elementList.add(element);
card.put("elements", elementList);
Expand Down

0 comments on commit f323ee3

Please sign in to comment.