use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class DeleteBranchSteps method sendAzureDeleteEvent.
public void sendAzureDeleteEvent(String deletedBranch) {
String meaningless_string = "some_string";
com.checkmarx.flow.dto.azure.PushEvent pushEvent = new com.checkmarx.flow.dto.azure.PushEvent();
pushEvent.setEventType(AZURE_PUSH_EVENT_TYPE);
Project_ project = new Project_();
project.setId(meaningless_string);
project.setBaseUrl("https://dev.azure.com/OrgName/");
ResourceContainers resourceContainers = new ResourceContainers();
resourceContainers.setProject(project);
pushEvent.setResourceContainers(resourceContainers);
RefUpdate refUpdate = new RefUpdate();
refUpdate.setName("refs/heads/" + deletedBranch);
refUpdate.setOldObjectId(meaningless_string);
refUpdate.setNewObjectId(AZURE_DELETED_BRANCH_OBJ_ID);
Resource resource = new Resource();
resource.setRefUpdates(Collections.singletonList(refUpdate));
resource.setStatus(meaningless_string);
resource.setUrl(meaningless_string);
com.checkmarx.flow.dto.azure.Repository repo = new com.checkmarx.flow.dto.azure.Repository();
repo.setId(meaningless_string);
repo.setName(adoRepo);
repo.setUrl(meaningless_string);
repo.setRemoteUrl(meaningless_string);
repo.setDefaultBranch(GIT_DEFAULT_BRANCH);
Project pr = new Project();
pr.setId(meaningless_string);
pr.setName(meaningless_string);
repo.setProject(pr);
resource.setRepository(repo);
pushEvent.setResource(resource);
ControllerRequest controllerRequest = new ControllerRequest();
AdoDetailsRequest adoRequest = new AdoDetailsRequest();
adoControllerSpy.pushRequest(pushEvent, AZURE_WEBHOOK_TOKEN_AUTH, null, controllerRequest, adoRequest);
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class GithubServiceMocker method openPullRequest.
@Override
public void openPullRequest() {
PullEvent pullEvent = new PullEvent();
Repository repo = new Repository();
repo.setName(githubProjectName);
repo.setCloneUrl(gitUrl);
Owner owner = new Owner();
owner.setName("");
owner.setLogin(GITHUB_USER);
repo.setOwner(owner);
Repo r = new Repo();
r.setOwner(owner);
pullEvent.setRepository(repo);
pullEvent.setAction("opened");
PullRequest pullRequest = new PullRequest();
pullRequest.setIssueUrl("");
Head headBranch = new Head();
headBranch.setRef(branchName);
headBranch.setRepo(r);
pullRequest.setHead(headBranch);
pullRequest.setBase(new Base());
pullRequest.setStatusesUrl(statusApiUrl);
pullRequest.setIssueUrl(githubPullRequestUrl);
pullEvent.setPullRequest(pullRequest);
try {
String pullEventStr = mapper.writeValueAsString(pullEvent);
ControllerRequest controllerRequest = new ControllerRequest();
controllerRequest.setApplication(githubProjectName);
controllerRequest.setBranch(Collections.singletonList(branchName));
controllerRequest.setProject(cxProjectName);
controllerRequest.setTeam(cxTeam);
controllerRequest.setPreset("default");
controllerRequest.setIncremental(false);
gitHubControllerSpy.pullRequest(pullEventStr, "SIGNATURE", "CX", controllerRequest);
} catch (JsonProcessingException e) {
fail("Unable to parse " + pullEvent.toString());
}
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class GitlabServiceMocker method sendPushEvent.
@Override
public void sendPushEvent() {
PushEvent pushEvent = new PushEvent();
pushEvent.setCommits(new LinkedList<>());
Repository repo = new Repository();
repo.setName(gitlabProjectName);
pushEvent.setRepository(repo);
pushEvent.setRef("refs/head/" + branchName);
Project project = new Project();
project.setGitHttpUrl(gitUrl);
project.setNamespace(GITLAB_USER);
project.setName(gitlabProjectName);
pushEvent.setProject(project);
ControllerRequest request = ControllerRequest.builder().application(gitlabProjectName).branch(Collections.singletonList(branchName)).project(cxProjectName).team(cxTeam).assignee("").preset("default").build();
gitlabControllerSpy.pushRequest(pushEvent, "SIGNATURE", "CX", request);
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class Github2AdoSteps method buildPushRequest.
public void buildPushRequest() {
PushEvent pushEvent = new PushEvent();
Repository repo = new Repository();
repo.setName(repoName);
repo.setCloneUrl(gitHubProperties.getUrl());
Owner owner = new Owner();
owner.setName(GITHUB_USER);
owner.setLogin(GITHUB_USER);
repo.setOwner(owner);
pushEvent.setRepository(repo);
pushEvent.setCommits(new LinkedList<>());
Pusher pusher = new Pusher();
pusher.setEmail("some@email");
pushEvent.setPusher(pusher);
pushEvent.setRef("refs/heads/master");
try {
String pullEventStr = mapper.writeValueAsString(pushEvent);
ControllerRequest request = ControllerRequest.builder().application(repoName).branch(Collections.singletonList(branch)).project(repoName).team("\\CxServer\\SP").assignee("").preset("default").build();
gitHubControllerSpy.pushRequest(pullEventStr, "SIGNATURE", "CX", request);
} catch (JsonProcessingException e) {
fail("Unable to parse " + pushEvent.toString());
}
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class CxConfigSteps method sendPullRequest.
static void sendPullRequest(PullEvent pullEvent, GitHubController gitHubController, String sourceBranch) {
log.info("Sending pull request event to controller.");
try {
String pullEventStr = mapper.writeValueAsString(pullEvent);
ControllerRequest request = ControllerRequest.builder().branch(Collections.singletonList(sourceBranch)).application("VB").team("\\CxServer\\SP").assignee("").preset("default").build();
gitHubController.pullRequest(pullEventStr, "SIGNATURE", "CX", request);
} catch (JsonProcessingException e) {
fail("Unable to parse " + pullEvent.toString());
}
}
Aggregations