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);
}
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;
}
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();
}
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();
}
Aggregations