Search in sources :

Example 1 with PullEvent

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

the class UpdatePullRequestCommentsSteps method buildGitHubPullRequest.

public void buildGitHubPullRequest() {
    PullEvent pullEvent = new PullEvent();
    Repository repo = new Repository();
    repo.setName("vb_test_udi");
    repo.setCloneUrl(gitHubProperties.getUrl());
    Owner owner = new Owner();
    owner.setName("");
    owner.setLogin("cxflowtestuser");
    Repo r = new Repo();
    r.setOwner(owner);
    repo.setOwner(owner);
    pullEvent.setRepository(repo);
    pullEvent.setAction("opened");
    PullRequest pullRequest = new PullRequest();
    pullRequest.setIssueUrl("");
    Head headBranch = new Head();
    headBranch.setRef(branchGitHub);
    headBranch.setRepo(r);
    pullRequest.setHead(headBranch);
    pullRequest.setBase(new Base());
    pullRequest.setStatusesUrl("");
    pullRequest.setIssueUrl(GITHUB_PR_BASE_URL + "/issues/" + GITHUB_PR_ID);
    pullEvent.setPullRequest(pullRequest);
    try {
        String pullEventStr = mapper.writeValueAsString(pullEvent);
        ControllerRequest controllerRequest = new ControllerRequest();
        controllerRequest.setApplication("VB");
        controllerRequest.setBranch(Collections.singletonList(branchGitHub));
        controllerRequest.setProject("VB");
        controllerRequest.setTeam("\\CxServer\\SP");
        controllerRequest.setPreset("default");
        controllerRequest.setIncremental(false);
        gitHubControllerSpy.pullRequest(pullEventStr, "SIGNATURE", "CX", controllerRequest);
    } catch (JsonProcessingException e) {
        fail("Unable to parse " + pullEvent);
    }
}
Also used : Repository(com.checkmarx.flow.dto.github.Repository) PullEvent(com.checkmarx.flow.dto.github.PullEvent) ControllerRequest(com.checkmarx.flow.dto.ControllerRequest) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 2 with PullEvent

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

the class UpdatePullRequestCommentsSteps method buildADOPullRequestEvent.

public void buildADOPullRequestEvent() {
    com.checkmarx.flow.dto.azure.PullEvent pullEvent = new com.checkmarx.flow.dto.azure.PullEvent();
    pullEvent.setEventType("git.pullrequest.updated");
    pullEvent.setId("4519989c-c157-4bf8-9651-e94b8d0fca27");
    pullEvent.setSubscriptionId("25aa3b80-54ed-4b26-976a-b74f94940852");
    pullEvent.setPublisherId("tfs");
    Project_ project = new Project_();
    project.setId("3172109f-8bcb-4f21-a8f7-4f94d4a825b0");
    project.setBaseUrl("https://dev.azure.com/OrgName/");
    ResourceContainers resourceContainers = new ResourceContainers();
    resourceContainers.setProject(project);
    pullEvent.setResourceContainers(resourceContainers);
    Resource resource = new Resource();
    resource.setStatus("active");
    resource.setSourceRefName("refs/heads/master");
    resource.setTargetRefName("refs/heads/udi-tests-2");
    resource.setUrl("https://dev.azure.com/CxNamespace/d50fc6e5-a5ab-4123-9bc9-ccb756c0bf16/_apis/git/repositories/a89a9d2f-ab67-4bda-9c56-a571224c2c66/pullRequests/" + ADO_PR_ID);
    com.checkmarx.flow.dto.azure.Repository repo = new com.checkmarx.flow.dto.azure.Repository();
    repo.setId("a89a9d2f-ab67-4bda-9c56-a571224c2c66");
    repo.setName("AdoPullRequestTests");
    repo.setUrl("https://dev.azure.com/CxNamespace/d50fc6e5-a5ab-4123-9bc9-ccb756c0bf16/_apis/git/repositories/a89a9d2f-ab67-4bda-9c56-a571224c2c66");
    repo.setRemoteUrl("https://CxNamespace@dev.azure.com/CxNamespace/AdoPullRequestTests/_git/AdoPullRequestTests");
    repo.setSshUrl("git@ssh.dev.azure.com:v3/CxNamespace/AdoPullRequestTests/AdoPullRequestTests");
    repo.setWebUrl("https://dev.azure.com/CxNamespace/AdoPullRequestTests/_git/AdoPullRequestTests");
    Project pr = new Project();
    pr.setId("d50fc6e5-a5ab-4123-9bc9-ccb756c0bf16");
    pr.setName("AdoPullRequestTests");
    repo.setProject(pr);
    resource.setRepository(repo);
    pullEvent.setResource(resource);
    ControllerRequest controllerRequest = new ControllerRequest();
    controllerRequest.setProject("AdoPullRequestTests-master");
    controllerRequest.setTeam("\\CxServer\\SP");
    AdoDetailsRequest adoRequest = new AdoDetailsRequest();
    adoControllerSpy.pullRequest(pullEvent, "Basic Y3hmbG93OjEyMzQ=", null, controllerRequest, adoRequest);
}
Also used : PullEvent(com.checkmarx.flow.dto.github.PullEvent) ControllerRequest(com.checkmarx.flow.dto.ControllerRequest) Repository(com.checkmarx.flow.dto.github.Repository) com.checkmarx.flow.dto.azure(com.checkmarx.flow.dto.azure)

Example 3 with PullEvent

use of com.checkmarx.flow.dto.github.PullEvent 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)

Aggregations

PullEvent (com.checkmarx.flow.dto.github.PullEvent)3 ControllerRequest (com.checkmarx.flow.dto.ControllerRequest)2 Repository (com.checkmarx.flow.dto.github.Repository)2 GitHubController (com.checkmarx.flow.controller.GitHubController)1 com.checkmarx.flow.dto.azure (com.checkmarx.flow.dto.azure)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 RestTemplate (org.springframework.web.client.RestTemplate)1