diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index a7d47f8a77..e3fbc8ceab 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -30,6 +30,7 @@ import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; +import org.kohsuke.github.function.InputStreamFunction; import java.io.FileNotFoundException; import java.io.IOException; @@ -49,7 +50,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.WeakHashMap; @@ -57,13 +57,8 @@ import javax.annotation.Nonnull; import static java.util.Arrays.*; -import static org.kohsuke.github.internal.Previews.ANTIOPE; -import static org.kohsuke.github.internal.Previews.ANT_MAN; -import static org.kohsuke.github.internal.Previews.BAPTISTE; -import static org.kohsuke.github.internal.Previews.FLASH; -import static org.kohsuke.github.internal.Previews.INERTIA; -import static org.kohsuke.github.internal.Previews.MERCY; -import static org.kohsuke.github.internal.Previews.SHADOW_CAT; +import static java.util.Objects.requireNonNull; +import static org.kohsuke.github.internal.Previews.*; /** * A repository on GitHub. @@ -1788,7 +1783,7 @@ public InputStream readBlob(String blobSha) throws IOException { return root.createRequest() .withHeader("Accept", "application/vnd.github.v3.raw") .withUrlPath(target) - .fetchStream(); + .fetchStream(Requester::copyInputStream); } /** @@ -2815,7 +2810,7 @@ public Reader renderMarkdown(String text, MarkdownMode mode) throws IOException .with("mode", mode == null ? null : mode.toString()) .with("context", getFullName()) .withUrlPath("/markdown") - .fetchStream(), + .fetchStream(Requester::copyInputStream), "UTF-8"); } @@ -2969,6 +2964,52 @@ public GHTagObject createTag(String tag, String message, String object, String t .wrap(this); } + /** + * Streams a zip archive of the repository, optionally at a given ref. + * + * @param + * the type of result + * @param streamFunction + * The {@link InputStreamFunction} that will process the stream + * @param ref + * if null the repository's default branch, usually master, + * @throws IOException + * The IO exception. + * @return the result of reading the stream. + */ + public T readZip(InputStreamFunction streamFunction, String ref) throws IOException { + return downloadArchive("zip", ref, streamFunction); + } + + /** + * Streams a tar archive of the repository, optionally at a given ref. + * + * @param + * the type of result + * @param streamFunction + * The {@link InputStreamFunction} that will process the stream + * @param ref + * if null the repository's default branch, usually master, + * @throws IOException + * The IO exception. + * @return the result of reading the stream. + */ + public T readTar(InputStreamFunction streamFunction, String ref) throws IOException { + return downloadArchive("tar", ref, streamFunction); + } + + private T downloadArchive(@Nonnull String type, + @CheckForNull String ref, + @Nonnull InputStreamFunction streamFunction) throws IOException { + requireNonNull(streamFunction, "Sink must not be null"); + String tailUrl = getApiTailUrl(type + "ball"); + if (ref != null) { + tailUrl += "/" + ref; + } + final Requester builder = root.createRequest().method("GET").withUrlPath(tailUrl); + return builder.fetchStream(streamFunction); + } + /** * Populate this object. * @@ -2980,7 +3021,7 @@ void populate() throws IOException { return; // can't populate if the root is offline } - final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!"); + final URL url = requireNonNull(getUrl(), "Missing instance URL!"); try { // IMPORTANT: the url for repository records does not reliably point to the API url. diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index ef070b4423..ef931c0af4 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -1278,7 +1278,7 @@ public Reader renderMarkdown(String text) throws IOException { .with(new ByteArrayInputStream(text.getBytes("UTF-8"))) .contentType("text/plain;charset=UTF-8") .withUrlPath("/markdown/raw") - .fetchStream(), + .fetchStream(Requester::copyInputStream), "UTF-8"); } diff --git a/src/main/java/org/kohsuke/github/GitHubResponse.java b/src/main/java/org/kohsuke/github/GitHubResponse.java index 9e82eb80dd..d86dcba190 100644 --- a/src/main/java/org/kohsuke/github/GitHubResponse.java +++ b/src/main/java/org/kohsuke/github/GitHubResponse.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.JsonMappingException; import org.apache.commons.io.IOUtils; +import org.kohsuke.github.function.FunctionThrows; import java.io.Closeable; import java.io.IOException; @@ -194,24 +195,11 @@ public T body() { /** * Represents a supplier of results that can throw. * - *

- * This is a functional interface whose functional method is - * {@link #apply(ResponseInfo)}. - * * @param * the type of results supplied by this supplier */ @FunctionalInterface - interface BodyHandler { - - /** - * Gets a result. - * - * @return a result - * @throws IOException - * if an I/O Exception occurs. - */ - T apply(ResponseInfo input) throws IOException; + interface BodyHandler extends FunctionThrows { } /** diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index 8166323514..72143154db 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -23,7 +23,9 @@ */ package org.kohsuke.github; +import edu.umd.cs.findbugs.annotations.NonNull; import org.apache.commons.io.IOUtils; +import org.kohsuke.github.function.InputStreamFunction; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -106,15 +108,31 @@ public int fetchHttpStatusCode() throws IOException { * Response input stream. There are scenarios where direct stream reading is needed, however it is better to use * {@link #fetch(Class)} where possible. * - * @return the input stream * @throws IOException * the io exception */ - public InputStream fetchStream() throws IOException { - return client - .sendRequest(this, - (responseInfo) -> new ByteArrayInputStream(IOUtils.toByteArray(responseInfo.bodyStream()))) - .body(); + public T fetchStream(@Nonnull InputStreamFunction handler) throws IOException { + return client.sendRequest(this, (responseInfo) -> handler.apply(responseInfo.bodyStream())).body(); + } + + /** + * Helper function to make it easy to pull streams. + * + * Copies an input stream to an in-memory input stream. The performance on this is not great but + * {@link GitHubResponse.ResponseInfo#bodyStream()} is closed at the end of every call to + * {@link GitHubClient#sendRequest(GitHubRequest, GitHubResponse.BodyHandler)}, so any reads to the original input + * stream must be completed before then. There are a number of deprecated methods that return {@link InputStream}. + * This method keeps all of them using the same code path. + * + * @param inputStream + * the input stream to be copied + * @return an in-memory copy of the passed input stream + * @throws IOException + * if an error occurs while copying the stream + */ + @NonNull + public static InputStream copyInputStream(InputStream inputStream) throws IOException { + return new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); } /** diff --git a/src/main/java/org/kohsuke/github/function/FunctionThrows.java b/src/main/java/org/kohsuke/github/function/FunctionThrows.java new file mode 100644 index 0000000000..cb23cc577c --- /dev/null +++ b/src/main/java/org/kohsuke/github/function/FunctionThrows.java @@ -0,0 +1,25 @@ +package org.kohsuke.github.function; + +/** + * A functional interface, equivalent to {@link java.util.function.Function} but that allows throwing {@link Throwable} + * + * @param + * the type of input + * @param + * the type of output + * @param + * the type of error + */ +@FunctionalInterface +public interface FunctionThrows { + /** + * Apply r. + * + * @param input + * the input + * @return the r + * @throws E + * the e + */ + R apply(T input) throws E; +} diff --git a/src/main/java/org/kohsuke/github/function/InputStreamFunction.java b/src/main/java/org/kohsuke/github/function/InputStreamFunction.java new file mode 100644 index 0000000000..efad6fcd12 --- /dev/null +++ b/src/main/java/org/kohsuke/github/function/InputStreamFunction.java @@ -0,0 +1,14 @@ +package org.kohsuke.github.function; + +import java.io.IOException; +import java.io.InputStream; + +/** + * A functional interface, equivalent to {@link java.util.function.Function} but that allows throwing {@link Throwable} + * + * @param + * the type to of object to be returned + */ +@FunctionalInterface +public interface InputStreamFunction extends FunctionThrows { +} diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index e71204970c..c858753646 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -4,8 +4,10 @@ import org.apache.commons.io.IOUtils; import org.junit.Test; +import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Date; @@ -29,6 +31,20 @@ private GHRepository getRepository(GitHub gitHub) throws IOException { return gitHub.getOrganization("hub4j-test-org").getRepository("github-api"); } + @Test + public void testZipball() throws IOException { + getTempRepository().readZip((InputStream inputstream) -> { + return new ByteArrayInputStream(IOUtils.toByteArray(inputstream)); + }, null); + } + + @Test + public void testTarball() throws IOException { + getTempRepository().readTar((InputStream inputstream) -> { + return new ByteArrayInputStream(IOUtils.toByteArray(inputstream)); + }, null); + } + @Test public void testGetters() throws IOException { GHRepository r = getTempRepository(); diff --git a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java index ddb35b037e..c389ee7e8a 100644 --- a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java @@ -8,6 +8,7 @@ import com.github.tomakehurst.wiremock.http.*; import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; import com.google.gson.*; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.File; import java.io.IOException; @@ -64,6 +65,10 @@ public WireMockServer uploadsServer() { return servers.get("uploads"); } + public WireMockServer codeloadServer() { + return servers.get("codeload"); + } + public boolean isUseProxy() { return GitHubWireMockRule.useProxy; } @@ -88,6 +93,10 @@ protected void initializeServers() { if (new File(apiServer().getOptions().filesRoot().getPath() + "_uploads").exists() || isUseProxy()) { initializeServer("uploads"); } + + if (new File(apiServer().getOptions().filesRoot().getPath() + "_codeload").exists() || isUseProxy()) { + initializeServer("codeload"); + } } @Override @@ -106,6 +115,11 @@ protected void before() { if (this.uploadsServer() != null) { this.uploadsServer().stubFor(proxyAllTo("https://uploads.github.com").atPriority(100)); } + + if (this.codeloadServer() != null) { + this.codeloadServer().stubFor(proxyAllTo("https://codeload.github.com").atPriority(100)); + } + } @Override @@ -121,6 +135,8 @@ protected void after() { recordSnapshot(this.rawServer(), "https://raw.githubusercontent.com", true); recordSnapshot(this.uploadsServer(), "https://uploads.github.com", false); + + recordSnapshot(this.codeloadServer(), "https://codeload.github.com", true); } private void recordSnapshot(WireMockServer server, String target, boolean isRawServer) { @@ -141,7 +157,7 @@ private void recordSnapshot(WireMockServer server, String target, boolean isRawS .extractTextBodiesOver(255)); // After taking the snapshot, format the output - formatTestResources(new File(this.apiServer().getOptions().filesRoot().getPath()).toPath(), false); + formatTestResources(new File(server.getOptions().filesRoot().getPath()).toPath(), isRawServer); } } @@ -213,6 +229,10 @@ public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContex fileText = fileText.replace(this.uploadsServer().baseUrl(), "https://uploads.github.com"); } + if (this.codeloadServer() != null) { + fileText = fileText.replace(this.codeloadServer().baseUrl(), "https://codeload.github.com"); + } + // point bodyFile in the mapping to the renamed body file if (entry != null && filePath.toString().contains("mappings")) { fileText = fileText.replace("-" + entry.getKey(), "-" + entry.getValue()); @@ -263,16 +283,23 @@ private Path renameFileToIndex(Path filePath, Map.Entry idToInde public String mapToMockGitHub(String body) { body = body.replace("https://api.github.com", this.apiServer().baseUrl()); - if (this.rawServer() != null) { - body = body.replace("https://raw.githubusercontent.com", this.rawServer().baseUrl()); - } else { - body = body.replace("https://raw.githubusercontent.com", this.apiServer().baseUrl() + "/raw"); - } + body = replaceTargetServerUrl(body, this.rawServer(), "https://raw.githubusercontent.com", "/raw"); - if (this.uploadsServer() != null) { - body = body.replace("https://uploads.github.com", this.uploadsServer().baseUrl()); + body = replaceTargetServerUrl(body, this.uploadsServer(), "https://uploads.github.com", "/uploads"); + + body = replaceTargetServerUrl(body, this.codeloadServer(), "https://codeload.github.com", "/codeload"); + return body; + } + + @NonNull + private String replaceTargetServerUrl(String body, + WireMockServer wireMockServer, + String rawTarget, + String inactiveTarget) { + if (wireMockServer != null) { + body = body.replace(rawTarget, wireMockServer.baseUrl()); } else { - body = body.replace("https://uploads.github.com", this.apiServer().baseUrl() + "/uploads"); + body = body.replace(rawTarget, this.apiServer().baseUrl() + inactiveTarget); } return body; } @@ -294,6 +321,7 @@ public Response transform(Request request, Response response, FileSource files, Collection headers = response.getHeaders().all(); fixListTraversalHeader(response, headers); + fixLocationHeader(response, headers); if ("application/json".equals(response.getHeaders().getContentTypeHeader().mimeTypePart())) { @@ -321,11 +349,20 @@ private String getBodyAsString(Response response, Collection headers } private void fixListTraversalHeader(Response response, Collection headers) { + // Lists are broken up into pages. The Link header contains urls for previous and next pages. HttpHeader linkHeader = response.getHeaders().getHeader("Link"); if (linkHeader.isPresent()) { headers.removeIf(item -> item.keyEquals("Link")); - headers.add(HttpHeader.httpHeader("Link", - linkHeader.firstValue().replace("https://api.github.com", rule.apiServer().baseUrl()))); + headers.add(HttpHeader.httpHeader("Link", rule.mapToMockGitHub(linkHeader.firstValue()))); + } + } + + private void fixLocationHeader(Response response, Collection headers) { + // For redirects, the Location header points to the new target. + HttpHeader linkHeader = response.getHeaders().getHeader("Location"); + if (linkHeader.isPresent()) { + headers.removeIf(item -> item.keyEquals("Location")); + headers.add(HttpHeader.httpHeader("Location", rule.mapToMockGitHub(linkHeader.firstValue()))); } } diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/__files/repos_hub4j-test-org_temp-testtarball-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/__files/repos_hub4j-test-org_temp-testtarball-2.json new file mode 100644 index 0000000000..3944bd1932 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/__files/repos_hub4j-test-org_temp-testtarball-2.json @@ -0,0 +1,126 @@ +{ + "id": 326623381, + "node_id": "MDEwOlJlcG9zaXRvcnkzMjY2MjMzODE=", + "name": "temp-testTarball", + "full_name": "hub4j-test-org/temp-testTarball", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/temp-testTarball", + "description": "A test repository for testing the github-api project: temp-testTarball", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball", + "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-testTarball/deployments", + "created_at": "2021-01-04T08:53:50Z", + "updated_at": "2021-01-04T08:53:54Z", + "pushed_at": "2021-01-04T08:53:52Z", + "git_url": "git://github.com/hub4j-test-org/temp-testTarball.git", + "ssh_url": "git@github.com:hub4j-test-org/temp-testTarball.git", + "clone_url": "https://github.com/hub4j-test-org/temp-testTarball.git", + "svn_url": "https://github.com/hub4j-test-org/temp-testTarball", + "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": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/__files/user-1.json new file mode 100644 index 0000000000..b7f22d3e22 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/__files/user-1.json @@ -0,0 +1,46 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": null, + "twitter_username": "bitwiseman", + "public_repos": 199, + "public_gists": 7, + "followers": 175, + "following": 11, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-12-23T22:23:08Z", + "private_gists": 19, + "total_private_repos": 17, + "owned_private_repos": 0, + "disk_usage": 33700, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/repos_hub4j-test-org_temp-testtarball-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/repos_hub4j-test-org_temp-testtarball-2.json new file mode 100644 index 0000000000..3e8f968a12 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/repos_hub4j-test-org_temp-testtarball-2.json @@ -0,0 +1,48 @@ +{ + "id": "9223893a-a7e9-427e-adb0-e3759a83884d", + "name": "repos_hub4j-test-org_temp-testtarball", + "request": { + "url": "/repos/hub4j-test-org/temp-testTarball", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_temp-testtarball-2.json", + "headers": { + "Date": "Mon, 04 Jan 2021 08:53:56 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "ETag": "W/\"0efc5253a075be861b75de091f949051cbb8d1edd1d9f5a2671361506750599f\"", + "Last-Modified": "Mon, 04 Jan 2021 08:53:54 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4956", + "X-RateLimit-Reset": "1609753350", + "X-RateLimit-Used": "44", + "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": "E328:327C:74BB33:94FCDB:5FF2D79D" + } + }, + "uuid": "9223893a-a7e9-427e-adb0-e3759a83884d", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/repos_hub4j-test-org_temp-testtarball_tarball-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/repos_hub4j-test-org_temp-testtarball_tarball-3.json new file mode 100644 index 0000000000..adc7fb4f1a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/repos_hub4j-test-org_temp-testtarball_tarball-3.json @@ -0,0 +1,43 @@ +{ + "id": "28a8f5bf-a72d-40cc-86a1-df9c1489c3ee", + "name": "repos_hub4j-test-org_temp-testtarball_tarball", + "request": { + "url": "/repos/hub4j-test-org/temp-testTarball/tarball", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 302, + "headers": { + "Date": "Mon, 04 Jan 2021 08:53:56 GMT", + "Content-Type": "text/html;charset=utf-8", + "Server": "GitHub.com", + "Status": "302 Found", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4956", + "X-RateLimit-Reset": "1609753350", + "X-RateLimit-Used": "44", + "Cache-Control": "public, must-revalidate, max-age=0", + "Expires": "Mon, 04 Jan 2021 08:53:56 GMT", + "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, Accept, X-Requested-With", + "Accept-Encoding" + ], + "X-GitHub-Request-Id": "E328:327C:74BB34:94FCF3:5FF2D7A4", + "Location": "https://codeload.github.com/hub4j-test-org/temp-testTarball/legacy.tar.gz/main" + } + }, + "uuid": "28a8f5bf-a72d-40cc-86a1-df9c1489c3ee", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/user-1.json new file mode 100644 index 0000000000..bdb2ccda16 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball/mappings/user-1.json @@ -0,0 +1,48 @@ +{ + "id": "7a5bb867-6b83-4051-8bde-da61b825d2f7", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Mon, 04 Jan 2021 08:53:49 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "ETag": "W/\"73c95077a6a9d4d2e0bf97071dc6bb996011f641c608a28e8e32e7c118fa0186\"", + "Last-Modified": "Wed, 23 Dec 2020 22:23:08 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4961", + "X-RateLimit-Reset": "1609753350", + "X-RateLimit-Used": "39", + "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": "E328:327C:74BB23:94FCDA:5FF2D79D" + } + }, + "uuid": "7a5bb867-6b83-4051-8bde-da61b825d2f7", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball_codeload/__files/hub4j-test-org_temp-testtarball_legacytargz_main-1.txt b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball_codeload/__files/hub4j-test-org_temp-testtarball_legacytargz_main-1.txt new file mode 100644 index 0000000000..ca2aa6fe30 Binary files /dev/null and b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball_codeload/__files/hub4j-test-org_temp-testtarball_legacytargz_main-1.txt differ diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball_codeload/mappings/hub4j-test-org_temp-testtarball_legacytargz_main-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball_codeload/mappings/hub4j-test-org_temp-testtarball_legacytargz_main-1.json new file mode 100644 index 0000000000..7f1e571679 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testTarball_codeload/mappings/hub4j-test-org_temp-testtarball_legacytargz_main-1.json @@ -0,0 +1,39 @@ +{ + "id": "05058fd3-c66f-4d07-b588-000cc532a926", + "name": "hub4j-test-org_temp-testtarball_legacytargz_main", + "request": { + "url": "/hub4j-test-org/temp-testTarball/legacy.tar.gz/main", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "hub4j-test-org_temp-testtarball_legacytargz_main-1.txt", + "headers": { + "Content-Disposition": "attachment; filename=hub4j-test-org-temp-testTarball-a74e312.tar.gz", + "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox", + "Content-Type": "application/x-gzip", + "ETag": "W/\"ca816dd3dc5e53614cac301940876a71113f01b4584f05ffe6942a9e1927f965\"", + "Strict-Transport-Security": "max-age=31536000", + "Vary": "Authorization,Accept-Encoding", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "Date": "Mon, 04 Jan 2021 09:05:18 GMT", + "X-Varnish": "290984704", + "Age": "0", + "Via": "1.1 varnish (Varnish/6.0)", + "X-Cache": "MISS", + "X-Cache-Hits": "0", + "Accept-Ranges": "bytes", + "X-GitHub-Request-Id": "E374:78B6:17DCE5:4AD2E5:5FF2DA4E" + } + }, + "uuid": "05058fd3-c66f-4d07-b588-000cc532a926", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/__files/repos_hub4j-test-org_temp-testzipball-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/__files/repos_hub4j-test-org_temp-testzipball-2.json new file mode 100644 index 0000000000..a05dae1ffe --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/__files/repos_hub4j-test-org_temp-testzipball-2.json @@ -0,0 +1,126 @@ +{ + "id": 326628164, + "node_id": "MDEwOlJlcG9zaXRvcnkzMjY2MjgxNjQ=", + "name": "temp-testZipball", + "full_name": "hub4j-test-org/temp-testZipball", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/temp-testZipball", + "description": "A test repository for testing the github-api project: temp-testZipball", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball", + "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-testZipball/deployments", + "created_at": "2021-01-04T09:12:57Z", + "updated_at": "2021-01-04T09:13:01Z", + "pushed_at": "2021-01-04T09:12:59Z", + "git_url": "git://github.com/hub4j-test-org/temp-testZipball.git", + "ssh_url": "git@github.com:hub4j-test-org/temp-testZipball.git", + "clone_url": "https://github.com/hub4j-test-org/temp-testZipball.git", + "svn_url": "https://github.com/hub4j-test-org/temp-testZipball", + "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": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/__files/user-1.json new file mode 100644 index 0000000000..b7f22d3e22 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/__files/user-1.json @@ -0,0 +1,46 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": null, + "twitter_username": "bitwiseman", + "public_repos": 199, + "public_gists": 7, + "followers": 175, + "following": 11, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-12-23T22:23:08Z", + "private_gists": 19, + "total_private_repos": 17, + "owned_private_repos": 0, + "disk_usage": 33700, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/repos_hub4j-test-org_temp-testzipball-2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/repos_hub4j-test-org_temp-testzipball-2.json new file mode 100644 index 0000000000..3d7d99b91c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/repos_hub4j-test-org_temp-testzipball-2.json @@ -0,0 +1,48 @@ +{ + "id": "21c59583-c3bc-4bb5-96ee-3f7c4475b063", + "name": "repos_hub4j-test-org_temp-testzipball", + "request": { + "url": "/repos/hub4j-test-org/temp-testZipball", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_temp-testzipball-2.json", + "headers": { + "Date": "Mon, 04 Jan 2021 09:13:03 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "ETag": "W/\"87a7caaccffcefd071b3d9aa2ac7931e4f002a6187bb57c85e817d21717a5614\"", + "Last-Modified": "Mon, 04 Jan 2021 09:13:01 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4928", + "X-RateLimit-Reset": "1609753350", + "X-RateLimit-Used": "72", + "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": "E3B3:1D4C:33F887F:3F4324E:5FF2DC18" + } + }, + "uuid": "21c59583-c3bc-4bb5-96ee-3f7c4475b063", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/repos_hub4j-test-org_temp-testzipball_zipball-3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/repos_hub4j-test-org_temp-testzipball_zipball-3.json new file mode 100644 index 0000000000..cc302a49db --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/repos_hub4j-test-org_temp-testzipball_zipball-3.json @@ -0,0 +1,43 @@ +{ + "id": "6045fad3-6145-4683-b92a-50944c7f44ba", + "name": "repos_hub4j-test-org_temp-testzipball_zipball", + "request": { + "url": "/repos/hub4j-test-org/temp-testZipball/zipball", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 302, + "headers": { + "Date": "Mon, 04 Jan 2021 09:13:03 GMT", + "Content-Type": "text/html;charset=utf-8", + "Server": "GitHub.com", + "Status": "302 Found", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4928", + "X-RateLimit-Reset": "1609753350", + "X-RateLimit-Used": "72", + "Cache-Control": "public, must-revalidate, max-age=0", + "Expires": "Mon, 04 Jan 2021 09:13:03 GMT", + "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, Accept, X-Requested-With", + "Accept-Encoding" + ], + "X-GitHub-Request-Id": "E3B3:1D4C:33F8888:3F433C2:5FF2DC1F", + "Location": "https://codeload.github.com/hub4j-test-org/temp-testZipball/legacy.zip/main" + } + }, + "uuid": "6045fad3-6145-4683-b92a-50944c7f44ba", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/user-1.json new file mode 100644 index 0000000000..0b75890bb4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball/mappings/user-1.json @@ -0,0 +1,48 @@ +{ + "id": "e1bf2ec7-7e15-4b19-9374-93affc205d86", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Mon, 04 Jan 2021 09:12:56 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With", + "Accept-Encoding" + ], + "ETag": "W/\"73c95077a6a9d4d2e0bf97071dc6bb996011f641c608a28e8e32e7c118fa0186\"", + "Last-Modified": "Wed, 23 Dec 2020 22:23:08 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4933", + "X-RateLimit-Reset": "1609753350", + "X-RateLimit-Used": "67", + "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": "E3B3:1D4C:33F875C:3F43247:5FF2DC18" + } + }, + "uuid": "e1bf2ec7-7e15-4b19-9374-93affc205d86", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball_codeload/__files/hub4j-test-org_temp-testzipball_legacyzip_main-1.txt b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball_codeload/__files/hub4j-test-org_temp-testzipball_legacyzip_main-1.txt new file mode 100644 index 0000000000..e69739991f Binary files /dev/null and b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball_codeload/__files/hub4j-test-org_temp-testzipball_legacyzip_main-1.txt differ diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball_codeload/mappings/hub4j-test-org_temp-testzipball_legacyzip_main-1.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball_codeload/mappings/hub4j-test-org_temp-testzipball_legacyzip_main-1.json new file mode 100644 index 0000000000..08c5f522ac --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testZipball_codeload/mappings/hub4j-test-org_temp-testzipball_legacyzip_main-1.json @@ -0,0 +1,39 @@ +{ + "id": "51e04476-36b5-4649-896c-a5246b65dd82", + "name": "hub4j-test-org_temp-testzipball_legacyzip_main", + "request": { + "url": "/hub4j-test-org/temp-testZipball/legacy.zip/main", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "hub4j-test-org_temp-testzipball_legacyzip_main-1.txt", + "headers": { + "Content-Disposition": "attachment; filename=hub4j-test-org-temp-testZipball-12b27ab.zip", + "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox", + "Content-Type": "application/zip", + "ETag": "W/\"f4e07ea59dbed7a35c54e3a8ce438769d12f814ae805bc39482dd897b93e86c0\"", + "Strict-Transport-Security": "max-age=31536000", + "Vary": "Authorization,Accept-Encoding", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "Date": "Mon, 04 Jan 2021 09:13:03 GMT", + "X-Varnish": "289418734", + "Age": "0", + "Via": "1.1 varnish (Varnish/6.0)", + "X-Cache": "HFM", + "X-Cache-Hits": "0", + "Accept-Ranges": "bytes", + "X-GitHub-Request-Id": "E3B7:6D29:177099:4A38D9:5FF2DC1F" + } + }, + "uuid": "51e04476-36b5-4649-896c-a5246b65dd82", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file