Search in sources :

Example 1 with EventResponse

use of com.checkmarx.flow.dto.EventResponse in project cx-flow by checkmarx-ltd.

the class FlowControllerTest method testScanApiWithDefaultParamters.

@Test
public void testScanApiWithDefaultParamters() {
    FlowController.CxScanRequest request = getScanRequestWithDefaults();
    FlowController.CxScanRequest referenceRequest = getScanRequestWithDefaults();
    referenceRequest.setFilters(getDefaultFilters());
    ArgumentCaptor<ScanRequest> captor = ArgumentCaptor.forClass(ScanRequest.class);
    ResponseEntity<EventResponse> response = flowController.initiateScan(request, flowProperties.getToken());
    verify(flowService).initiateAutomation(captor.capture());
    ScanRequest actual = captor.getValue();
    assertScanRequest(actual, referenceRequest);
    assertOKResponse(response);
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) EventResponse(com.checkmarx.flow.dto.EventResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 2 with EventResponse

use of com.checkmarx.flow.dto.EventResponse in project cx-flow by checkmarx-ltd.

the class FlowControllerTest method testScanApiWithFilters.

@ParameterizedTest
@MethodSource("generateDataForScanApi")
public void testScanApiWithFilters(String filterSeverity, String filterCwe, String filterOwasp, String filterType, String filterStatus, String id) {
    FlowController.CxScanRequest request = getScanRequestWithDefaults();
    List<Filter> filters = prepareScanApiFilters(filterSeverity, filterCwe, filterOwasp, filterType, filterStatus);
    request.setFilters(filters);
    ResponseEntity<EventResponse> response = flowController.initiateScan(request, flowProperties.getToken());
    ArgumentCaptor<ScanRequest> captor = ArgumentCaptor.forClass(ScanRequest.class);
    verify(flowService).initiateAutomation(captor.capture());
    ScanRequest actual = captor.getValue();
    assertScanApiFilters(actual.getFilter().getSastFilters().getSimpleFilters(), filters);
    assertOKResponse(response);
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) EventResponse(com.checkmarx.flow.dto.EventResponse) Filter(com.checkmarx.sdk.dto.sast.Filter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with EventResponse

use of com.checkmarx.flow.dto.EventResponse in project cx-flow by checkmarx-ltd.

the class FlowControllerTest method testScanIncrementalParameter.

@ParameterizedTest
@CsvSource({ "false", "true" })
public void testScanIncrementalParameter(boolean incremental) {
    FlowController.CxScanRequest request = getScanRequestWithDefaults();
    request.setIncremental(incremental);
    ResponseEntity<EventResponse> response = flowController.initiateScan(request, flowProperties.getToken());
    assertOKResponse(response);
    ArgumentCaptor<ScanRequest> captor = ArgumentCaptor.forClass(ScanRequest.class);
    verify(flowService, times(1)).initiateAutomation(captor.capture());
    ScanRequest actual = captor.getValue();
    assertScanRequest(actual, request);
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) EventResponse(com.checkmarx.flow.dto.EventResponse) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EventResponse (com.checkmarx.flow.dto.EventResponse)3 ScanRequest (com.checkmarx.flow.dto.ScanRequest)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 Filter (com.checkmarx.sdk.dto.sast.Filter)1 Test (org.junit.jupiter.api.Test)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1