Skip to content

Commit

Permalink
Fixed some tests and html templates mercedes-benz#345
Browse files Browse the repository at this point in the history
  • Loading branch information
zigfridus committed Aug 16, 2023
1 parent 07bf0ee commit a039d35
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 152 deletions.
98 changes: 49 additions & 49 deletions sechub-api-java/src/main/resources/reduced-openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3185,6 +3185,55 @@
}
}
},
"ExecutionProfileFetch": {
"title": "ExecutionProfileFetch",
"type": "object",
"properties": {
"configurations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productIdentifier": {
"type": "string",
"description": "executed product"
},
"name": {
"type": "string",
"description": "name of configuration"
},
"executorVersion": {
"type": "number",
"description": "executor version"
},
"uuid": {
"type": "string",
"description": "uuid of configuration"
},
"enabled": {
"type": "boolean",
"description": "enabled state of this config"
}
}
}
},
"description": {
"type": "string",
"description": "A short description for the profile"
},
"projectIds": {
"type": "array",
"description": "Projects can be linked by their ids here",
"items": {
"type": "string"
}
},
"enabled": {
"type": "boolean",
"description": "Enabled state of profile, default is false"
}
}
},
"FalsePositives": {
"title": "FalsePositives",
"type": "object",
Expand Down Expand Up @@ -3298,55 +3347,6 @@
}
}
},
"ExecutionProfileFetch": {
"title": "ExecutionProfileFetch",
"type": "object",
"properties": {
"configurations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productIdentifier": {
"type": "string",
"description": "executed product"
},
"name": {
"type": "string",
"description": "name of configuration"
},
"executorVersion": {
"type": "number",
"description": "executor version"
},
"uuid": {
"type": "string",
"description": "uuid of configuration"
},
"enabled": {
"type": "boolean",
"description": "enabled state of this config"
}
}
}
},
"description": {
"type": "string",
"description": "A short description for the profile"
},
"projectIds": {
"type": "array",
"description": "Projects can be linked by their ids here",
"items": {
"type": "string"
}
},
"enabled": {
"type": "boolean",
"description": "Enabled state of profile, default is false"
}
}
},
"FullScanDataZIP": {
"title": "FullScanDataZIP",
"type": "object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class SecHubReportMetaDataSummaryDetailsTest {
static final int MEDIUM_FINDING_CWEID = 456;
static final int LOW_FINDING_CWEID = 789;

static final String HIGH_FINDING_NAME = "Cross Site Scripting (Reflected)";
static final String MEDIUM_FINDING_NAME = "CSP: Wildcard Directive";
static final String LOW_FINDING_NAME = "Cookie Without Secure Flag";

SecHubReportMetaDataSummaryDetails secHubReportMetaDataSummaryDetails;
SecHubFinding highFinding;
SecHubFinding mediumFinding;
Expand All @@ -28,17 +32,17 @@ void beforeEach() {
highFinding = new SecHubFinding();
highFinding.setCweId(HIGH_FINDING_CWEID);
highFinding.setSeverity(Severity.HIGH);
highFinding.setName("Cross Site Scripting (Reflected)");
highFinding.setName(HIGH_FINDING_NAME);

mediumFinding = new SecHubFinding();
mediumFinding.setCweId(MEDIUM_FINDING_CWEID);
mediumFinding.setSeverity(Severity.MEDIUM);
mediumFinding.setName("CSP: Wildcard Directive");
mediumFinding.setName(MEDIUM_FINDING_NAME);

lowFinding = new SecHubFinding();
lowFinding.setCweId(LOW_FINDING_CWEID);
lowFinding.setSeverity(Severity.LOW);
lowFinding.setName("Cookie Without Secure Flag");
lowFinding.setName(LOW_FINDING_NAME);
}

@Test
Expand All @@ -47,7 +51,7 @@ void new_element_in_high_map_must_be_created() {
secHubReportMetaDataSummaryDetails.detailsHelper(highFinding);

/* test */
assertNotNull(secHubReportMetaDataSummaryDetails.high.get(HIGH_FINDING_CWEID));
assertNotNull(secHubReportMetaDataSummaryDetails.high.get(HIGH_FINDING_NAME));
}

@Test
Expand All @@ -56,7 +60,7 @@ void new_element_in_medium_map_must_be_created() {
secHubReportMetaDataSummaryDetails.detailsHelper(mediumFinding);

/* test */
assertNotNull(secHubReportMetaDataSummaryDetails.medium.get(MEDIUM_FINDING_CWEID));
assertNotNull(secHubReportMetaDataSummaryDetails.medium.get(MEDIUM_FINDING_NAME));
}

@Test
Expand All @@ -65,42 +69,42 @@ void new_element_in_low_map_must_be_created() {
secHubReportMetaDataSummaryDetails.detailsHelper(lowFinding);

/* test */
assertNotNull(secHubReportMetaDataSummaryDetails.low.get(LOW_FINDING_CWEID));
assertNotNull(secHubReportMetaDataSummaryDetails.low.get(LOW_FINDING_NAME));
}

@Test
void instance_variables_of_new_element_in_high_map_initialized_correctly() {
/* execute */
secHubReportMetaDataSummaryDetails.detailsHelper(highFinding);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.high.get(HIGH_FINDING_CWEID);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.high.get(HIGH_FINDING_NAME);

/* test */
assertEquals(HIGH_FINDING_CWEID, severityDetails.getCweId());
assertEquals("Cross Site Scripting (Reflected)", severityDetails.getName());
assertEquals(HIGH_FINDING_NAME, severityDetails.getName());
assertEquals(1, severityDetails.getCount());
}

@Test
void instance_variables_of_new_element_in_medium_map_initialized_correctly() {
/* execute */
secHubReportMetaDataSummaryDetails.detailsHelper(mediumFinding);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.medium.get(MEDIUM_FINDING_CWEID);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.medium.get(MEDIUM_FINDING_NAME);

/* test */
assertEquals(MEDIUM_FINDING_CWEID, severityDetails.getCweId());
assertEquals("CSP: Wildcard Directive", severityDetails.getName());
assertEquals(MEDIUM_FINDING_NAME, severityDetails.getName());
assertEquals(1, severityDetails.getCount());
}

@Test
void instance_variables_of_new_element_in_low_map_initialized_correctly() {
/* execute */
secHubReportMetaDataSummaryDetails.detailsHelper(lowFinding);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.low.get(LOW_FINDING_CWEID);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.low.get(LOW_FINDING_NAME);

/* test */
assertEquals(LOW_FINDING_CWEID, severityDetails.getCweId());
assertEquals("Cookie Without Secure Flag", severityDetails.getName());
assertEquals(LOW_FINDING_NAME, severityDetails.getName());
assertEquals(1, severityDetails.getCount());
}

Expand All @@ -110,7 +114,7 @@ void if_adding_multiple_similar_findings_into_high_map_counter_contains_correct_
for (int i = 0; i < 101; i++) {
secHubReportMetaDataSummaryDetails.detailsHelper(highFinding);
}
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.high.get(HIGH_FINDING_CWEID);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.high.get(HIGH_FINDING_NAME);

/* test */
assertEquals(101, severityDetails.getCount());
Expand All @@ -122,7 +126,7 @@ void if_adding_multiple_similar_findings_into_medium_map_counter_contains_correc
for (int i = 0; i < 101; i++) {
secHubReportMetaDataSummaryDetails.detailsHelper(mediumFinding);
}
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.medium.get(MEDIUM_FINDING_CWEID);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.medium.get(MEDIUM_FINDING_NAME);

/* test */
assertEquals(101, severityDetails.getCount());
Expand All @@ -134,7 +138,7 @@ void if_adding_multiple_similar_findings_into_low_map_counter_contains_correct_v
for (int i = 0; i < 101; i++) {
secHubReportMetaDataSummaryDetails.detailsHelper(lowFinding);
}
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.low.get(LOW_FINDING_CWEID);
SecHubReportMetaDataSummaryDetails.SeverityDetails severityDetails = secHubReportMetaDataSummaryDetails.low.get(LOW_FINDING_NAME);

/* test */
assertEquals(101, severityDetails.getCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ void beforeEach() {

highFinding = new SecHubFinding();
highFinding.setSeverity(Severity.HIGH);
highFinding.setName("Cross Site Scripting (Reflected)");

mediumFinding = new SecHubFinding();
mediumFinding.setSeverity(Severity.MEDIUM);
mediumFinding.setName("CSP: Wildcard Directive");

lowFinding = new SecHubFinding();
lowFinding.setSeverity(Severity.LOW);
lowFinding.setName("Cookie Without Secure Flag");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;

import org.junit.Before;
import org.junit.Test;
Expand All @@ -38,6 +34,7 @@
import com.mercedesbenz.sechub.commons.model.TrafficLight;
import com.mercedesbenz.sechub.docgen.util.RestDocFactory;
import com.mercedesbenz.sechub.domain.scan.HTMLScanResultReportModelBuilder;
import com.mercedesbenz.sechub.domain.scan.ScanTypeCount;
import com.mercedesbenz.sechub.domain.scan.report.DownloadScanReportService;
import com.mercedesbenz.sechub.domain.scan.report.DownloadSpdxScanReportService;
import com.mercedesbenz.sechub.domain.scan.report.ScanReport;
Expand Down Expand Up @@ -241,7 +238,8 @@ public void before() throws Exception {
map.put("yellowList", new ArrayList<>());
map.put("greenList", new ArrayList<>());
map.put("isWebDesignMode", false);
map.put("metaData", Optional.ofNullable(null));
map.put("metaData", null);
map.put("scanTypeCountSet", new TreeSet<ScanTypeCount>());
when(modelBuilder.build(any())).thenReturn(map);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<th:block th:fragment="details_footer (finding)">
<th:block th:fragment="details_footer(finding)">
<h3 class="rDetailHeadline1">Description</h3>
<div th:if="${reportHelper.hasDescription(finding)}" class="rText" th:text="${reportHelper.getDescription(finding)}">Description1</div>
<div th:if="${reportHelper.hasDescription(finding) == false AND finding.cweId != null}" class="rCalculatedText">
Expand Down
Loading

0 comments on commit a039d35

Please sign in to comment.