diff --git a/src/main/java/org/kohsuke/github/GHGistBuilder.java b/src/main/java/org/kohsuke/github/GHGistBuilder.java index fd9bf00ce3..8df07bb99e 100644 --- a/src/main/java/org/kohsuke/github/GHGistBuilder.java +++ b/src/main/java/org/kohsuke/github/GHGistBuilder.java @@ -4,6 +4,8 @@ import java.util.Collections; import java.util.LinkedHashMap; +import javax.annotation.Nonnull; + /** * Builder pattern for creating a new Gist. * @@ -59,7 +61,7 @@ public GHGistBuilder public_(boolean v) { * the content * @return Adds a new file. */ - public GHGistBuilder file(String fileName, String content) { + public GHGistBuilder file(@Nonnull String fileName, @Nonnull String content) { files.put(fileName, Collections.singletonMap("content", content)); return this; } diff --git a/src/main/java/org/kohsuke/github/GHGistUpdater.java b/src/main/java/org/kohsuke/github/GHGistUpdater.java index 216d38f963..f1351ce4ed 100644 --- a/src/main/java/org/kohsuke/github/GHGistUpdater.java +++ b/src/main/java/org/kohsuke/github/GHGistUpdater.java @@ -2,7 +2,11 @@ import java.io.IOException; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.Map; + +import javax.annotation.Nonnull; /** * Builder pattern for updating a Gist. @@ -12,7 +16,7 @@ public class GHGistUpdater { private final GHGist base; private final Requester builder; - LinkedHashMap files; + LinkedHashMap> files; GHGistUpdater(GHGist base) { this.base = base; @@ -32,16 +36,15 @@ public class GHGistUpdater { * @throws IOException * the io exception */ - public GHGistUpdater addFile(String fileName, String content) throws IOException { + public GHGistUpdater addFile(@Nonnull String fileName, @Nonnull 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 deleteFile(@Nonnull String fileName) throws IOException { + files.put(fileName, null); + return this; + } /** * Rename file gh gist updater. @@ -54,8 +57,9 @@ public GHGistUpdater addFile(String fileName, String content) throws IOException * @throws IOException * the io exception */ - public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException { - files.put(fileName, Collections.singletonMap("filename", newFileName)); + public GHGistUpdater renameFile(@Nonnull String fileName, @Nonnull String newFileName) throws IOException { + Map file = files.computeIfAbsent(fileName, d -> new HashMap<>()); + file.put("filename", newFileName); return this; } @@ -70,8 +74,31 @@ public GHGistUpdater renameFile(String fileName, String newFileName) throws IOEx * @throws IOException * the io exception */ - public GHGistUpdater updateFile(String fileName, String content) throws IOException { - files.put(fileName, Collections.singletonMap("content", content)); + public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String content) throws IOException { + Map file = files.computeIfAbsent(fileName, d -> new HashMap<>()); + file.put("content", content); + return this; + } + + /** + * Update file name and content + * + * @param fileName + * the file name + * @param newFileName + * the new file name + * @param content + * the content + * @return the gh gist updater + * @throws IOException + * the io exception + */ + public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String newFileName, @Nonnull String content) + throws IOException { + Map file = files.computeIfAbsent(fileName, d -> new HashMap<>()); + file.put("content", content); + file.put("filename", newFileName); + files.put(fileName, file); return this; } diff --git a/src/test/java/org/kohsuke/github/GHGistTest.java b/src/test/java/org/kohsuke/github/GHGistTest.java index cbb70d77aa..8dfd082fbf 100644 --- a/src/test/java/org/kohsuke/github/GHGistTest.java +++ b/src/test/java/org/kohsuke/github/GHGistTest.java @@ -2,7 +2,9 @@ import org.junit.Test; -import static org.hamcrest.Matchers.notNullValue; +import java.io.FileNotFoundException; + +import static org.hamcrest.Matchers.*; import static org.hamcrest.core.Is.is; /** @@ -17,9 +19,12 @@ public void lifecycleTest() throws Exception { .description("Test Gist") .file("abc.txt", "abc") .file("def.txt", "def") + .file("ghi.txt", "ghi") .create(); assertThat(gist.getCreatedAt(), is(notNullValue())); + assertThat(gist.getDescription(), equalTo("Test Gist")); + assertThat(gist.getFiles().size(), equalTo(3)); assertNotNull(gist.getUpdatedAt()); assertNotNull(gist.getCommentsUrl()); @@ -28,7 +33,69 @@ public void lifecycleTest() throws Exception { assertNotNull(gist.getGitPushUrl()); assertNotNull(gist.getHtmlUrl()); + String id = gist.getGistId(); + + GHGist gistUpdate = gitHub.getGist(id); + assertThat(gistUpdate.getGistId(), equalTo(gist.getGistId())); + assertThat(gistUpdate.getDescription(), equalTo(gist.getDescription())); + assertThat(gistUpdate.getFiles().size(), equalTo(3)); + + gistUpdate = gistUpdate.update().description("Gist Test").addFile("jkl.txt", "jkl").update(); + + assertThat(gistUpdate.getGistId(), equalTo(gist.getGistId())); + assertThat(gistUpdate.getDescription(), equalTo("Gist Test")); + assertThat(gistUpdate.getFiles().size(), equalTo(4)); + + gistUpdate = gistUpdate.update() + .renameFile("abc.txt", "ab.txt") + .deleteFile("def.txt") + .updateFile("ghi.txt", "gh") + .updateFile("jkl.txt", "klm.txt", "nop") + .update(); + + assertThat(gistUpdate.getGistId(), equalTo(gist.getGistId())); + assertThat(gistUpdate.getDescription(), equalTo("Gist Test")); + assertThat(gistUpdate.getFiles().size(), equalTo(3)); + + // verify delete works + assertThat(gistUpdate.getFile("def.txt"), nullValue()); + + // verify rename + assertThat(gistUpdate.getFile("ab.txt").getContent(), equalTo("abc")); + + // verify updates + assertThat(gistUpdate.getFile("ghi.txt").getContent(), equalTo("gh")); + assertThat(gistUpdate.getFile("klm.txt").getContent(), equalTo("nop")); + + // rename and update on the same file in one update shoudl work. + gistUpdate = gistUpdate.update() + .renameFile("ab.txt", "a.txt") + .updateFile("ab.txt", "abcd") + .update(); + + assertThat(gistUpdate.getGistId(), equalTo(gist.getGistId())); + assertThat(gistUpdate.getFiles().size(), equalTo(3)); + + // verify rename and update + assertThat(gistUpdate.getFile("a.txt").getContent(), equalTo("abcd")); + + try { + gist.getId(); + fail("Newly created gists do not have numeric ids."); + } catch (NumberFormatException e) { + assertThat(e, notNullValue()); + } + + assertThat(gist.getGistId(), notNullValue()); + gist.delete(); + + try { + gitHub.getGist(id); + fail("Gist should be deleted."); + } catch (FileNotFoundException e) { + assertThat(e, notNullValue()); + } } @Test @@ -63,6 +130,8 @@ public void gistFile() throws Exception { GHGist gist = gitHub.getGist("9903708"); assertTrue(gist.isPublic()); + assertThat(gist.getId(), equalTo(9903708L)); + assertThat(gist.getGistId(), equalTo("9903708")); assertEquals(1, gist.getFiles().size()); GHGistFile f = gist.getFile("keybase.md"); diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2.json index 3ae7954793..24f2722830 100644 --- a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2.json +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2.json @@ -1,18 +1,18 @@ { - "url": "https://api.github.com/gists/9faa55cd67b21a789bb44e34e5e41f72", - "forks_url": "https://api.github.com/gists/9faa55cd67b21a789bb44e34e5e41f72/forks", - "commits_url": "https://api.github.com/gists/9faa55cd67b21a789bb44e34e5e41f72/commits", - "id": "9faa55cd67b21a789bb44e34e5e41f72", - "node_id": "MDQ6R2lzdDlmYWE1NWNkNjdiMjFhNzg5YmI0NGUzNGU1ZTQxZjcy", - "git_pull_url": "https://gist.github.com/9faa55cd67b21a789bb44e34e5e41f72.git", - "git_push_url": "https://gist.github.com/9faa55cd67b21a789bb44e34e5e41f72.git", - "html_url": "https://gist.github.com/9faa55cd67b21a789bb44e34e5e41f72", + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682", + "forks_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/forks", + "commits_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/commits", + "id": "11a257b91982aafd6370089ef877a682", + "node_id": "MDQ6R2lzdDExYTI1N2I5MTk4MmFhZmQ2MzcwMDg5ZWY4NzdhNjgy", + "git_pull_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "git_push_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "html_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682", "files": { "abc.txt": { "filename": "abc.txt", "type": "text/plain", "language": "Text", - "raw_url": "https://gist.githubusercontent.com/bitwiseman/9faa55cd67b21a789bb44e34e5e41f72/raw/f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f/abc.txt", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f/abc.txt", "size": 3, "truncated": false, "content": "abc" @@ -21,19 +21,28 @@ "filename": "def.txt", "type": "text/plain", "language": "Text", - "raw_url": "https://gist.githubusercontent.com/bitwiseman/9faa55cd67b21a789bb44e34e5e41f72/raw/0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc/def.txt", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc/def.txt", "size": 3, "truncated": false, "content": "def" + }, + "ghi.txt": { + "filename": "ghi.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/45a82e295c52473114c57c18f4f52368df2a3cfd/ghi.txt", + "size": 3, + "truncated": false, + "content": "ghi" } }, "public": false, - "created_at": "2019-09-08T06:47:42Z", - "updated_at": "2019-09-08T06:47:42Z", + "created_at": "2020-04-27T17:24:06Z", + "updated_at": "2020-04-27T17:24:06Z", "description": "Test Gist", "comments": 0, "user": null, - "comments_url": "https://api.github.com/gists/9faa55cd67b21a789bb44e34e5e41f72/comments", + "comments_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/comments", "owner": { "login": "bitwiseman", "id": 1958953, @@ -77,14 +86,14 @@ "type": "User", "site_admin": false }, - "version": "b25886c9892025e090e71bdf1bb9b20927cb4a19", - "committed_at": "2019-09-08T06:47:42Z", + "version": "580ab68864a16653f98107dad574acb502f35deb", + "committed_at": "2020-04-27T17:24:05Z", "change_status": { - "total": 2, - "additions": 2, + "total": 3, + "additions": 3, "deletions": 0 }, - "url": "https://api.github.com/gists/9faa55cd67b21a789bb44e34e5e41f72/b25886c9892025e090e71bdf1bb9b20927cb4a19" + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/580ab68864a16653f98107dad574acb502f35deb" } ], "truncated": false diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-3.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-3.json new file mode 100644 index 0000000000..24f2722830 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-3.json @@ -0,0 +1,100 @@ +{ + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682", + "forks_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/forks", + "commits_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/commits", + "id": "11a257b91982aafd6370089ef877a682", + "node_id": "MDQ6R2lzdDExYTI1N2I5MTk4MmFhZmQ2MzcwMDg5ZWY4NzdhNjgy", + "git_pull_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "git_push_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "html_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682", + "files": { + "abc.txt": { + "filename": "abc.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f/abc.txt", + "size": 3, + "truncated": false, + "content": "abc" + }, + "def.txt": { + "filename": "def.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc/def.txt", + "size": 3, + "truncated": false, + "content": "def" + }, + "ghi.txt": { + "filename": "ghi.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/45a82e295c52473114c57c18f4f52368df2a3cfd/ghi.txt", + "size": 3, + "truncated": false, + "content": "ghi" + } + }, + "public": false, + "created_at": "2020-04-27T17:24:06Z", + "updated_at": "2020-04-27T17:24:06Z", + "description": "Test Gist", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/comments", + "owner": { + "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 + }, + "forks": [], + "history": [ + { + "user": { + "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 + }, + "version": "580ab68864a16653f98107dad574acb502f35deb", + "committed_at": "2020-04-27T17:24:05Z", + "change_status": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/580ab68864a16653f98107dad574acb502f35deb" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-4.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-4.json new file mode 100644 index 0000000000..373084e9eb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-4.json @@ -0,0 +1,139 @@ +{ + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682", + "forks_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/forks", + "commits_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/commits", + "id": "11a257b91982aafd6370089ef877a682", + "node_id": "MDQ6R2lzdDExYTI1N2I5MTk4MmFhZmQ2MzcwMDg5ZWY4NzdhNjgy", + "git_pull_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "git_push_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "html_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682", + "files": { + "abc.txt": { + "filename": "abc.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f/abc.txt", + "size": 3, + "truncated": false, + "content": "abc" + }, + "def.txt": { + "filename": "def.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/0c003832e7bfa9ca8b5c2035c9bd684a5f2623bc/def.txt", + "size": 3, + "truncated": false, + "content": "def" + }, + "ghi.txt": { + "filename": "ghi.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/45a82e295c52473114c57c18f4f52368df2a3cfd/ghi.txt", + "size": 3, + "truncated": false, + "content": "ghi" + }, + "jkl.txt": { + "filename": "jkl.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/45328c36ff2e9b9b4e592c847d3f9a7fd9b3e716/jkl.txt", + "size": 3, + "truncated": false, + "content": "jkl" + } + }, + "public": false, + "created_at": "2020-04-27T17:24:06Z", + "updated_at": "2020-04-27T17:24:07Z", + "description": "Gist Test", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/comments", + "owner": { + "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 + }, + "forks": [], + "history": [ + { + "user": { + "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 + }, + "version": "a26d6b3c15d9e0732af78c9b6a0f5a82a5495b0f", + "committed_at": "2020-04-27T17:24:07Z", + "change_status": { + "total": 1, + "additions": 1, + "deletions": 0 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/a26d6b3c15d9e0732af78c9b6a0f5a82a5495b0f" + }, + { + "user": { + "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 + }, + "version": "580ab68864a16653f98107dad574acb502f35deb", + "committed_at": "2020-04-27T17:24:05Z", + "change_status": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/580ab68864a16653f98107dad574acb502f35deb" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-5.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-5.json new file mode 100644 index 0000000000..4e05234814 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-5.json @@ -0,0 +1,160 @@ +{ + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682", + "forks_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/forks", + "commits_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/commits", + "id": "11a257b91982aafd6370089ef877a682", + "node_id": "MDQ6R2lzdDExYTI1N2I5MTk4MmFhZmQ2MzcwMDg5ZWY4NzdhNjgy", + "git_pull_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "git_push_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "html_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682", + "files": { + "ab.txt": { + "filename": "ab.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f/ab.txt", + "size": 3, + "truncated": false, + "content": "abc" + }, + "ghi.txt": { + "filename": "ghi.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/c036c168e478a94fde05f915c9670df03fa4ce84/ghi.txt", + "size": 2, + "truncated": false, + "content": "gh" + }, + "klm.txt": { + "filename": "klm.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/8df050ad266e0e86aa01a534dd9faf202f8c3d80/klm.txt", + "size": 3, + "truncated": false, + "content": "nop" + } + }, + "public": false, + "created_at": "2020-04-27T17:24:06Z", + "updated_at": "2020-04-27T17:24:08Z", + "description": "Gist Test", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/comments", + "owner": { + "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 + }, + "forks": [], + "history": [ + { + "user": { + "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 + }, + "version": "1ba147d5e2114bad9da3eaf42bc88843f91da2c9", + "committed_at": "2020-04-27T17:24:08Z", + "change_status": { + "total": 5, + "additions": 2, + "deletions": 3 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/1ba147d5e2114bad9da3eaf42bc88843f91da2c9" + }, + { + "user": { + "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 + }, + "version": "a26d6b3c15d9e0732af78c9b6a0f5a82a5495b0f", + "committed_at": "2020-04-27T17:24:07Z", + "change_status": { + "total": 1, + "additions": 1, + "deletions": 0 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/a26d6b3c15d9e0732af78c9b6a0f5a82a5495b0f" + }, + { + "user": { + "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 + }, + "version": "580ab68864a16653f98107dad574acb502f35deb", + "committed_at": "2020-04-27T17:24:05Z", + "change_status": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/580ab68864a16653f98107dad574acb502f35deb" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-6.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-6.json new file mode 100644 index 0000000000..6ad68a8b04 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists_11a257b91982aafd6370089ef877a682-6.json @@ -0,0 +1,190 @@ +{ + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682", + "forks_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/forks", + "commits_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/commits", + "id": "11a257b91982aafd6370089ef877a682", + "node_id": "MDQ6R2lzdDExYTI1N2I5MTk4MmFhZmQ2MzcwMDg5ZWY4NzdhNjgy", + "git_pull_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "git_push_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682.git", + "html_url": "https://gist.github.com/11a257b91982aafd6370089ef877a682", + "files": { + "a.txt": { + "filename": "a.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/85df50785d62d3b05ab03d9cbf7e4a0b49449730/a.txt", + "size": 4, + "truncated": false, + "content": "abcd" + }, + "ghi.txt": { + "filename": "ghi.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/c036c168e478a94fde05f915c9670df03fa4ce84/ghi.txt", + "size": 2, + "truncated": false, + "content": "gh" + }, + "klm.txt": { + "filename": "klm.txt", + "type": "text/plain", + "language": "Text", + "raw_url": "https://gist.githubusercontent.com/bitwiseman/11a257b91982aafd6370089ef877a682/raw/8df050ad266e0e86aa01a534dd9faf202f8c3d80/klm.txt", + "size": 3, + "truncated": false, + "content": "nop" + } + }, + "public": false, + "created_at": "2020-04-27T17:24:06Z", + "updated_at": "2020-04-27T17:24:09Z", + "description": "Gist Test", + "comments": 0, + "user": null, + "comments_url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/comments", + "owner": { + "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 + }, + "forks": [], + "history": [ + { + "user": { + "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 + }, + "version": "923dcb52ebb92dfa1d1db75f11e7ef15336f69a6", + "committed_at": "2020-04-27T17:24:09Z", + "change_status": { + "total": 2, + "additions": 1, + "deletions": 1 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/923dcb52ebb92dfa1d1db75f11e7ef15336f69a6" + }, + { + "user": { + "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 + }, + "version": "1ba147d5e2114bad9da3eaf42bc88843f91da2c9", + "committed_at": "2020-04-27T17:24:08Z", + "change_status": { + "total": 5, + "additions": 2, + "deletions": 3 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/1ba147d5e2114bad9da3eaf42bc88843f91da2c9" + }, + { + "user": { + "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 + }, + "version": "a26d6b3c15d9e0732af78c9b6a0f5a82a5495b0f", + "committed_at": "2020-04-27T17:24:07Z", + "change_status": { + "total": 1, + "additions": 1, + "deletions": 0 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/a26d6b3c15d9e0732af78c9b6a0f5a82a5495b0f" + }, + { + "user": { + "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 + }, + "version": "580ab68864a16653f98107dad574acb502f35deb", + "committed_at": "2020-04-27T17:24:05Z", + "change_status": { + "total": 3, + "additions": 3, + "deletions": 0 + }, + "url": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682/580ab68864a16653f98107dad574acb502f35deb" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-1.json index b9ce24cb03..034471d43c 100644 --- a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-1.json @@ -24,10 +24,22 @@ "email": "bitwiseman@gmail.com", "hireable": null, "bio": "https://twitter.com/bitwiseman", - "public_repos": 166, - "public_gists": 4, - "followers": 133, + "public_repos": 182, + "public_gists": 7, + "followers": 157, "following": 9, "created_at": "2012-07-11T20:38:33Z", - "updated_at": "2019-06-03T17:47:20Z" + "updated_at": "2020-04-24T22:10:21Z", + "private_gists": 19, + "total_private_repos": 10, + "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/GHGistTest/wiremock/lifecycleTest/mappings/gists-2.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists-2.json index 98027c3a76..023100eb13 100644 --- a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists-2.json +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists-2.json @@ -1,55 +1,53 @@ { - "id": "2f93eec6-32ad-4c3d-a7bf-33a134d16dbe", + "id": "971e54f9-b6df-4cc0-b04e-19c3772ba46a", "name": "gists", "request": { "url": "/gists", "method": "POST", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + }, "bodyPatterns": [ { - "equalToJson": "{\"public\":false,\"description\":\"Test Gist\",\"files\":{\"abc.txt\":{\"content\":\"abc\"},\"def.txt\":{\"content\":\"def\"}}}", + "equalToJson": "{\"public\":false,\"description\":\"Test Gist\",\"files\":{\"abc.txt\":{\"content\":\"abc\"},\"def.txt\":{\"content\":\"def\"},\"ghi.txt\":{\"content\":\"ghi\"}}}", "ignoreArrayOrder": true, "ignoreExtraElements": true } - ], - "headers": { - "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" - } - } + ] }, "response": { "status": 201, "bodyFileName": "gists-2.json", "headers": { - "Date": "Sun, 08 Sep 2019 06:47:43 GMT", + "Date": "Mon, 27 Apr 2020 17:24:06 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "201 Created", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4800", - "X-RateLimit-Reset": "1567926046", + "X-RateLimit-Remaining": "4975", + "X-RateLimit-Reset": "1588010945", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", - "Accept-Encoding" + "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "\"32bd93e7c792880260a7f86efe7fa182\"", - "X-OAuth-Scopes": "gist, notifications, repo", + "ETag": "\"7b67efd855ab094b8909712c7e622749\"", + "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": "", - "Location": "https://api.github.com/gists/9faa55cd67b21a789bb44e34e5e41f72", + "Location": "https://api.github.com/gists/11a257b91982aafd6370089ef877a682", "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": "FD4E:40BC:96FAEF:B22CDC:5D74A40D" + "X-GitHub-Request-Id": "FA20:78D7:86994:A56E8:5EA71534" } }, - "uuid": "2f93eec6-32ad-4c3d-a7bf-33a134d16dbe", + "uuid": "971e54f9-b6df-4cc0-b04e-19c3772ba46a", "persistent": true, "insertionIndex": 2 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-3.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-3.json new file mode 100644 index 0000000000..eeda02c741 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-3.json @@ -0,0 +1,49 @@ +{ + "id": "672ecd2e-b88a-4e19-ab4e-ceb4702c59c8", + "name": "gists_11a257b91982aafd6370089ef877a682", + "request": { + "url": "/gists/11a257b91982aafd6370089ef877a682", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "gists_11a257b91982aafd6370089ef877a682-3.json", + "headers": { + "Date": "Mon, 27 Apr 2020 17:24:07 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4974", + "X-RateLimit-Reset": "1588010945", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"7b67efd855ab094b8909712c7e622749\"", + "Last-Modified": "Mon, 27 Apr 2020 17:24:06 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "FA20:78D7:86A22:A57AE:5EA71536" + } + }, + "uuid": "672ecd2e-b88a-4e19-ab4e-ceb4702c59c8", + "persistent": true, + "scenarioName": "scenario-1-gists-11a257b91982aafd6370089ef877a682", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-gists-11a257b91982aafd6370089ef877a682-2", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-4.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-4.json new file mode 100644 index 0000000000..75764b1eee --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-4.json @@ -0,0 +1,52 @@ +{ + "id": "11cf89c6-50c1-442e-8aae-5ba5beb52230", + "name": "gists_11a257b91982aafd6370089ef877a682", + "request": { + "url": "/gists/11a257b91982aafd6370089ef877a682", + "method": "PATCH", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"description\":\"Gist Test\",\"files\":{\"jkl.txt\":{\"content\":\"jkl\"}}}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "gists_11a257b91982aafd6370089ef877a682-4.json", + "headers": { + "Date": "Mon, 27 Apr 2020 17:24:08 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4973", + "X-RateLimit-Reset": "1588010945", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"b8a9404454da84ac2c2ff9b2e23adc99\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "FA20:78D7:86A33:A57CF:5EA71537" + } + }, + "uuid": "11cf89c6-50c1-442e-8aae-5ba5beb52230", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-5.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-5.json new file mode 100644 index 0000000000..39a5718d14 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-5.json @@ -0,0 +1,52 @@ +{ + "id": "531a14a5-5fb1-41e7-a3df-4a5fe33d6f82", + "name": "gists_11a257b91982aafd6370089ef877a682", + "request": { + "url": "/gists/11a257b91982aafd6370089ef877a682", + "method": "PATCH", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"files\":{\"abc.txt\":{\"filename\":\"ab.txt\"},\"def.txt\":null,\"ghi.txt\":{\"content\":\"gh\"},\"jkl.txt\":{\"filename\":\"klm.txt\",\"content\":\"nop\"}}}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "gists_11a257b91982aafd6370089ef877a682-5.json", + "headers": { + "Date": "Mon, 27 Apr 2020 17:24:09 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4972", + "X-RateLimit-Reset": "1588010944", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"83d6c9cbd2997429e8c33c292c7ebb3f\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "FA20:78D7:86A7E:A5823:5EA71538" + } + }, + "uuid": "531a14a5-5fb1-41e7-a3df-4a5fe33d6f82", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-6.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-6.json new file mode 100644 index 0000000000..54750a2654 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-6.json @@ -0,0 +1,52 @@ +{ + "id": "4dad2796-6a58-49f9-91b9-24cd29d39b9f", + "name": "gists_11a257b91982aafd6370089ef877a682", + "request": { + "url": "/gists/11a257b91982aafd6370089ef877a682", + "method": "PATCH", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"files\":{\"ab.txt\":{\"filename\":\"a.txt\",\"content\":\"abcd\"}}}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "gists_11a257b91982aafd6370089ef877a682-6.json", + "headers": { + "Date": "Mon, 27 Apr 2020 17:24:10 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4971", + "X-RateLimit-Reset": "1588010945", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"f320a9fcfad2313a94e0d6fe844fc03b\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "FA20:78D7:86AC9:A586E:5EA71539" + } + }, + "uuid": "4dad2796-6a58-49f9-91b9-24cd29d39b9f", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-7.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-7.json new file mode 100644 index 0000000000..25f750bfdb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-7.json @@ -0,0 +1,38 @@ +{ + "id": "d5a2d9d0-7a88-46e7-983a-0028e6a3e07c", + "name": "gists_11a257b91982aafd6370089ef877a682", + "request": { + "url": "/gists/11a257b91982aafd6370089ef877a682", + "method": "DELETE", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 204, + "headers": { + "Date": "Mon, 27 Apr 2020 17:24:10 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4970", + "X-RateLimit-Reset": "1588010945", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "X-GitHub-Request-Id": "FA20:78D7:86B0B:A58BD:5EA7153A" + } + }, + "uuid": "d5a2d9d0-7a88-46e7-983a-0028e6a3e07c", + "persistent": true, + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-8.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-8.json new file mode 100644 index 0000000000..2b78326914 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_11a257b91982aafd6370089ef877a682-8.json @@ -0,0 +1,42 @@ +{ + "id": "4fe10692-b65f-41c0-a057-8af6804e45bd", + "name": "gists_11a257b91982aafd6370089ef877a682", + "request": { + "url": "/gists/11a257b91982aafd6370089ef877a682", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 404, + "body": "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/gists/#get-a-single-gist\"}", + "headers": { + "Date": "Mon, 27 Apr 2020 17:24:10 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "404 Not Found", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4969", + "X-RateLimit-Reset": "1588010945", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding, Accept, X-Requested-With", + "X-GitHub-Request-Id": "FA20:78D7:86B19:A58DC:5EA7153A" + } + }, + "uuid": "4fe10692-b65f-41c0-a057-8af6804e45bd", + "persistent": true, + "scenarioName": "scenario-1-gists-11a257b91982aafd6370089ef877a682", + "requiredScenarioState": "scenario-1-gists-11a257b91982aafd6370089ef877a682-2", + "insertionIndex": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3.json deleted file mode 100644 index 904d860d2e..0000000000 --- a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "id": "26c31487-5829-47c9-969a-2fc3b34fec9e", - "name": "gists_9faa55cd67b21a789bb44e34e5e41f72", - "request": { - "url": "/gists/9faa55cd67b21a789bb44e34e5e41f72", - "method": "DELETE", - "headers": { - "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" - } - } - }, - "response": { - "status": 204, - "headers": { - "Date": "Sun, 08 Sep 2019 06:47:43 GMT", - "Content-Type": "application/octet-stream", - "Server": "GitHub.com", - "Status": "204 No Content", - "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4799", - "X-RateLimit-Reset": "1567926046", - "X-OAuth-Scopes": "gist, notifications, repo", - "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'", - "Vary": "Accept-Encoding", - "X-GitHub-Request-Id": "FD4E:40BC:96FB51:B22D68:5D74A40F" - } - }, - "uuid": "26c31487-5829-47c9-969a-2fc3b34fec9e", - "persistent": true, - "insertionIndex": 3 -} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1.json index b12f897ad2..dd56dc131c 100644 --- a/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1.json @@ -1,5 +1,5 @@ { - "id": "3380f859-169e-41b0-9a8a-aa66277dfb8b", + "id": "cddf682c-1555-4d63-a993-0a5eca50871a", "name": "user", "request": { "url": "/user", @@ -14,35 +14,33 @@ "status": 200, "bodyFileName": "user-1.json", "headers": { - "Date": "Sun, 08 Sep 2019 06:47:41 GMT", + "Date": "Mon, 27 Apr 2020 17:24:04 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4801", - "X-RateLimit-Reset": "1567926046", + "X-RateLimit-Remaining": "4977", + "X-RateLimit-Reset": "1588010945", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", - "Accept-Encoding" + "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"3ba1de3523043df743651bd23efc7def\"", - "Last-Modified": "Mon, 03 Jun 2019 17:47:20 GMT", - "X-OAuth-Scopes": "gist, notifications, repo", + "ETag": "W/\"a5448adf17aa9d24f1eb6fe9f2dd8e9b\"", + "Last-Modified": "Fri, 24 Apr 2020 22:10:21 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": "FD4E:40BC:96FAD6:B22CD5:5D74A40D" + "X-GitHub-Request-Id": "FA20:78D7:86962:A56DD:5EA71534" } }, - "uuid": "3380f859-169e-41b0-9a8a-aa66277dfb8b", + "uuid": "cddf682c-1555-4d63-a993-0a5eca50871a", "persistent": true, "insertionIndex": 1 } \ No newline at end of file