From 2af4f6188268e8216fd2d7e10a95eb6dda4c9062 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 18 Nov 2019 11:35:45 -0800 Subject: [PATCH 1/5] Cleanup imports --- pom.xml | 87 +++++++++++-------- .../java/org/kohsuke/github/DeleteToken.java | 3 +- .../github/GHAppCreateTokenBuilder.java | 4 +- .../kohsuke/github/GHBranchProtection.java | 4 +- src/main/java/org/kohsuke/github/GHEvent.java | 50 +++++++++-- .../github/GHFileNotFoundException.java | 3 +- .../org/kohsuke/github/GHIOException.java | 3 +- src/main/java/org/kohsuke/github/GHIssue.java | 51 ++++++----- .../java/org/kohsuke/github/GHObject.java | 3 +- .../org/kohsuke/github/GHOrganization.java | 1 + .../org/kohsuke/github/GHPullRequest.java | 47 ++++++---- .../kohsuke/github/GHPullRequestReview.java | 5 +- .../github/GHPullRequestReviewComment.java | 1 + .../java/org/kohsuke/github/GHRateLimit.java | 3 +- .../java/org/kohsuke/github/GHRepository.java | 4 - .../github/GHRepositoryStatistics.java | 1 + src/main/java/org/kohsuke/github/GitHub.java | 5 +- .../org/kohsuke/github/HttpException.java | 3 +- .../java/org/kohsuke/github/Refreshable.java | 3 - .../java/org/kohsuke/github/Requester.java | 19 ++-- .../example/dataobject/ReadOnlyObjects.java | 11 ++- .../github/extras/OkHttpConnector.java | 4 - .../extras/okhttp3/ObsoleteUrlFactory.java | 44 +++++----- .../extras/okhttp3/OkHttpConnector.java | 4 +- src/test/java/org/kohsuke/HookApp.java | 4 +- .../github/AbstractGitHubApiTestBase.java | 9 -- src/test/java/org/kohsuke/github/AppTest.java | 2 - .../java/org/kohsuke/github/GHAppTest.java | 6 +- .../github/GHBranchProtectionTest.java | 11 ++- .../github/GHContentIntegrationTest.java | 4 +- .../org/kohsuke/github/GHDeploymentTest.java | 1 + .../kohsuke/github/GHEventPayloadTest.java | 44 +++++----- .../org/kohsuke/github/GHGistUpdaterTest.java | 11 ++- .../java/org/kohsuke/github/GHHookTest.java | 5 +- .../org/kohsuke/github/GHIssueEventTest.java | 3 +- .../kohsuke/github/GHOrganizationTest.java | 11 ++- .../org/kohsuke/github/GHPullRequestTest.java | 43 ++++++--- .../org/kohsuke/github/GHRateLimitTest.java | 6 -- .../org/kohsuke/github/GHRepositoryTest.java | 19 ++-- .../java/org/kohsuke/github/GHTeamTest.java | 1 - .../java/org/kohsuke/github/GistTest.java | 2 - .../org/kohsuke/github/GitHubStaticTest.java | 2 - .../java/org/kohsuke/github/GitHubTest.java | 6 +- .../org/kohsuke/github/Github2faTest.java | 4 +- .../org/kohsuke/github/LifecycleTest.java | 29 +++++-- .../java/org/kohsuke/github/PayloadRule.java | 13 +-- .../kohsuke/github/RepositoryMockTest.java | 2 +- .../kohsuke/github/RepositoryTrafficTest.java | 6 +- .../github/WireMockStatusReporterTest.java | 14 +-- .../github/extras/OkHttpConnectorTest.java | 3 +- .../extras/okhttp3/OkHttpConnectorTest.java | 15 ++-- .../github/junit/GitHubWireMockRule.java | 28 +++--- .../github/junit/WireMockMultiServerRule.java | 3 +- .../kohsuke/github/junit/WireMockRule.java | 20 +---- 54 files changed, 404 insertions(+), 286 deletions(-) diff --git a/pom.xml b/pom.xml index 7b3feb66a4..34b8eb50f3 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ 4.2.2 2.4.1 format + sort .80 0.20 0.50 @@ -181,6 +182,23 @@ + + net.revelc.code + impsort-maven-plugin + 1.3.2 + + *,java.,javax. + true + true + + + + + ${impsort-maven-plugin.goal} + + + + com.github.spotbugs spotbugs-maven-plugin @@ -359,6 +377,7 @@ ci validate + check @@ -406,44 +425,44 @@ - - - - + + + + METHOD COVEREDRATIO ${jacoco.coverage.target.method} - - - - - + + + + + org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.** @@ -461,7 +480,7 @@ - release + release diff --git a/src/main/java/org/kohsuke/github/DeleteToken.java b/src/main/java/org/kohsuke/github/DeleteToken.java index ebef1967f8..30079d0a21 100644 --- a/src/main/java/org/kohsuke/github/DeleteToken.java +++ b/src/main/java/org/kohsuke/github/DeleteToken.java @@ -28,7 +28,8 @@ /** * @author Kohsuke Kawaguchi */ -@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "Being constructed by JSON deserialization") +@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", + justification = "Being constructed by JSON deserialization") class DeleteToken { public String delete_token; } diff --git a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java index 43291820b7..29830425ba 100644 --- a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java +++ b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java @@ -55,7 +55,9 @@ public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) { @Preview @Deprecated public GHAppInstallationToken create() throws IOException { - return builder.method("POST").withPreview(MACHINE_MAN).to(apiUrlTail, GHAppInstallationToken.class) + return builder.method("POST") + .withPreview(MACHINE_MAN) + .to(apiUrlTail, GHAppInstallationToken.class) .wrapUp(root); } diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java index 80a5e7bb4e..d434c4039f 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtection.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java @@ -3,11 +3,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import static org.kohsuke.github.Previews.ZZZAX; - import java.io.IOException; import java.util.Collection; +import static org.kohsuke.github.Previews.ZZZAX; + /** * The type GHBranchProtection. */ diff --git a/src/main/java/org/kohsuke/github/GHEvent.java b/src/main/java/org/kohsuke/github/GHEvent.java index 7d92543449..c82584096a 100644 --- a/src/main/java/org/kohsuke/github/GHEvent.java +++ b/src/main/java/org/kohsuke/github/GHEvent.java @@ -10,12 +10,50 @@ * @see Event type reference */ public enum GHEvent { - COMMIT_COMMENT, CREATE, DELETE, DEPLOYMENT, DEPLOYMENT_STATUS, DOWNLOAD, FOLLOW, FORK, FORK_APPLY, GIST, GOLLUM, INSTALLATION, INSTALLATION_REPOSITORIES, INTEGRATION_INSTALLATION_REPOSITORIES, CHECK_SUITE, ISSUE_COMMENT, ISSUES, LABEL, MARKETPLACE_PURCHASE, MEMBER, MEMBERSHIP, MILESTONE, ORGANIZATION, ORG_BLOCK, PAGE_BUILD, PROJECT_CARD, PROJECT_COLUMN, PROJECT, PUBLIC, PULL_REQUEST, PULL_REQUEST_REVIEW, PULL_REQUEST_REVIEW_COMMENT, PUSH, RELEASE, REPOSITORY, // only - // valid - // for - // org - // hooks - STATUS, TEAM, TEAM_ADD, WATCH, PING, + COMMIT_COMMENT, + CREATE, + DELETE, + DEPLOYMENT, + DEPLOYMENT_STATUS, + DOWNLOAD, + FOLLOW, + FORK, + FORK_APPLY, + GIST, + GOLLUM, + INSTALLATION, + INSTALLATION_REPOSITORIES, + INTEGRATION_INSTALLATION_REPOSITORIES, + CHECK_SUITE, + ISSUE_COMMENT, + ISSUES, + LABEL, + MARKETPLACE_PURCHASE, + MEMBER, + MEMBERSHIP, + MILESTONE, + ORGANIZATION, + ORG_BLOCK, + PAGE_BUILD, + PROJECT_CARD, + PROJECT_COLUMN, + PROJECT, + PUBLIC, + PULL_REQUEST, + PULL_REQUEST_REVIEW, + PULL_REQUEST_REVIEW_COMMENT, + PUSH, + RELEASE, + REPOSITORY, // only + // valid + // for + // org + // hooks + STATUS, + TEAM, + TEAM_ADD, + WATCH, + PING, /** * Special event type that means "every possible event" */ diff --git a/src/main/java/org/kohsuke/github/GHFileNotFoundException.java b/src/main/java/org/kohsuke/github/GHFileNotFoundException.java index 4db5b5b05f..6475515929 100644 --- a/src/main/java/org/kohsuke/github/GHFileNotFoundException.java +++ b/src/main/java/org/kohsuke/github/GHFileNotFoundException.java @@ -1,11 +1,12 @@ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.FileNotFoundException; import java.net.HttpURLConnection; import java.util.List; import java.util.Map; +import javax.annotation.CheckForNull; + /** * Request/responce contains useful metadata. Custom exception allows store info for next diagnostics. * diff --git a/src/main/java/org/kohsuke/github/GHIOException.java b/src/main/java/org/kohsuke/github/GHIOException.java index bb792ec1aa..b385968674 100644 --- a/src/main/java/org/kohsuke/github/GHIOException.java +++ b/src/main/java/org/kohsuke/github/GHIOException.java @@ -1,11 +1,12 @@ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.HttpURLConnection; import java.util.List; import java.util.Map; +import javax.annotation.CheckForNull; + /** * Request/responce contains useful metadata. Custom exception allows store info for next diagnostics. * diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 71a95639e1..ec0620d08f 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -24,10 +24,9 @@ package org.kohsuke.github; -import static org.kohsuke.github.Previews.SQUIRREL_GIRL; - import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.IOException; import java.net.URL; import java.util.ArrayList; @@ -35,10 +34,10 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; -import java.util.HashSet; import java.util.List; import java.util.Locale; -import java.util.Set; + +import static org.kohsuke.github.Previews.SQUIRREL_GIRL; /** * Represents an issue on GitHub. @@ -179,7 +178,7 @@ public Collection getLabels() throws IOException { if (labels == null) { return Collections.emptyList(); } - return Collections. unmodifiableList(labels); + return Collections.unmodifiableList(labels); } /** @@ -231,8 +230,8 @@ public void unlock() throws IOException { */ @WithBridgeMethods(void.class) public GHIssueComment comment(String message) throws IOException { - GHIssueComment r = new Requester(root).with("body", message).to(getIssuesApiRoute() + "/comments", - GHIssueComment.class); + GHIssueComment r = new Requester(root).with("body", message) + .to(getIssuesApiRoute() + "/comments", GHIssueComment.class); return r.wrapUp(this); } @@ -443,22 +442,27 @@ public List getComments() throws IOException { * the io exception */ public PagedIterable listComments() throws IOException { - return root.retrieve().asPagedIterable(getIssuesApiRoute() + "/comments", GHIssueComment[].class, - item -> item.wrapUp(GHIssue.this)); + return root.retrieve() + .asPagedIterable(getIssuesApiRoute() + "/comments", + GHIssueComment[].class, + item -> item.wrapUp(GHIssue.this)); } @Preview @Deprecated public GHReaction createReaction(ReactionContent content) throws IOException { - return new Requester(owner.root).withPreview(SQUIRREL_GIRL).with("content", content.getContent()) - .to(getApiRoute() + "/reactions", GHReaction.class).wrap(root); + return new Requester(owner.root).withPreview(SQUIRREL_GIRL) + .with("content", content.getContent()) + .to(getApiRoute() + "/reactions", GHReaction.class) + .wrap(root); } @Preview @Deprecated public PagedIterable listReactions() { - return owner.root.retrieve().withPreview(SQUIRREL_GIRL).asPagedIterable(getApiRoute() + "/reactions", - GHReaction[].class, item -> item.wrap(owner.root)); + return owner.root.retrieve() + .withPreview(SQUIRREL_GIRL) + .asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root)); } /** @@ -482,8 +486,10 @@ public void addAssignees(GHUser... assignees) throws IOException { * the io exception */ public void addAssignees(Collection assignees) throws IOException { - root.retrieve().method("POST").with(ASSIGNEES, getLogins(assignees)).to(getIssuesApiRoute() + "/assignees", - this); + root.retrieve() + .method("POST") + .with(ASSIGNEES, getLogins(assignees)) + .to(getIssuesApiRoute() + "/assignees", this); } /** @@ -531,7 +537,10 @@ public void removeAssignees(GHUser... assignees) throws IOException { * the io exception */ public void removeAssignees(Collection assignees) throws IOException { - root.retrieve().method("DELETE").with(ASSIGNEES, getLogins(assignees)).inBody() + root.retrieve() + .method("DELETE") + .with(ASSIGNEES, getLogins(assignees)) + .inBody() .to(getIssuesApiRoute() + "/assignees", this); } @@ -645,8 +654,8 @@ public GHMilestone getMilestone() { /** * The type PullRequest. */ - @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", - "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" }, + justification = "JSON API") public static class PullRequest { private String diff_url, patch_url, html_url; @@ -694,7 +703,9 @@ protected static List getLogins(Collection users) { * the io exception */ public PagedIterable listEvents() throws IOException { - return root.retrieve().asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)), - GHIssueEvent[].class, item -> item.wrapUp(GHIssue.this)); + return root.retrieve() + .asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)), + GHIssueEvent[].class, + item -> item.wrapUp(GHIssue.this)); } } diff --git a/src/main/java/org/kohsuke/github/GHObject.java b/src/main/java/org/kohsuke/github/GHObject.java index a2893c2e12..ae7fd8b51a 100644 --- a/src/main/java/org/kohsuke/github/GHObject.java +++ b/src/main/java/org/kohsuke/github/GHObject.java @@ -5,7 +5,6 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import javax.annotation.CheckForNull; import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; @@ -13,6 +12,8 @@ import java.util.List; import java.util.Map; +import javax.annotation.CheckForNull; + /** * Most (all?) domain objects in GitHub seems to have these 4 properties. */ diff --git a/src/main/java/org/kohsuke/github/GHOrganization.java b/src/main/java/org/kohsuke/github/GHOrganization.java index c7edefdb41..390f7b4b9a 100644 --- a/src/main/java/org/kohsuke/github/GHOrganization.java +++ b/src/main/java/org/kohsuke/github/GHOrganization.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; + import static org.kohsuke.github.Previews.INERTIA; /** diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 831309b883..f8a9bb4bc7 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -23,7 +23,6 @@ */ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.URL; import java.util.ArrayList; @@ -33,6 +32,8 @@ import java.util.Date; import java.util.List; +import javax.annotation.CheckForNull; + import static org.kohsuke.github.Previews.SHADOW_CAT; /** @@ -392,8 +393,8 @@ public void refresh() throws IOException { * @return the paged iterable */ public PagedIterable listFiles() { - return root.retrieve().asPagedIterable(String.format("%s/files", getApiRoute()), - GHPullRequestFileDetail[].class, null); + return root.retrieve() + .asPagedIterable(String.format("%s/files", getApiRoute()), GHPullRequestFileDetail[].class, null); } /** @@ -402,8 +403,10 @@ public PagedIterable listFiles() { * @return the paged iterable */ public PagedIterable listReviews() { - return root.retrieve().asPagedIterable(String.format("%s/reviews", getApiRoute()), GHPullRequestReview[].class, - item -> item.wrapUp(GHPullRequest.this)); + return root.retrieve() + .asPagedIterable(String.format("%s/reviews", getApiRoute()), + GHPullRequestReview[].class, + item -> item.wrapUp(GHPullRequest.this)); } /** @@ -414,8 +417,10 @@ public PagedIterable listReviews() { * the io exception */ public PagedIterable listReviewComments() throws IOException { - return root.retrieve().asPagedIterable(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment[].class, - item -> item.wrapUp(GHPullRequest.this)); + return root.retrieve() + .asPagedIterable(getApiRoute() + COMMENTS_ACTION, + GHPullRequestReviewComment[].class, + item -> item.wrapUp(GHPullRequest.this)); } /** @@ -424,8 +429,10 @@ public PagedIterable listReviewComments() throws IOE * @return the paged iterable */ public PagedIterable listCommits() { - return root.retrieve().asPagedIterable(String.format("%s/commits", getApiRoute()), - GHPullRequestCommitDetail[].class, item -> item.wrapUp(GHPullRequest.this)); + return root.retrieve() + .asPagedIterable(String.format("%s/commits", getApiRoute()), + GHPullRequestCommitDetail[].class, + item -> item.wrapUp(GHPullRequest.this)); } /** @@ -442,7 +449,8 @@ public PagedIterable listCommits() { * the io exception * @deprecated Use {@link #createReview()} */ - public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, + public GHPullRequestReview createReview(String body, + @CheckForNull GHPullRequestReviewState event, GHPullRequestReviewComment... comments) throws IOException { return createReview(body, event, Arrays.asList(comments)); } @@ -461,7 +469,8 @@ public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequest * the io exception * @deprecated Use {@link #createReview()} */ - public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, + public GHPullRequestReview createReview(String body, + @CheckForNull GHPullRequestReviewState event, List comments) throws IOException { GHPullRequestReviewBuilder b = createReview().body(body); for (GHPullRequestReviewComment c : comments) { @@ -496,8 +505,12 @@ public GHPullRequestReviewBuilder createReview() { */ public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position) throws IOException { - return new Requester(root).method("POST").with("body", body).with("commit_id", sha).with("path", path) - .with("position", position).to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class) + return new Requester(root).method("POST") + .with("body", body) + .with("commit_id", sha) + .with("path", path) + .with("position", position) + .to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class) .wrapUp(this); } @@ -510,7 +523,8 @@ public GHPullRequestReviewComment createReviewComment(String body, String sha, S * the io exception */ public void requestReviewers(List reviewers) throws IOException { - new Requester(root).method("POST").with("reviewers", getLogins(reviewers)) + new Requester(root).method("POST") + .with("reviewers", getLogins(reviewers)) .to(getApiRoute() + REQUEST_REVIEWERS); } @@ -575,7 +589,10 @@ public void merge(String msg, String sha) throws IOException { * the io exception */ public void merge(String msg, String sha, MergeMethod method) throws IOException { - new Requester(root).method("PUT").with("commit_message", msg).with("sha", sha).with("merge_method", method) + new Requester(root).method("PUT") + .with("commit_message", msg) + .with("sha", sha) + .with("merge_method", method) .to(getApiRoute() + "/merge"); } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReview.java b/src/main/java/org/kohsuke/github/GHPullRequestReview.java index 6dc1ee359d..65a29d33a7 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReview.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReview.java @@ -25,10 +25,11 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Date; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.URL; +import java.util.Date; + +import javax.annotation.CheckForNull; /** * Review to a pull request. diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java b/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java index e1e6a1cf72..74f9dd8d02 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.net.URL; + import javax.annotation.CheckForNull; import static org.kohsuke.github.Previews.*; diff --git a/src/main/java/org/kohsuke/github/GHRateLimit.java b/src/main/java/org/kohsuke/github/GHRateLimit.java index 08e2cfa539..00d788b295 100644 --- a/src/main/java/org/kohsuke/github/GHRateLimit.java +++ b/src/main/java/org/kohsuke/github/GHRateLimit.java @@ -5,7 +5,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; -import javax.annotation.Nonnull; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; @@ -13,6 +12,8 @@ import java.util.Objects; import java.util.logging.Logger; +import javax.annotation.Nonnull; + import static java.util.logging.Level.FINEST; /** diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 7588034288..58047b3429 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -24,9 +24,6 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; @@ -54,7 +51,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.WeakHashMap; -import java.util.NoSuchElementException; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java b/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java index 6edeb733cf..043a585f15 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.IOException; import java.io.InputStream; import java.net.URL; diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index a6918e4b63..4ef0782f4c 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -32,8 +32,6 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; @@ -46,6 +44,9 @@ import java.util.function.Supplier; import java.util.logging.Logger; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; diff --git a/src/main/java/org/kohsuke/github/HttpException.java b/src/main/java/org/kohsuke/github/HttpException.java index 8367fbe576..df29f269dd 100644 --- a/src/main/java/org/kohsuke/github/HttpException.java +++ b/src/main/java/org/kohsuke/github/HttpException.java @@ -1,10 +1,11 @@ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import javax.annotation.CheckForNull; + /** * {@link IOException} for http exceptions because {@link HttpURLConnection} throws un-discerned {@link IOException} and * it can help to know the http response code to decide how to handle an http exceptions. diff --git a/src/main/java/org/kohsuke/github/Refreshable.java b/src/main/java/org/kohsuke/github/Refreshable.java index 1f92457c12..1793a3c430 100644 --- a/src/main/java/org/kohsuke/github/Refreshable.java +++ b/src/main/java/org/kohsuke/github/Refreshable.java @@ -1,9 +1,6 @@ package org.kohsuke.github; -import org.kohsuke.github.extras.ImpatientHttpConnector; - import java.io.IOException; -import java.net.HttpURLConnection; import java.net.URL; /** diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index 1a86bf407c..51b8e5be8a 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -28,8 +28,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import javax.annotation.CheckForNull; -import javax.annotation.WillClose; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -46,7 +44,6 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -60,6 +57,9 @@ import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; +import javax.annotation.CheckForNull; +import javax.annotation.WillClose; + import static java.util.Arrays.asList; import static java.util.logging.Level.*; import static org.apache.commons.lang3.StringUtils.defaultString; @@ -723,8 +723,9 @@ private void findNextURL() throws MalformedURLException { private void setupConnection(URL url) throws IOException { if (LOGGER.isLoggable(FINE)) { - LOGGER.log(FINE, "GitHub API request [" + (root.login == null ? "anonymous" : root.login) + "]: " + method - + " " + url.toString()); + LOGGER.log(FINE, + "GitHub API request [" + (root.login == null ? "anonymous" : root.login) + "]: " + method + " " + + url.toString()); } uc = root.getConnector().connect(url); @@ -811,7 +812,7 @@ private T parse(Class type, T instance, int timeouts) throws IOException throw (IOException) new IOException("Failed to deserialize " + data).initCause(e); } if (instance != null) { - return setResponseHeaders(MAPPER.readerForUpdating(instance). readValue(data)); + return setResponseHeaders(MAPPER.readerForUpdating(instance).readValue(data)); } return null; } catch (FileNotFoundException e) { @@ -872,8 +873,10 @@ void handleApiError(IOException e) throws IOException { // likely to be a network exception (e.g. SSLHandshakeException), // uc.getResponseCode() and any other getter on the response will cause an exception if (LOGGER.isLoggable(FINE)) - LOGGER.log(FINE, "Silently ignore exception retrieving response code for '" + uc.getURL() + "'" - + " handling exception " + e, e); + LOGGER.log(FINE, + "Silently ignore exception retrieving response code for '" + uc.getURL() + "'" + + " handling exception " + e, + e); throw e; } InputStream es = wrapStream(uc.getErrorStream()); diff --git a/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java b/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java index ea39c8e006..c9e96613bd 100644 --- a/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java +++ b/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java @@ -4,11 +4,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.annotation.Nonnull; + /** * {@link org.kohsuke.github.GHMeta} wraps the list of GitHub's IP addresses. *

@@ -504,8 +505,10 @@ public static class GHMetaGettersFinalCreator implements GHMetaExample { @JsonCreator private GHMetaGettersFinalCreator(@Nonnull @JsonProperty("hooks") List hooks, - @Nonnull @JsonProperty("git") List git, @Nonnull @JsonProperty("web") List web, - @Nonnull @JsonProperty("api") List api, @Nonnull @JsonProperty("pages") List pages, + @Nonnull @JsonProperty("git") List git, + @Nonnull @JsonProperty("web") List web, + @Nonnull @JsonProperty("api") List api, + @Nonnull @JsonProperty("pages") List pages, @Nonnull @JsonProperty("importer") List importer, @JsonProperty("verifiable_password_authentication") boolean verifiablePasswordAuthentication) { this.verifiablePasswordAuthentication = verifiablePasswordAuthentication; @@ -545,4 +548,4 @@ public List getImporter() { return importer; } } -} \ No newline at end of file +} diff --git a/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java b/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java index 43c2da4c19..9c54c71cb7 100644 --- a/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java +++ b/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java @@ -4,17 +4,13 @@ import com.squareup.okhttp.ConnectionSpec; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkUrlFactory; - import org.kohsuke.github.HttpConnector; import java.io.IOException; - import java.net.HttpURLConnection; import java.net.URL; - import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; - import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java b/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java index 3c453ed119..ba38334d0c 100644 --- a/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java +++ b/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java @@ -1,5 +1,25 @@ package org.kohsuke.github.extras.okhttp3; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Dispatcher; +import okhttp3.Handshake; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Protocol; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; +import okio.Pipe; +import okio.Timeout; + /* * Copyright (C) 2014 Square, Inc. * @@ -15,7 +35,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -40,31 +59,12 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; + import javax.annotation.Nullable; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.Dispatcher; -import okhttp3.Handshake; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.Interceptor; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Protocol; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okio.Buffer; -import okio.BufferedSink; -import okio.Okio; -import okio.Pipe; -import okio.Timeout; - import static java.net.HttpURLConnection.HTTP_NOT_MODIFIED; import static java.net.HttpURLConnection.HTTP_NO_CONTENT; @@ -1366,4 +1366,4 @@ static final class UnexpectedException extends IOException { super(cause); } } -} \ No newline at end of file +} diff --git a/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java b/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java index d9bd2b0273..ebfc09ad6e 100644 --- a/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java +++ b/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java @@ -3,13 +3,11 @@ import com.squareup.okhttp.CacheControl; import okhttp3.ConnectionSpec; import okhttp3.OkHttpClient; - import org.kohsuke.github.HttpConnector; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; - import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; @@ -81,4 +79,4 @@ public HttpURLConnection connect(URL url) throws IOException { private List TlsConnectionSpecs() { return Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.CLEARTEXT); } -} \ No newline at end of file +} diff --git a/src/test/java/org/kohsuke/HookApp.java b/src/test/java/org/kohsuke/HookApp.java index 32f2e0157b..9ee51407a0 100644 --- a/src/test/java/org/kohsuke/HookApp.java +++ b/src/test/java/org/kohsuke/HookApp.java @@ -26,8 +26,8 @@ public static void main(String[] args) throws Exception { public void doIndex(StaplerRequest req) throws IOException { String str = req.getParameter("payload"); // System.out.println(str); - GHEventPayload.PullRequest o = GitHub.connect().parseEventPayload(new StringReader(str), - GHEventPayload.PullRequest.class); + GHEventPayload.PullRequest o = GitHub.connect() + .parseEventPayload(new StringReader(str), GHEventPayload.PullRequest.class); // System.out.println(o); } } diff --git a/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java b/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java index 797362e500..ff5d5955ae 100644 --- a/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java +++ b/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java @@ -1,17 +1,8 @@ package org.kohsuke.github; -import java.io.FileInputStream; -import java.util.Properties; - -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Assume; import org.junit.Before; import org.kohsuke.randname.RandomNameGenerator; -import java.io.File; -import java.io.IOException; - import static org.junit.Assume.assumeTrue; /** diff --git a/src/test/java/org/kohsuke/github/AppTest.java b/src/test/java/org/kohsuke/github/AppTest.java index 64edd87280..fd223bb287 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -2,8 +2,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - import org.apache.commons.io.IOUtils; import org.junit.Ignore; import org.junit.Test; diff --git a/src/test/java/org/kohsuke/github/GHAppTest.java b/src/test/java/org/kohsuke/github/GHAppTest.java index eb9f96be75..980f3c8f6f 100644 --- a/src/test/java/org/kohsuke/github/GHAppTest.java +++ b/src/test/java/org/kohsuke/github/GHAppTest.java @@ -20,7 +20,8 @@ public class GHAppTest extends AbstractGitHubWireMockTest { protected GitHubBuilder getGitHubBuilder() { return super.getGitHubBuilder() // ensure that only JWT will be used against the tests below - .withPassword(null, null).withJwtToken("bogus"); + .withPassword(null, null) + .withJwtToken("bogus"); } @Test @@ -101,7 +102,8 @@ public void createToken() throws IOException { permissions.put("metadata", GHPermissionType.READ); GHAppInstallationToken installationToken = installation.createToken(permissions) - .repositoryIds(Arrays.asList((long) 111111111)).create(); + .repositoryIds(Arrays.asList((long) 111111111)) + .create(); assertThat(installationToken.getToken(), is("bogus")); assertThat(installation.getPermissions(), is(permissions)); diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 8717d6775c..ee6c62695e 100644 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -48,9 +48,14 @@ public void setUp() throws Exception { @Test public void testEnableBranchProtections() throws Exception { // team/user restrictions require an organization repo to test against - GHBranchProtection protection = branch.enableProtection().addRequiredChecks("test-status-check") - .requireBranchIsUpToDate().requireCodeOwnReviews().dismissStaleReviews().requiredReviewers(2) - .includeAdmins().enable(); + GHBranchProtection protection = branch.enableProtection() + .addRequiredChecks("test-status-check") + .requireBranchIsUpToDate() + .requireCodeOwnReviews() + .dismissStaleReviews() + .requiredReviewers(2) + .includeAdmins() + .enable(); RequiredStatusChecks statusChecks = protection.getRequiredStatusChecks(); assertNotNull(statusChecks); diff --git a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java index 32e0f0090d..4b4b591353 100644 --- a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java +++ b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -73,7 +72,8 @@ public void testGetDirectoryContentTrailingSlash() throws Exception { @Test public void testCRUDContent() throws Exception { GHContentUpdateResponse created = repo.createContent("this is an awesome file I created\n", - "Creating a file for integration tests.", createdFilename); + "Creating a file for integration tests.", + createdFilename); GHContent createdContent = created.getContent(); assertNotNull(created.getCommit()); diff --git a/src/test/java/org/kohsuke/github/GHDeploymentTest.java b/src/test/java/org/kohsuke/github/GHDeploymentTest.java index 1c228c7aad..b2dc602b15 100644 --- a/src/test/java/org/kohsuke/github/GHDeploymentTest.java +++ b/src/test/java/org/kohsuke/github/GHDeploymentTest.java @@ -3,6 +3,7 @@ import org.junit.Test; import java.io.IOException; + import static org.junit.Assert.assertNotNull; /** diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 4f3b92a075..481396a48c 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -14,8 +14,8 @@ public class GHEventPayloadTest { @Test public void commit_comment() throws Exception { - GHEventPayload.CommitComment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.CommitComment.class); + GHEventPayload.CommitComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.CommitComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getComment().getSHA1(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); assertThat(event.getComment().getUser().getLogin(), is("baxterthehacker")); @@ -26,8 +26,8 @@ public void commit_comment() throws Exception { @Test public void create() throws Exception { - GHEventPayload.Create event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Create.class); + GHEventPayload.Create event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Create.class); assertThat(event.getRef(), is("0.0.1")); assertThat(event.getRefType(), is("tag")); assertThat(event.getMasterBranch(), is("master")); @@ -39,8 +39,8 @@ public void create() throws Exception { @Test public void delete() throws Exception { - GHEventPayload.Delete event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Delete.class); + GHEventPayload.Delete event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Delete.class); assertThat(event.getRef(), is("simple-tag")); assertThat(event.getRefType(), is("tag")); assertThat(event.getRepository().getName(), is("public-repo")); @@ -50,8 +50,8 @@ public void delete() throws Exception { @Test public void deployment() throws Exception { - GHEventPayload.Deployment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Deployment.class); + GHEventPayload.Deployment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Deployment.class); assertThat(event.getDeployment().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); assertThat(event.getDeployment().getEnvironment(), is("production")); assertThat(event.getDeployment().getCreator().getLogin(), is("baxterthehacker")); @@ -62,8 +62,8 @@ public void deployment() throws Exception { @Test public void deployment_status() throws Exception { - GHEventPayload.DeploymentStatus event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.DeploymentStatus.class); + GHEventPayload.DeploymentStatus event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.DeploymentStatus.class); assertThat(event.getDeploymentStatus().getState(), is(GHDeploymentState.SUCCESS)); assertThat(event.getDeploymentStatus().getTargetUrl(), nullValue()); assertThat(event.getDeployment().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); @@ -104,8 +104,8 @@ public void fork() throws Exception { @Test public void issue_comment() throws Exception { - GHEventPayload.IssueComment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.IssueComment.class); + GHEventPayload.IssueComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.IssueComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getIssue().getNumber(), is(2)); assertThat(event.getIssue().getTitle(), is("Spelling error in the README file")); @@ -156,8 +156,8 @@ public void issues() throws Exception { @Test @Payload("public") public void public_() throws Exception { - GHEventPayload.Public event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Public.class); + GHEventPayload.Public event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Public.class); assertThat(event.getRepository().getName(), is("public-repo")); assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker")); assertThat(event.getSender().getLogin(), is("baxterthehacker")); @@ -165,8 +165,8 @@ public void public_() throws Exception { @Test public void pull_request() throws Exception { - GHEventPayload.PullRequest event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.PullRequest.class); + GHEventPayload.PullRequest event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class); assertThat(event.getAction(), is("opened")); assertThat(event.getNumber(), is(1)); assertThat(event.getPullRequest().getNumber(), is(1)); @@ -198,8 +198,8 @@ public void pull_request() throws Exception { @Test public void pull_request_review() throws Exception { - GHEventPayload.PullRequestReview event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.PullRequestReview.class); + GHEventPayload.PullRequestReview event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReview.class); assertThat(event.getAction(), is("submitted")); assertThat(event.getReview().getId(), is(2626884L)); @@ -227,8 +227,8 @@ public void pull_request_review() throws Exception { @Test public void pull_request_review_comment() throws Exception { - GHEventPayload.PullRequestReviewComment event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.PullRequestReviewComment.class); + GHEventPayload.PullRequestReviewComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReviewComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getComment().getBody(), is("Maybe you should use more emojji on this line.")); @@ -285,8 +285,8 @@ public void push() throws Exception { @Test public void repository() throws Exception { - GHEventPayload.Repository event = GitHub.offline().parseEventPayload(payload.asReader(), - GHEventPayload.Repository.class); + GHEventPayload.Repository event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Repository.class); assertThat(event.getAction(), is("created")); assertThat(event.getRepository().getName(), is("new-repository")); assertThat(event.getRepository().getOwner().getLogin(), is("baxterandthehackers")); diff --git a/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java index 89d5b0f3e6..83156723f4 100644 --- a/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java +++ b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java @@ -21,9 +21,13 @@ public class GHGistUpdaterTest extends AbstractGitHubWireMockTest { @Before public void setUp() throws IOException { GHGistBuilder builder = new GHGistBuilder(gitHub); - gist = builder.description("Test for the API").file("unmodified.txt", "Should be unmodified") + gist = builder.description("Test for the API") + .file("unmodified.txt", "Should be unmodified") // .file("delete-me.txt", "To be deleted") - .file("rename-me.py", "print 'hello'").file("update-me.txt", "To be updated").public_(true).create(); + .file("rename-me.py", "print 'hello'") + .file("update-me.txt", "To be updated") + .public_(true) + .create(); } @After @@ -42,7 +46,8 @@ public void testGitUpdater() throws Exception { GHGist updatedGist = updater.description("Description updated by API") .addFile("new-file.txt", "Added by updater") // .deleteFile("delete-me.txt") - .renameFile("rename-me.py", "renamed.py").updateFile("update-me.txt", "Content updated by API") + .renameFile("rename-me.py", "renamed.py") + .updateFile("update-me.txt", "Content updated by API") .update(); assertEquals("Description updated by API", updatedGist.getDescription()); diff --git a/src/test/java/org/kohsuke/github/GHHookTest.java b/src/test/java/org/kohsuke/github/GHHookTest.java index 6fee386ca1..d527097821 100644 --- a/src/test/java/org/kohsuke/github/GHHookTest.java +++ b/src/test/java/org/kohsuke/github/GHHookTest.java @@ -13,7 +13,6 @@ import static java.util.Collections.singletonMap; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasKey; -import static org.hamcrest.Matchers.hasValue; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertThat; @@ -58,8 +57,8 @@ public void exposeResponceHeaders() throws Exception { try { // fails because application isn't approved in organisation and you can find it only after doing real call - final GHHook hook = repository.createHook("my-hook", singletonMap("url", "http://localhost"), - singletonList(GHEvent.PUSH), true); + final GHHook hook = repository + .createHook("my-hook", singletonMap("url", "http://localhost"), singletonList(GHEvent.PUSH), true); } catch (IOException ex) { assertThat(ex, instanceOf(GHFileNotFoundException.class)); final GHFileNotFoundException ghFileNotFoundException = (GHFileNotFoundException) ex; diff --git a/src/test/java/org/kohsuke/github/GHIssueEventTest.java b/src/test/java/org/kohsuke/github/GHIssueEventTest.java index 82417e3219..e65f7d59c5 100644 --- a/src/test/java/org/kohsuke/github/GHIssueEventTest.java +++ b/src/test/java/org/kohsuke/github/GHIssueEventTest.java @@ -1,8 +1,9 @@ package org.kohsuke.github; +import org.junit.Test; + import java.io.IOException; import java.util.List; -import org.junit.Test; /** * @author Martin van Zijl diff --git a/src/test/java/org/kohsuke/github/GHOrganizationTest.java b/src/test/java/org/kohsuke/github/GHOrganizationTest.java index d9f693edee..11d5adb663 100644 --- a/src/test/java/org/kohsuke/github/GHOrganizationTest.java +++ b/src/test/java/org/kohsuke/github/GHOrganizationTest.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import com.jcraft.jsch.IO; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -33,8 +32,10 @@ public void testCreateRepository() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); GHRepository repository = org.createRepository(GITHUB_API_TEST, - "a test repository used to test kohsuke's github-api", "http://github-api.kohsuke.org/", - "Core Developers", true); + "a test repository used to test kohsuke's github-api", + "http://github-api.kohsuke.org/", + "Core Developers", + true); Assert.assertNotNull(repository); } @@ -45,7 +46,9 @@ public void testCreateRepositoryWithAutoInitialization() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); GHRepository repository = org.createRepository(GITHUB_API_TEST) .description("a test repository used to test kohsuke's github-api") - .homepage("http://github-api.kohsuke.org/").team(org.getTeamByName("Core Developers")).autoInit(true) + .homepage("http://github-api.kohsuke.org/") + .team(org.getTeamByName("Core Developers")) + .autoInit(true) .create(); Assert.assertNotNull(repository); Assert.assertNotNull(repository.getReadme()); diff --git a/src/test/java/org/kohsuke/github/GHPullRequestTest.java b/src/test/java/org/kohsuke/github/GHPullRequestTest.java index 71ae5db660..4ee1750908 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -85,8 +85,10 @@ public void closePullRequest() throws Exception { public void pullRequestReviews() throws Exception { String name = "testPullRequestReviews"; GHPullRequest p = getRepository().createPullRequest(name, "test/stable", "master", "## test"); - GHPullRequestReview draftReview = p.createReview().body("Some draft review") - .comment("Some niggle", "README.md", 1).create(); + GHPullRequestReview draftReview = p.createReview() + .body("Some draft review") + .comment("Some niggle", "README.md", 1) + .create(); assertThat(draftReview.getState(), is(GHPullRequestReviewState.PENDING)); assertThat(draftReview.getBody(), is("Some draft review")); assertThat(draftReview.getCommitId(), notNullValue()); @@ -156,13 +158,17 @@ public void testPullRequestTeamReviewRequests() throws Exception { int baseRequestCount = mockGitHub.getRequestCount(); p.refresh(); assertThat("We should not eagerly load organizations for teams", - mockGitHub.getRequestCount() - baseRequestCount, equalTo(1)); + mockGitHub.getRequestCount() - baseRequestCount, + equalTo(1)); assertThat(p.getRequestedTeams().size(), equalTo(1)); assertThat("We should not eagerly load organizations for teams", - mockGitHub.getRequestCount() - baseRequestCount, equalTo(1)); + mockGitHub.getRequestCount() - baseRequestCount, + equalTo(1)); assertThat("Org should be queried for automatically if asked for", - p.getRequestedTeams().get(0).getOrganization(), notNullValue()); - assertThat("Request count should show lazy load occurred", mockGitHub.getRequestCount() - baseRequestCount, + p.getRequestedTeams().get(0).getOrganization(), + notNullValue()); + assertThat("Request count should show lazy load occurred", + mockGitHub.getRequestCount() - baseRequestCount, equalTo(2)); } @@ -224,8 +230,13 @@ public void updateContentSquashMerge() throws Exception { GHContentUpdateResponse response = getRepository().createContent(name, name, name, branchName); Thread.sleep(1000); - getRepository().createContent().content(name + name).path(name).branch(branchName).message(name) - .sha(response.getContent().getSha()).commit(); + getRepository().createContent() + .content(name + name) + .path(name) + .branch(branchName) + .message(name) + .sha(response.getContent().getSha()) + .commit(); GHPullRequest p = getRepository().createPullRequest(name, branchName, "master", "## test squash"); Thread.sleep(1000); p.merge("squash merge", null, GHPullRequest.MergeMethod.SQUASH); @@ -239,8 +250,12 @@ public void queryPullRequestsQualifiedHead() throws Exception { repo.createPullRequest("queryPullRequestsQualifiedHead_rc", "test/rc", "master", null); // Query by one of the heads and make sure we only get that branch's PR back. - List prs = repo.queryPullRequests().state(GHIssueState.OPEN) - .head("github-api-test-org:test/stable").base("master").list().asList(); + List prs = repo.queryPullRequests() + .state(GHIssueState.OPEN) + .head("github-api-test-org:test/stable") + .base("master") + .list() + .asList(); assertNotNull(prs); assertEquals(1, prs.size()); assertEquals("test/stable", prs.get(0).getHead().getRef()); @@ -254,8 +269,12 @@ public void queryPullRequestsUnqualifiedHead() throws Exception { repo.createPullRequest("queryPullRequestsUnqualifiedHead_rc", "test/rc", "master", null); // Query by one of the heads and make sure we only get that branch's PR back. - List prs = repo.queryPullRequests().state(GHIssueState.OPEN).head("test/stable").base("master") - .list().asList(); + List prs = repo.queryPullRequests() + .state(GHIssueState.OPEN) + .head("test/stable") + .base("master") + .list() + .asList(); assertNotNull(prs); assertEquals(1, prs.size()); assertEquals("test/stable", prs.get(0).getHead().getRef()); diff --git a/src/test/java/org/kohsuke/github/GHRateLimitTest.java b/src/test/java/org/kohsuke/github/GHRateLimitTest.java index bf7e49f1a3..2aa9e78bf5 100644 --- a/src/test/java/org/kohsuke/github/GHRateLimitTest.java +++ b/src/test/java/org/kohsuke/github/GHRateLimitTest.java @@ -2,16 +2,10 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; -import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; -import okhttp3.Cache; -import okhttp3.OkHttpClient; -import org.apache.commons.io.FileUtils; import org.hamcrest.CoreMatchers; -import org.junit.Before; import org.junit.Test; import org.kohsuke.github.extras.okhttp3.OkHttpConnector; -import java.io.File; import java.io.IOException; import java.util.Date; diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index ca3e145733..64a738fdc4 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -11,7 +11,6 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.is; import static org.junit.Assert.*; -import static org.junit.Assume.assumeFalse; /** * @author Liam Newman @@ -197,8 +196,11 @@ public void listEmptyContributors() throws IOException { @Test public void searchRepositories() throws Exception { - PagedSearchIterable r = gitHub.searchRepositories().q("tetris").language("assembly") - .sort(GHRepositorySearchBuilder.Sort.STARS).list(); + PagedSearchIterable r = gitHub.searchRepositories() + .q("tetris") + .language("assembly") + .sort(GHRepositorySearchBuilder.Sort.STARS) + .list(); GHRepository u = r.iterator().next(); // System.out.println(u.getName()); assertNotNull(u.getId()); @@ -279,7 +281,8 @@ public void testSetTopics() throws Exception { topics.add("java"); topics.add("api-test-dummy"); repo.setTopics(topics); - assertThat("Topics retain input order (are not sort when stored)", repo.listTopics(), + assertThat("Topics retain input order (are not sort when stored)", + repo.listTopics(), contains("java", "api-test-dummy")); topics = new ArrayList<>(); @@ -287,18 +290,20 @@ public void testSetTopics() throws Exception { topics.add("api-test-dummy"); topics.add("java"); repo.setTopics(topics); - assertThat("Topics behave as a set and retain order from previous calls", repo.listTopics(), + assertThat("Topics behave as a set and retain order from previous calls", + repo.listTopics(), contains("java", "api-test-dummy", "ordered-state")); topics = new ArrayList<>(); topics.add("ordered-state"); topics.add("api-test-dummy"); repo.setTopics(topics); - assertThat("Topics retain order even when some are removed", repo.listTopics(), + assertThat("Topics retain order even when some are removed", + repo.listTopics(), contains("api-test-dummy", "ordered-state")); topics = new ArrayList<>(); repo.setTopics(topics); assertTrue("Topics can be set to empty", repo.listTopics().isEmpty()); } -} \ No newline at end of file +} diff --git a/src/test/java/org/kohsuke/github/GHTeamTest.java b/src/test/java/org/kohsuke/github/GHTeamTest.java index 8fbe267abb..742d89a3b7 100644 --- a/src/test/java/org/kohsuke/github/GHTeamTest.java +++ b/src/test/java/org/kohsuke/github/GHTeamTest.java @@ -3,7 +3,6 @@ import org.junit.Test; import java.io.IOException; -import java.util.Random; public class GHTeamTest extends AbstractGitHubWireMockTest { diff --git a/src/test/java/org/kohsuke/github/GistTest.java b/src/test/java/org/kohsuke/github/GistTest.java index ed11bc5284..117a76d6a9 100644 --- a/src/test/java/org/kohsuke/github/GistTest.java +++ b/src/test/java/org/kohsuke/github/GistTest.java @@ -1,11 +1,9 @@ package org.kohsuke.github; -import com.github.tomakehurst.wiremock.stubbing.Scenario; import org.junit.Test; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static org.hamcrest.Matchers.notNullValue; - import static org.hamcrest.core.Is.is; /** diff --git a/src/test/java/org/kohsuke/github/GitHubStaticTest.java b/src/test/java/org/kohsuke/github/GitHubStaticTest.java index 83bed2f043..8066dd9f1a 100644 --- a/src/test/java/org/kohsuke/github/GitHubStaticTest.java +++ b/src/test/java/org/kohsuke/github/GitHubStaticTest.java @@ -1,7 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import org.eclipse.jgit.api.Git; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/org/kohsuke/github/GitHubTest.java b/src/test/java/org/kohsuke/github/GitHubTest.java index f89d1faa5c..6b4d3b7a02 100644 --- a/src/test/java/org/kohsuke/github/GitHubTest.java +++ b/src/test/java/org/kohsuke/github/GitHubTest.java @@ -1,12 +1,12 @@ package org.kohsuke.github; -import java.io.IOException; -import java.util.*; - import com.google.common.collect.Iterables; import org.junit.Test; import org.kohsuke.github.example.dataobject.ReadOnlyObjects; +import java.io.IOException; +import java.util.*; + import static org.hamcrest.CoreMatchers.*; /** diff --git a/src/test/java/org/kohsuke/github/Github2faTest.java b/src/test/java/org/kohsuke/github/Github2faTest.java index 7681a50680..fb3c9cb6bf 100644 --- a/src/test/java/org/kohsuke/github/Github2faTest.java +++ b/src/test/java/org/kohsuke/github/Github2faTest.java @@ -1,11 +1,11 @@ package org.kohsuke.github; +import org.junit.Test; + import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Test; - /** * @author Kevin Harrington mad.hephaestus@gmail.com */ diff --git a/src/test/java/org/kohsuke/github/LifecycleTest.java b/src/test/java/org/kohsuke/github/LifecycleTest.java index ad892a1de5..fc8ed64244 100644 --- a/src/test/java/org/kohsuke/github/LifecycleTest.java +++ b/src/test/java/org/kohsuke/github/LifecycleTest.java @@ -25,19 +25,30 @@ public void testCreateRepository() throws IOException, GitAPIException, Interrup repository.delete(); Thread.sleep(1000); } - repository = org.createRepository("github-api-test", "a test repository used to test kohsuke's github-api", - "http://github-api.kohsuke.org/", "Core Developers", true); + repository = org.createRepository("github-api-test", + "a test repository used to test kohsuke's github-api", + "http://github-api.kohsuke.org/", + "Core Developers", + true); Thread.sleep(1000); // wait for the repository to become ready assertTrue(repository.getReleases().isEmpty()); try { GHMilestone milestone = repository.createMilestone("Initial Release", "first one"); - GHIssue issue = repository.createIssue("Test Issue").body("issue body just for grins").milestone(milestone) - .assignee(myself).label("bug").create(); + GHIssue issue = repository.createIssue("Test Issue") + .body("issue body just for grins") + .milestone(milestone) + .assignee(myself) + .label("bug") + .create(); File repoDir = new File(System.getProperty("java.io.tmpdir"), "github-api-test"); delete(repoDir); - Git origin = Git.cloneRepository().setBare(false).setURI(repository.getSshUrl()).setDirectory(repoDir) - .setCredentialsProvider(getCredentialsProvider(myself)).call(); + Git origin = Git.cloneRepository() + .setBare(false) + .setURI(repository.getSshUrl()) + .setDirectory(repoDir) + .setCredentialsProvider(getCredentialsProvider(myself)) + .call(); commitTestFile(myself, repoDir, origin); @@ -74,8 +85,10 @@ private GHAsset uploadAsset(GHRelease release) throws IOException { } private GHRelease createRelease(GHRepository repository) throws IOException { - GHRelease builder = repository.createRelease("release_tag").name("Test Release") - .body("How exciting! To be able to programmatically create releases is a dream come true!").create(); + GHRelease builder = repository.createRelease("release_tag") + .name("Test Release") + .body("How exciting! To be able to programmatically create releases is a dream come true!") + .create(); List releases = repository.getReleases(); assertEquals(1, releases.size()); GHRelease release = releases.get(0); diff --git a/src/test/java/org/kohsuke/github/PayloadRule.java b/src/test/java/org/kohsuke/github/PayloadRule.java index 6a24a8e5c2..063441ccc2 100644 --- a/src/test/java/org/kohsuke/github/PayloadRule.java +++ b/src/test/java/org/kohsuke/github/PayloadRule.java @@ -1,5 +1,10 @@ package org.kohsuke.github; +import org.apache.commons.io.IOUtils; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -7,11 +12,6 @@ import java.io.Reader; import java.nio.charset.Charset; -import org.apache.commons.io.IOUtils; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - /** * @author Stephen Connolly */ @@ -44,7 +44,8 @@ public void evaluate() throws Throwable { } public InputStream asInputStream() throws FileNotFoundException { - String name = resourceName.startsWith("/") ? resourceName + type + String name = resourceName.startsWith("/") + ? resourceName + type : testClass.getSimpleName() + "/" + resourceName + type; InputStream stream = testClass.getResourceAsStream(name); if (stream == null) { diff --git a/src/test/java/org/kohsuke/github/RepositoryMockTest.java b/src/test/java/org/kohsuke/github/RepositoryMockTest.java index 5805ba66ec..6e8969adae 100644 --- a/src/test/java/org/kohsuke/github/RepositoryMockTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryMockTest.java @@ -39,7 +39,7 @@ public void listCollaborators() throws Exception { user2.login = "login2"; when(iterator.hasNext()).thenReturn(true, false, true); - when(iterator.next()).thenReturn(new GHUser[] { user1 }, new GHUser[] { user2 }); + when(iterator.next()).thenReturn(new GHUser[]{ user1 }, new GHUser[]{ user2 }); Requester requester = Mockito.mock(Requester.class); when(mockGitHub.retrieve()).thenReturn(requester); diff --git a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java index b921d5ea4d..4ba98b0a7c 100644 --- a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java @@ -91,7 +91,8 @@ private void testTraffic(T expectedResult) throw @Test public void testGetViews() throws IOException { - GHRepositoryViewTraffic expectedResult = new GHRepositoryViewTraffic(21523359, 65534, + GHRepositoryViewTraffic expectedResult = new GHRepositoryViewTraffic(21523359, + 65534, Arrays.asList(new GHRepositoryViewTraffic.DailyInfo("2016-10-10T00:00:00Z", 3, 2), new GHRepositoryViewTraffic.DailyInfo("2016-10-11T00:00:00Z", 9, 4), new GHRepositoryViewTraffic.DailyInfo("2016-10-12T00:00:00Z", 27, 8), @@ -112,7 +113,8 @@ public void testGetViews() throws IOException { @Test public void testGetClones() throws IOException { - GHRepositoryCloneTraffic expectedResult = new GHRepositoryCloneTraffic(1500, 455, + GHRepositoryCloneTraffic expectedResult = new GHRepositoryCloneTraffic(1500, + 455, Arrays.asList(new GHRepositoryCloneTraffic.DailyInfo("2016-10-10T00:00:00Z", 10, 3), new GHRepositoryCloneTraffic.DailyInfo("2016-10-11T00:00:00Z", 20, 6), new GHRepositoryCloneTraffic.DailyInfo("2016-10-12T00:00:00Z", 30, 5), diff --git a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java index 975881ac71..843becc145 100644 --- a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java +++ b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import org.kohsuke.github.junit.WireMockRule; import org.hamcrest.Matchers; import org.junit.Ignore; import org.junit.Test; @@ -25,7 +24,8 @@ public void user_whenProxying_AuthCorrectlyConfigured() throws Exception { assertThat( "GitHub connection believes it is anonymous. Make sure you set GITHUB_OAUTH or both GITHUB_USER and GITHUB_PASSWORD environment variables", - gitHub.isAnonymous(), is(false)); + gitHub.isAnonymous(), + is(false)); assertThat(gitHub.login, not(equalTo(STUBBED_USER_LOGIN))); @@ -80,7 +80,7 @@ public void BasicBehaviors_whenNotProxying() throws Exception { e = ex; } - assertThat(e, Matchers. instanceOf(GHFileNotFoundException.class)); + assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); assertThat(e.getMessage(), containsString("Request was not matched")); // Invalid repository, without stub - fails 404 when not proxying @@ -92,7 +92,7 @@ public void BasicBehaviors_whenNotProxying() throws Exception { e = ex; } - assertThat(e, Matchers. instanceOf(GHFileNotFoundException.class)); + assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); assertThat(e.getMessage(), containsString("Request was not matched")); } @@ -120,9 +120,9 @@ public void BasicBehaviors_whenProxying() throws Exception { e = ex; } - assertThat(e, Matchers. instanceOf(GHFileNotFoundException.class)); - assertThat(e.getMessage(), equalTo( - "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}")); + assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); + assertThat(e.getMessage(), + equalTo("{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}")); } @Test diff --git a/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java b/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java index c9bdda95ec..00f85bdfd2 100644 --- a/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java @@ -2,10 +2,9 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; -import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; -import com.squareup.okhttp.OkUrlFactory; import com.squareup.okhttp.Cache; import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.OkUrlFactory; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Ignore; diff --git a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java index 5992bf84c8..a60221f8d4 100644 --- a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java @@ -108,7 +108,8 @@ public void OkHttpConnector_NoCache() throws Exception { OkHttpClient client = createClient(false); OkHttpConnector connector = new OkHttpConnector(client); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -133,7 +134,8 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client, -1); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -163,7 +165,8 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client, 3); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -187,7 +190,8 @@ public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client); - this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).withConnector(connector) + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) .build(); doTestActions(); @@ -207,7 +211,8 @@ private void checkRequestAndLimit(int networkRequestCount, int rateLimitUsed) th assertThat("Request Count", getRequestCount(), is(networkRequestCount + userRequestCount)); // Rate limit must be under this value, but if it wiggles we don't care - assertThat("Rate Limit Change", rateLimitBefore.remaining - rateLimitAfter.remaining, + assertThat("Rate Limit Change", + rateLimitBefore.remaining - rateLimitAfter.remaining, is(lessThanOrEqualTo(rateLimitUsed + userRequestCount))); } diff --git a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java index 47600bf0aa..e53f6e4331 100644 --- a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java @@ -1,10 +1,8 @@ package org.kohsuke.github.junit; import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.VerificationException; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.core.Options; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.extension.Parameters; import com.github.tomakehurst.wiremock.extension.ResponseTransformer; @@ -12,11 +10,6 @@ import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; import com.github.tomakehurst.wiremock.verification.*; import com.google.gson.*; -import org.junit.rules.MethodRule; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; import java.io.File; import java.io.IOException; @@ -24,7 +17,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; -import java.util.List; import java.util.Map; import static com.github.tomakehurst.wiremock.client.WireMock.*; @@ -94,11 +86,15 @@ protected void before() { protected void after() { super.after(); if (isTakeSnapshot()) { - this.apiServer().snapshotRecord(recordSpec().forTarget("https://api.github.com") - .captureHeader("If-None-Match").extractTextBodiesOver(255)); + this.apiServer() + .snapshotRecord(recordSpec().forTarget("https://api.github.com") + .captureHeader("If-None-Match") + .extractTextBodiesOver(255)); - this.rawServer().snapshotRecord(recordSpec().forTarget("https://raw.githubusercontent.com") - .captureHeader("If-None-Match").extractTextBodiesOver(255)); + this.rawServer() + .snapshotRecord(recordSpec().forTarget("https://raw.githubusercontent.com") + .captureHeader("If-None-Match") + .extractTextBodiesOver(255)); // After taking the snapshot, format the output formatJsonFiles(new File(this.apiServer().getOptions().filesRoot().getPath()).toPath()); @@ -118,7 +114,10 @@ public static int getRequestCount(WireMockServer server) { private void formatJsonFiles(Path path) { // The more consistent we can make the json output the more meaningful it will be. - Gson g = new Gson().newBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting() + Gson g = new Gson().newBuilder() + .serializeNulls() + .disableHtmlEscaping() + .setPrettyPrinting() .registerTypeAdapter(Double.class, new JsonSerializer() { @Override public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { @@ -128,7 +127,8 @@ public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContex return new JsonPrimitive(src.longValue()); return new JsonPrimitive(src); } - }).create(); + }) + .create(); try { Files.walk(path).forEach(filePath -> { diff --git a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java index f11b4ca025..81e1a958d8 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java @@ -88,7 +88,8 @@ protected final void initializeServer(String serverId, Extension... extensions) directoryName += "_" + serverId; } - final Options localOptions = new WireMockRuleConfiguration(WireMockMultiServerRule.this.options, directoryName, + final Options localOptions = new WireMockRuleConfiguration(WireMockMultiServerRule.this.options, + directoryName, extensions); new File(localOptions.filesRoot().getPath(), "mappings").mkdirs(); diff --git a/src/test/java/org/kohsuke/github/junit/WireMockRule.java b/src/test/java/org/kohsuke/github/junit/WireMockRule.java index 2f5dc3c3f8..4ddc9d00ba 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockRule.java @@ -7,14 +7,9 @@ import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.*; import com.github.tomakehurst.wiremock.core.*; -import com.github.tomakehurst.wiremock.extension.Extension; import com.github.tomakehurst.wiremock.global.GlobalSettings; import com.github.tomakehurst.wiremock.global.GlobalSettingsHolder; -import com.github.tomakehurst.wiremock.http.CaseInsensitiveKey; -import com.github.tomakehurst.wiremock.http.HttpServerFactory; import com.github.tomakehurst.wiremock.http.RequestListener; -import com.github.tomakehurst.wiremock.http.ThreadPoolFactory; -import com.github.tomakehurst.wiremock.http.trafficlistener.WiremockNetworkTrafficListener; import com.github.tomakehurst.wiremock.junit.Stubbing; import com.github.tomakehurst.wiremock.matching.RequestPattern; import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; @@ -23,27 +18,20 @@ import com.github.tomakehurst.wiremock.recording.RecordSpecBuilder; import com.github.tomakehurst.wiremock.recording.RecordingStatusResult; import com.github.tomakehurst.wiremock.recording.SnapshotRecordResult; -import com.github.tomakehurst.wiremock.security.Authenticator; -import com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource; import com.github.tomakehurst.wiremock.standalone.MappingsLoader; -import com.github.tomakehurst.wiremock.standalone.MappingsSource; import com.github.tomakehurst.wiremock.stubbing.ServeEvent; import com.github.tomakehurst.wiremock.stubbing.StubImport; import com.github.tomakehurst.wiremock.stubbing.StubMapping; import com.github.tomakehurst.wiremock.verification.*; - -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import com.github.tomakehurst.wiremock.verification.notmatched.NotMatchedRenderer; import org.junit.rules.MethodRule; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.Statement; -import wiremock.com.google.common.base.Optional; + +import java.io.File; +import java.util.List; +import java.util.UUID; /** * @author Liam Newman From 9a5467dcac863bf9c424dbfe29309052212d0764 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 18 Nov 2019 12:54:41 -0800 Subject: [PATCH 2/5] Re-enable GHBranchProtection test --- .../java/org/kohsuke/github/Requester.java | 14 +- .../github/GHBranchProtectionTest.java | 31 +---- ...-02ee4913-4f10-4403-9f86-c911719d8b88.json | 124 ++++++++++++++++++ ...-040c1d69-d6af-4a94-b583-7d18957bad10.json | 89 +++++++++++++ ...-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json | 21 +++ ...-c38b2b92-6669-42ee-838f-7422bb4f300d.json | 45 +++++++ ...-testenablebranchprotections-2-02ee49.json | 43 ++++++ ...hprotections_branches_master-3-040c1d.json | 42 ++++++ ...s_branches_master_protection-4-aa97cf.json | 49 +++++++ .../mappings/user-1-c38b2b.json | 43 ++++++ ...-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json | 124 ++++++++++++++++++ ...-88328244-0928-4737-b1a5-674c59027a58.json | 89 +++++++++++++ ...-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json | 89 +++++++++++++ ...-857c661d-4431-4504-9088-c0bbf3a8d667.json | 7 + ...-100e4407-70e6-4ea4-aad4-70d93d35dd38.json | 45 +++++++ ...emp-testenableprotectiononly-2-bc3099.json | 43 ++++++ ...otectiononly_branches_master-3-883282.json | 45 +++++++ ...otectiononly_branches_master-5-90ab1b.json | 44 +++++++ ...y_branches_master_protection-4-857c66.json | 49 +++++++ .../mappings/user-1-100e44.json | 43 ++++++ ...-318e0aa4-9fc4-4f30-8174-400001f1bae4.json | 124 ++++++++++++++++++ ...-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json | 89 +++++++++++++ ...-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json | 13 ++ ...-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json | 45 +++++++ ...testenablerequirereviewsonly-2-318e0a.json | 43 ++++++ ...ereviewsonly_branches_master-3-0e0c4c.json | 42 ++++++ ...y_branches_master_protection-4-b57fab.json | 49 +++++++ .../mappings/user-1-64a678.json | 43 ++++++ ...-126c7a91-25f8-4610-a015-12535c6f79bd.json | 124 ++++++++++++++++++ ...-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json | 89 +++++++++++++ ...-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json | 7 + ...-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json | 45 +++++++ ...t-org_temp-testsignedcommits-2-126c7a.json | 43 ++++++ ...ignedcommits_branches_master-3-7a0577.json | 42 ++++++ ...s_branches_master_protection-4-4b8a92.json | 49 +++++++ ...otection_required_signatures-5-c0150d.json | 45 +++++++ ...otection_required_signatures-6-e29707.json | 49 +++++++ ...otection_required_signatures-7-fa5a0d.json | 45 +++++++ ...otection_required_signatures-8-8c2a08.json | 35 +++++ ...otection_required_signatures-9-c0efc3.json | 44 +++++++ .../mappings/user-1-94ed9a.json | 43 ++++++ 41 files changed, 2157 insertions(+), 30 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/user-c38b2b92-6669-42ee-838f-7422bb4f300d.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections-2-02ee49.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-3-040c1d.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-4-aa97cf.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/user-1-c38b2b.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly-2-bc3099.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-3-883282.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-5-90ab1b.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-4-857c66.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/user-1-100e44.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly-2-318e0a.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-3-0e0c4c.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-4-b57fab.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/user-1-64a678.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits-2-126c7a.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master-3-7a0577.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4-4b8a92.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-5-c0150d.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-6-e29707.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-7-fa5a0d.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-8-8c2a08.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-9-c0efc3.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/user-1-94ed9a.json diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index 51b8e5be8a..1c69c3e154 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -795,10 +795,20 @@ private T parse(Class type, T instance, int timeouts) throws IOException return type.cast(Array.newInstance(type.getComponentType(), 0)); } - // Response code 202 means the statistics are still being cached. + // Response code 202 means data is being generated still being cached. + // This happens in for statistics: // See https://developer.github.com/v3/repos/statistics/#a-word-about-caching + // And for fork creation: + // See https://developer.github.com/v3/repos/forks/#create-a-fork if (responseCode == 202) { - LOGGER.log(INFO, "The statistics are still being generated. Please try again in 5 seconds."); + if (uc.getURL().toString().endsWith("/forks")) { + LOGGER.log(INFO, "The fork is being created. Please try again in 5 seconds."); + } else if (uc.getURL().toString().endsWith("/statistics")) { + LOGGER.log(INFO, "The statistics are being generated. Please try again in 5 seconds."); + } else { + LOGGER.log(INFO, + "Received 202 from " + uc.getURL().toString() + " . Please try again in 5 seconds."); + } // Maybe throw an exception instead? return null; } diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index ee6c62695e..7f15ea61c9 100644 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -6,10 +6,8 @@ import org.kohsuke.github.GHBranchProtection.RequiredReviews; import org.kohsuke.github.GHBranchProtection.RequiredStatusChecks; -import java.io.FileNotFoundException; - -public class GHBranchProtectionTest extends AbstractGitHubApiTestBase { - private static final String BRANCH = "bp-test"; +public class GHBranchProtectionTest extends AbstractGitHubWireMockTest { + private static final String BRANCH = "master"; private static final String BRANCH_REF = "heads/" + BRANCH; private GHBranch branch; @@ -17,32 +15,9 @@ public class GHBranchProtectionTest extends AbstractGitHubApiTestBase { private GHRepository repo; @Before - @Override public void setUp() throws Exception { - super.setUp(); - - repo = gitHub.getRepository("github-api-test-org/GHContentIntegrationTest").fork(); - - try { - repo.getRef(BRANCH_REF); - } catch (FileNotFoundException e) { - repo.createRef("refs/" + BRANCH_REF, repo.getBranch("master").getSHA1()); - } - - branch = repo.getBranch(BRANCH); - - if (branch.isProtected()) { - GHBranchProtection protection = branch.getProtection(); - if (protection.getRequiredSignatures()) { - protection.disableSignedCommits(); - } - - assertFalse(protection.getRequiredSignatures()); - branch.disableProtection(); - } - + repo = getTempRepository(); branch = repo.getBranch(BRANCH); - assertFalse(branch.isProtected()); } @Test diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json new file mode 100644 index 0000000000..c9f0d6061d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json @@ -0,0 +1,124 @@ +{ + "id": 222596043, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYwNDM=", + "name": "temp-testEnableBranchProtections", + "full_name": "github-api-test-org/temp-testEnableBranchProtections", + "private": false, + "owner": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections", + "description": "A test repository for testing the github-api project: temp-testEnableBranchProtections", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/deployments", + "created_at": "2019-11-19T03:01:26Z", + "updated_at": "2019-11-19T03:01:31Z", + "pushed_at": "2019-11-19T03:01:27Z", + "git_url": "git://github.com/github-api-test-org/temp-testEnableBranchProtections.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testEnableBranchProtections.git", + "clone_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections.git", + "svn_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "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": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json new file mode 100644 index 0000000000..6f6492ef01 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDQzOjI5OGZmZmY5Yzc5MjhiMDZlOWI3NGQwMWFlOGEzNGFiOThlOWI0YzI=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:27Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:27Z" + }, + "message": "Initial commit", + "tree": { + "sha": "3858cfba073ecd82947ddca0dc3613584db75e4c", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/trees/3858cfba073ecd82947ddca0dc3613584db75e4c" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/commits/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sHCRBK7hj4Ov3rIwAAdHIIABgp0lFAcHc2m3RCcuCUqfMl\nzfgjjYNYsqyWgwWeB0c44naL8nqhF/a80KlY4+1T2gVR8GOSZNyC8ewDH/6V+X3q\n5MzjTNJBk2ks5oA4bz2fgdsE7fm8kKDZQRqL9+BN4JF9MNps4M2+nR5Rg4sBm2+A\nSZHcdfzZ6ll0ptcTGl7403Xe9irj/V6iymycUapbK4+RHBotrN6kbBGZtjILempU\nMbYrIuqteQF3B2p9FSXFCJ8SpAL/Cq/GkpGvEbYIPdQ2IFQ6ImiRSf6eNTvSXxtG\nLJygBJsaRCH81FEhBfUnbP+stB9x4dloj/yhPLd6BXv1VCuzT2h9roYtaemjb7c=\n=ycC3\n-----END PGP SIGNATURE-----\n", + "payload": "tree 3858cfba073ecd82947ddca0dc3613584db75e4c\nauthor Liam Newman 1574132487 -0800\ncommitter GitHub 1574132487 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/commits/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "html_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections/commit/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/commits/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2/comments", + "author": { + "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 + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableBranchProtections/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json new file mode 100644 index 0000000000..36fb6cf9bd --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json @@ -0,0 +1,21 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection", + "required_status_checks": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/required_status_checks", + "strict": true, + "contexts": [ + "test-status-check" + ], + "contexts_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/required_status_checks/contexts" + }, + "required_pull_request_reviews": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/required_pull_request_reviews", + "dismiss_stale_reviews": true, + "require_code_owner_reviews": true, + "required_approving_review_count": 2 + }, + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/enforce_admins", + "enabled": true + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/user-c38b2b92-6669-42ee-838f-7422bb4f300d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/user-c38b2b92-6669-42ee-838f-7422bb4f300d.json new file mode 100644 index 0000000000..6f84c075f5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/user-c38b2b92-6669-42ee-838f-7422bb4f300d.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": 176, + "public_gists": 7, + "followers": 140, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "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/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections-2-02ee49.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections-2-02ee49.json new file mode 100644 index 0000000000..834aa92e8e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections-2-02ee49.json @@ -0,0 +1,43 @@ +{ + "id": "02ee4913-4f10-4403-9f86-c911719d8b88", + "name": "repos_github-api-test-org_temp-testenablebranchprotections", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableBranchProtections", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:32 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4937", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"85ef7d73fa0d8de7e964cdc69d1648a0\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:31 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C495:6994:5EFFF:6F6AF:5DD35B05" + } + }, + "uuid": "02ee4913-4f10-4403-9f86-c911719d8b88", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-3-040c1d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-3-040c1d.json new file mode 100644 index 0000000000..0e79036a26 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-3-040c1d.json @@ -0,0 +1,42 @@ +{ + "id": "040c1d69-d6af-4a94-b583-7d18957bad10", + "name": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:32 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4936", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"b4b2b52ee5173543cc0d41dfff61781c\"", + "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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C495:6994:5F01F:6FB32:5DD35B0C" + } + }, + "uuid": "040c1d69-d6af-4a94-b583-7d18957bad10", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-4-aa97cf.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-4-aa97cf.json new file mode 100644 index 0000000000..090479e8d6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-4-aa97cf.json @@ -0,0 +1,49 @@ +{ + "id": "aa97cf7b-7c9d-4c01-b7c5-bccc62b30873", + "name": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":{\"required_approving_review_count\":2,\"require_code_owner_reviews\":true,\"dismiss_stale_reviews\":true},\"required_status_checks\":{\"contexts\":[\"test-status-check\"],\"strict\":true},\"restrictions\":null,\"enforce_admins\":true}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:32 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4935", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"51724a4f269fbb64510394b0e2b948b3\"", + "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.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C495:6994:5F041:6FB54:5DD35B0C" + } + }, + "uuid": "aa97cf7b-7c9d-4c01-b7c5-bccc62b30873", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/user-1-c38b2b.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/user-1-c38b2b.json new file mode 100644 index 0000000000..1c3c09fb22 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/user-1-c38b2b.json @@ -0,0 +1,43 @@ +{ + "id": "c38b2b92-6669-42ee-838f-7422bb4f300d", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-c38b2b92-6669-42ee-838f-7422bb4f300d.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:25 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4945", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C495:6994:5EC24:6F69A:5DD35B04" + } + }, + "uuid": "c38b2b92-6669-42ee-838f-7422bb4f300d", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json new file mode 100644 index 0000000000..a253c10ac1 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json @@ -0,0 +1,124 @@ +{ + "id": 222596090, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYwOTA=", + "name": "temp-testEnableProtectionOnly", + "full_name": "github-api-test-org/temp-testEnableProtectionOnly", + "private": false, + "owner": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly", + "description": "A test repository for testing the github-api project: temp-testEnableProtectionOnly", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/deployments", + "created_at": "2019-11-19T03:01:43Z", + "updated_at": "2019-11-19T03:01:49Z", + "pushed_at": "2019-11-19T03:01:45Z", + "git_url": "git://github.com/github-api-test-org/temp-testEnableProtectionOnly.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testEnableProtectionOnly.git", + "clone_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly.git", + "svn_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "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": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json new file mode 100644 index 0000000000..d1efd113fc --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "b9a9b314add8ca449fc2de050518c0fad721a60c", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDkwOmI5YTliMzE0YWRkOGNhNDQ5ZmMyZGUwNTA1MThjMGZhZDcyMWE2MGM=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:44Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:44Z" + }, + "message": "Initial commit", + "tree": { + "sha": "c9119b8fcff0b781ab9fd8faf418c42c08593560", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/trees/c9119b8fcff0b781ab9fd8faf418c42c08593560" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sYCRBK7hj4Ov3rIwAAdHIIAILysEwjSJK+Ks9FXnOnzhPY\nM1KpvTeWF1B7HfuExazu185ER/0pvyI6A9WArZaCYoit1tTLFVkUiT0Elnoi+6Wi\nOEbdFmKoIaOf6htKq6GREtT6aCGyLoW9k3kfYuJdRpn5Wu2lgI085pJZc08XsLmj\nTjlK1NvxGKqHJ2tn2wzxfz3AizJhpMn2JEIx8yEHkXBCQLNq9D6f8MyAQRuv6TVd\nVfKgyJGhB6ndz8D+7vXxxDYFw5PAqcOsm8IBHnNTxzwZoNxZ0cTXWPkgZqyRbny1\nN/qRQ3ERkOP0z4hJimXkVYUAgVRUwIVMVwc8TvlluVLZrCYCHRcGKbhD+uH66QM=\n=Cu8z\n-----END PGP SIGNATURE-----\n", + "payload": "tree c9119b8fcff0b781ab9fd8faf418c42c08593560\nauthor Liam Newman 1574132504 -0800\ncommitter GitHub 1574132504 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "html_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/commit/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c/comments", + "author": { + "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 + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json new file mode 100644 index 0000000000..be28272ae2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "b9a9b314add8ca449fc2de050518c0fad721a60c", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDkwOmI5YTliMzE0YWRkOGNhNDQ5ZmMyZGUwNTA1MThjMGZhZDcyMWE2MGM=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:44Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:44Z" + }, + "message": "Initial commit", + "tree": { + "sha": "c9119b8fcff0b781ab9fd8faf418c42c08593560", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/trees/c9119b8fcff0b781ab9fd8faf418c42c08593560" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sYCRBK7hj4Ov3rIwAAdHIIAILysEwjSJK+Ks9FXnOnzhPY\nM1KpvTeWF1B7HfuExazu185ER/0pvyI6A9WArZaCYoit1tTLFVkUiT0Elnoi+6Wi\nOEbdFmKoIaOf6htKq6GREtT6aCGyLoW9k3kfYuJdRpn5Wu2lgI085pJZc08XsLmj\nTjlK1NvxGKqHJ2tn2wzxfz3AizJhpMn2JEIx8yEHkXBCQLNq9D6f8MyAQRuv6TVd\nVfKgyJGhB6ndz8D+7vXxxDYFw5PAqcOsm8IBHnNTxzwZoNxZ0cTXWPkgZqyRbny1\nN/qRQ3ERkOP0z4hJimXkVYUAgVRUwIVMVwc8TvlluVLZrCYCHRcGKbhD+uH66QM=\n=Cu8z\n-----END PGP SIGNATURE-----\n", + "payload": "tree c9119b8fcff0b781ab9fd8faf418c42c08593560\nauthor Liam Newman 1574132504 -0800\ncommitter GitHub 1574132504 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "html_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/commit/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c/comments", + "author": { + "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 + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/tree/master" + }, + "protected": true, + "protection": { + "enabled": true, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json new file mode 100644 index 0000000000..15ca7f2682 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json @@ -0,0 +1,7 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection", + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection/enforce_admins", + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json new file mode 100644 index 0000000000..6f84c075f5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/user-100e4407-70e6-4ea4-aad4-70d93d35dd38.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": 176, + "public_gists": 7, + "followers": 140, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "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/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly-2-bc3099.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly-2-bc3099.json new file mode 100644 index 0000000000..ac0603dffa --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly-2-bc3099.json @@ -0,0 +1,43 @@ +{ + "id": "bc30994e-6cf0-42fa-b6e8-7c21803346f0", + "name": "repos_github-api-test-org_temp-testenableprotectiononly", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:49 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4911", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"5a52275541e01dfed3bd8a7c449f6b0f\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:49 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4A6:4FEE:63367:740CA:5DD35B16" + } + }, + "uuid": "bc30994e-6cf0-42fa-b6e8-7c21803346f0", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-3-883282.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-3-883282.json new file mode 100644 index 0000000000..54e19738d9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-3-883282.json @@ -0,0 +1,45 @@ +{ + "id": "88328244-0928-4737-b1a5-674c59027a58", + "name": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4910", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"e50899adde0516ef560b178cfb58c9f4\"", + "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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4A6:4FEE:6338F:74499:5DD35B1D" + } + }, + "uuid": "88328244-0928-4737-b1a5-674c59027a58", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master-2", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-5-90ab1b.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-5-90ab1b.json new file mode 100644 index 0000000000..7e410f2def --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-5-90ab1b.json @@ -0,0 +1,44 @@ +{ + "id": "90ab1b21-6ee8-4607-bcf5-f14061c3936f", + "name": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4908", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"6e892f7878965d871f858924a9515a9a\"", + "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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4A6:4FEE:633CF:744E4:5DD35B1E" + } + }, + "uuid": "90ab1b21-6ee8-4607-bcf5-f14061c3936f", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master-2", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-4-857c66.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-4-857c66.json new file mode 100644 index 0000000000..30591e0826 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-4-857c66.json @@ -0,0 +1,49 @@ +{ + "id": "857c661d-4431-4504-9088-c0bbf3a8d667", + "name": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4909", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"48347246916d88cb97b0bff8a430e78c\"", + "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.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4A6:4FEE:633A5:744B7:5DD35B1E" + } + }, + "uuid": "857c661d-4431-4504-9088-c0bbf3a8d667", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/user-1-100e44.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/user-1-100e44.json new file mode 100644 index 0000000000..49eec8a122 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/user-1-100e44.json @@ -0,0 +1,43 @@ +{ + "id": "100e4407-70e6-4ea4-aad4-70d93d35dd38", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:42 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4919", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4A6:4FEE:63031:740B3:5DD35B16" + } + }, + "uuid": "100e4407-70e6-4ea4-aad4-70d93d35dd38", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json new file mode 100644 index 0000000000..4d24749b25 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json @@ -0,0 +1,124 @@ +{ + "id": 222596057, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYwNTc=", + "name": "temp-testEnableRequireReviewsOnly", + "full_name": "github-api-test-org/temp-testEnableRequireReviewsOnly", + "private": false, + "owner": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly", + "description": "A test repository for testing the github-api project: temp-testEnableRequireReviewsOnly", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/deployments", + "created_at": "2019-11-19T03:01:34Z", + "updated_at": "2019-11-19T03:01:40Z", + "pushed_at": "2019-11-19T03:01:36Z", + "git_url": "git://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testEnableRequireReviewsOnly.git", + "clone_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly.git", + "svn_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "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": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json new file mode 100644 index 0000000000..e22e3f01c4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "d32e320555f9d47f78e64fc3889e567d5eebee8e", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDU3OmQzMmUzMjA1NTVmOWQ0N2Y3OGU2NGZjMzg4OWU1NjdkNWVlYmVlOGU=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:35Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:35Z" + }, + "message": "Initial commit", + "tree": { + "sha": "32d1abb4db4e0b5f067f13f8ec544e62126ef47a", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/trees/32d1abb4db4e0b5f067f13f8ec544e62126ef47a" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/commits/d32e320555f9d47f78e64fc3889e567d5eebee8e", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sPCRBK7hj4Ov3rIwAAdHIIADGTF2CM1Q6wUw3RB/sKFvl2\npKkcGV3+0W4+Clnx1k1b60TbjD8hnq+ZtkWxvo3QmUplUapunHoj4zrUkqmzwOVg\nKrCwsvBzSJoRxbKN5j04wCTwB9oUSCEPxs9UxolqCOumwa+GzLv2t4EjGeDEf09S\n18C9Dg9+eiIMaXbO+HXOkltj4V9BTI8+IWA/0EMHVBqeh8daWcbyhQcaHBdkNgR6\nDq9UKMz0Ny2S6/A2v+y8YBj6ftXs+q5/fAPSu6hI4SMAVz26nl1SvkJmR8N79PQ9\nbiybCEzd5is507e8ufr7ElJ/1bfV2z0c0wkXfV6nNX+xYSKP+IfOLAfUljeoCZM=\n=RhfP\n-----END PGP SIGNATURE-----\n", + "payload": "tree 32d1abb4db4e0b5f067f13f8ec544e62126ef47a\nauthor Liam Newman 1574132495 -0800\ncommitter GitHub 1574132495 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/commits/d32e320555f9d47f78e64fc3889e567d5eebee8e", + "html_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly/commit/d32e320555f9d47f78e64fc3889e567d5eebee8e", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/commits/d32e320555f9d47f78e64fc3889e567d5eebee8e/comments", + "author": { + "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 + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json new file mode 100644 index 0000000000..1113b5739d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json @@ -0,0 +1,13 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection", + "required_pull_request_reviews": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection/required_pull_request_reviews", + "dismiss_stale_reviews": false, + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + }, + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection/enforce_admins", + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json new file mode 100644 index 0000000000..6f84c075f5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.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": 176, + "public_gists": 7, + "followers": 140, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "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/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly-2-318e0a.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly-2-318e0a.json new file mode 100644 index 0000000000..51d26c8131 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly-2-318e0a.json @@ -0,0 +1,43 @@ +{ + "id": "318e0aa4-9fc4-4f30-8174-400001f1bae4", + "name": "repos_github-api-test-org_temp-testenablerequirereviewsonly", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableRequireReviewsOnly", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:41 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4924", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"2b8d8ba2c42054c376d47a34ded30f4b\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:40 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C49E:6D70:39A9D:4459F:5DD35B0D" + } + }, + "uuid": "318e0aa4-9fc4-4f30-8174-400001f1bae4", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-3-0e0c4c.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-3-0e0c4c.json new file mode 100644 index 0000000000..a44e412beb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-3-0e0c4c.json @@ -0,0 +1,42 @@ +{ + "id": "0e0c4c56-198f-4d87-b13e-b146cad7ffdb", + "name": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:41 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4923", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"51ae00091b56c866a8b2b00d1a3e57ec\"", + "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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C49E:6D70:39AA6:447F2:5DD35B15" + } + }, + "uuid": "0e0c4c56-198f-4d87-b13e-b146cad7ffdb", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-4-b57fab.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-4-b57fab.json new file mode 100644 index 0000000000..d4b63f5d20 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-4-b57fab.json @@ -0,0 +1,49 @@ +{ + "id": "b57fab91-f2a6-4d52-b6d4-05e4a8be5df4", + "name": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":{},\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:41 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4922", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"b2d6921837e9e4b720085673dae0aa59\"", + "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.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C49E:6D70:39AC3:44807:5DD35B15" + } + }, + "uuid": "b57fab91-f2a6-4d52-b6d4-05e4a8be5df4", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/user-1-64a678.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/user-1-64a678.json new file mode 100644 index 0000000000..b872603f56 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/user-1-64a678.json @@ -0,0 +1,43 @@ +{ + "id": "64a67881-ce5e-4dd2-9d28-af9f67a4d9d1", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:33 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4932", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C49E:6D70:398BA:44594:5DD35B0D" + } + }, + "uuid": "64a67881-ce5e-4dd2-9d28-af9f67a4d9d1", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json new file mode 100644 index 0000000000..9c334614f7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json @@ -0,0 +1,124 @@ +{ + "id": 222596117, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYxMTc=", + "name": "temp-testSignedCommits", + "full_name": "github-api-test-org/temp-testSignedCommits", + "private": false, + "owner": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testSignedCommits", + "description": "A test repository for testing the github-api project: temp-testSignedCommits", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/deployments", + "created_at": "2019-11-19T03:01:51Z", + "updated_at": "2019-11-19T03:01:58Z", + "pushed_at": "2019-11-19T03:01:53Z", + "git_url": "git://github.com/github-api-test-org/temp-testSignedCommits.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testSignedCommits.git", + "clone_url": "https://github.com/github-api-test-org/temp-testSignedCommits.git", + "svn_url": "https://github.com/github-api-test-org/temp-testSignedCommits", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "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": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-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/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json new file mode 100644 index 0000000000..5fa5d2a202 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "9ef208e9f31fee7de1f0d10728f914022791e127", + "node_id": "MDY6Q29tbWl0MjIyNTk2MTE3OjllZjIwOGU5ZjMxZmVlN2RlMWYwZDEwNzI4ZjkxNDAyMjc5MWUxMjc=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:53Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:53Z" + }, + "message": "Initial commit", + "tree": { + "sha": "5bc9e3c14a62b6c19ec7ea436245290591751fc4", + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/trees/5bc9e3c14a62b6c19ec7ea436245290591751fc4" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/commits/9ef208e9f31fee7de1f0d10728f914022791e127", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01shCRBK7hj4Ov3rIwAAdHIIADWylhXW45yghg2gvvoO7JjK\n/0+CpNsQyfSiLQ9hFkAFfWUstUr1DhknQGFWdKKyDEXtPDu0J/Ed/d5yb9ebiz1n\nvCTQcSK0VxNkVVtf1+wYNi8+9OOb+GfAt6pUtqbYzV2pAUdgqsSOO/g/1svGlGPq\nz8+aV17OuGnY+IIB3FA0LWYG4b+b9LmZQHjiWSOpyJvZ+i4JVyJGYokrb4BzhkUy\ng30rjoVw8+q9deJjUAs/p8X0X2VtG3K4BSiIXraF54qi1yoYrjJlMOsGfl1MA4iE\n/Omt7fiVdhfy85+BAPthu4+HssuHgVPbWKU17DF0CMy0HYYiPirY4uioNiXkkT8=\n=p6ni\n-----END PGP SIGNATURE-----\n", + "payload": "tree 5bc9e3c14a62b6c19ec7ea436245290591751fc4\nauthor Liam Newman 1574132513 -0800\ncommitter GitHub 1574132513 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/commits/9ef208e9f31fee7de1f0d10728f914022791e127", + "html_url": "https://github.com/github-api-test-org/temp-testSignedCommits/commit/9ef208e9f31fee7de1f0d10728f914022791e127", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/commits/9ef208e9f31fee7de1f0d10728f914022791e127/comments", + "author": { + "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 + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master", + "html": "https://github.com/github-api-test-org/temp-testSignedCommits/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json new file mode 100644 index 0000000000..0107dc1a09 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json @@ -0,0 +1,7 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection", + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/enforce_admins", + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json new file mode 100644 index 0000000000..6f84c075f5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.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": 176, + "public_gists": 7, + "followers": 140, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "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/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits-2-126c7a.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits-2-126c7a.json new file mode 100644 index 0000000000..373f2754c1 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits-2-126c7a.json @@ -0,0 +1,43 @@ +{ + "id": "126c7a91-25f8-4610-a015-12535c6f79bd", + "name": "repos_github-api-test-org_temp-testsignedcommits", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"0f68d4fb4620d1d60575c184b481409e\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:58 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:205F5:2518C:5DD35B1F" + } + }, + "uuid": "126c7a91-25f8-4610-a015-12535c6f79bd", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master-3-7a0577.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master-3-7a0577.json new file mode 100644 index 0000000000..90da917e2c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master-3-7a0577.json @@ -0,0 +1,42 @@ +{ + "id": "7a0577f3-c41c-4cbe-9965-f6f53aea602d", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4896", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"64cf89312c87f9689cb2a8583eeddda2\"", + "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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:20604:252C3:5DD35B26" + } + }, + "uuid": "7a0577f3-c41c-4cbe-9965-f6f53aea602d", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4-4b8a92.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4-4b8a92.json new file mode 100644 index 0000000000..621ea86f30 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4-4b8a92.json @@ -0,0 +1,49 @@ +{ + "id": "4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4895", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"da9d21f9528a07ca0c4ac56de0278d58\"", + "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.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:2060C:252CE:5DD35B26" + } + }, + "uuid": "4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-5-c0150d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-5-c0150d.json new file mode 100644 index 0000000000..a82444ecdd --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-5-c0150d.json @@ -0,0 +1,45 @@ +{ + "id": "c0150d3b-dbf8-4426-9a59-af31e3448299", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":false}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4894", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"6381f33d367d1e194e371ef617d6d17f\"", + "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.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:20620:252E1:5DD35B26" + } + }, + "uuid": "c0150d3b-dbf8-4426-9a59-af31e3448299", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-2", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-6-e29707.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-6-e29707.json new file mode 100644 index 0000000000..f2f9c59c84 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-6-e29707.json @@ -0,0 +1,49 @@ +{ + "id": "e2970726-71d5-4880-bd8f-bb6ad1f578a8", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":true}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4893", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"bca005912506b8129cdb5bb65d6b7c0a\"", + "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.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:2062B:252EF:5DD35B27" + } + }, + "uuid": "e2970726-71d5-4880-bd8f-bb6ad1f578a8", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-7-fa5a0d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-7-fa5a0d.json new file mode 100644 index 0000000000..cded0f0020 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-7-fa5a0d.json @@ -0,0 +1,45 @@ +{ + "id": "fa5a0df8-3cdd-424a-a744-9b96a2455f68", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":true}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4892", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"bca005912506b8129cdb5bb65d6b7c0a\"", + "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.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:20644:25307:5DD35B27" + } + }, + "uuid": "fa5a0df8-3cdd-424a-a744-9b96a2455f68", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-2", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-3", + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-8-8c2a08.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-8-8c2a08.json new file mode 100644 index 0000000000..2a35de7a76 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-8-8c2a08.json @@ -0,0 +1,35 @@ +{ + "id": "8c2a0866-3d67-4b80-a36a-a37714ca5af9", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "DELETE" + }, + "response": { + "status": 204, + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4891", + "X-RateLimit-Reset": "1574135997", + "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.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "C4B1:6D6F:20655:25325:5DD35B27" + } + }, + "uuid": "8c2a0866-3d67-4b80-a36a-a37714ca5af9", + "persistent": true, + "insertionIndex": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-9-c0efc3.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-9-c0efc3.json new file mode 100644 index 0000000000..7f93da8175 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-9-c0efc3.json @@ -0,0 +1,44 @@ +{ + "id": "c0efc3bb-2eaf-4225-a416-dc9f9371d508", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":false}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:02:00 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4890", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"6381f33d367d1e194e371ef617d6d17f\"", + "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.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:20668:25337:5DD35B27" + } + }, + "uuid": "c0efc3bb-2eaf-4225-a416-dc9f9371d508", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-3", + "insertionIndex": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/user-1-94ed9a.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/user-1-94ed9a.json new file mode 100644 index 0000000000..9dae95e727 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/user-1-94ed9a.json @@ -0,0 +1,43 @@ +{ + "id": "94ed9a81-5dda-4f29-8f0b-18eab8a75f14", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:51 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4905", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 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", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "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": "C4B1:6D6F:204F4:25187:5DD35B1F" + } + }, + "uuid": "94ed9a81-5dda-4f29-8f0b-18eab8a75f14", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From d02af5ccb0be883c93f3e0ef83ff19ed093c2c21 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 18 Nov 2019 12:57:09 -0800 Subject: [PATCH 3/5] Switch property mapper to snake case Jackson to automatically map property names using known patterns. GitHub uses snake_case. --- src/main/java/org/kohsuke/github/GHApp.java | 5 ----- .../java/org/kohsuke/github/GHAppInstallationToken.java | 2 -- src/main/java/org/kohsuke/github/GHBranchProtection.java | 8 ++------ src/main/java/org/kohsuke/github/GHEventPayload.java | 5 ----- src/main/java/org/kohsuke/github/GitHub.java | 4 +++- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHApp.java b/src/main/java/org/kohsuke/github/GHApp.java index a7fb74feed..affdf9eca1 100644 --- a/src/main/java/org/kohsuke/github/GHApp.java +++ b/src/main/java/org/kohsuke/github/GHApp.java @@ -1,7 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonProperty; - import java.io.IOException; import java.net.URL; import java.util.List; @@ -21,13 +19,10 @@ public class GHApp extends GHObject { private GHUser owner; private String name; private String description; - @JsonProperty("external_url") private String externalUrl; private Map permissions; private List events; - @JsonProperty("installations_count") private long installationsCount; - @JsonProperty("html_url") private String htmlUrl; /** diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java index 61e5b54e98..22acc291c3 100644 --- a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java +++ b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonProperty; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -22,7 +21,6 @@ public class GHAppInstallationToken { protected String expires_at; private Map permissions; private List repositories; - @JsonProperty("repository_selection") private GHRepositorySelection repositorySelection; /** diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java index d434c4039f..4c9246d9de 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtection.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java @@ -18,7 +18,7 @@ public class GHBranchProtection { private static final String REQUIRE_SIGNATURES_URI = "/required_signatures"; - @JsonProperty("enforce_admins") + @JsonProperty private EnforceAdmins enforceAdmins; private GitHub root; @@ -26,7 +26,7 @@ public class GHBranchProtection { @JsonProperty("required_pull_request_reviews") private RequiredReviews requiredReviews; - @JsonProperty("required_status_checks") + @JsonProperty private RequiredStatusChecks requiredStatusChecks; @JsonProperty @@ -162,10 +162,8 @@ public static class RequiredReviews { @JsonProperty("dismissal_restrictions") private Restrictions dismissalRestriction; - @JsonProperty("dismiss_stale_reviews") private boolean dismissStaleReviews; - @JsonProperty("require_code_owner_reviews") private boolean requireCodeOwnerReviews; @JsonProperty("required_approving_review_count") @@ -294,7 +292,6 @@ public static class Restrictions { @JsonProperty private Collection teams; - @JsonProperty("teams_url") private String teamsUrl; @JsonProperty @@ -303,7 +300,6 @@ public static class Restrictions { @JsonProperty private Collection users; - @JsonProperty("users_url") private String usersUrl; /** diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index ddf0b17e13..7c18ae7d61 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -491,9 +490,7 @@ void wrapUp(GitHub root) { justification = "Constructed by JSON deserialization") public static class Create extends GHEventPayload { private String ref; - @JsonProperty("ref_type") private String refType; - @JsonProperty("master_branch") private String masterBranch; private String description; private GHRepository repository; @@ -575,7 +572,6 @@ void wrapUp(GitHub root) { justification = "Constructed by JSON deserialization") public static class Delete extends GHEventPayload { private String ref; - @JsonProperty("ref_type") private String refType; private GHRepository repository; @@ -695,7 +691,6 @@ void wrapUp(GitHub root) { @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class DeploymentStatus extends GHEventPayload { - @JsonProperty("deployment_status") private GHDeploymentStatus deploymentStatus; private GHDeployment deployment; private GHRepository repository; diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 4ef0782f4c..27b29540e4 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import org.apache.commons.codec.Charsets; @@ -1379,9 +1380,10 @@ static String printDate(Date dt) { }; static { - MAPPER.setVisibilityChecker(new Std(NONE, NONE, NONE, NONE, ANY)); + MAPPER.setVisibility(new Std(NONE, NONE, NONE, NONE, ANY)); MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true); + MAPPER.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); } static final String GITHUB_URL = "https://api.github.com"; From a8dbe65e30ab6c03a45bc6b6f3e1433745271b20 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 18 Nov 2019 19:13:10 -0800 Subject: [PATCH 4/5] Move GistTest to GHGistTest --- .../java/org/kohsuke/github/{GistTest.java => GHGistTest.java} | 2 +- .../gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json | 0 .../__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json | 0 .../wiremock/gistFile/mappings/gists_9903708-2-c3067d.json | 0 .../wiremock/gistFile/mappings/user-1-9226d6.json | 0 .../__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json | 0 .../__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json | 0 .../wiremock/lifecycleTest/mappings/gists-2-2f93ee.json | 0 .../gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json | 0 .../wiremock/lifecycleTest/mappings/user-1-3380f8.json | 0 .../gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json | 0 ...ists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json | 0 ...ists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json | 0 .../__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json | 0 .../gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json | 0 .../wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json | 0 .../starTest/mappings/gists_9903708_forks-7-42d6e4.json | 0 .../starTest/mappings/gists_9903708_forks-8-992bf5.json | 0 .../wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json | 0 .../wiremock/starTest/mappings/gists_9903708_star-4-680201.json | 0 .../wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json | 0 .../wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json | 0 .../wiremock/starTest/mappings/user-1-075004.json | 0 23 files changed, 1 insertion(+), 1 deletion(-) rename src/test/java/org/kohsuke/github/{GistTest.java => GHGistTest.java} (97%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/gistFile/mappings/user-1-9226d6.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/lifecycleTest/mappings/user-1-3380f8.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_9903708_star-4-680201.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json (100%) rename src/test/resources/org/kohsuke/github/{GistTest => GHGistTest}/wiremock/starTest/mappings/user-1-075004.json (100%) diff --git a/src/test/java/org/kohsuke/github/GistTest.java b/src/test/java/org/kohsuke/github/GHGistTest.java similarity index 97% rename from src/test/java/org/kohsuke/github/GistTest.java rename to src/test/java/org/kohsuke/github/GHGistTest.java index 117a76d6a9..beae248f27 100644 --- a/src/test/java/org/kohsuke/github/GistTest.java +++ b/src/test/java/org/kohsuke/github/GHGistTest.java @@ -9,7 +9,7 @@ /** * @author Kohsuke Kawaguchi */ -public class GistTest extends AbstractGitHubWireMockTest { +public class GHGistTest extends AbstractGitHubWireMockTest { @Test public void lifecycleTest() throws Exception { // CRUD operation diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/user-1-9226d6.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/user-1-9226d6.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/user-1-9226d6.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/user-1-9226d6.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/user-1-075004.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/user-1-075004.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/user-1-075004.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/user-1-075004.json From 82fa340c07d902654344876d69b7597417f8d8dc Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 18 Nov 2019 19:14:24 -0800 Subject: [PATCH 5/5] Import sorting cleanup --- src/main/java/org/kohsuke/github/GHBranch.java | 2 +- src/test/java/org/kohsuke/github/GHRepositoryTest.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index 5c210fe0ec..7e1ff1a4f7 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonMappingException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.IOException; import java.net.URL; import java.util.Collection; diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 5c80815424..6bfc2fd1b7 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -1,7 +1,6 @@ package org.kohsuke.github; import org.apache.commons.io.IOUtils; -import org.junit.Ignore; import org.junit.Test; import java.io.FileNotFoundException;