|
4 | 4 | import com.checkmarx.ast.results.ReportFormat; |
5 | 5 | import com.checkmarx.ast.results.Results; |
6 | 6 | import com.checkmarx.ast.results.ResultsSummary; |
| 7 | +import com.checkmarx.ast.results.result.Data; |
| 8 | +import com.checkmarx.ast.results.result.Node; |
| 9 | +import com.checkmarx.ast.results.result.Result; |
7 | 10 | import com.checkmarx.ast.scan.Scan; |
| 11 | +import com.checkmarx.ast.wrapper.CxConstants; |
8 | 12 | import org.junit.jupiter.api.Assertions; |
9 | 13 | import org.junit.jupiter.api.Test; |
10 | 14 |
|
| 15 | +import java.util.ArrayList; |
11 | 16 | import java.util.List; |
12 | 17 | import java.util.UUID; |
13 | 18 |
|
14 | 19 | class ResultTest extends BaseTest { |
15 | 20 | private static String CWE_ID = "79"; |
16 | 21 | private static String LANGUAGE = "PHP"; |
17 | 22 | private static String QUERY_NAME = "Reflected XSS All Clients"; |
| 23 | + |
18 | 24 | @Test |
19 | 25 | void testResultsHTML() throws Exception { |
20 | 26 | List<Scan> scanList = wrapper.scanList(); |
@@ -54,9 +60,31 @@ void testResultsStructure() throws Exception { |
54 | 60 |
|
55 | 61 | @Test() |
56 | 62 | void testResultsCodeBashing() throws Exception { |
57 | | - List<CodeBashing> codeBashingList = wrapper.codeBashingList(CWE_ID,LANGUAGE,QUERY_NAME); |
| 63 | + List<CodeBashing> codeBashingList = wrapper.codeBashingList(CWE_ID, LANGUAGE, QUERY_NAME); |
58 | 64 | Assertions.assertTrue(codeBashingList.size() > 0); |
59 | 65 | String path = codeBashingList.get(0).getPath(); |
60 | 66 | Assertions.assertTrue(path.length() > 0); |
61 | 67 | } |
| 68 | + |
| 69 | + @Test |
| 70 | + void testResultsBflJSON() throws Exception { |
| 71 | + |
| 72 | + UUID scanId = UUID.fromString(CX_SCAN_ID); |
| 73 | + Results results = wrapper.results(scanId); |
| 74 | + Result result = results.getResults().stream().filter(res -> res.getType().equalsIgnoreCase(CxConstants.SAST)).findFirst().get(); |
| 75 | + Data data = result.getData(); |
| 76 | + String queryId = data.getQueryId(); |
| 77 | + int bflNodeIndex = wrapper.getResultsBfl(scanId, queryId, data.getNodes()); |
| 78 | + Assertions.assertTrue(bflNodeIndex == -1 || bflNodeIndex >= 0); |
| 79 | + |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + void testResultsBflWithInvalidQueryId() throws Exception { |
| 84 | + |
| 85 | + UUID scanId = UUID.fromString(CX_SCAN_ID); |
| 86 | + String queryId = "0000"; |
| 87 | + int bflNodeIndex = wrapper.getResultsBfl(scanId, queryId, new ArrayList<Node>()); |
| 88 | + Assertions.assertEquals(-1, bflNodeIndex); |
| 89 | + } |
62 | 90 | } |
0 commit comments