use of com.mercedesbenz.sechub.domain.scan.report.ScanReport in project sechub by mercedes-benz.
the class ScanReportRestControllerRestDocTest method get_report_from_existing_job_returns_information_as_json_when_type_is_APPLICATION_JSON_UTF8.
@UseCaseRestDoc(useCase = UseCaseUserDownloadsJobReport.class, variant = "JSON", wanted = { SpringRestDocOutput.PATH_PARAMETERS, SpringRestDocOutput.REQUEST_FIELDS, SpringRestDocOutput.CURL_REQUEST })
@Test
@WithMockUser
public void get_report_from_existing_job_returns_information_as_json_when_type_is_APPLICATION_JSON_UTF8() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildGetJobReportUrl(PROJECT_ID.pathElement(), JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserDownloadsJobReport.class;
ScanReport report = new ScanReport(jobUUID, PROJECT1_ID);
report.setResult("{'count':'1'}");
report.setTrafficLight(TrafficLight.YELLOW);
ScanSecHubReport scanSecHubReport = new ScanSecHubReport(report);
when(downloadReportService.getScanSecHubReport(PROJECT1_ID, jobUUID)).thenReturn(scanSecHubReport);
/* execute + test @formatter:off */
this.mockMvc.perform(get(apiEndpoint, PROJECT1_ID, jobUUID).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().json("{\"jobUUID\":\"" + jobUUID.toString() + "\",\"result\":{\"count\":0,\"findings\":[]},\"trafficLight\":\"YELLOW\"}")).andDo(defineRestService().with().useCaseData(useCase, "JSON").tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.SECHUB_REPORT.getSchema()).and().document(pathParameters(parameterWithName(PROJECT_ID.paramName()).description("The project Id"), parameterWithName(JOB_UUID.paramName()).description("The job UUID"))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.scan.report.ScanReport in project sechub by mercedes-benz.
the class ScanReportRestControllerRestDocTest method get_report_from_existing_job_returns_information_as_html_when_type_is_APPLICATION_XHTML_XML.
@UseCaseRestDoc(useCase = UseCaseUserDownloadsJobReport.class, variant = "HTML", wanted = { SpringRestDocOutput.PATH_PARAMETERS, SpringRestDocOutput.REQUEST_FIELDS, SpringRestDocOutput.CURL_REQUEST })
@Test
@WithMockUser
public void get_report_from_existing_job_returns_information_as_html_when_type_is_APPLICATION_XHTML_XML() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildGetJobReportUrl(PROJECT_ID.pathElement(), JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserDownloadsJobReport.class;
ScanReport report = new ScanReport(jobUUID, PROJECT1_ID);
report.setResult("{'count':'1'}");
report.setTrafficLight(TrafficLight.YELLOW);
ScanSecHubReport scanSecHubReport = new ScanSecHubReport(report);
when(downloadReportService.getScanSecHubReport(PROJECT1_ID, jobUUID)).thenReturn(scanSecHubReport);
/* execute + test @formatter:off */
this.mockMvc.perform(get(apiEndpoint, PROJECT1_ID, jobUUID).accept(MediaType.APPLICATION_XHTML_XML).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType("text/html;charset=UTF-8")).andExpect(content().encoding("UTF-8")).andExpect(content().string(containsString(jobUUID.toString()))).andExpect(content().string(containsString("theRedStyle"))).andDo(defineRestService().with().useCaseData(useCase, "HTML").tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.SECHUB_REPORT.getSchema()).and().document(pathParameters(parameterWithName(PROJECT_ID.paramName()).description("The project Id"), parameterWithName(JOB_UUID.paramName()).description("The job UUID"))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.scan.report.ScanReport in project sechub by mercedes-benz.
the class ScanReportRestControllerMockTest method get_report_from_existing_job_returns_406_NOT_ACCEPTABLE__when_type_is_APPLICATION_PDF.
@Test
@WithMockUser
public void get_report_from_existing_job_returns_406_NOT_ACCEPTABLE__when_type_is_APPLICATION_PDF() throws Exception {
/* prepare */
ScanReport scanReport = new ScanReport(randomUUID, PROJECT1_ID);
scanReport.setResult("{'count':'1'}");
scanReport.setTrafficLight(TrafficLight.YELLOW);
ScanSecHubReport scanSecHubReport = new ScanSecHubReport(scanReport);
when(downloadReportService.getScanSecHubReport(PROJECT1_ID, randomUUID)).thenReturn(scanSecHubReport);
/* execute + test @formatter:off */
this.mockMvc.perform(get(https(PORT_USED).buildGetJobReportUrl(PROJECT1_ID, randomUUID)).accept(MediaType.APPLICATION_PDF).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isNotAcceptable());
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.scan.report.ScanReport in project sechub by mercedes-benz.
the class ScanReportRestControllerMockTest method internalTestAcceptedAndReturnsJSON.
private void internalTestAcceptedAndReturnsJSON(MediaType acceptedType) throws Exception {
/* prepare */
ScanReport report = new ScanReport(randomUUID, PROJECT1_ID);
report.setResult("{'count':'1'}");
report.setTrafficLight(TrafficLight.YELLOW);
ScanSecHubReport scanSecHubReport = new ScanSecHubReport(report);
when(downloadReportService.getScanSecHubReport(PROJECT1_ID, randomUUID)).thenReturn(scanSecHubReport);
/* execute + test @formatter:off */
this.mockMvc.perform(get(https(PORT_USED).buildGetJobReportUrl(PROJECT1_ID, randomUUID)).accept(acceptedType).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().json("{\"jobUUID\":\"" + randomUUID.toString() + "\",\"result\":{\"count\":0,\"findings\":[]},\"trafficLight\":\"YELLOW\"}"));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.scan.report.ScanReport in project sechub by mercedes-benz.
the class ScanReportRestControllerMockTest method internalTestAcceptedAndReturnsHTML.
private void internalTestAcceptedAndReturnsHTML(MediaType acceptedType) throws Exception {
/* prepare */
ScanReport report = new ScanReport(randomUUID, PROJECT1_ID);
report.setResult("{'count':'1'}");
report.setTrafficLight(TrafficLight.YELLOW);
ScanSecHubReport scanSecHubReport = new ScanSecHubReport(report);
when(downloadReportService.getScanSecHubReport(PROJECT1_ID, randomUUID)).thenReturn(scanSecHubReport);
/* execute + test @formatter:off */
this.mockMvc.perform(get(https(PORT_USED).buildGetJobReportUrl(PROJECT1_ID, randomUUID)).accept(acceptedType).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("theRedStyle")));
/* @formatter:on */
}
Aggregations