use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class ScanReportRestControllerMockTest method get_html_report_with_cwe_id.
@Test
@WithMockUser
public void get_html_report_with_cwe_id() throws Exception {
/* prepare */
Integer cweId = Integer.valueOf(77);
SecHubFinding finding = new SecHubFinding();
finding.setCweId(cweId);
Map<String, Object> map = new HashMap<>();
map.put("jobuuid", randomUUID);
map.put("styleRed", "theRedStyle");
map.put("styleGreen", "display:none");
map.put("styleYellow", "display:none");
map.put("redList", Arrays.asList(finding));
map.put("yellowList", new ArrayList<>());
map.put("greenList", new ArrayList<>());
map.put("isWebDesignMode", false);
map.put("codeScanSupport", new HtmlCodeScanDescriptionSupport());
map.put("codeScanEntries", new ArrayList<>());
when(modelBuilder.build(any())).thenReturn(map);
/* execute + test @formatter:off */
this.mockMvc.perform(get(https(PORT_USED).buildGetJobReportUrl(PROJECT1_ID, randomUUID)).accept(MediaType.TEXT_HTML).contentType(MediaType.APPLICATION_JSON_VALUE)).andDo(print()).andExpect(status().isOk()).andExpect(content().contentType("text/html;charset=UTF-8")).andExpect(content().encoding("UTF-8")).andExpect(content().string(containsString(randomUUID.toString()))).andExpect(content().string(containsString("CWE-" + cweId.toString()))).andExpect(content().string(containsString("href=\"https://cwe.mitre.org/data/definitions/" + cweId.toString() + ".html\"")));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class HtmlCodeScanDescriptionSupportTest method build_entries__creates_html_scan_entries_with_correct_callnumbers.
@Test
void build_entries__creates_html_scan_entries_with_correct_callnumbers() {
/* prepare */
SecHubFinding finding = new SecHubFinding();
SecHubCodeCallStack code1 = new SecHubCodeCallStack();
SecHubCodeCallStack code2 = new SecHubCodeCallStack();
SecHubCodeCallStack code3 = new SecHubCodeCallStack();
SecHubCodeCallStack code4 = new SecHubCodeCallStack();
finding.setCode(code1);
code1.setCalls(code2);
code2.setCalls(code3);
code3.setCalls(code4);
/* execute */
List<HTMLScanResultCodeScanEntry> fourElementsResult = descriptionSupport.buildEntries(finding);
/* test */
assertEquals(4, fourElementsResult.size());
assertEquals(1, fourElementsResult.get(0).getCallNumber());
assertEquals(2, fourElementsResult.get(1).getCallNumber());
assertEquals(3, fourElementsResult.get(2).getCallNumber());
assertEquals(4, fourElementsResult.get(3).getCallNumber());
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class HtmlCodeScanDescriptionSupportTest method build_entries__creates_html_scan_entries_with_correct_linenumbers.
@Test
void build_entries__creates_html_scan_entries_with_correct_linenumbers() {
/* prepare */
SecHubFinding finding = new SecHubFinding();
SecHubCodeCallStack code1 = new SecHubCodeCallStack();
code1.setLine(0);
SecHubCodeCallStack code2 = new SecHubCodeCallStack();
code2.setLine(1);
SecHubCodeCallStack code3 = new SecHubCodeCallStack();
code3.setLine(2);
SecHubCodeCallStack code4 = new SecHubCodeCallStack();
code4.setLine(3);
finding.setCode(code1);
code1.setCalls(code2);
code2.setCalls(code3);
code3.setCalls(code4);
/* execute */
List<HTMLScanResultCodeScanEntry> fourElementsResult = descriptionSupport.buildEntries(finding);
/* test */
assertEquals(4, fourElementsResult.size());
assertEquals(code1.getLine(), fourElementsResult.get(0).getLine());
assertEquals(code2.getLine(), fourElementsResult.get(1).getLine());
assertEquals(code3.getLine(), fourElementsResult.get(2).getLine());
assertEquals(code4.getLine(), fourElementsResult.get(3).getLine());
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class HtmlCodeScanDescriptionSupportTest method test_is_code_scan_with_non_code_scan_finding.
@Test
void test_is_code_scan_with_non_code_scan_finding() {
/* prepare */
SecHubFinding finding = new SecHubFinding();
/* test */
assertFalse(descriptionSupport.isCodeScan(finding));
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class AssertReport method assertFindings.
private List<SecHubFinding> assertFindings(SecHubReport report) {
assertNotNull("Report may not be null", report);
SecHubResult result = report.getResult();
assertNotNull(result);
List<SecHubFinding> findings = result.getFindings();
assertNotNull(findings);
return findings;
}
Aggregations