Search in sources :

Example 46 with ScanRequest

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

the class GetResultsAnalyticsTestSteps method getSCAResults.

@When("doing get results operation on SCA scan with {int} {int} {int} results")
public void getSCAResults(int high, int medium, int low) throws InterruptedException {
    try {
        scanResultsToInject = createFakeSCAScanResults(high, medium, low);
        ScanRequest scanRequest = createScanRequest();
        // addAdditionalInfoToResults();
        // addFlowSummaryToResults(high, medium, low, info);
        CompletableFuture<ScanResults> task = resultsService.processScanResultsAsync(scanRequest, PROJECT_ID, SCAN_ID, null, null);
        task.get(1, TimeUnit.MINUTES);
    } catch (MachinaException | ExecutionException | TimeoutException e) {
        String message = "Error processing scan results.";
        log.error(message, e);
        Assert.fail(message);
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) When(io.cucumber.java.en.When)

Example 47 with ScanRequest

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

the class GetResultsAnalyticsTestSteps method getSASTResults.

@When("doing get results operation on SAST scan with {int} {int} {int} {int} results")
public void getSASTResults(int high, int medium, int low, int info) throws InterruptedException {
    try {
        scanResultsToInject = createFakeSASTScanResults();
        ScanRequest scanRequest = createScanRequest();
        setFindingsSummary(high, medium, low, info);
        addAdditionalInfoToResults();
        addFlowSummaryToResults(high, medium, low, info);
        CompletableFuture<ScanResults> task = resultsService.processScanResultsAsync(scanRequest, PROJECT_ID, SCAN_ID, null, null);
        task.get(1, TimeUnit.MINUTES);
    } catch (MachinaException | ExecutionException | TimeoutException e) {
        String message = "Error processing scan results.";
        log.error(message, e);
        Assert.fail(message);
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) When(io.cucumber.java.en.When)

Example 48 with ScanRequest

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

the class GetResultsAnalyticsTestSteps method getResultsWithFilter.

@When("doing get results operation on SAST scan with {int} {int} {int} {int} results and filter is {string}")
public void getResultsWithFilter(int high, int medium, int low, int info, String filter) throws InterruptedException {
    try {
        scanResultsToInject = createFakeSASTScanResults();
        ScanRequest scanRequest = createScanRequest();
        setFindingsSummary(high, medium, low, info, filter);
        addAdditionalInfoToResults();
        addFlowSummaryToResults(high, medium, low, info);
        CompletableFuture<ScanResults> task = resultsService.processScanResultsAsync(scanRequest, PROJECT_ID, SCAN_ID, null, null);
        task.get(1, TimeUnit.MINUTES);
    } catch (MachinaException | ExecutionException | TimeoutException e) {
        String message = "Error processing scan results.";
        log.error(message, e);
        Assert.fail(message);
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) When(io.cucumber.java.en.When)

Example 49 with ScanRequest

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

the class AnalyticsSteps method createScanRequest.

private static ScanRequest createScanRequest(String repoUrl) {
    ScanRequest scanRequest = new ScanRequest();
    BugTracker issueTracker = BugTracker.builder().type(BugTracker.Type.GITHUBPULL).build();
    scanRequest.setBugTracker(issueTracker);
    scanRequest.setMergeNoteUri(MERGE_NOTE_URL);
    scanRequest.setProduct(ScanRequest.Product.CX);
    scanRequest.setRepoUrl(repoUrl);
    HashMap<String, String> metadata = new HashMap<>();
    metadata.put("statuses_url", PULL_REQUEST_STATUSES_URL);
    scanRequest.setAdditionalMetadata(metadata);
    return scanRequest;
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) BugTracker(com.checkmarx.flow.dto.BugTracker)

Example 50 with ScanRequest

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

the class CxConfigBugTrackerSteps method sendPushEvent.

@When("push event arrives")
public void sendPushEvent() {
    assertFlowPropertiesBugTracker("Json");
    ArgumentCaptor<ScanRequest> ac = ArgumentCaptor.forClass(ScanRequest.class);
    FlowService flowServiceMock = Mockito.mock(FlowService.class);
    gitHubControllerSpy = new GitHubController(gitHubProperties, flowProperties, jiraProperties, flowServiceMock, helperService, gitHubService, gitHubAppAuthService, filterFactory, configOverrider, scmConfigOverrider, gitAuthUrlGenerator);
    gitHubControllerSpy = spy(gitHubControllerSpy);
    initGitHubControllerSpy();
    buildPushRequest();
    verify(flowServiceMock, times(1)).initiateAutomation(ac.capture());
    request = ac.getValue();
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) GitHubController(com.checkmarx.flow.controller.GitHubController) When(io.cucumber.java.en.When)

Aggregations

ScanRequest (com.checkmarx.flow.dto.ScanRequest)68 BugTracker (com.checkmarx.flow.dto.BugTracker)24 ScanResults (com.checkmarx.sdk.dto.ScanResults)20 When (io.cucumber.java.en.When)14 FilterConfiguration (com.checkmarx.sdk.dto.filtering.FilterConfiguration)12 MachinaException (com.checkmarx.flow.exception.MachinaException)11 CxConfig (com.checkmarx.sdk.dto.sast.CxConfig)11 Test (org.junit.Test)11 File (java.io.File)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Issue (com.checkmarx.flow.dto.Issue)5 MachinaRuntimeException (com.checkmarx.flow.exception.MachinaRuntimeException)5 IOException (java.io.IOException)5 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 IfProfileValue (org.springframework.test.annotation.IfProfileValue)4 EventResponse (com.checkmarx.flow.dto.EventResponse)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 FlowProperties (com.checkmarx.flow.config.FlowProperties)2