From 872d713e50d30539e178bd9164dbd75d4160ef5e Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 3 Oct 2019 17:34:52 -0700 Subject: [PATCH] Fix one more case of connecting outside the proxy --- .../org/kohsuke/github/GHRepositoryTest.java | 4 +- ...-af73e21a-68d3-4683-a1e1-3415319211e4.json | 124 ++++++++++++++++++ ...8d2ebbe4-ff50-4d3e-9932-d48541155f86.json} | 2 +- ...os_github-api-test-org_empty-2-af73e2.json | 43 ++++++ ...-test-org_empty_contributors-3-dae0e3.json | 35 +++++ ...{user-1-009b9e.json => user-1-8d2ebb.json} | 16 +-- 6 files changed, 213 insertions(+), 11 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/repos_github-api-test-org_empty-af73e21a-68d3-4683-a1e1-3415319211e4.json rename src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/{user-009b9e10-1f02-4c40-bc83-b37bfd70670e.json => user-8d2ebbe4-ff50-4d3e-9932-d48541155f86.json} (98%) create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty-2-af73e2.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty_contributors-3-dae0e3.json rename src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/{user-1-009b9e.json => user-1-8d2ebb.json} (77%) diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 6a5549306b..99c89fb2c6 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -178,9 +178,9 @@ public void listLanguages() throws IOException { @Test // Issue #261 public void listEmptyContributors() throws IOException { - GitHub gh = GitHub.connect(); - for (GHRepository.Contributor c : gh.getRepository(GITHUB_API_TEST_ORG + "/empty").listContributors()) { + for (GHRepository.Contributor c : gitHub.getRepository(GITHUB_API_TEST_ORG + "/empty").listContributors()) { System.out.println(c); + fail("This list should be empty, but should return a valid empty iterable."); } } diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/repos_github-api-test-org_empty-af73e21a-68d3-4683-a1e1-3415319211e4.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/repos_github-api-test-org_empty-af73e21a-68d3-4683-a1e1-3415319211e4.json new file mode 100644 index 0000000000..5179da1394 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/repos_github-api-test-org_empty-af73e21a-68d3-4683-a1e1-3415319211e4.json @@ -0,0 +1,124 @@ +{ + "id": 60391080, + "node_id": "MDEwOlJlcG9zaXRvcnk2MDM5MTA4MA==", + "name": "empty", + "full_name": "github-api-test-org/empty", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/empty", + "description": "Repository that has no contributor", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/empty", + "forks_url": "https://api.github.com/repos/github-api-test-org/empty/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/empty/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/empty/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/empty/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/empty/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/empty/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/empty/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/empty/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/empty/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/empty/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/empty/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/empty/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/empty/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/empty/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/empty/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/empty/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/empty/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/empty/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/empty/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/empty/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/empty/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/empty/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/empty/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/empty/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/empty/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/empty/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/empty/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/empty/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/empty/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/empty/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/empty/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/empty/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/empty/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/empty/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/empty/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/empty/deployments", + "created_at": "2016-06-04T03:22:22Z", + "updated_at": "2016-06-04T03:22:22Z", + "pushed_at": "2016-06-04T03:22:23Z", + "git_url": "git://github.com/github-api-test-org/empty.git", + "ssh_url": "git@github.com:github-api-test-org/empty.git", + "clone_url": "https://github.com/github-api-test-org/empty.git", + "svn_url": "https://github.com/github-api-test-org/empty", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/user-009b9e10-1f02-4c40-bc83-b37bfd70670e.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/user-8d2ebbe4-ff50-4d3e-9932-d48541155f86.json similarity index 98% rename from src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/user-009b9e10-1f02-4c40-bc83-b37bfd70670e.json rename to src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/user-8d2ebbe4-ff50-4d3e-9932-d48541155f86.json index 39d6c8353e..41fc9e3d00 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/user-009b9e10-1f02-4c40-bc83-b37bfd70670e.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/__files/user-8d2ebbe4-ff50-4d3e-9932-d48541155f86.json @@ -24,7 +24,7 @@ "email": "bitwiseman@gmail.com", "hireable": null, "bio": "https://twitter.com/bitwiseman", - "public_repos": 167, + "public_repos": 168, "public_gists": 4, "followers": 136, "following": 9, diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty-2-af73e2.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty-2-af73e2.json new file mode 100644 index 0000000000..bfb49f1f76 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty-2-af73e2.json @@ -0,0 +1,43 @@ +{ + "id": "af73e21a-68d3-4683-a1e1-3415319211e4", + "name": "repos_github-api-test-org_empty", + "request": { + "url": "/repos/github-api-test-org/empty", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_empty-af73e21a-68d3-4683-a1e1-3415319211e4.json", + "headers": { + "Date": "Fri, 04 Oct 2019 00:34:14 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4826", + "X-RateLimit-Reset": "1570151182", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"71a57ee919c57e5e9eb076f615232a66\"", + "Last-Modified": "Sat, 04 Jun 2016 03:22:22 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D778:2CE6:7EE78B:96BD39:5D969385" + } + }, + "uuid": "af73e21a-68d3-4683-a1e1-3415319211e4", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty_contributors-3-dae0e3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty_contributors-3-dae0e3.json new file mode 100644 index 0000000000..58ae5449a7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/repos_github-api-test-org_empty_contributors-3-dae0e3.json @@ -0,0 +1,35 @@ +{ + "id": "dae0e321-23f5-462b-8d0b-cb67f101e856", + "name": "repos_github-api-test-org_empty_contributors", + "request": { + "url": "/repos/github-api-test-org/empty/contributors", + "method": "GET" + }, + "response": { + "status": 204, + "headers": { + "Date": "Fri, 04 Oct 2019 00:34:14 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4825", + "X-RateLimit-Reset": "1570151182", + "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'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "D778:2CE6:7EE795:96BD55:5D969386" + } + }, + "uuid": "dae0e321-23f5-462b-8d0b-cb67f101e856", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/user-1-009b9e.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/user-1-8d2ebb.json similarity index 77% rename from src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/user-1-009b9e.json rename to src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/user-1-8d2ebb.json index 04c50620c8..e5adbdccc8 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/user-1-009b9e.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/listEmptyContributors/mappings/user-1-8d2ebb.json @@ -1,5 +1,5 @@ { - "id": "009b9e10-1f02-4c40-bc83-b37bfd70670e", + "id": "8d2ebbe4-ff50-4d3e-9932-d48541155f86", "name": "user", "request": { "url": "/user", @@ -7,21 +7,21 @@ }, "response": { "status": 200, - "bodyFileName": "user-009b9e10-1f02-4c40-bc83-b37bfd70670e.json", + "bodyFileName": "user-8d2ebbe4-ff50-4d3e-9932-d48541155f86.json", "headers": { - "Date": "Thu, 03 Oct 2019 18:56:13 GMT", + "Date": "Fri, 04 Oct 2019 00:34:13 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4879", - "X-RateLimit-Reset": "1570132527", + "X-RateLimit-Remaining": "4828", + "X-RateLimit-Reset": "1570151182", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], - "ETag": "W/\"cf6199fecf47b59c42190e1e11147ee2\"", + "ETag": "W/\"af0c41afcacb8ceee14b7d896719c3bd\"", "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", @@ -34,10 +34,10 @@ "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": "F373:78E9:F56BC4:1244F1E:5D96444C" + "X-GitHub-Request-Id": "D778:2CE6:7EE777:96BD36:5D969385" } }, - "uuid": "009b9e10-1f02-4c40-bc83-b37bfd70670e", + "uuid": "8d2ebbe4-ff50-4d3e-9932-d48541155f86", "persistent": true, "insertionIndex": 1 } \ No newline at end of file