Search in sources :

Example 1 with GitHubController

use of com.checkmarx.flow.controller.GitHubController in project cx-flow by checkmarx-ltd.

the class ConfigAsCodeBranchSteps method githubNotifiesCxFlow.

@When("GitHub notifies CxFlow that a pull request was created for the {string} branch")
public void githubNotifiesCxFlow(String srcBranch) {
    log.info("Creating RestTemplate mock.");
    RestTemplate restTemplateMock = mock(RestTemplate.class);
    when(gettingFileFromRepo(restTemplateMock)).thenAnswer(this::interceptConfigAsCodeBranch);
    PullEvent pullEvent = CxConfigSteps.createPullEventDto(srcBranch, defaultBranch, gitHubProperties);
    GitHubController controllerSpy = getGitHubControllerSpy(restTemplateMock);
    CxConfigSteps.sendPullRequest(pullEvent, controllerSpy, srcBranch);
}
Also used : GitHubController(com.checkmarx.flow.controller.GitHubController) RestTemplate(org.springframework.web.client.RestTemplate) PullEvent(com.checkmarx.flow.dto.github.PullEvent)

Example 2 with GitHubController

use of com.checkmarx.flow.controller.GitHubController in project cx-flow by checkmarx-ltd.

the class ConfigAsCodeBranchSteps method getGitHubControllerSpy.

private GitHubController getGitHubControllerSpy(RestTemplate restTemplateMock) {
    log.info("Creating GitHub controller spy.");
    // Don't start automation.
    FlowService flowServiceMock = mock(FlowService.class);
    GitHubService gitHubService = new GitHubService(restTemplateMock, gitHubProperties, flowProperties, null, scmConfigOverrider, gitHubAppAuthService, cxProperties, sessionTracker, cxService);
    GitHubAppAuthService gitHubAppAuthService = new GitHubAppAuthService(restTemplateMock, gitHubProperties);
    GitHubController gitHubControllerSpy = Mockito.spy(new GitHubController(gitHubProperties, flowProperties, null, flowServiceMock, helperService, gitHubService, gitHubAppAuthService, filterFactory, configOverrider, scmConfigOverrider, gitAuthUrlGenerator));
    doNothing().when(gitHubControllerSpy).verifyHmacSignature(any(), any(), any());
    return gitHubControllerSpy;
}
Also used : GitHubController(com.checkmarx.flow.controller.GitHubController)

Example 3 with GitHubController

use of com.checkmarx.flow.controller.GitHubController in project cx-flow by checkmarx-ltd.

the class CxConfigBugTrackerSteps method sendPullRequestWebhookEvent.

@When("pull request webhook arrives")
public void sendPullRequestWebhookEvent() {
    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();
    buildPullRequest();
    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)

Example 4 with GitHubController

use of com.checkmarx.flow.controller.GitHubController 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

GitHubController (com.checkmarx.flow.controller.GitHubController)4 ScanRequest (com.checkmarx.flow.dto.ScanRequest)2 When (io.cucumber.java.en.When)2 PullEvent (com.checkmarx.flow.dto.github.PullEvent)1 RestTemplate (org.springframework.web.client.RestTemplate)1