diff --git a/src/main/java/org/kohsuke/github/GHCheckRun.java b/src/main/java/org/kohsuke/github/GHCheckRun.java index 52a8da3b8..4f0bbe273 100644 --- a/src/main/java/org/kohsuke/github/GHCheckRun.java +++ b/src/main/java/org/kohsuke/github/GHCheckRun.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; @@ -17,6 +18,8 @@ import java.util.List; @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" }, justification = "JSON API") public class GHCheckRun extends GHObject { + + @JsonProperty("repository") GHRepository owner; GitHub root; @@ -37,7 +40,7 @@ public class GHCheckRun extends GHObject { GHCheckRun wrap(GHRepository owner) { this.owner = owner; - this.root = owner.root; + wrap(owner.root); return this; } @@ -45,7 +48,24 @@ public class GHCheckRun extends GHObject { this.root = root; if (owner != null) { owner.wrap(root); + if (pullRequests != null && pullRequests.length != 0) { + for (GHPullRequest singlePull : pullRequests) { + singlePull.wrap(owner); + } + } + } + if (checkSuite != null) { + if (owner != null) { + checkSuite.wrap(owner); + } else { + checkSuite.wrap(root); + } + } + if (app != null) { + app.wrapUp(root); + } + return this; } @@ -108,14 +128,18 @@ public class GHCheckRun extends GHObject { /** * Gets the pull requests participated in this check run. * - * @return Pull requests of this check run + * Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is + * always empty. + * + * @return the list of {@link GHPullRequest}s for this check run. Only populated for events. * @throws IOException * the io exception */ public List getPullRequests() throws IOException { if (pullRequests != null && pullRequests.length != 0) { for (GHPullRequest singlePull : pullRequests) { - singlePull.refresh(); + // Only refresh if we haven't do so before + singlePull.refresh(singlePull.getTitle()); } return Collections.unmodifiableList(Arrays.asList(pullRequests)); } diff --git a/src/main/java/org/kohsuke/github/GHCheckSuite.java b/src/main/java/org/kohsuke/github/GHCheckSuite.java index 812fea145..2f4bf5543 100644 --- a/src/main/java/org/kohsuke/github/GHCheckSuite.java +++ b/src/main/java/org/kohsuke/github/GHCheckSuite.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; @@ -17,6 +18,8 @@ import java.util.List; @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" }, justification = "JSON API") public class GHCheckSuite extends GHObject { + + @JsonProperty("repository") GHRepository owner; GitHub root; @@ -35,7 +38,7 @@ public class GHCheckSuite extends GHObject { GHCheckSuite wrap(GHRepository owner) { this.owner = owner; - this.root = owner.root; + this.wrap(owner.root); return this; } @@ -43,6 +46,14 @@ public class GHCheckSuite extends GHObject { this.root = root; if (owner != null) { owner.wrap(root); + if (pullRequests != null && pullRequests.length != 0) { + for (GHPullRequest singlePull : pullRequests) { + singlePull.wrap(owner); + } + } + } + if (app != null) { + app.wrapUp(root); } return this; } @@ -156,14 +167,18 @@ public class GHCheckSuite extends GHObject { /** * Gets the pull requests participated in this check suite. * - * @return Pull requests + * Note this field is only populated for events. When getting a {@link GHCheckSuite} outside of an event, this is + * always empty. + * + * @return the list of {@link GHPullRequest}s for this check suite. Only populated for events. * @throws IOException * the io exception */ public List getPullRequests() throws IOException { if (pullRequests != null && pullRequests.length != 0) { for (GHPullRequest singlePull : pullRequests) { - singlePull.refresh(); + // Only refresh if we haven't do so before + singlePull.refresh(singlePull.getTitle()); } return Collections.unmodifiableList(Arrays.asList(pullRequests)); } diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index b8dd31172..b618635d7 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -3,6 +3,7 @@ package org.kohsuke.github; import org.junit.Rule; import org.junit.Test; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.TimeZone; @@ -387,7 +388,25 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest { @Payload("check-run") public void checkRunEvent() throws Exception { GHEventPayload.CheckRun event = GitHub.offline() - .parseEventPayload(payload.asReader(), GHEventPayload.CheckRun.class); + .parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.CheckRun.class); + GHCheckRun checkRun = verifyBasicCheckRunEvent(event); + assertThat("pull body not populated offline", checkRun.getPullRequests().get(0).getBody(), nullValue()); + assertThat("using offline github", mockGitHub.getRequestCount(), equalTo(0)); + + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build(); + event = gitHub.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.CheckRun.class); + checkRun = verifyBasicCheckRunEvent(event); + + int expectedRequestCount = mockGitHub.isUseProxy() ? 3 : 2; + assertThat("pull body should be populated", + checkRun.getPullRequests().get(0).getBody(), + equalTo("This is a pretty simple change that we need to pull into master.")); + assertThat("multiple getPullRequests() calls are made, the pull is populated only once", + mockGitHub.getRequestCount(), + equalTo(expectedRequestCount)); + } + + private GHCheckRun verifyBasicCheckRunEvent(GHEventPayload.CheckRun event) throws IOException { assertThat(event.getRepository().getName(), is("Hello-World")); assertThat(event.getRepository().getOwner().getLogin(), is("Codertocat")); assertThat(event.getAction(), is("created")); @@ -406,9 +425,9 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest { assertThat(formatter.format(checkRun.getCompletedAt()), is("2019-05-15T20:22:22Z")); assertThat(checkRun.getConclusion(), is("success")); - assertThat(checkRun.getUrl().toString(), - is("https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228")); - assertThat(checkRun.getHtmlUrl().toString(), is("https://github.com/Codertocat/Hello-World/runs/128620228")); + assertThat(checkRun.getUrl().toString(), endsWith("/repos/Codertocat/Hello-World/check-runs/128620228")); + assertThat(checkRun.getHtmlUrl().toString(), + endsWith("https://github.com/Codertocat/Hello-World/runs/128620228")); assertThat(checkRun.getDetailsUrl().toString(), is("https://octocoders.io")); assertThat(checkRun.getApp().getId(), is(29310L)); assertThat(checkRun.getCheckSuite().getId(), is(118578147L)); @@ -417,18 +436,41 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest { assertThat(checkRun.getOutput().getText(), nullValue()); assertThat(checkRun.getOutput().getAnnotationsCount(), is(0)); assertThat(checkRun.getOutput().getAnnotationsUrl().toString(), - is("https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228/annotations")); + endsWith("/repos/Codertocat/Hello-World/check-runs/128620228/annotations")); // Checks the deserialization of sender assertThat(event.getSender().getId(), is(21031067L)); + + assertThat(checkRun.getPullRequests(), notNullValue()); + assertThat(checkRun.getPullRequests().size(), equalTo(1)); + assertThat(checkRun.getPullRequests().get(0).getNumber(), equalTo(2)); + return checkRun; } @Test @Payload("check-suite") public void checkSuiteEvent() throws Exception { GHEventPayload.CheckSuite event = GitHub.offline() - .parseEventPayload(payload.asReader(), GHEventPayload.CheckSuite.class); + .parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.CheckSuite.class); + GHCheckSuite checkSuite = verifyBasicCheckSuiteEvent(event); + assertThat("pull body not populated offline", checkSuite.getPullRequests().get(0).getBody(), nullValue()); + assertThat("using offline github", mockGitHub.getRequestCount(), equalTo(0)); + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build(); + event = gitHub.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), + GHEventPayload.CheckSuite.class); + checkSuite = verifyBasicCheckSuiteEvent(event); + + int expectedRequestCount = mockGitHub.isUseProxy() ? 3 : 2; + assertThat("pull body should be populated", + checkSuite.getPullRequests().get(0).getBody(), + equalTo("This is a pretty simple change that we need to pull into master.")); + assertThat("multiple getPullRequests() calls are made, the pull is populated only once", + mockGitHub.getRequestCount(), + lessThanOrEqualTo(expectedRequestCount)); + } + + private GHCheckSuite verifyBasicCheckSuiteEvent(GHEventPayload.CheckSuite event) throws IOException { assertThat(event.getRepository().getName(), is("Hello-World")); assertThat(event.getRepository().getOwner().getLogin(), is("Codertocat")); assertThat(event.getAction(), is("completed")); @@ -445,7 +487,7 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest { assertThat(checkSuite.getAfter(), is("ec26c3e57ca3a959ca5aad62de7213c562f8c821")); assertThat(checkSuite.getLatestCheckRunsCount(), is(1)); assertThat(checkSuite.getCheckRunsUrl().toString(), - is("https://api.github.com/repos/Codertocat/Hello-World/check-suites/118578147/check-runs")); + endsWith("/repos/Codertocat/Hello-World/check-suites/118578147/check-runs")); assertThat(checkSuite.getHeadCommit().getMessage(), is("Update README.md")); assertThat(checkSuite.getHeadCommit().getId(), is("ec26c3e57ca3a959ca5aad62de7213c562f8c821")); assertThat(checkSuite.getHeadCommit().getTreeId(), is("31b122c26a97cf9af023e9ddab94a82c6e77b0ea")); @@ -457,6 +499,11 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest { assertThat(formatter.format(checkSuite.getHeadCommit().getTimestamp()), is("2019-05-15T15:20:30Z")); assertThat(checkSuite.getApp().getId(), is(29310L)); + + assertThat(checkSuite.getPullRequests(), notNullValue()); + assertThat(checkSuite.getPullRequests().size(), equalTo(1)); + assertThat(checkSuite.getPullRequests().get(0).getNumber(), equalTo(2)); + return checkSuite; } @Test diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/repos_codertocat_hello-world_pulls_2-3.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/repos_codertocat_hello-world_pulls_2-3.json new file mode 100644 index 000000000..c2f9a50f4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/repos_codertocat_hello-world_pulls_2-3.json @@ -0,0 +1,329 @@ +{ + "url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2", + "id": 279147437, + "node_id": "MDExOlB1bGxSZXF1ZXN0Mjc5MTQ3NDM3", + "html_url": "https://github.com/Codertocat/Hello-World/pull/2", + "diff_url": "https://github.com/Codertocat/Hello-World/pull/2.diff", + "patch_url": "https://github.com/Codertocat/Hello-World/pull/2.patch", + "issue_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2", + "number": 2, + "state": "closed", + "locked": false, + "title": "Update the README with new information.", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into master.", + "created_at": "2019-05-15T15:20:33Z", + "updated_at": "2020-07-11T10:41:23Z", + "closed_at": "2019-05-15T15:21:18Z", + "merged_at": null, + "merge_commit_sha": "c4295bd74fb0f4fda03689c3df3f2803b658fd85", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/commits", + "review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/comments", + "review_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/comments", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/ec26c3e57ca3a959ca5aad62de7213c562f8c821", + "head": { + "label": "Codertocat:changes", + "ref": "changes", + "sha": "ec26c3e57ca3a959ca5aad62de7213c562f8c821", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 186853002, + "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "private": false, + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2019-05-15T15:19:25Z", + "updated_at": "2020-03-18T18:23:11Z", + "pushed_at": "2019-05-15T15:20:57Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 1, + "stargazers_count": 4, + "watchers_count": 4, + "language": "Ruby", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 2, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 2, + "open_issues": 1, + "watchers": 4, + "default_branch": "master" + } + }, + "base": { + "label": "Codertocat:master", + "ref": "master", + "sha": "f95f852bd8fca8fcc58a9a2d6c842781e32a215e", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 186853002, + "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "private": false, + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2019-05-15T15:19:25Z", + "updated_at": "2020-03-18T18:23:11Z", + "pushed_at": "2019-05-15T15:20:57Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 1, + "stargazers_count": 4, + "watchers_count": 4, + "language": "Ruby", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 2, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 2, + "open_issues": 1, + "watchers": 4, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2" + }, + "html": { + "href": "https://github.com/Codertocat/Hello-World/pull/2" + }, + "issue": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/2" + }, + "comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/statuses/ec26c3e57ca3a959ca5aad62de7213c562f8c821" + } + }, + "author_association": "OWNER", + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": false, + "mergeable_state": "clean", + "merged_by": null, + "comments": 2, + "review_comments": 3, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/user-1.json new file mode 100644 index 000000000..ab7a3f404 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/user-1.json @@ -0,0 +1,46 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": null, + "twitter_username": "bitwiseman", + "public_repos": 197, + "public_gists": 7, + "followers": 164, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-07-30T20:38:23Z", + "private_gists": 19, + "total_private_repos": 13, + "owned_private_repos": 0, + "disk_usage": 33700, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/users_codertocat-2.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/users_codertocat-2.json new file mode 100644 index 000000000..5c9453c4b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/__files/users_codertocat-2.json @@ -0,0 +1,34 @@ +{ + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false, + "name": "Codertocat", + "company": null, + "blog": "", + "location": "Octoverse", + "email": null, + "hireable": null, + "bio": "⚡️ ☕️ ", + "twitter_username": null, + "public_repos": 3, + "public_gists": 0, + "followers": 38, + "following": 0, + "created_at": "2016-08-15T03:51:49Z", + "updated_at": "2020-05-25T00:39:05Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/repos_codertocat_hello-world_pulls_2-3.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/repos_codertocat_hello-world_pulls_2-3.json new file mode 100644 index 000000000..93152212b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/repos_codertocat_hello-world_pulls_2-3.json @@ -0,0 +1,46 @@ +{ + "id": "abca14dd-149a-458c-8aa6-a774c620cc44", + "name": "repos_codertocat_hello-world_pulls_2", + "request": { + "url": "/repos/Codertocat/Hello-World/pulls/2", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.shadow-cat-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_codertocat_hello-world_pulls_2-3.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 31 Jul 2020 21:47:31 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4980", + "X-RateLimit-Reset": "1596235134", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"6f504844c60099cd7bf7576af481d6b8\"", + "Last-Modified": "Sat, 11 Jul 2020 10:41:23 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; param=shadow-cat-preview; format=json", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F660:5BE7:14CF46:300F25:5F249173" + } + }, + "uuid": "abca14dd-149a-458c-8aa6-a774c620cc44", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/user-1.json new file mode 100644 index 000000000..da2d9cc24 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/user-1.json @@ -0,0 +1,46 @@ +{ + "id": "7311a2f2-a7f7-45a8-bd1b-8eaa4dd986d5", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 31 Jul 2020 21:47:31 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4982", + "X-RateLimit-Reset": "1596235134", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"fd90864a27d8465275943fa60d303b11\"", + "Last-Modified": "Thu, 30 Jul 2020 20:38:23 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F660:5BE7:14CF24:300ED5:5F249173" + } + }, + "uuid": "7311a2f2-a7f7-45a8-bd1b-8eaa4dd986d5", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/users_codertocat-2.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/users_codertocat-2.json new file mode 100644 index 000000000..efb210c26 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkRunEvent/mappings/users_codertocat-2.json @@ -0,0 +1,46 @@ +{ + "id": "dda0acac-03c9-444c-8bca-8054f499937e", + "name": "users_codertocat", + "request": { + "url": "/users/Codertocat", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "users_codertocat-2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 31 Jul 2020 21:47:31 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4981", + "X-RateLimit-Reset": "1596235134", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"d13752bbc4a282a7318b1ee3e52f041e\"", + "Last-Modified": "Mon, 25 May 2020 00:39:05 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F660:5BE7:14CF3D:300EDF:5F249173" + } + }, + "uuid": "dda0acac-03c9-444c-8bca-8054f499937e", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/repos_codertocat_hello-world_pulls_2-3.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/repos_codertocat_hello-world_pulls_2-3.json new file mode 100644 index 000000000..c2f9a50f4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/repos_codertocat_hello-world_pulls_2-3.json @@ -0,0 +1,329 @@ +{ + "url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2", + "id": 279147437, + "node_id": "MDExOlB1bGxSZXF1ZXN0Mjc5MTQ3NDM3", + "html_url": "https://github.com/Codertocat/Hello-World/pull/2", + "diff_url": "https://github.com/Codertocat/Hello-World/pull/2.diff", + "patch_url": "https://github.com/Codertocat/Hello-World/pull/2.patch", + "issue_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2", + "number": 2, + "state": "closed", + "locked": false, + "title": "Update the README with new information.", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into master.", + "created_at": "2019-05-15T15:20:33Z", + "updated_at": "2020-07-11T10:41:23Z", + "closed_at": "2019-05-15T15:21:18Z", + "merged_at": null, + "merge_commit_sha": "c4295bd74fb0f4fda03689c3df3f2803b658fd85", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/commits", + "review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/comments", + "review_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/comments", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/ec26c3e57ca3a959ca5aad62de7213c562f8c821", + "head": { + "label": "Codertocat:changes", + "ref": "changes", + "sha": "ec26c3e57ca3a959ca5aad62de7213c562f8c821", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 186853002, + "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "private": false, + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2019-05-15T15:19:25Z", + "updated_at": "2020-03-18T18:23:11Z", + "pushed_at": "2019-05-15T15:20:57Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 1, + "stargazers_count": 4, + "watchers_count": 4, + "language": "Ruby", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 2, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 2, + "open_issues": 1, + "watchers": 4, + "default_branch": "master" + } + }, + "base": { + "label": "Codertocat:master", + "ref": "master", + "sha": "f95f852bd8fca8fcc58a9a2d6c842781e32a215e", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 186853002, + "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "private": false, + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2019-05-15T15:19:25Z", + "updated_at": "2020-03-18T18:23:11Z", + "pushed_at": "2019-05-15T15:20:57Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 1, + "stargazers_count": 4, + "watchers_count": 4, + "language": "Ruby", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 2, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 2, + "open_issues": 1, + "watchers": 4, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2" + }, + "html": { + "href": "https://github.com/Codertocat/Hello-World/pull/2" + }, + "issue": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/2" + }, + "comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/statuses/ec26c3e57ca3a959ca5aad62de7213c562f8c821" + } + }, + "author_association": "OWNER", + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": false, + "mergeable_state": "clean", + "merged_by": null, + "comments": 2, + "review_comments": 3, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/user-1.json new file mode 100644 index 000000000..ab7a3f404 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/user-1.json @@ -0,0 +1,46 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": null, + "twitter_username": "bitwiseman", + "public_repos": 197, + "public_gists": 7, + "followers": 164, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-07-30T20:38:23Z", + "private_gists": 19, + "total_private_repos": 13, + "owned_private_repos": 0, + "disk_usage": 33700, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/users_codertocat-2.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/users_codertocat-2.json new file mode 100644 index 000000000..5c9453c4b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/__files/users_codertocat-2.json @@ -0,0 +1,34 @@ +{ + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false, + "name": "Codertocat", + "company": null, + "blog": "", + "location": "Octoverse", + "email": null, + "hireable": null, + "bio": "⚡️ ☕️ ", + "twitter_username": null, + "public_repos": 3, + "public_gists": 0, + "followers": 38, + "following": 0, + "created_at": "2016-08-15T03:51:49Z", + "updated_at": "2020-05-25T00:39:05Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/repos_codertocat_hello-world_pulls_2-3.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/repos_codertocat_hello-world_pulls_2-3.json new file mode 100644 index 000000000..2ecbc42e0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/repos_codertocat_hello-world_pulls_2-3.json @@ -0,0 +1,46 @@ +{ + "id": "450042f9-be05-4c1c-bc1b-3e8a86a99d81", + "name": "repos_codertocat_hello-world_pulls_2", + "request": { + "url": "/repos/Codertocat/Hello-World/pulls/2", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.shadow-cat-preview+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_codertocat_hello-world_pulls_2-3.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 31 Jul 2020 21:49:55 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4962", + "X-RateLimit-Reset": "1596235134", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"6f504844c60099cd7bf7576af481d6b8\"", + "Last-Modified": "Sat, 11 Jul 2020 10:41:23 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.v3; param=shadow-cat-preview; format=json", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F8DC:246B:17C38A:34AD28:5F249203" + } + }, + "uuid": "450042f9-be05-4c1c-bc1b-3e8a86a99d81", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/user-1.json new file mode 100644 index 000000000..3d794489e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/user-1.json @@ -0,0 +1,46 @@ +{ + "id": "bb8d640f-470f-49f1-8e0e-1a0181669592", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 31 Jul 2020 21:49:54 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4964", + "X-RateLimit-Reset": "1596235133", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"fd90864a27d8465275943fa60d303b11\"", + "Last-Modified": "Thu, 30 Jul 2020 20:38:23 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F8DC:246B:17C362:34ACEF:5F249202" + } + }, + "uuid": "bb8d640f-470f-49f1-8e0e-1a0181669592", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/users_codertocat-2.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/users_codertocat-2.json new file mode 100644 index 000000000..02c4a8d10 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/checkSuiteEvent/mappings/users_codertocat-2.json @@ -0,0 +1,46 @@ +{ + "id": "b29d95ea-fbcf-4efe-84d1-14f729bb4322", + "name": "users_codertocat", + "request": { + "url": "/users/Codertocat", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "users_codertocat-2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 31 Jul 2020 21:49:55 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4963", + "X-RateLimit-Reset": "1596235134", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"d13752bbc4a282a7318b1ee3e52f041e\"", + "Last-Modified": "Mon, 25 May 2020 00:39:05 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F8DC:246B:17C37F:34ACF6:5F249202" + } + }, + "uuid": "b29d95ea-fbcf-4efe-84d1-14f729bb4322", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file