diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 67fca6424..561c89176 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -24,6 +24,7 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; @@ -47,6 +48,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.WeakHashMap; @@ -2158,6 +2160,12 @@ public class GHRepository extends GHObject { if (root.isOffline() && owner != null) { owner.wrapUp(root); } + if (source != null) { + source.wrap(root); + } + if (parent != null) { + parent.wrap(root); + } return this; } @@ -2477,10 +2485,13 @@ public class GHRepository extends GHObject { * @see #getParent() #getParent() */ public GHRepository getSource() throws IOException { - if (source == null) + if (fork && source == null) { + populate(); + } + if (source == null) { return null; - if (source.root == null) - source = root.getRepository(source.getFullName()); + } + return source; } @@ -2495,10 +2506,13 @@ public class GHRepository extends GHObject { * @see #getSource() #getSource() */ public GHRepository getParent() throws IOException { - if (parent == null) + if (fork && parent == null) { + populate(); + } + + if (parent == null) { return null; - if (parent.root == null) - parent = root.getRepository(parent.getFullName()); + } return parent; } @@ -2828,6 +2842,20 @@ public class GHRepository extends GHObject { if (root.isOffline()) return; // can't populate if the root is offline - root.createRequest().withApiUrl(root.getApiUrl() + full_name).fetchInto(this).wrap(root); + final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!"); + + try { + // IMPORTANT: the url for repository records is does not reliably point to the API url. + // There is bug in Push event payloads that returns the wrong url. + // All other occurrences of "url" take the form "https://api.github.com/...". + // For Push event repository records, they take the form "https://github.com/{fullName}". + root.createRequest().setRawUrlPath(url.toString()).fetchInto(this).wrap(root); + } catch (HttpException e) { + if (e.getCause() instanceof JsonParseException) { + root.createRequest().withUrlPath("/repos/" + full_name).fetchInto(this).wrap(root); + } else { + throw e; + } + } } } diff --git a/src/main/java/org/kohsuke/github/GitHubResponse.java b/src/main/java/org/kohsuke/github/GitHubResponse.java index a73f9d801..12a74510f 100644 --- a/src/main/java/org/kohsuke/github/GitHubResponse.java +++ b/src/main/java/org/kohsuke/github/GitHubResponse.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.JsonMappingException; import org.apache.commons.io.IOUtils; @@ -16,6 +17,8 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; @@ -31,6 +34,8 @@ import javax.annotation.Nonnull; */ class GitHubResponse { + private static final Logger LOGGER = Logger.getLogger(GitHubResponse.class.getName()); + private final int statusCode; @Nonnull @@ -83,9 +88,10 @@ class GitHubResponse { inject.addValue(ResponseInfo.class, responseInfo); return GitHubClient.getMappingObjectReader(responseInfo).forType(type).readValue(data); - } catch (JsonMappingException e) { - String message = "Failed to deserialize " + data; - throw new IOException(message, e); + } catch (JsonMappingException | JsonParseException e) { + String message = "Failed to deserialize: " + data; + LOGGER.log(Level.FINE, message); + throw e; } } @@ -108,9 +114,10 @@ class GitHubResponse { String data = responseInfo.getBodyAsString(); try { return GitHubClient.getMappingObjectReader(responseInfo).withValueToUpdate(instance).readValue(data); - } catch (JsonMappingException e) { - String message = "Failed to deserialize " + data; - throw new IOException(message, e); + } catch (JsonMappingException | JsonParseException e) { + String message = "Failed to deserialize: " + data; + LOGGER.log(Level.FINE, message); + throw e; } } @@ -307,6 +314,7 @@ class GitHubResponse { * @throws IOException * if an I/O Exception occurs. */ + @Nonnull String getBodyAsString() throws IOException { InputStreamReader r = null; try { diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 3194dc3b2..b8dd31172 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -7,15 +7,17 @@ import java.text.SimpleDateFormat; import java.util.Collections; import java.util.TimeZone; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; -public class GHEventPayloadTest { +public class GHEventPayloadTest extends AbstractGitHubWireMockTest { @Rule public final PayloadRule payload = new PayloadRule(".json"); + public GHEventPayloadTest() { + useDefaultGitHub = false; + } + @Test public void commit_comment() throws Exception { GHEventPayload.CommitComment event = GitHub.offline() @@ -283,6 +285,70 @@ public class GHEventPayloadTest { assertThat(event.getSender().getLogin(), is("baxterthehacker")); } + @Test + @Payload("push.fork") + public void pushToFork() throws Exception { + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build(); + + GHEventPayload.Push event = GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Push.class); + assertThat(event.getRef(), is("refs/heads/changes")); + assertThat(event.getBefore(), is("85c44b352958bf6d81b74ab8b21920f1d313a287")); + assertThat(event.getHead(), is("1393706f1364742defbc28ba459082630ca979af")); + assertThat(event.isCreated(), is(false)); + assertThat(event.isDeleted(), is(false)); + assertThat(event.isForced(), is(false)); + assertThat(event.getCommits().size(), is(1)); + assertThat(event.getCommits().get(0).getSha(), is("1393706f1364742defbc28ba459082630ca979af")); + assertThat(event.getCommits().get(0).getAuthor().getEmail(), is("bitwiseman@gmail.com")); + assertThat(event.getCommits().get(0).getCommitter().getEmail(), is("bitwiseman@gmail.com")); + assertThat(event.getCommits().get(0).getAdded().size(), is(6)); + assertThat(event.getCommits().get(0).getRemoved().size(), is(0)); + assertThat(event.getCommits().get(0).getModified().size(), is(2)); + assertThat(event.getCommits().get(0).getModified().get(0), + is("src/main/java/org/kohsuke/github/GHLicense.java")); + assertThat(event.getRepository().getName(), is("github-api")); + assertThat(event.getRepository().getOwnerName(), is("hub4j-test-org")); + assertThat(event.getRepository().getUrl().toExternalForm(), is("https://github.com/hub4j-test-org/github-api")); + assertThat(event.getPusher().getName(), is("bitwiseman")); + assertThat(event.getPusher().getEmail(), is("bitwiseman@gmail.com")); + assertThat(event.getSender().getLogin(), is("bitwiseman")); + + assertThat(event.getRepository().isFork(), is(true)); + + // in offliine mode, we should not populate missing fields + assertThat(event.getRepository().getSource(), is(nullValue())); + assertThat(event.getRepository().getParent(), is(nullValue())); + + assertThat(event.getRepository().getUrl().toString(), is("https://github.com/hub4j-test-org/github-api")); + assertThat(event.getRepository().getHttpTransportUrl().toString(), + is("https://github.com/hub4j-test-org/github-api.git")); + + // Test repository populate + event = gitHub.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.Push.class); + assertThat(event.getRepository().getUrl().toString(), is("https://github.com/hub4j-test-org/github-api")); + assertThat(event.getRepository().getHttpTransportUrl(), is("https://github.com/hub4j-test-org/github-api.git")); + + event.getRepository().populate(); + + // After populate the url is fixed to point to the correct API endpoint + assertThat(event.getRepository().getUrl().toString(), + is(mockGitHub.apiServer().baseUrl() + "/repos/hub4j-test-org/github-api")); + assertThat(event.getRepository().getHttpTransportUrl(), is("https://github.com/hub4j-test-org/github-api.git")); + + // ensure that root has been bound after populate + event.getRepository().getSource().getRef("heads/master"); + event.getRepository().getParent().getRef("heads/master"); + + // Source + event = gitHub.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.Push.class); + assertThat(event.getRepository().getSource().getFullName(), is("hub4j/github-api")); + + // Parent + event = gitHub.parseEventPayload(payload.asReader(mockGitHub::mapToMockGitHub), GHEventPayload.Push.class); + assertThat(event.getRepository().getParent().getFullName(), is("hub4j/github-api")); + + } + // TODO implement support classes and write test // @Test // public void release() throws Exception {} diff --git a/src/test/java/org/kohsuke/github/GHRateLimitTest.java b/src/test/java/org/kohsuke/github/GHRateLimitTest.java index 1a877dd8a..32b9ceba1 100644 --- a/src/test/java/org/kohsuke/github/GHRateLimitTest.java +++ b/src/test/java/org/kohsuke/github/GHRateLimitTest.java @@ -340,9 +340,8 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest { fail("Invalid rate limit missing some records should throw"); } catch (Exception e) { assertThat(e, instanceOf(HttpException.class)); - assertThat(e.getCause(), instanceOf(IOException.class)); - assertThat(e.getCause().getCause(), instanceOf(ValueInstantiationException.class)); - assertThat(e.getCause().getCause().getMessage(), + assertThat(e.getCause(), instanceOf(ValueInstantiationException.class)); + assertThat(e.getCause().getMessage(), containsString( "Cannot construct instance of `org.kohsuke.github.GHRateLimit`, problem: `java.lang.NullPointerException`")); } @@ -352,9 +351,8 @@ public class GHRateLimitTest extends AbstractGitHubWireMockTest { fail("Invalid rate limit record missing a value should throw"); } catch (Exception e) { assertThat(e, instanceOf(HttpException.class)); - assertThat(e.getCause(), instanceOf(IOException.class)); - assertThat(e.getCause().getCause(), instanceOf(MismatchedInputException.class)); - assertThat(e.getCause().getCause().getMessage(), + assertThat(e.getCause(), instanceOf(MismatchedInputException.class)); + assertThat(e.getCause().getMessage(), containsString("Missing required creator property 'reset' (index 2)")); } diff --git a/src/test/java/org/kohsuke/github/PayloadRule.java b/src/test/java/org/kohsuke/github/PayloadRule.java index 063441ccc..c12a5ff45 100644 --- a/src/test/java/org/kohsuke/github/PayloadRule.java +++ b/src/test/java/org/kohsuke/github/PayloadRule.java @@ -10,7 +10,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.io.StringReader; import java.nio.charset.Charset; +import java.util.function.Function; + +import javax.annotation.Nonnull; /** * @author Stephen Connolly @@ -79,6 +83,11 @@ public class PayloadRule implements TestRule { return new InputStreamReader(asInputStream(), Charset.defaultCharset()); } + public Reader asReader(@Nonnull Function transformer) throws IOException { + String payloadString = asString(); + return new StringReader(transformer.apply(payloadString)); + } + public Reader asReader(String encoding) throws IOException { return new InputStreamReader(asInputStream(), encoding); } diff --git a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java index e0652f3aa..bc945f099 100644 --- a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java @@ -1,14 +1,12 @@ package org.kohsuke.github.junit; import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.FileSource; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.extension.Parameters; import com.github.tomakehurst.wiremock.extension.ResponseTransformer; import com.github.tomakehurst.wiremock.http.*; import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; -import com.github.tomakehurst.wiremock.verification.*; import com.google.gson.*; import java.io.File; @@ -20,6 +18,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import javax.annotation.Nonnull; + import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.common.Gzip.unGzipToString; @@ -264,6 +264,24 @@ public class GitHubWireMockRule extends WireMockMultiServerRule { return targetPath; } + @Nonnull + public String mapToMockGitHub(String body) { + body = body.replace("https://api.github.com", this.apiServer().baseUrl()); + + if (this.rawServer() != null) { + body = body.replace("https://raw.githubusercontent.com", this.rawServer().baseUrl()); + } else { + body = body.replace("https://raw.githubusercontent.com", this.apiServer().baseUrl() + "/raw"); + } + + if (this.uploadsServer() != null) { + body = body.replace("https://uploads.github.com", this.uploadsServer().baseUrl()); + } else { + body = body.replace("https://uploads.github.com", this.apiServer().baseUrl() + "/uploads"); + } + return body; + } + /** * A number of modifications are needed as runtime to make responses target the WireMock server and not accidentally * switch to using the live github servers. @@ -286,19 +304,7 @@ public class GitHubWireMockRule extends WireMockMultiServerRule { String body; body = getBodyAsString(response, headers); - body = body.replace("https://api.github.com", rule.apiServer().baseUrl()); - - if (rule.rawServer() != null) { - body = body.replace("https://raw.githubusercontent.com", rule.rawServer().baseUrl()); - } else { - body = body.replace("https://raw.githubusercontent.com", rule.apiServer().baseUrl() + "/raw"); - } - - if (rule.uploadsServer() != null) { - body = body.replace("https://uploads.github.com", rule.uploadsServer().baseUrl()); - } else { - body = body.replace("https://uploads.github.com", rule.apiServer().baseUrl() + "/uploads"); - } + body = rule.mapToMockGitHub(body); builder.body(body); diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/push.fork.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/push.fork.json new file mode 100644 index 000000000..e6ceee11a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/push.fork.json @@ -0,0 +1,195 @@ +{ + "ref": "refs/heads/changes", + "before": "85c44b352958bf6d81b74ab8b21920f1d313a287", + "after": "1393706f1364742defbc28ba459082630ca979af", + "repository": { + "id": 206888201, + "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=", + "name": "github-api", + "full_name": "hub4j-test-org/github-api", + "private": false, + "owner": { + "name": "hub4j-test-org", + "email": null, + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/github-api", + "description": "Tricky", + "fork": true, + "url": "https://github.com/hub4j-test-org/github-api", + "forks_url": "https://api.github.com/repos/hub4j-test-org/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api/deployments", + "created_at": 1567812364, + "updated_at": "2020-01-16T21:22:56Z", + "pushed_at": 1589991763, + "git_url": "git://github.com/hub4j-test-org/github-api.git", + "ssh_url": "git@github.com:hub4j-test-org/github-api.git", + "clone_url": "https://github.com/hub4j-test-org/github-api.git", + "svn_url": "https://github.com/hub4j-test-org/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 11414, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 0, + "open_issues": 5, + "watchers": 0, + "default_branch": "master", + "stargazers": 0, + "master_branch": "master", + "organization": "hub4j-test-org" + }, + "pusher": { + "name": "bitwiseman", + "email": "bitwiseman@gmail.com" + }, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "url": "https://api.github.com/orgs/hub4j-test-org", + "repos_url": "https://api.github.com/orgs/hub4j-test-org/repos", + "events_url": "https://api.github.com/orgs/hub4j-test-org/events", + "hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks", + "issues_url": "https://api.github.com/orgs/hub4j-test-org/issues", + "members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}", + "public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "description": null + }, + "sender": { + "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 + }, + "created": false, + "deleted": false, + "forced": false, + "base_ref": null, + "compare": "https://github.com/hub4j-test-org/github-api/compare/85c44b352958...1393706f1364", + "commits": [{ + "id": "1393706f1364742defbc28ba459082630ca979af", + "tree_id": "ebd431dfee05235fee0d292308a0f51bfed74333", + "distinct": true, + "message": "Prevent NPE when accessing description for license\n\nWhen license can be identified, the description will be null. So will the url.\nTht means that url cannot be converted to string.\n\nFixes #800 .", + "timestamp": "2020-05-19T17:06:59-07:00", + "url": "https://github.com/hub4j-test-org/github-api/commit/1393706f1364742defbc28ba459082630ca979af", + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "username": "bitwiseman" + }, + "committer": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "username": "bitwiseman" + }, + "added": ["src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/__files/repos_bndtools_bnd-2.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/__files/repos_bndtools_bnd_license-3.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/__files/user-1.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/mappings/repos_bndtools_bnd-2.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/mappings/repos_bndtools_bnd_license-3.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/mappings/user-1.json"], + "removed": [], + "modified": ["src/main/java/org/kohsuke/github/GHLicense.java", "src/test/java/org/kohsuke/github/GHLicenseTest.java"] + }], + "head_commit": { + "id": "1393706f1364742defbc28ba459082630ca979af", + "tree_id": "ebd431dfee05235fee0d292308a0f51bfed74333", + "distinct": true, + "message": "Prevent NPE when accessing description for license\n\nWhen license can be identified, the description will be null. So will the url.\nTht means that url cannot be converted to string.\n\nFixes #800 .", + "timestamp": "2020-05-19T17:06:59-07:00", + "url": "https://github.com/hub4j-test-org/github-api/commit/1393706f1364742defbc28ba459082630ca979af", + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "username": "bitwiseman" + }, + "committer": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "username": "bitwiseman" + }, + "added": ["src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/__files/repos_bndtools_bnd-2.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/__files/repos_bndtools_bnd_license-3.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/__files/user-1.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/mappings/repos_bndtools_bnd-2.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/mappings/repos_bndtools_bnd_license-3.json", "src/test/resources/org/kohsuke/github/GHLicenseTest/wiremock/checkRepositoryLicenseForIndeterminate/mappings/user-1.json"], + "removed": [], + "modified": ["src/main/java/org/kohsuke/github/GHLicense.java", "src/test/java/org/kohsuke/github/GHLicenseTest.java"] + } +} diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/repos_hub4j-test-org_github-api-2.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/repos_hub4j-test-org_github-api-2.json new file mode 100644 index 000000000..194a6c042 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/repos_hub4j-test-org_github-api-2.json @@ -0,0 +1,332 @@ +{ + "id": 206888201, + "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=", + "name": "github-api", + "full_name": "hub4j-test-org/github-api", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/github-api", + "description": "Tricky", + "fork": true, + "url": "https://api.github.com/repos/hub4j-test-org/github-api", + "forks_url": "https://api.github.com/repos/hub4j-test-org/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api/deployments", + "created_at": "2019-09-06T23:26:04Z", + "updated_at": "2020-01-16T21:22:56Z", + "pushed_at": "2020-05-20T16:22:43Z", + "git_url": "git://github.com/hub4j-test-org/github-api.git", + "ssh_url": "git@github.com:hub4j-test-org/github-api.git", + "clone_url": "https://github.com/hub4j-test-org/github-api.git", + "svn_url": "https://github.com/hub4j-test-org/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 19035, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 0, + "open_issues": 5, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "hub4j/github-api", + "private": false, + "owner": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/hub4j/github-api", + "forks_url": "https://api.github.com/repos/hub4j/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2020-05-20T00:25:18Z", + "pushed_at": "2020-05-20T00:25:15Z", + "git_url": "git://github.com/hub4j/github-api.git", + "ssh_url": "git@github.com:hub4j/github-api.git", + "clone_url": "https://github.com/hub4j/github-api.git", + "svn_url": "https://github.com/hub4j/github-api", + "homepage": "https://github-api.kohsuke.org/", + "size": 23100, + "stargazers_count": 655, + "watchers_count": 655, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 478, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 67, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 478, + "open_issues": 67, + "watchers": 655, + "default_branch": "master" + }, + "source": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "hub4j/github-api", + "private": false, + "owner": { + "login": "hub4j", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j", + "html_url": "https://github.com/hub4j", + "followers_url": "https://api.github.com/users/hub4j/followers", + "following_url": "https://api.github.com/users/hub4j/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j/orgs", + "repos_url": "https://api.github.com/users/hub4j/repos", + "events_url": "https://api.github.com/users/hub4j/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/hub4j/github-api", + "forks_url": "https://api.github.com/repos/hub4j/github-api/forks", + "keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j/github-api/teams", + "hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j/github-api/events", + "assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j/github-api/tags", + "blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j/github-api/languages", + "stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription", + "commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j/github-api/merges", + "archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads", + "issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2020-05-20T00:25:18Z", + "pushed_at": "2020-05-20T00:25:15Z", + "git_url": "git://github.com/hub4j/github-api.git", + "ssh_url": "git@github.com:hub4j/github-api.git", + "clone_url": "https://github.com/hub4j/github-api.git", + "svn_url": "https://github.com/hub4j/github-api", + "homepage": "https://github-api.kohsuke.org/", + "size": 23100, + "stargazers_count": 655, + "watchers_count": 655, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 478, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 67, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 478, + "open_issues": 67, + "watchers": 655, + "default_branch": "master" + }, + "network_count": 478, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/repos_hub4j_github-api_git_refs_heads_master-3.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/repos_hub4j_github-api_git_refs_heads_master-3.json new file mode 100644 index 000000000..aa53adf4d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/repos_hub4j_github-api_git_refs_heads_master-3.json @@ -0,0 +1,10 @@ +{ + "ref": "refs/heads/master", + "node_id": "MDM6UmVmNjE3MjEwOnJlZnMvaGVhZHMvbWFzdGVy", + "url": "https://api.github.com/repos/hub4j/github-api/git/refs/heads/master", + "object": { + "sha": "ba12efea9d8604cad5c174620628aceb1fe224fb", + "type": "commit", + "url": "https://api.github.com/repos/hub4j/github-api/git/commits/ba12efea9d8604cad5c174620628aceb1fe224fb" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/user-1.json new file mode 100644 index 000000000..e4fc4d865 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/__files/user-1.json @@ -0,0 +1,45 @@ +{ + "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": "https://twitter.com/bitwiseman", + "public_repos": 183, + "public_gists": 7, + "followers": 159, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-05-20T16:02:42Z", + "private_gists": 19, + "total_private_repos": 12, + "owned_private_repos": 0, + "disk_usage": 33697, + "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/pushToFork/mappings/repos_hub4j-test-org_github-api-2.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/repos_hub4j-test-org_github-api-2.json new file mode 100644 index 000000000..e3d32d748 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/repos_hub4j-test-org_github-api-2.json @@ -0,0 +1,47 @@ +{ + "id": "90aa0017-3f50-4829-bda4-6531fbcfba60", + "name": "repos_hub4j-test-org_github-api", + "request": { + "url": "/repos/hub4j-test-org/github-api", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_github-api-2.json", + "headers": { + "Date": "Wed, 20 May 2020 20:11:32 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4997", + "X-RateLimit-Reset": "1590009090", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "ETag": "W/\"c8baf5cd9feb904ed7ded78b091ebdf0\"", + "Last-Modified": "Thu, 16 Jan 2020 21:22:56 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": "repo", + "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": "DAE4:7DBC:8D513:A9FF1:5EC58EF3" + } + }, + "uuid": "90aa0017-3f50-4829-bda4-6531fbcfba60", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/repos_hub4j_github-api_git_refs_heads_master-3.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/repos_hub4j_github-api_git_refs_heads_master-3.json new file mode 100644 index 000000000..28e044682 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/repos_hub4j_github-api_git_refs_heads_master-3.json @@ -0,0 +1,48 @@ +{ + "id": "79569c1e-168b-4816-930b-1ac370e164b9", + "name": "repos_hub4j_github-api_git_refs_heads_master", + "request": { + "url": "/repos/hub4j/github-api/git/refs/heads/master", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j_github-api_git_refs_heads_master-3.json", + "headers": { + "Date": "Thu, 21 May 2020 01:53:46 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4998", + "X-RateLimit-Reset": "1590029625", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "ETag": "W/\"26677f2557ca0b327908d0e7832aea69\"", + "Last-Modified": "Wed, 20 May 2020 22:54:46 GMT", + "X-Poll-Interval": "300", + "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": "repo", + "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": "C6EA:403C:271AF9:2E9847:5EC5DF2A" + } + }, + "uuid": "79569c1e-168b-4816-930b-1ac370e164b9", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/user-1.json new file mode 100644 index 000000000..b87ed5ba4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/wiremock/pushToFork/mappings/user-1.json @@ -0,0 +1,47 @@ +{ + "id": "e3214167-ee78-4bb4-b7d9-efec0dbe2c5f", + "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": { + "Date": "Wed, 20 May 2020 20:11:31 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4998", + "X-RateLimit-Reset": "1590009090", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "ETag": "W/\"12430b620554d3ea3486a0972ee86bc8\"", + "Last-Modified": "Wed, 20 May 2020 16:02:42 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": "DAE4:7DBC:8D4A6:A9FDF:5EC58EF2" + } + }, + "uuid": "e3214167-ee78-4bb4-b7d9-efec0dbe2c5f", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file