use of com.checkmarx.flow.dto.github.Repository in project cx-flow by checkmarx-ltd.
the class GitHubService method initConfigProviderOnPushEvent.
public void initConfigProviderOnPushEvent(String uid, PushEvent event) {
if (properties != null) {
try {
ConfigProvider configProvider = ConfigProvider.getInstance();
Repository repository = event.getRepository();
// According to GitHub the recommended way to extract the branch name
// is by using the 'ref' parameter which is in the following format: 'refs/heads/<branch>'
configProvider.init(uid, new RepoReader(properties.getApiUrl(), repository.getOwner().getName(), repository.getName(), ScanUtils.getBranchFromRef(event.getRef()), properties.getToken(), SourceProviderType.GITHUB));
} catch (ConfigurationException e) {
log.warn("Failed to init config provider with the following error: {}", e.getMessage());
}
}
}
use of com.checkmarx.flow.dto.github.Repository 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);
}
}
use of com.checkmarx.flow.dto.github.Repository in project cx-flow by checkmarx-ltd.
the class DeleteBranchSteps method sendGithubDeleteEvent.
private void sendGithubDeleteEvent() {
DeleteEvent deleteEvent = new DeleteEvent();
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);
deleteEvent.setRepository(repo);
deleteEvent.setRefType(trigger);
deleteEvent.setRef(githubBranch);
try {
String deleteEventStr = mapper.writeValueAsString(deleteEvent);
gitHubControllerSpy.deleteBranchRequest(deleteEventStr, "SIGNATURE", "CX", null, null, TEAM);
} catch (JsonProcessingException e) {
fail("Unable to parse " + deleteEvent.toString());
}
}
use of com.checkmarx.flow.dto.github.Repository in project cx-flow by checkmarx-ltd.
the class GitHubService method initConfigProviderOnPullEvent.
public void initConfigProviderOnPullEvent(String uid, PullEvent event) {
if (properties != null) {
try {
ConfigProvider configProvider = ConfigProvider.getInstance();
Repository repository = event.getRepository();
String branch = event.getPullRequest().getHead().getRef();
configProvider.init(uid, new RepoReader(properties.getApiUrl(), repository.getOwner().getLogin(), repository.getName(), branch, properties.getToken(), SourceProviderType.GITHUB));
} catch (ConfigurationException e) {
log.warn("Failed to init config provider with the following error: {}", e.getMessage());
}
}
}
Aggregations