fix(测试跟踪): 只有测试计划执行的权限,执行关联接口的功能用例会权限错误

--bug=1032874 --user=陈建星 有测试计划执行的权限,无法执行功能用例 https://www.tapd.cn/55049933/s/1436100
This commit is contained in:
AgAngle 2023-11-15 11:20:08 +08:00 committed by jianxing
parent f912c5c0b8
commit 3cb5202f98
2 changed files with 50 additions and 26 deletions

View File

@ -327,26 +327,38 @@ public class TestPlanTestCaseService {
switch (type) { switch (type) {
case "performance": case "performance":
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) { if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
try {
LoadTest loadTest = planPerformanceTestService.get(id); LoadTest loadTest = planPerformanceTestService.get(id);
if (loadTest != null) { if (loadTest != null) {
dto.setTestName(loadTest.getName()); dto.setTestName(loadTest.getName());
} }
} catch (Exception e) {
LogUtil.error(e);
}
} }
break; break;
case "testcase": case "testcase":
if (serviceIdSet.contains(MicroServiceName.API_TEST)) { if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
try {
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = planApiTestCaseService.get(id); ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = planApiTestCaseService.get(id);
if (apiTestCaseWithBLOBs != null) { if (apiTestCaseWithBLOBs != null) {
dto.setTestName(apiTestCaseWithBLOBs.getName()); dto.setTestName(apiTestCaseWithBLOBs.getName());
} }
} catch (Exception e) {
LogUtil.error(e);
}
} }
break; break;
case "automation": case "automation":
if (serviceIdSet.contains(MicroServiceName.API_TEST)) { if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
try {
ApiScenarioWithBLOBs apiScenarioWithBLOBs = panApiAutomationService.get(id); ApiScenarioWithBLOBs apiScenarioWithBLOBs = panApiAutomationService.get(id);
if (apiScenarioWithBLOBs != null) { if (apiScenarioWithBLOBs != null) {
dto.setTestName(apiScenarioWithBLOBs.getName()); dto.setTestName(apiScenarioWithBLOBs.getName());
} }
} catch (Exception e) {
LogUtil.error(e);
}
} }
break; break;
default: default:

View File

@ -2846,6 +2846,7 @@ public class TestCaseService {
List<UiScenario> uiScenarios = new ArrayList<>(); List<UiScenario> uiScenarios = new ArrayList<>();
if (serviceIdSet.contains(MicroServiceName.API_TEST)) { if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
try {
apiCases = relevanceApiCaseService.getApiCaseByIds( apiCases = relevanceApiCaseService.getApiCaseByIds(
getTestIds(testCaseTests, TestCaseTestType.testcase.name())); getTestIds(testCaseTests, TestCaseTestType.testcase.name()));
apiScenarios = relevanceApiCaseService.getScenarioCaseByIds( apiScenarios = relevanceApiCaseService.getScenarioCaseByIds(
@ -2855,20 +2856,31 @@ public class TestCaseService {
projectIds.addAll(scenarioProjectIds); projectIds.addAll(scenarioProjectIds);
versionIds.addAll(apiCases.stream().map(s -> s.getVersionId()).collect(Collectors.toList())); versionIds.addAll(apiCases.stream().map(s -> s.getVersionId()).collect(Collectors.toList()));
versionIds.addAll(apiScenarios.stream().map(s -> s.getVersionId()).collect(Collectors.toList())); versionIds.addAll(apiScenarios.stream().map(s -> s.getVersionId()).collect(Collectors.toList()));
} catch (Exception e) {
LogUtil.error(e);
}
} }
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) { if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
try {
apiLoadTests = relevanceLoadCaseService.getLoadCaseByIds( apiLoadTests = relevanceLoadCaseService.getLoadCaseByIds(
getTestIds(testCaseTests, TestCaseTestType.performance.name())); getTestIds(testCaseTests, TestCaseTestType.performance.name()));
projectIds.addAll(apiLoadTests.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); projectIds.addAll(apiLoadTests.stream().map(s -> s.getProjectId()).collect(Collectors.toList()));
versionIds.addAll(apiLoadTests.stream().map(l -> l.getVersionId()).collect(Collectors.toList())); versionIds.addAll(apiLoadTests.stream().map(l -> l.getVersionId()).collect(Collectors.toList()));
} catch (Exception e) {
LogUtil.error(e);
}
} }
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) { if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
try {
uiScenarios = relevanceUiCaseService.getUiCaseByIds( uiScenarios = relevanceUiCaseService.getUiCaseByIds(
getTestIds(testCaseTests, TestCaseTestType.uiAutomation.name())); getTestIds(testCaseTests, TestCaseTestType.uiAutomation.name()));
projectIds.addAll(uiScenarios.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); projectIds.addAll(uiScenarios.stream().map(s -> s.getProjectId()).collect(Collectors.toList()));
versionIds.addAll(uiScenarios.stream().map(l -> l.getVersionId()).collect(Collectors.toList())); versionIds.addAll(uiScenarios.stream().map(l -> l.getVersionId()).collect(Collectors.toList()));
} catch (Exception e) {
LogUtil.error(e);
}
} }