fix(接口自动化): #1007053 【github#6680】环境里上传了证书,测试用例、场景用例转换成性能测试任务的时候,证书没带过去

--bug=1007053 --user=宋天阳
【github#6680】环境里上传了证书,测试用例、场景用例转换成性能测试任务的时候,证书没带过去
https://www.tapd.cn/55049933/s/1054099
This commit is contained in:
song-tianyang 2021-10-09 16:09:11 +08:00 committed by song-tianyang
parent 5bda6d22b3
commit 8bb7873fc1
2 changed files with 27 additions and 3 deletions

View File

@ -520,6 +520,9 @@ public class APITestService {
//HTTPSamplerProxy 进行附件转化 1.elementProp里去掉路径 2elementProp->filePath获取路径并读出来
attachmentFilePathList.addAll(this.parseAttachmentFileInfo(element));
}
//如果存在证书文件也要匹配出来
attachmentFilePathList.addAll(this.parseAttachmentFileInfo(innerHashTreeElement));
}
jmxString = root.asXML();
} catch (Exception e) {
@ -585,20 +588,40 @@ public class APITestService {
try {
String filePath = elementProp.attributeValue("name");
File file = new File(filePath);
if(file.exists() && file.isFile()){
if (file.exists() && file.isFile()) {
attachmentFilePathList.add(filePath);
String fileName = file.getName();
elementProp.attribute("name").setText(fileName);
}
}catch (Exception e){
} catch (Exception e) {
}
}
}
}
}
}
}else if (StringUtils.equals(qname, "KeystoreConfig")) {
List<Element> stringPropList = parentElement.elements("stringProp");
for (Element element : stringPropList) {
if (StringUtils.equals(element.attributeValue("name"), "MS-KEYSTORE-FILE-PATH")) {
try {
String filePath = element.getStringValue();
File file = new File(filePath);
if(file.exists() && file.isFile()){
attachmentFilePathList.add(filePath);
String fileName = file.getName();
element.setText(fileName);
}
}catch (Exception e){
}
}
}
} else if (StringUtils.equals(qname, "hashTree")) {
attachmentFilePathList.addAll(this.parseAttachmentFileInfo(parentElement));
}
}
return attachmentFilePathList;
}

View File

@ -3,7 +3,8 @@ package io.metersphere.commons.constants;
public enum FileType {
JMX(".jmx"), CSV(".csv"), JSON(".json"), PDF(".pdf"),
JPG(".jpg"), PNG(".png"), JPEG(".jpeg"), DOC(".doc"),
XLSX(".xlsx"), DOCX(".docx"), JAR(".jar"), JS(".js"), TXT(".txt");
XLSX(".xlsx"), DOCX(".docx"), JAR(".jar"), JS(".js"), TXT(".txt"),
P12("p12"),JKS("jks"),PFX("pfx");
// 保存后缀
private String suffix;