Search in sources :

Example 6 with ControllerRequest

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);
}
Also used : ControllerRequest(com.checkmarx.flow.dto.ControllerRequest) Repository(com.checkmarx.flow.dto.github.Repository) com.checkmarx.flow.dto.azure(com.checkmarx.flow.dto.azure)

Example 7 with ControllerRequest

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());
    }
}
Also used : ControllerRequest(com.checkmarx.flow.dto.ControllerRequest) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 8 with ControllerRequest

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);
}
Also used : Project(com.checkmarx.flow.dto.gitlab.Project) Repository(com.checkmarx.flow.dto.gitlab.Repository) PushEvent(com.checkmarx.flow.dto.gitlab.PushEvent) ControllerRequest(com.checkmarx.flow.dto.ControllerRequest)

Example 9 with ControllerRequest

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());
    }
}
Also used : ControllerRequest(com.checkmarx.flow.dto.ControllerRequest) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 10 with ControllerRequest

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());
    }
}
Also used : ControllerRequest(com.checkmarx.flow.dto.ControllerRequest) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

ControllerRequest (com.checkmarx.flow.dto.ControllerRequest)15 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)7 Repository (com.checkmarx.flow.dto.github.Repository)3 FilterConfiguration (com.checkmarx.sdk.dto.filtering.FilterConfiguration)3 BugTracker (com.checkmarx.flow.dto.BugTracker)2 FlowOverride (com.checkmarx.flow.dto.FlowOverride)2 com.checkmarx.flow.dto.azure (com.checkmarx.flow.dto.azure)2 PullEvent (com.checkmarx.flow.dto.github.PullEvent)2 EngineFilterConfiguration (com.checkmarx.sdk.dto.filtering.EngineFilterConfiguration)2 ScanRequest (com.checkmarx.flow.dto.ScanRequest)1 LastCommit (com.checkmarx.flow.dto.gitlab.LastCommit)1 MergeEvent (com.checkmarx.flow.dto.gitlab.MergeEvent)1 Project (com.checkmarx.flow.dto.gitlab.Project)1 PushEvent (com.checkmarx.flow.dto.gitlab.PushEvent)1 Repository (com.checkmarx.flow.dto.gitlab.Repository)1 ShardSession (com.checkmarx.sdk.ShardManager.ShardSession)1 ScanResults (com.checkmarx.sdk.dto.ScanResults)1 Filter (com.checkmarx.sdk.dto.sast.Filter)1