diff --git a/src/main/java/org/kohsuke/github/GHGist.java b/src/main/java/org/kohsuke/github/GHGist.java index c4c91737d6..8de2f02585 100644 --- a/src/main/java/org/kohsuke/github/GHGist.java +++ b/src/main/java/org/kohsuke/github/GHGist.java @@ -1,6 +1,7 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.net.URL; @@ -115,8 +116,13 @@ private void wrapUp() { e.getValue().fileName = e.getKey(); } } + String getApiTailUrl(String tail) { - return "/gists/" + id + '/' + tail; + String result = "/gists/" + id; + if (!StringUtils.isBlank(tail)) { + result += StringUtils.prependIfMissing(tail, "/"); + } + return result; } public void star() throws IOException { @@ -159,6 +165,13 @@ public void delete() throws IOException { new Requester(root).method("DELETE").to("/gists/" + id); } + /** + * Updates this gist via a builder. + */ + public GHGistUpdater update() throws IOException { + return new GHGistUpdater(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -172,4 +185,10 @@ public boolean equals(Object o) { public int hashCode() { return id.hashCode(); } + + GHGist wrap(GHUser owner) { + this.owner = owner; + this.root = owner.root; + return this; + } } diff --git a/src/main/java/org/kohsuke/github/GHGistUpdater.java b/src/main/java/org/kohsuke/github/GHGistUpdater.java new file mode 100644 index 0000000000..71bff34e22 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHGistUpdater.java @@ -0,0 +1,60 @@ +package org.kohsuke.github; + +import java.io.IOException; +import java.util.Collections; +import java.util.LinkedHashMap; + +/** + * Builder pattern for updating a Gist. + * + * @author Martin van Zijl + */ +public class GHGistUpdater { + private final GHGist base; + private final Requester builder; + LinkedHashMap files; + + GHGistUpdater(GHGist base) { + this.base = base; + this.builder = new Requester(base.root); + + files = new LinkedHashMap<>(); + } + + public GHGistUpdater addFile(String fileName, String content) throws IOException { + updateFile(fileName, content); + return this; + } + +// // This method does not work. +// public GHGistUpdater deleteFile(String fileName) throws IOException { +// files.put(fileName, Collections.singletonMap("filename", null)); +// return this; +// } + + public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException + { + files.put(fileName, Collections.singletonMap("filename", newFileName)); + return this; + } + + public GHGistUpdater updateFile(String fileName, String content) throws IOException { + files.put(fileName, Collections.singletonMap("content", content)); + return this; + } + + public GHGistUpdater description(String desc) { + builder.with("description",desc); + return this; + } + + /** + * Updates the Gist based on the parameters specified thus far. + */ + public GHGist update() throws IOException { + builder._with("files", files); + return builder + .method("PATCH") + .to(base.getApiTailUrl(""), GHGist.class).wrap(base.owner); + } +} diff --git a/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java new file mode 100644 index 0000000000..23bd4622f3 --- /dev/null +++ b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java @@ -0,0 +1,73 @@ +package org.kohsuke.github; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * @author Martin van Zijl + */ +public class GHGistUpdaterTest extends AbstractGitHubWireMockTest { + + private GHGist gist; + + @Before + public void setUp() throws IOException { + GHGistBuilder builder = new GHGistBuilder(gitHub); + 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(); + } + + @After + public void cleanUp() throws Exception { + // Cleanup is only needed when proxying + if (!mockGitHub.isUseProxy()) { + return; + } + + gist.delete(); + } + + @Test + public void testGitUpdater() throws Exception { + GHGistUpdater updater = gist.update(); + 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") + .update(); + + assertEquals("Description updated by API", updatedGist.getDescription()); + + Map files = updatedGist.getFiles(); + + // Check that the unmodified file stays intact. + assertTrue(files.containsKey("unmodified.txt")); + assertEquals("Should be unmodified", files.get("unmodified.txt").getContent()); + + // Check that the files are updated as expected. + //assertFalse("File was not deleted.", files.containsKey("delete-me.txt")); + + assertTrue(files.containsKey("new-file.txt")); + assertEquals("Added by updater", files.get("new-file.txt").getContent()); + + assertFalse(files.containsKey("rename-me.py")); + assertTrue(files.containsKey("renamed.py")); + assertEquals("print 'hello'", files.get("renamed.py").getContent()); + + assertEquals("Content updated by API", files.get("update-me.txt").getContent()); + } +} diff --git a/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/__files/gists-fde9aa5a-83fc-41d8-b556-16335859de73.json b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/__files/gists-fde9aa5a-83fc-41d8-b556-16335859de73.json new file mode 100644 index 0000000000..c0d3a5cb17 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/__files/gists-fde9aa5a-83fc-41d8-b556-16335859de73.json @@ -0,0 +1,100 @@ +{ + "url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d", + "forks_url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/forks", + "commits_url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/commits", + "id": "209fef72c25fe4b3f673437603ab6d5d", + "node_id": "MDQ6R2lzdDIwOWZlZjcyYzI1ZmU0YjNmNjczNDM3NjAzYWI2ZDVk", + "git_pull_url": "https://gist.github.com/209fef72c25fe4b3f673437603ab6d5d.git", + "git_push_url": "https://gist.github.com/209fef72c25fe4b3f673437603ab6d5d.git", + "html_url": "https://gist.github.com/209fef72c25fe4b3f673437603ab6d5d", + "files": { + "rename-me.py": { + "filename": "rename-me.py", + "type": "application/x-python", + "language": "Python", + "raw_url": "https://gist.githubusercontent.com/martinvanzijl/209fef72c25fe4b3f673437603ab6d5d/raw/b609dee383ab7aee026b182aa99086777a97cb77/rename-me.py", + "size": 13, + "truncated": false, + "content": "print 'hello'" + }, + "unmodified.txt": { + "filename": "unmodified.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/martinvanzijl/209fef72c25fe4b3f673437603ab6d5d/raw/92aaf920c4873e413416e552aaad16cd79d361b7/unmodified.txt", + "size": 20, + "truncated": false, + "content": "Should be unmodified" + }, + "update-me.txt": { + "filename": "update-me.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/martinvanzijl/209fef72c25fe4b3f673437603ab6d5d/raw/bd835e30ff8e75fb7f435c1868b747f83c3ba243/update-me.txt", + "size": 13, + "truncated": false, + "content": "To be updated" + } + }, + "public": true, + "created_at": "2019-10-09T18:06:38Z", + "updated_at": "2019-10-09T18:06:38Z", + "description": "Test for the API", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/comments", + "owner": { + "login": "martinvanzijl", + "id": 24422213, + "node_id": "MDQ6VXNlcjI0NDIyMjEz", + "avatar_url": "https://avatars0.githubusercontent.com/u/24422213?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/martinvanzijl", + "html_url": "https://github.com/martinvanzijl", + "followers_url": "https://api.github.com/users/martinvanzijl/followers", + "following_url": "https://api.github.com/users/martinvanzijl/following{/other_user}", + "gists_url": "https://api.github.com/users/martinvanzijl/gists{/gist_id}", + "starred_url": "https://api.github.com/users/martinvanzijl/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/martinvanzijl/subscriptions", + "organizations_url": "https://api.github.com/users/martinvanzijl/orgs", + "repos_url": "https://api.github.com/users/martinvanzijl/repos", + "events_url": "https://api.github.com/users/martinvanzijl/events{/privacy}", + "received_events_url": "https://api.github.com/users/martinvanzijl/received_events", + "type": "User", + "site_admin": false + }, + "forks": [], + "history": [ + { + "user": { + "login": "martinvanzijl", + "id": 24422213, + "node_id": "MDQ6VXNlcjI0NDIyMjEz", + "avatar_url": "https://avatars0.githubusercontent.com/u/24422213?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/martinvanzijl", + "html_url": "https://github.com/martinvanzijl", + "followers_url": "https://api.github.com/users/martinvanzijl/followers", + "following_url": "https://api.github.com/users/martinvanzijl/following{/other_user}", + "gists_url": "https://api.github.com/users/martinvanzijl/gists{/gist_id}", + "starred_url": "https://api.github.com/users/martinvanzijl/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/martinvanzijl/subscriptions", + "organizations_url": "https://api.github.com/users/martinvanzijl/orgs", + "repos_url": "https://api.github.com/users/martinvanzijl/repos", + "events_url": "https://api.github.com/users/martinvanzijl/events{/privacy}", + "received_events_url": "https://api.github.com/users/martinvanzijl/received_events", + "type": "User", + "site_admin": false + }, + "version": "3ef13d1c0c4fc4deef97527c758d1068d2ca4fe3", + "committed_at": "2019-10-09T18:06:37Z", + "change_status": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/3ef13d1c0c4fc4deef97527c758d1068d2ca4fe3" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/__files/gists_209fef72c25fe4b3f673437603ab6d5d-d3ef0c04-12e0-4815-a871-ab7a397b00d7.json b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/__files/gists_209fef72c25fe4b3f673437603ab6d5d-d3ef0c04-12e0-4815-a871-ab7a397b00d7.json new file mode 100644 index 0000000000..0aeeb7f2b7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/__files/gists_209fef72c25fe4b3f673437603ab6d5d-d3ef0c04-12e0-4815-a871-ab7a397b00d7.json @@ -0,0 +1,139 @@ +{ + "url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d", + "forks_url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/forks", + "commits_url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/commits", + "id": "209fef72c25fe4b3f673437603ab6d5d", + "node_id": "MDQ6R2lzdDIwOWZlZjcyYzI1ZmU0YjNmNjczNDM3NjAzYWI2ZDVk", + "git_pull_url": "https://gist.github.com/209fef72c25fe4b3f673437603ab6d5d.git", + "git_push_url": "https://gist.github.com/209fef72c25fe4b3f673437603ab6d5d.git", + "html_url": "https://gist.github.com/209fef72c25fe4b3f673437603ab6d5d", + "files": { + "new-file.txt": { + "filename": "new-file.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/martinvanzijl/209fef72c25fe4b3f673437603ab6d5d/raw/be732fb7a4178a55e5794e0b142b6e251545d7e4/new-file.txt", + "size": 16, + "truncated": false, + "content": "Added by updater" + }, + "renamed.py": { + "filename": "renamed.py", + "type": "application/x-python", + "language": "Python", + "raw_url": "https://gist.githubusercontent.com/martinvanzijl/209fef72c25fe4b3f673437603ab6d5d/raw/b609dee383ab7aee026b182aa99086777a97cb77/renamed.py", + "size": 13, + "truncated": false, + "content": "print 'hello'" + }, + "unmodified.txt": { + "filename": "unmodified.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/martinvanzijl/209fef72c25fe4b3f673437603ab6d5d/raw/92aaf920c4873e413416e552aaad16cd79d361b7/unmodified.txt", + "size": 20, + "truncated": false, + "content": "Should be unmodified" + }, + "update-me.txt": { + "filename": "update-me.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/martinvanzijl/209fef72c25fe4b3f673437603ab6d5d/raw/401c618749d9904b511a478bf45934966158b5bb/update-me.txt", + "size": 22, + "truncated": false, + "content": "Content updated by API" + } + }, + "public": true, + "created_at": "2019-10-09T18:06:38Z", + "updated_at": "2019-10-09T18:06:39Z", + "description": "Description updated by API", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/comments", + "owner": { + "login": "martinvanzijl", + "id": 24422213, + "node_id": "MDQ6VXNlcjI0NDIyMjEz", + "avatar_url": "https://avatars0.githubusercontent.com/u/24422213?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/martinvanzijl", + "html_url": "https://github.com/martinvanzijl", + "followers_url": "https://api.github.com/users/martinvanzijl/followers", + "following_url": "https://api.github.com/users/martinvanzijl/following{/other_user}", + "gists_url": "https://api.github.com/users/martinvanzijl/gists{/gist_id}", + "starred_url": "https://api.github.com/users/martinvanzijl/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/martinvanzijl/subscriptions", + "organizations_url": "https://api.github.com/users/martinvanzijl/orgs", + "repos_url": "https://api.github.com/users/martinvanzijl/repos", + "events_url": "https://api.github.com/users/martinvanzijl/events{/privacy}", + "received_events_url": "https://api.github.com/users/martinvanzijl/received_events", + "type": "User", + "site_admin": false + }, + "forks": [], + "history": [ + { + "user": { + "login": "martinvanzijl", + "id": 24422213, + "node_id": "MDQ6VXNlcjI0NDIyMjEz", + "avatar_url": "https://avatars0.githubusercontent.com/u/24422213?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/martinvanzijl", + "html_url": "https://github.com/martinvanzijl", + "followers_url": "https://api.github.com/users/martinvanzijl/followers", + "following_url": "https://api.github.com/users/martinvanzijl/following{/other_user}", + "gists_url": "https://api.github.com/users/martinvanzijl/gists{/gist_id}", + "starred_url": "https://api.github.com/users/martinvanzijl/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/martinvanzijl/subscriptions", + "organizations_url": "https://api.github.com/users/martinvanzijl/orgs", + "repos_url": "https://api.github.com/users/martinvanzijl/repos", + "events_url": "https://api.github.com/users/martinvanzijl/events{/privacy}", + "received_events_url": "https://api.github.com/users/martinvanzijl/received_events", + "type": "User", + "site_admin": false + }, + "version": "a081e0cf18f30a48b337375327d1f04d4d61b2ab", + "committed_at": "2019-10-09T18:06:39Z", + "change_status": { + "total": 3, + "additions": 2, + "deletions": 1 + }, + "url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/a081e0cf18f30a48b337375327d1f04d4d61b2ab" + }, + { + "user": { + "login": "martinvanzijl", + "id": 24422213, + "node_id": "MDQ6VXNlcjI0NDIyMjEz", + "avatar_url": "https://avatars0.githubusercontent.com/u/24422213?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/martinvanzijl", + "html_url": "https://github.com/martinvanzijl", + "followers_url": "https://api.github.com/users/martinvanzijl/followers", + "following_url": "https://api.github.com/users/martinvanzijl/following{/other_user}", + "gists_url": "https://api.github.com/users/martinvanzijl/gists{/gist_id}", + "starred_url": "https://api.github.com/users/martinvanzijl/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/martinvanzijl/subscriptions", + "organizations_url": "https://api.github.com/users/martinvanzijl/orgs", + "repos_url": "https://api.github.com/users/martinvanzijl/repos", + "events_url": "https://api.github.com/users/martinvanzijl/events{/privacy}", + "received_events_url": "https://api.github.com/users/martinvanzijl/received_events", + "type": "User", + "site_admin": false + }, + "version": "3ef13d1c0c4fc4deef97527c758d1068d2ca4fe3", + "committed_at": "2019-10-09T18:06:37Z", + "change_status": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "url": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d/3ef13d1c0c4fc4deef97527c758d1068d2ca4fe3" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists-1-fde9aa.json b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists-1-fde9aa.json new file mode 100644 index 0000000000..15895715f0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists-1-fde9aa.json @@ -0,0 +1,48 @@ +{ + "id": "fde9aa5a-83fc-41d8-b556-16335859de73", + "name": "gists", + "request": { + "url": "/gists", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"public\":true,\"description\":\"Test for the API\",\"files\":{\"unmodified.txt\":{\"content\":\"Should be unmodified\"},\"rename-me.py\":{\"content\":\"print 'hello'\"},\"update-me.txt\":{\"content\":\"To be updated\"}}}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "gists-fde9aa5a-83fc-41d8-b556-16335859de73.json", + "headers": { + "Date": "Wed, 09 Oct 2019 18:06:38 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4986", + "X-RateLimit-Reset": "1570647617", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"f60e43f46988893f64e50f632c072e41\"", + "Location": "https://api.github.com/gists/209fef72c25fe4b3f673437603ab6d5d", + "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": "AF56:13F4:1234663:150EFE0:5D9E21AD" + } + }, + "uuid": "fde9aa5a-83fc-41d8-b556-16335859de73", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists_209fef72c25fe4b3f673437603ab6d5d-2-d3ef0c.json b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists_209fef72c25fe4b3f673437603ab6d5d-2-d3ef0c.json new file mode 100644 index 0000000000..a7225467da --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists_209fef72c25fe4b3f673437603ab6d5d-2-d3ef0c.json @@ -0,0 +1,47 @@ +{ + "id": "d3ef0c04-12e0-4815-a871-ab7a397b00d7", + "name": "gists_209fef72c25fe4b3f673437603ab6d5d", + "request": { + "url": "/gists/209fef72c25fe4b3f673437603ab6d5d", + "method": "PATCH", + "bodyPatterns": [ + { + "equalToJson": "{\"description\":\"Description updated by API\",\"files\":{\"new-file.txt\":{\"content\":\"Added by updater\"},\"rename-me.py\":{\"filename\":\"renamed.py\"},\"update-me.txt\":{\"content\":\"Content updated by API\"}}}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "gists_209fef72c25fe4b3f673437603ab6d5d-d3ef0c04-12e0-4815-a871-ab7a397b00d7.json", + "headers": { + "Date": "Wed, 09 Oct 2019 18:06:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4985", + "X-RateLimit-Reset": "1570647617", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"428bc6a3a9c8f9c26b9023cf8ff0ac9f\"", + "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": "AF56:13F4:1234695:150F007:5D9E21AE" + } + }, + "uuid": "d3ef0c04-12e0-4815-a871-ab7a397b00d7", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists_209fef72c25fe4b3f673437603ab6d5d-3-94cd51.json b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists_209fef72c25fe4b3f673437603ab6d5d-3-94cd51.json new file mode 100644 index 0000000000..1341899dd2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistUpdaterTest/wiremock/testGitUpdater/mappings/gists_209fef72c25fe4b3f673437603ab6d5d-3-94cd51.json @@ -0,0 +1,33 @@ +{ + "id": "94cd5114-cc74-4003-ba1f-6bedcb561d20", + "name": "gists_209fef72c25fe4b3f673437603ab6d5d", + "request": { + "url": "/gists/209fef72c25fe4b3f673437603ab6d5d", + "method": "DELETE" + }, + "response": { + "status": 204, + "headers": { + "Date": "Wed, 09 Oct 2019 18:06:40 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4984", + "X-RateLimit-Reset": "1570647617", + "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'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "AF56:13F4:12346B2:150F02F:5D9E21B0" + } + }, + "uuid": "94cd5114-cc74-4003-ba1f-6bedcb561d20", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file