From 21e9dd6f51366ed319c044993e5f50872a3b282a Mon Sep 17 00:00:00 2001 From: Sladyn Nunes Date: Thu, 2 Apr 2020 17:55:21 +0530 Subject: [PATCH 1/8] Change withURLPath to setRawURLPath --- src/main/java/org/kohsuke/github/GHGist.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHGist.java b/src/main/java/org/kohsuke/github/GHGist.java index 2dfae110ed..41ec5c66c8 100644 --- a/src/main/java/org/kohsuke/github/GHGist.java +++ b/src/main/java/org/kohsuke/github/GHGist.java @@ -172,7 +172,7 @@ String getApiTailUrl(String tail) { * the io exception */ public void star() throws IOException { - root.createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send(); + root.createRequest().method("PUT").setRawUrlPath(getApiTailUrl("star")).send(); } /** @@ -182,7 +182,7 @@ public void star() throws IOException { * the io exception */ public void unstar() throws IOException { - root.createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send(); + root.createRequest().method("DELETE").setRawUrlPath(getApiTailUrl("star")).send(); } /** From 191dd49653ba5d52909966b6a690f9b5f2df7359 Mon Sep 17 00:00:00 2001 From: Sladyn Nunes Date: Mon, 6 Apr 2020 18:13:26 +0530 Subject: [PATCH 2/8] added test and modified url --- src/main/java/org/kohsuke/github/GHBranch.java | 2 +- .../java/org/kohsuke/github/GHBranchProtectionTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index ecd1f948d1..0dbbf1ecfa 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -120,7 +120,7 @@ public String getSHA1() { * if disabling protection fails */ public void disableProtection() throws IOException { - root.createRequest().method("DELETE").withUrlPath(protection_url).send(); + root.createRequest().method("DELETE").setRawUrlPath(protection_url).send(); } /** diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 7f15ea61c9..e8cab120bb 100644 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -54,6 +54,12 @@ public void testEnableProtectionOnly() throws Exception { assertTrue(repo.getBranch(BRANCH).isProtected()); } + @Test + public void testDisableProtectionOnly() throws Exception { + branch.disableProtection(); + System.out.println(repo.getBranch(BRANCH).isProtected()); + } + @Test public void testEnableRequireReviewsOnly() throws Exception { GHBranchProtection protection = branch.enableProtection().requireReviews().enable(); From 81d7d6236bfab3afb04d45acd5f8fe32bbe78081 Mon Sep 17 00:00:00 2001 From: Sladyn Nunes Date: Tue, 7 Apr 2020 18:17:20 +0530 Subject: [PATCH 3/8] Add resource files --- ...-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json | 126 ++++++++++++++++++ ...-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json | 89 +++++++++++++ ...-331a04ec-31ba-497c-98c6-8fff6cce8e27.json | 16 +++ ...-537294b2-ffff-4e92-b075-d089a64978b5.json | 45 +++++++ ...mp-testdisableprotectiononly-2-e2ecf2.json | 48 +++++++ ...otectiononly_branches_master-3-3da4ed.json | 47 +++++++ ...y_branches_master_protection-4-331a04.json | 54 ++++++++ ...y_branches_master_protection-5-7e7df9.json | 40 ++++++ .../mappings/user-1-537294.json | 48 +++++++ 9 files changed, 513 insertions(+) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1-537294.json diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json new file mode 100644 index 0000000000..f61bff74a3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json @@ -0,0 +1,126 @@ +{ + "id": 253490066, + "node_id": "MDEwOlJlcG9zaXRvcnkyNTM0OTAwNjY=", + "name": "temp-testDisableProtectionOnly", + "full_name": "github-api-test-org/temp-testDisableProtectionOnly", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly", + "description": "A test repository for testing the github-api project: temp-testDisableProtectionOnly", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/deployments", + "created_at": "2020-04-06T12:25:14Z", + "updated_at": "2020-04-06T12:25:18Z", + "pushed_at": "2020-04-06T12:25:15Z", + "git_url": "git://github.com/github-api-test-org/temp-testDisableProtectionOnly.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testDisableProtectionOnly.git", + "clone_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly.git", + "svn_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "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": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json new file mode 100644 index 0000000000..bfa2847bd4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "f2e92a7002bf8ac91750d647a0be2c15411e2942", + "node_id": "MDY6Q29tbWl0MjUzNDkwMDY2OmYyZTkyYTcwMDJiZjhhYzkxNzUwZDY0N2EwYmUyYzE1NDExZTI5NDI=", + "commit": { + "author": { + "name": "Sladyn", + "email": "sladynnunes98@gmail.com", + "date": "2020-04-06T12:25:15Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2020-04-06T12:25:15Z" + }, + "message": "Initial commit", + "tree": { + "sha": "e0f408fb90498b93fb29f15f65a716d635b935aa", + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees/e0f408fb90498b93fb29f15f65a716d635b935aa" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits/f2e92a7002bf8ac91750d647a0be2c15411e2942", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeix+rCRBK7hj4Ov3rIwAAdHIIAAqSgHCUcQf1yvtvaDYKbIqg\nQn+VcaCXqJWl8wcxNNcp3VAzUEmUAsB64hOWN1pxOFikfrTt+YXw8Jn8LJUKrs0r\ne+tNjoBAWFRn6zMK4SAiEgbVsuMztDg7TBiAt12+cJ3F8vrTlovCfpvUqSD2b1HG\nq/bE4Ihrmz90Jr8PALTHLdDV+zZEt/Dz1iVQuQ6PHD+Fo3j9PQNmsl1csi5+c+wA\netoAj+BuA34LIwxJJYpZ0GvkB/+4kBU316h8SlcmCTZepKRgeEqfmgT+MisUfMGe\nRXxixhZTkk6nozvsk+r3km8OouOKuijSJ3Ik+PJ+2gE6LxsasByktDLswIE0VW8=\n=Y+YS\n-----END PGP SIGNATURE-----\n", + "payload": "tree e0f408fb90498b93fb29f15f65a716d635b935aa\nauthor Sladyn 1586175915 +0530\ncommitter GitHub 1586175915 +0530\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/f2e92a7002bf8ac91750d647a0be2c15411e2942", + "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/commit/f2e92a7002bf8ac91750d647a0be2c15411e2942", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/f2e92a7002bf8ac91750d647a0be2c15411e2942/comments", + "author": { + "login": "sladyn98", + "id": 28837406, + "node_id": "MDQ6VXNlcjI4ODM3NDA2", + "avatar_url": "https://avatars1.githubusercontent.com/u/28837406?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sladyn98", + "html_url": "https://github.com/sladyn98", + "followers_url": "https://api.github.com/users/sladyn98/followers", + "following_url": "https://api.github.com/users/sladyn98/following{/other_user}", + "gists_url": "https://api.github.com/users/sladyn98/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sladyn98/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sladyn98/subscriptions", + "organizations_url": "https://api.github.com/users/sladyn98/orgs", + "repos_url": "https://api.github.com/users/sladyn98/repos", + "events_url": "https://api.github.com/users/sladyn98/events{/privacy}", + "received_events_url": "https://api.github.com/users/sladyn98/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json new file mode 100644 index 0000000000..910977f94d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json @@ -0,0 +1,16 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection/enforce_admins", + "enabled": false + }, + "required_linear_history": { + "enabled": false + }, + "allow_force_pushes": { + "enabled": false + }, + "allow_deletions": { + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json new file mode 100644 index 0000000000..d01375916d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json @@ -0,0 +1,45 @@ +{ + "login": "sladyn98", + "id": 28837406, + "node_id": "MDQ6VXNlcjI4ODM3NDA2", + "avatar_url": "https://avatars1.githubusercontent.com/u/28837406?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sladyn98", + "html_url": "https://github.com/sladyn98", + "followers_url": "https://api.github.com/users/sladyn98/followers", + "following_url": "https://api.github.com/users/sladyn98/following{/other_user}", + "gists_url": "https://api.github.com/users/sladyn98/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sladyn98/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sladyn98/subscriptions", + "organizations_url": "https://api.github.com/users/sladyn98/orgs", + "repos_url": "https://api.github.com/users/sladyn98/repos", + "events_url": "https://api.github.com/users/sladyn98/events{/privacy}", + "received_events_url": "https://api.github.com/users/sladyn98/received_events", + "type": "User", + "site_admin": false, + "name": "Sladyn", + "company": "VESIT", + "blog": "https://sladyn98.netlify.com", + "location": "Mumbai", + "email": "sladynnunes98@gmail.com", + "hireable": null, + "bio": "Open-Source Enthusiast\r\nPrev: Intern @Jenkins 2019 \r\n @openmainframeproject 2019 \r\n@cloudyBoss | \r\n@coala Developer\r\nInterests: Distributed Systems | Dev-Ops", + "public_repos": 100, + "public_gists": 3, + "followers": 51, + "following": 37, + "created_at": "2017-05-21T08:36:24Z", + "updated_at": "2020-04-04T09:32:22Z", + "private_gists": 2, + "total_private_repos": 9, + "owned_private_repos": 7, + "disk_usage": 58617, + "collaborators": 8, + "two_factor_authentication": false, + "plan": { + "name": "pro", + "space": 976562499, + "collaborators": 0, + "private_repos": 9999 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json new file mode 100644 index 0000000000..ffd26c0e58 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json @@ -0,0 +1,48 @@ +{ + "id": "e2ecf292-54f5-475c-a5ce-f5a68d383a16", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json", + "headers": { + "Date": "Mon, 06 Apr 2020 12:25:19 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4926", + "X-RateLimit-Reset": "1586177716", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"720a808c8c4e708cc849295c3460fd0b\"", + "Last-Modified": "Mon, 06 Apr 2020 12:25:18 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "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, Deprecation, Sunset", + "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": "8132:6389:4E43F5:6286EE:5E8B1FAF" + } + }, + "uuid": "e2ecf292-54f5-475c-a5ce-f5a68d383a16", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json new file mode 100644 index 0000000000..2b547222cb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json @@ -0,0 +1,47 @@ +{ + "id": "3da4ed3b-3b42-4e4a-962b-2003a42a07b2", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json", + "headers": { + "Date": "Mon, 06 Apr 2020 12:25:19 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4925", + "X-RateLimit-Reset": "1586177716", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"f6edbbdd2685a0d246fe768f6f5149b2\"", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "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, Deprecation, Sunset", + "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": "8132:6389:4E4409:628700:5E8B1FAF" + } + }, + "uuid": "3da4ed3b-3b42-4e4a-962b-2003a42a07b2", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json new file mode 100644 index 0000000000..6b9f3bdc6e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json @@ -0,0 +1,54 @@ +{ + "id": "331a04ec-31ba-497c-98c6-8fff6cce8e27", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "method": "PUT", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.luke-cage-preview+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json", + "headers": { + "Date": "Mon, 06 Apr 2020 12:35:36 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4831", + "X-RateLimit-Reset": "1586177716", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"807a9b4a2da9009925b6ad08258e1169\"", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", + "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": "D9B6:7E40:49DA85:5E5B14:5E8B2218" + } + }, + "uuid": "331a04ec-31ba-497c-98c6-8fff6cce8e27", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json new file mode 100644 index 0000000000..7f60544c54 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json @@ -0,0 +1,40 @@ +{ + "id": "7e7df941-02b5-42f7-b713-845e9905741b", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "method": "DELETE", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 204, + "headers": { + "Date": "Mon, 06 Apr 2020 12:35:37 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4830", + "X-RateLimit-Reset": "1586177716", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "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, Deprecation, Sunset", + "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, Accept, X-Requested-With", + "X-GitHub-Request-Id": "D9B6:7E40:49DA99:5E5B2A:5E8B2218" + } + }, + "uuid": "7e7df941-02b5-42f7-b713-845e9905741b", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1-537294.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1-537294.json new file mode 100644 index 0000000000..764286ac33 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1-537294.json @@ -0,0 +1,48 @@ +{ + "id": "537294b2-ffff-4e92-b075-d089a64978b5", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-537294b2-ffff-4e92-b075-d089a64978b5.json", + "headers": { + "Date": "Sat, 04 Apr 2020 10:34:26 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4957", + "X-RateLimit-Reset": "1585999516", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"461eaf3b4017bd8853bf35f5a9b3f9bb\"", + "Last-Modified": "Sat, 04 Apr 2020 09:32:22 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "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, Deprecation, Sunset", + "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": "A1E0:6389:E5E9C:11C0F7:5E8862B2" + } + }, + "uuid": "537294b2-ffff-4e92-b075-d089a64978b5", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From 057ba3887374c951afb9056ef939a7c1fac5c7e9 Mon Sep 17 00:00:00 2001 From: Sladyn Nunes Date: Mon, 20 Apr 2020 16:32:48 +0530 Subject: [PATCH 4/8] Added getProtectionTest --- .../java/org/kohsuke/github/GHBranch.java | 2 +- .../github/GHBranchProtectionTest.java | 10 +- ...pi-test-org_temp-testgetprotection-2.json} | 102 +++++++++--------- ...-testgetprotection_branches_master-3.json} | 30 +++--- ...tection_branches_master_protection-5.json} | 4 +- .../__files/user-1.json} | 12 +-- ...pi-test-org_temp-testgetprotection-2.json} | 24 ++--- ...-testgetprotection_branches_master-3.json} | 22 ++-- ...tection_branches_master_protection-4.json} | 28 ++--- ...tection_branches_master_protection-5.json} | 24 ++--- .../mappings/user-1.json} | 20 ++-- 11 files changed, 139 insertions(+), 139 deletions(-) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json => testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json} (67%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json => testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json} (68%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json => testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json} (72%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json => testGetProtection/__files/user-1.json} (90%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json => testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json} (57%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json => testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json} (57%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json => testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json} (53%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json => testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json} (60%) rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/{testDisableProtectionOnly/mappings/user-1-537294.json => testGetProtection/mappings/user-1.json} (63%) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index 0dbbf1ecfa..baa8a74800 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -101,7 +101,7 @@ public URL getProtectionUrl() { * the io exception */ public GHBranchProtection getProtection() throws IOException { - return root.createRequest().withUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this); + return root.createRequest().setRawUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this); } /** diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index e8cab120bb..56a667904e 100644 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -56,8 +56,9 @@ public void testEnableProtectionOnly() throws Exception { @Test public void testDisableProtectionOnly() throws Exception { + GHBranchProtection protection = branch.enableProtection().enable(); branch.disableProtection(); - System.out.println(repo.getBranch(BRANCH).isProtected()); + assertFalse(repo.getBranch(BRANCH).isProtected()); } @Test @@ -79,4 +80,11 @@ public void testSignedCommits() throws Exception { protection.disableSignedCommits(); assertFalse(protection.getRequiredSignatures()); } + + @Test + public void testGetProtectionTest() throws Exception { + GHBranchProtection protection = branch.enableProtection().enable(); + GHBranchProtection protectionTest = branch.getProtection(); + assertTrue(protectionTest instanceof GHBranchProtection); + } } diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json similarity index 67% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json index f61bff74a3..b56eb87adb 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json @@ -1,8 +1,8 @@ { - "id": 253490066, - "node_id": "MDEwOlJlcG9zaXRvcnkyNTM0OTAwNjY=", - "name": "temp-testDisableProtectionOnly", - "full_name": "github-api-test-org/temp-testDisableProtectionOnly", + "id": 257214977, + "node_id": "MDEwOlJlcG9zaXRvcnkyNTcyMTQ5Nzc=", + "name": "temp-testGetProtection", + "full_name": "github-api-test-org/temp-testGetProtection", "private": false, "owner": { "login": "github-api-test-org", @@ -24,53 +24,53 @@ "type": "Organization", "site_admin": false }, - "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly", - "description": "A test repository for testing the github-api project: temp-testDisableProtectionOnly", + "html_url": "https://github.com/github-api-test-org/temp-testGetProtection", + "description": "A test repository for testing the github-api project: temp-testGetProtection", "fork": false, - "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly", - "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/forks", - "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/teams", - "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/hooks", - "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/events{/number}", - "events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/events", - "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/assignees{/user}", - "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches{/branch}", - "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/tags", - "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/statuses/{sha}", - "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/languages", - "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/stargazers", - "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contributors", - "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscribers", - "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscription", - "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contents/{+path}", - "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/merges", - "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/downloads", - "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues{/number}", - "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/pulls{/number}", - "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/milestones{/number}", - "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/labels{/name}", - "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/releases{/id}", - "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/deployments", - "created_at": "2020-04-06T12:25:14Z", - "updated_at": "2020-04-06T12:25:18Z", - "pushed_at": "2020-04-06T12:25:15Z", - "git_url": "git://github.com/github-api-test-org/temp-testDisableProtectionOnly.git", - "ssh_url": "git@github.com:github-api-test-org/temp-testDisableProtectionOnly.git", - "clone_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly.git", - "svn_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/deployments", + "created_at": "2020-04-20T08:15:10Z", + "updated_at": "2020-04-20T08:15:15Z", + "pushed_at": "2020-04-20T08:15:12Z", + "git_url": "git://github.com/github-api-test-org/temp-testGetProtection.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testGetProtection.git", + "clone_url": "https://github.com/github-api-test-org/temp-testGetProtection.git", + "svn_url": "https://github.com/github-api-test-org/temp-testGetProtection", "homepage": "http://github-api.kohsuke.org/", "size": 0, "stargazers_count": 0, @@ -122,5 +122,5 @@ "site_admin": false }, "network_count": 0, - "subscribers_count": 7 + "subscribers_count": 8 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json similarity index 68% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json index bfa2847bd4..1f94cf4c44 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json @@ -1,36 +1,36 @@ { "name": "master", "commit": { - "sha": "f2e92a7002bf8ac91750d647a0be2c15411e2942", - "node_id": "MDY6Q29tbWl0MjUzNDkwMDY2OmYyZTkyYTcwMDJiZjhhYzkxNzUwZDY0N2EwYmUyYzE1NDExZTI5NDI=", + "sha": "fe352bd9e8dd386691a68be4dd59c9fd24da63d7", + "node_id": "MDY6Q29tbWl0MjU3MjE0OTc3OmZlMzUyYmQ5ZThkZDM4NjY5MWE2OGJlNGRkNTljOWZkMjRkYTYzZDc=", "commit": { "author": { "name": "Sladyn", "email": "sladynnunes98@gmail.com", - "date": "2020-04-06T12:25:15Z" + "date": "2020-04-20T08:15:11Z" }, "committer": { "name": "GitHub", "email": "noreply@github.com", - "date": "2020-04-06T12:25:15Z" + "date": "2020-04-20T08:15:11Z" }, "message": "Initial commit", "tree": { - "sha": "e0f408fb90498b93fb29f15f65a716d635b935aa", - "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees/e0f408fb90498b93fb29f15f65a716d635b935aa" + "sha": "7e4b67f31859a5c6348d83419539ba9fa8864ed0", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/trees/7e4b67f31859a5c6348d83419539ba9fa8864ed0" }, - "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits/f2e92a7002bf8ac91750d647a0be2c15411e2942", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/commits/fe352bd9e8dd386691a68be4dd59c9fd24da63d7", "comment_count": 0, "verification": { "verified": true, "reason": "valid", - "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeix+rCRBK7hj4Ov3rIwAAdHIIAAqSgHCUcQf1yvtvaDYKbIqg\nQn+VcaCXqJWl8wcxNNcp3VAzUEmUAsB64hOWN1pxOFikfrTt+YXw8Jn8LJUKrs0r\ne+tNjoBAWFRn6zMK4SAiEgbVsuMztDg7TBiAt12+cJ3F8vrTlovCfpvUqSD2b1HG\nq/bE4Ihrmz90Jr8PALTHLdDV+zZEt/Dz1iVQuQ6PHD+Fo3j9PQNmsl1csi5+c+wA\netoAj+BuA34LIwxJJYpZ0GvkB/+4kBU316h8SlcmCTZepKRgeEqfmgT+MisUfMGe\nRXxixhZTkk6nozvsk+r3km8OouOKuijSJ3Ik+PJ+2gE6LxsasByktDLswIE0VW8=\n=Y+YS\n-----END PGP SIGNATURE-----\n", - "payload": "tree e0f408fb90498b93fb29f15f65a716d635b935aa\nauthor Sladyn 1586175915 +0530\ncommitter GitHub 1586175915 +0530\n\nInitial commit" + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJenVoPCRBK7hj4Ov3rIwAAdHIIADxk98COSq8twY32znmzSQDe\nMWe+qYegYWwQr3qN/T6MS2WWDleXzyE0Jmp2eLY3xAO0dQeIy/axlcgaZkx4rq/w\nwpOh0XMmpe3cijrOtZlqKebyXl1ctCndaob+4WN55R07BPOL6Skl7mokmFBFsLkr\nnT4VnB3fJuhy0CuES75VZ6lQ839nNPkJ9Afmq/mTy/RAr6ZeBL3oH4hHGoB7JJ07\n0Q/7zSs3yZQGZ87g9rGjt54B3pXX2qmJtNP5uxW9NtdOQefvMDmQkj+jvHWMVrgb\n0g2foW0M+/sSSs925Rz8QweLB1UK+f7wSmyGJpkT3UJg9zaQ6oSUKO/F4gtvyFU=\n=GtXJ\n-----END PGP SIGNATURE-----\n", + "payload": "tree 7e4b67f31859a5c6348d83419539ba9fa8864ed0\nauthor Sladyn 1587370511 +0530\ncommitter GitHub 1587370511 +0530\n\nInitial commit" } }, - "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/f2e92a7002bf8ac91750d647a0be2c15411e2942", - "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/commit/f2e92a7002bf8ac91750d647a0be2c15411e2942", - "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/f2e92a7002bf8ac91750d647a0be2c15411e2942/comments", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/fe352bd9e8dd386691a68be4dd59c9fd24da63d7", + "html_url": "https://github.com/github-api-test-org/temp-testGetProtection/commit/fe352bd9e8dd386691a68be4dd59c9fd24da63d7", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/fe352bd9e8dd386691a68be4dd59c9fd24da63d7/comments", "author": { "login": "sladyn98", "id": 28837406, @@ -74,8 +74,8 @@ "parents": [] }, "_links": { - "self": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", - "html": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/tree/master" + "self": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master", + "html": "https://github.com/github-api-test-org/temp-testGetProtection/tree/master" }, "protected": false, "protection": { @@ -85,5 +85,5 @@ "contexts": [] } }, - "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection" + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master/protection" } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json similarity index 72% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json index 910977f94d..a3b6658e5e 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json @@ -1,7 +1,7 @@ { - "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", "enforce_admins": { - "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection/enforce_admins", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master/protection/enforce_admins", "enabled": false }, "required_linear_history": { diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/user-1.json similarity index 90% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/user-1.json index d01375916d..c6eaa5b837 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-537294b2-ffff-4e92-b075-d089a64978b5.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/user-1.json @@ -24,18 +24,18 @@ "email": "sladynnunes98@gmail.com", "hireable": null, "bio": "Open-Source Enthusiast\r\nPrev: Intern @Jenkins 2019 \r\n @openmainframeproject 2019 \r\n@cloudyBoss | \r\n@coala Developer\r\nInterests: Distributed Systems | Dev-Ops", - "public_repos": 100, + "public_repos": 103, "public_gists": 3, - "followers": 51, - "following": 37, + "followers": 53, + "following": 39, "created_at": "2017-05-21T08:36:24Z", - "updated_at": "2020-04-04T09:32:22Z", + "updated_at": "2020-04-20T07:32:04Z", "private_gists": 2, "total_private_repos": 9, "owned_private_repos": 7, - "disk_usage": 58617, + "disk_usage": 58635, "collaborators": 8, - "two_factor_authentication": false, + "two_factor_authentication": true, "plan": { "name": "pro", "space": 976562499, diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json similarity index 57% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json index ffd26c0e58..d9b6b4986f 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2-e2ecf2.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json @@ -1,8 +1,8 @@ { - "id": "e2ecf292-54f5-475c-a5ce-f5a68d383a16", - "name": "repos_github-api-test-org_temp-testdisableprotectiononly", + "id": "895df30d-257a-4635-9826-1613885e710e", + "name": "repos_github-api-test-org_temp-testgetprotection", "request": { - "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly", + "url": "/repos/github-api-test-org/temp-testGetProtection", "method": "GET", "headers": { "Accept": { @@ -12,37 +12,35 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly-e2ecf292-54f5-475c-a5ce-f5a68d383a16.json", + "bodyFileName": "repos_github-api-test-org_temp-testgetprotection-2.json", "headers": { - "Date": "Mon, 06 Apr 2020 12:25:19 GMT", + "Date": "Mon, 20 Apr 2020 08:15:16 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4926", - "X-RateLimit-Reset": "1586177716", + "X-RateLimit-Remaining": "4913", + "X-RateLimit-Reset": "1587370940", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"720a808c8c4e708cc849295c3460fd0b\"", - "Last-Modified": "Mon, 06 Apr 2020 12:25:18 GMT", + "ETag": "W/\"17566056d13738600df96fee745ecacf\"", + "Last-Modified": "Mon, 20 Apr 2020 08:15:15 GMT", "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", "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, Deprecation, Sunset", - "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": "8132:6389:4E43F5:6286EE:5E8B1FAF" + "X-GitHub-Request-Id": "D5CC:4297:AB954:E2B06:5E9D5A0C" } }, - "uuid": "e2ecf292-54f5-475c-a5ce-f5a68d383a16", + "uuid": "895df30d-257a-4635-9826-1613885e710e", "persistent": true, "insertionIndex": 2 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json similarity index 57% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json index 2b547222cb..46ba9ae048 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3-3da4ed.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json @@ -1,8 +1,8 @@ { - "id": "3da4ed3b-3b42-4e4a-962b-2003a42a07b2", - "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master", + "id": "6af0c781-30dd-4c9a-bb73-6efa52595ffc", + "name": "repos_github-api-test-org_temp-testgetprotection_branches_master", "request": { - "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master", "method": "GET", "headers": { "Accept": { @@ -12,36 +12,34 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3da4ed3b-3b42-4e4a-962b-2003a42a07b2.json", + "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master-3.json", "headers": { - "Date": "Mon, 06 Apr 2020 12:25:19 GMT", + "Date": "Mon, 20 Apr 2020 08:15:16 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4925", - "X-RateLimit-Reset": "1586177716", + "X-RateLimit-Remaining": "4912", + "X-RateLimit-Reset": "1587370940", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"f6edbbdd2685a0d246fe768f6f5149b2\"", + "ETag": "W/\"e854e72f207b42cc1b5edbaa30f35024\"", "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", "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, Deprecation, Sunset", - "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": "8132:6389:4E4409:628700:5E8B1FAF" + "X-GitHub-Request-Id": "D5CC:4297:AB95D:E2BAA:5E9D5A14" } }, - "uuid": "3da4ed3b-3b42-4e4a-962b-2003a42a07b2", + "uuid": "6af0c781-30dd-4c9a-bb73-6efa52595ffc", "persistent": true, "insertionIndex": 3 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json similarity index 53% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json index 7f60544c54..05af0a85ef 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-5-7e7df9.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json @@ -1,9 +1,9 @@ { - "id": "7e7df941-02b5-42f7-b713-845e9905741b", - "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection", + "id": "1d395564-9154-440b-ade4-b18cb8b970cc", + "name": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection", "request": { - "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", - "method": "DELETE", + "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", + "method": "GET", "headers": { "Accept": { "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" @@ -11,19 +11,19 @@ } }, "response": { - "status": 204, + "status": 404, + "body": "{\"message\":\"Branch not protected\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#get-branch-protection\"}", "headers": { - "Date": "Mon, 06 Apr 2020 12:35:37 GMT", + "Date": "Mon, 20 Apr 2020 08:15:17 GMT", + "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", - "Status": "204 No Content", + "Status": "404 Not Found", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4830", - "X-RateLimit-Reset": "1586177716", + "X-RateLimit-Remaining": "4911", + "X-RateLimit-Reset": "1587370940", "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", "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, Deprecation, Sunset", - "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Frame-Options": "deny", "X-Content-Type-Options": "nosniff", @@ -31,10 +31,10 @@ "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": "D9B6:7E40:49DA99:5E5B2A:5E8B2218" + "X-GitHub-Request-Id": "D5CC:4297:AB966:E2BB8:5E9D5A14" } }, - "uuid": "7e7df941-02b5-42f7-b713-845e9905741b", + "uuid": "1d395564-9154-440b-ade4-b18cb8b970cc", "persistent": true, - "insertionIndex": 5 + "insertionIndex": 4 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json similarity index 60% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json index 6b9f3bdc6e..3d7d7e47d8 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4-331a04.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json @@ -1,8 +1,8 @@ { - "id": "331a04ec-31ba-497c-98c6-8fff6cce8e27", - "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection", + "id": "fc1a35dc-4e0b-42f3-8209-cdcb10c22061", + "name": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection", "request": { - "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", "method": "PUT", "headers": { "Accept": { @@ -19,36 +19,34 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-331a04ec-31ba-497c-98c6-8fff6cce8e27.json", + "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json", "headers": { - "Date": "Mon, 06 Apr 2020 12:35:36 GMT", + "Date": "Mon, 20 Apr 2020 08:18:47 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4831", - "X-RateLimit-Reset": "1586177716", + "X-RateLimit-Remaining": "4880", + "X-RateLimit-Reset": "1587370940", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"807a9b4a2da9009925b6ad08258e1169\"", + "ETag": "W/\"85947a574037691379fb4fb191aa311e\"", "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", - "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", - "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": "D9B6:7E40:49DA85:5E5B14:5E8B2218" + "X-GitHub-Request-Id": "D61E:711F:2B87AA:384FE6:5E9D5AE6" } }, - "uuid": "331a04ec-31ba-497c-98c6-8fff6cce8e27", + "uuid": "fc1a35dc-4e0b-42f3-8209-cdcb10c22061", "persistent": true, - "insertionIndex": 4 + "insertionIndex": 5 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1-537294.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/user-1.json similarity index 63% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1-537294.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/user-1.json index 764286ac33..a3da8d980a 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1-537294.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/user-1.json @@ -1,5 +1,5 @@ { - "id": "537294b2-ffff-4e92-b075-d089a64978b5", + "id": "63501c5d-4dae-4bdf-8d4f-98d4a2c908ed", "name": "user", "request": { "url": "/user", @@ -12,37 +12,35 @@ }, "response": { "status": 200, - "bodyFileName": "user-537294b2-ffff-4e92-b075-d089a64978b5.json", + "bodyFileName": "user-1.json", "headers": { - "Date": "Sat, 04 Apr 2020 10:34:26 GMT", + "Date": "Mon, 20 Apr 2020 08:15:08 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4957", - "X-RateLimit-Reset": "1585999516", + "X-RateLimit-Remaining": "4918", + "X-RateLimit-Reset": "1587370940", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"461eaf3b4017bd8853bf35f5a9b3f9bb\"", - "Last-Modified": "Sat, 04 Apr 2020 09:32:22 GMT", + "ETag": "W/\"c64535ca0763246449d97ae6f960052c\"", + "Last-Modified": "Mon, 20 Apr 2020 07:32:04 GMT", "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", "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, Deprecation, Sunset", - "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": "A1E0:6389:E5E9C:11C0F7:5E8862B2" + "X-GitHub-Request-Id": "D5CC:4297:AB8D2:E2B02:5E9D5A0C" } }, - "uuid": "537294b2-ffff-4e92-b075-d089a64978b5", + "uuid": "63501c5d-4dae-4bdf-8d4f-98d4a2c908ed", "persistent": true, "insertionIndex": 1 } \ No newline at end of file From c3e94585552ef7fcf2aa8bf3f6cbc17ddd89ac44 Mon Sep 17 00:00:00 2001 From: Sladyn Nunes Date: Mon, 20 Apr 2020 17:47:34 +0530 Subject: [PATCH 5/8] Additional modifications to test --- .../github/GHBranchProtectionTest.java | 4 +- ...otection_branches_master_protection-6.json | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/test/java/org/kohsuke/github/GHBranchProtectionTest.java create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java old mode 100644 new mode 100755 index 56a667904e..0dea2d475f --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -82,9 +82,9 @@ public void testSignedCommits() throws Exception { } @Test - public void testGetProtectionTest() throws Exception { + public void testGetProtection() throws Exception { GHBranchProtection protection = branch.enableProtection().enable(); - GHBranchProtection protectionTest = branch.getProtection(); + GHBranchProtection protectionTest = repo.getBranch(BRANCH).getProtection(); assertTrue(protectionTest instanceof GHBranchProtection); } } diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json new file mode 100644 index 0000000000..844bd0d55d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json @@ -0,0 +1,40 @@ +{ + "id": "60b50898-f2af-4e49-882e-facd861bd374", + "name": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", + "method": "DELETE", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 404, + "body": "{\"message\":\"Branch not protected\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#remove-branch-protection\"}", + "headers": { + "Date": "Mon, 20 Apr 2020 11:43:08 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "404 Not Found", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4845", + "X-RateLimit-Reset": "1587385073", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "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": "BB96:659F:3A6383:49C440:5E9D8ACC" + } + }, + "uuid": "60b50898-f2af-4e49-882e-facd861bd374", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file From 83122ac99e501c1242d43e3d9250406d2657a733 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 23 Apr 2020 10:43:09 -0700 Subject: [PATCH 6/8] Take new snapshot of testGetProtection() --- .../github/GHBranchProtectionTest.java | 1 + ...api-test-org_temp-testgetprotection-2.json | 10 +-- ...p-testgetprotection_branches_master-3.json | 54 +++++------ ...p-testgetprotection_branches_master-5.json | 89 +++++++++++++++++++ ...p-testgetprotection_branches_master-7.json | 89 +++++++++++++++++++ ...tection_branches_master_protection-4.json} | 0 ...otection_branches_master_protection-6.json | 16 ++++ .../testGetProtection/__files/user-1.json | 68 +++++++------- ...api-test-org_temp-testgetprotection-2.json | 18 ++-- ...p-testgetprotection_branches_master-3.json | 19 ++-- ...p-testgetprotection_branches_master-5.json | 48 ++++++++++ ...p-testgetprotection_branches_master-7.json | 47 ++++++++++ ...otection_branches_master_protection-4.json | 42 +++++---- ...otection_branches_master_protection-5.json | 52 ----------- ...otection_branches_master_protection-6.json | 29 +++--- .../testGetProtection/mappings/user-1.json | 18 ++-- 16 files changed, 429 insertions(+), 171 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/{repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json => repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json} (100%) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json delete mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 0dea2d475f..73e117bfe1 100755 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -86,5 +86,6 @@ public void testGetProtection() throws Exception { GHBranchProtection protection = branch.enableProtection().enable(); GHBranchProtection protectionTest = repo.getBranch(BRANCH).getProtection(); assertTrue(protectionTest instanceof GHBranchProtection); + assertTrue(repo.getBranch(BRANCH).isProtected()); } } diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json index b56eb87adb..e60929f83c 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection-2.json @@ -1,6 +1,6 @@ { - "id": 257214977, - "node_id": "MDEwOlJlcG9zaXRvcnkyNTcyMTQ5Nzc=", + "id": 258283935, + "node_id": "MDEwOlJlcG9zaXRvcnkyNTgyODM5MzU=", "name": "temp-testGetProtection", "full_name": "github-api-test-org/temp-testGetProtection", "private": false, @@ -64,9 +64,9 @@ "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/labels{/name}", "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/releases{/id}", "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/deployments", - "created_at": "2020-04-20T08:15:10Z", - "updated_at": "2020-04-20T08:15:15Z", - "pushed_at": "2020-04-20T08:15:12Z", + "created_at": "2020-04-23T17:41:59Z", + "updated_at": "2020-04-23T17:42:03Z", + "pushed_at": "2020-04-23T17:42:01Z", "git_url": "git://github.com/github-api-test-org/temp-testGetProtection.git", "ssh_url": "git@github.com:github-api-test-org/temp-testGetProtection.git", "clone_url": "https://github.com/github-api-test-org/temp-testGetProtection.git", diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json index 1f94cf4c44..b72ebe835d 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json @@ -1,53 +1,53 @@ { "name": "master", "commit": { - "sha": "fe352bd9e8dd386691a68be4dd59c9fd24da63d7", - "node_id": "MDY6Q29tbWl0MjU3MjE0OTc3OmZlMzUyYmQ5ZThkZDM4NjY5MWE2OGJlNGRkNTljOWZkMjRkYTYzZDc=", + "sha": "24fbd7cfa8192262e63efd9e64c4005e64429508", + "node_id": "MDY6Q29tbWl0MjU4MjgzOTM1OjI0ZmJkN2NmYTgxOTIyNjJlNjNlZmQ5ZTY0YzQwMDVlNjQ0Mjk1MDg=", "commit": { "author": { - "name": "Sladyn", - "email": "sladynnunes98@gmail.com", - "date": "2020-04-20T08:15:11Z" + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2020-04-23T17:42:00Z" }, "committer": { "name": "GitHub", "email": "noreply@github.com", - "date": "2020-04-20T08:15:11Z" + "date": "2020-04-23T17:42:00Z" }, "message": "Initial commit", "tree": { "sha": "7e4b67f31859a5c6348d83419539ba9fa8864ed0", "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/trees/7e4b67f31859a5c6348d83419539ba9fa8864ed0" }, - "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/commits/fe352bd9e8dd386691a68be4dd59c9fd24da63d7", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/commits/24fbd7cfa8192262e63efd9e64c4005e64429508", "comment_count": 0, "verification": { "verified": true, "reason": "valid", - "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJenVoPCRBK7hj4Ov3rIwAAdHIIADxk98COSq8twY32znmzSQDe\nMWe+qYegYWwQr3qN/T6MS2WWDleXzyE0Jmp2eLY3xAO0dQeIy/axlcgaZkx4rq/w\nwpOh0XMmpe3cijrOtZlqKebyXl1ctCndaob+4WN55R07BPOL6Skl7mokmFBFsLkr\nnT4VnB3fJuhy0CuES75VZ6lQ839nNPkJ9Afmq/mTy/RAr6ZeBL3oH4hHGoB7JJ07\n0Q/7zSs3yZQGZ87g9rGjt54B3pXX2qmJtNP5uxW9NtdOQefvMDmQkj+jvHWMVrgb\n0g2foW0M+/sSSs925Rz8QweLB1UK+f7wSmyGJpkT3UJg9zaQ6oSUKO/F4gtvyFU=\n=GtXJ\n-----END PGP SIGNATURE-----\n", - "payload": "tree 7e4b67f31859a5c6348d83419539ba9fa8864ed0\nauthor Sladyn 1587370511 +0530\ncommitter GitHub 1587370511 +0530\n\nInitial commit" + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeodNoCRBK7hj4Ov3rIwAAdHIIABVjG29Eq8rutPjoj27JFA0K\nfu9nvW5Rtu7nrONdwoOOpkV5gE//JCwtUGdQgkG1/gpNt6YvZ+gl+dk8uGFgF6Hc\nOI6yviZmlofd/95hATqB81w/b9r3nxNROw9WRpmDWZslHZvEfumyGMsB5qq2ig8N\npGgNkGRE2EIepv/m0rudorZMGrvUt3RT2CBqGc5lmPQoYXKlvHjo4/vx/tdQq6ev\n2orEjhyibWRNwulGbBdCLeqdOjYTBEjQ4dSCdanXUd6bY0JXojc2EufUOI80mFne\nIab5ZeyYbaznvmCl4j1OPl78H4G19Cee/r3EUxHuWZb+Re3xOSy5ldH9OWCTCJM=\n=LJqa\n-----END PGP SIGNATURE-----\n", + "payload": "tree 7e4b67f31859a5c6348d83419539ba9fa8864ed0\nauthor Liam Newman 1587663720 -0700\ncommitter GitHub 1587663720 -0700\n\nInitial commit" } }, - "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/fe352bd9e8dd386691a68be4dd59c9fd24da63d7", - "html_url": "https://github.com/github-api-test-org/temp-testGetProtection/commit/fe352bd9e8dd386691a68be4dd59c9fd24da63d7", - "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/fe352bd9e8dd386691a68be4dd59c9fd24da63d7/comments", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/24fbd7cfa8192262e63efd9e64c4005e64429508", + "html_url": "https://github.com/github-api-test-org/temp-testGetProtection/commit/24fbd7cfa8192262e63efd9e64c4005e64429508", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/24fbd7cfa8192262e63efd9e64c4005e64429508/comments", "author": { - "login": "sladyn98", - "id": 28837406, - "node_id": "MDQ6VXNlcjI4ODM3NDA2", - "avatar_url": "https://avatars1.githubusercontent.com/u/28837406?v=4", + "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/sladyn98", - "html_url": "https://github.com/sladyn98", - "followers_url": "https://api.github.com/users/sladyn98/followers", - "following_url": "https://api.github.com/users/sladyn98/following{/other_user}", - "gists_url": "https://api.github.com/users/sladyn98/gists{/gist_id}", - "starred_url": "https://api.github.com/users/sladyn98/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/sladyn98/subscriptions", - "organizations_url": "https://api.github.com/users/sladyn98/orgs", - "repos_url": "https://api.github.com/users/sladyn98/repos", - "events_url": "https://api.github.com/users/sladyn98/events{/privacy}", - "received_events_url": "https://api.github.com/users/sladyn98/received_events", + "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 }, diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json new file mode 100644 index 0000000000..512e04d989 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "24fbd7cfa8192262e63efd9e64c4005e64429508", + "node_id": "MDY6Q29tbWl0MjU4MjgzOTM1OjI0ZmJkN2NmYTgxOTIyNjJlNjNlZmQ5ZTY0YzQwMDVlNjQ0Mjk1MDg=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2020-04-23T17:42:00Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2020-04-23T17:42:00Z" + }, + "message": "Initial commit", + "tree": { + "sha": "7e4b67f31859a5c6348d83419539ba9fa8864ed0", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/trees/7e4b67f31859a5c6348d83419539ba9fa8864ed0" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/commits/24fbd7cfa8192262e63efd9e64c4005e64429508", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeodNoCRBK7hj4Ov3rIwAAdHIIABVjG29Eq8rutPjoj27JFA0K\nfu9nvW5Rtu7nrONdwoOOpkV5gE//JCwtUGdQgkG1/gpNt6YvZ+gl+dk8uGFgF6Hc\nOI6yviZmlofd/95hATqB81w/b9r3nxNROw9WRpmDWZslHZvEfumyGMsB5qq2ig8N\npGgNkGRE2EIepv/m0rudorZMGrvUt3RT2CBqGc5lmPQoYXKlvHjo4/vx/tdQq6ev\n2orEjhyibWRNwulGbBdCLeqdOjYTBEjQ4dSCdanXUd6bY0JXojc2EufUOI80mFne\nIab5ZeyYbaznvmCl4j1OPl78H4G19Cee/r3EUxHuWZb+Re3xOSy5ldH9OWCTCJM=\n=LJqa\n-----END PGP SIGNATURE-----\n", + "payload": "tree 7e4b67f31859a5c6348d83419539ba9fa8864ed0\nauthor Liam Newman 1587663720 -0700\ncommitter GitHub 1587663720 -0700\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/24fbd7cfa8192262e63efd9e64c4005e64429508", + "html_url": "https://github.com/github-api-test-org/temp-testGetProtection/commit/24fbd7cfa8192262e63efd9e64c4005e64429508", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/24fbd7cfa8192262e63efd9e64c4005e64429508/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master", + "html": "https://github.com/github-api-test-org/temp-testGetProtection/tree/master" + }, + "protected": true, + "protection": { + "enabled": true, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json new file mode 100644 index 0000000000..512e04d989 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "24fbd7cfa8192262e63efd9e64c4005e64429508", + "node_id": "MDY6Q29tbWl0MjU4MjgzOTM1OjI0ZmJkN2NmYTgxOTIyNjJlNjNlZmQ5ZTY0YzQwMDVlNjQ0Mjk1MDg=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2020-04-23T17:42:00Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2020-04-23T17:42:00Z" + }, + "message": "Initial commit", + "tree": { + "sha": "7e4b67f31859a5c6348d83419539ba9fa8864ed0", + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/trees/7e4b67f31859a5c6348d83419539ba9fa8864ed0" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/git/commits/24fbd7cfa8192262e63efd9e64c4005e64429508", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeodNoCRBK7hj4Ov3rIwAAdHIIABVjG29Eq8rutPjoj27JFA0K\nfu9nvW5Rtu7nrONdwoOOpkV5gE//JCwtUGdQgkG1/gpNt6YvZ+gl+dk8uGFgF6Hc\nOI6yviZmlofd/95hATqB81w/b9r3nxNROw9WRpmDWZslHZvEfumyGMsB5qq2ig8N\npGgNkGRE2EIepv/m0rudorZMGrvUt3RT2CBqGc5lmPQoYXKlvHjo4/vx/tdQq6ev\n2orEjhyibWRNwulGbBdCLeqdOjYTBEjQ4dSCdanXUd6bY0JXojc2EufUOI80mFne\nIab5ZeyYbaznvmCl4j1OPl78H4G19Cee/r3EUxHuWZb+Re3xOSy5ldH9OWCTCJM=\n=LJqa\n-----END PGP SIGNATURE-----\n", + "payload": "tree 7e4b67f31859a5c6348d83419539ba9fa8864ed0\nauthor Liam Newman 1587663720 -0700\ncommitter GitHub 1587663720 -0700\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/24fbd7cfa8192262e63efd9e64c4005e64429508", + "html_url": "https://github.com/github-api-test-org/temp-testGetProtection/commit/24fbd7cfa8192262e63efd9e64c4005e64429508", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/commits/24fbd7cfa8192262e63efd9e64c4005e64429508/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master", + "html": "https://github.com/github-api-test-org/temp-testGetProtection/tree/master" + }, + "protected": true, + "protection": { + "enabled": true, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json new file mode 100644 index 0000000000..a3b6658e5e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json @@ -0,0 +1,16 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testGetProtection/branches/master/protection/enforce_admins", + "enabled": false + }, + "required_linear_history": { + "enabled": false + }, + "allow_force_pushes": { + "enabled": false + }, + "allow_deletions": { + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/user-1.json index c6eaa5b837..c16e56c77f 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/__files/user-1.json @@ -1,45 +1,45 @@ { - "login": "sladyn98", - "id": 28837406, - "node_id": "MDQ6VXNlcjI4ODM3NDA2", - "avatar_url": "https://avatars1.githubusercontent.com/u/28837406?v=4", + "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/sladyn98", - "html_url": "https://github.com/sladyn98", - "followers_url": "https://api.github.com/users/sladyn98/followers", - "following_url": "https://api.github.com/users/sladyn98/following{/other_user}", - "gists_url": "https://api.github.com/users/sladyn98/gists{/gist_id}", - "starred_url": "https://api.github.com/users/sladyn98/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/sladyn98/subscriptions", - "organizations_url": "https://api.github.com/users/sladyn98/orgs", - "repos_url": "https://api.github.com/users/sladyn98/repos", - "events_url": "https://api.github.com/users/sladyn98/events{/privacy}", - "received_events_url": "https://api.github.com/users/sladyn98/received_events", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", "type": "User", "site_admin": false, - "name": "Sladyn", - "company": "VESIT", - "blog": "https://sladyn98.netlify.com", - "location": "Mumbai", - "email": "sladynnunes98@gmail.com", + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", "hireable": null, - "bio": "Open-Source Enthusiast\r\nPrev: Intern @Jenkins 2019 \r\n @openmainframeproject 2019 \r\n@cloudyBoss | \r\n@coala Developer\r\nInterests: Distributed Systems | Dev-Ops", - "public_repos": 103, - "public_gists": 3, - "followers": 53, - "following": 39, - "created_at": "2017-05-21T08:36:24Z", - "updated_at": "2020-04-20T07:32:04Z", - "private_gists": 2, - "total_private_repos": 9, - "owned_private_repos": 7, - "disk_usage": 58635, - "collaborators": 8, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 182, + "public_gists": 7, + "followers": 158, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-04-19T04:18:55Z", + "private_gists": 11, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, "two_factor_authentication": true, "plan": { - "name": "pro", + "name": "free", "space": 976562499, "collaborators": 0, - "private_repos": 9999 + "private_repos": 10000 } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json index d9b6b4986f..4674428187 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection-2.json @@ -1,5 +1,5 @@ { - "id": "895df30d-257a-4635-9826-1613885e710e", + "id": "2337b0a7-eeca-48be-a266-0a068a79e12e", "name": "repos_github-api-test-org_temp-testgetprotection", "request": { "url": "/repos/github-api-test-org/temp-testGetProtection", @@ -14,21 +14,21 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_temp-testgetprotection-2.json", "headers": { - "Date": "Mon, 20 Apr 2020 08:15:16 GMT", + "Date": "Thu, 23 Apr 2020 17:42:04 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4913", - "X-RateLimit-Reset": "1587370940", + "X-RateLimit-Remaining": "4933", + "X-RateLimit-Reset": "1587666973", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"17566056d13738600df96fee745ecacf\"", - "Last-Modified": "Mon, 20 Apr 2020 08:15:15 GMT", - "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "ETag": "W/\"d13b13503d75ee6f873b07336e3980d6\"", + "Last-Modified": "Thu, 23 Apr 2020 17:42:03 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", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", @@ -37,10 +37,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": "D5CC:4297:AB954:E2B06:5E9D5A0C" + "X-GitHub-Request-Id": "F2F9:7AE6:6C1B6:848F3:5EA1D366" } }, - "uuid": "895df30d-257a-4635-9826-1613885e710e", + "uuid": "2337b0a7-eeca-48be-a266-0a068a79e12e", "persistent": true, "insertionIndex": 2 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json index 46ba9ae048..89eec01144 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-3.json @@ -1,5 +1,5 @@ { - "id": "6af0c781-30dd-4c9a-bb73-6efa52595ffc", + "id": "1b37059d-fd2e-4bf9-91aa-320203aad872", "name": "repos_github-api-test-org_temp-testgetprotection_branches_master", "request": { "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master", @@ -14,20 +14,20 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master-3.json", "headers": { - "Date": "Mon, 20 Apr 2020 08:15:16 GMT", + "Date": "Thu, 23 Apr 2020 17:42:05 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4912", - "X-RateLimit-Reset": "1587370940", + "X-RateLimit-Remaining": "4932", + "X-RateLimit-Reset": "1587666972", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"e854e72f207b42cc1b5edbaa30f35024\"", - "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "ETag": "W/\"7fdb679ba6b890c4bb0b4d403e27fbef\"", + "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", @@ -36,10 +36,13 @@ "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": "D5CC:4297:AB95D:E2BAA:5E9D5A14" + "X-GitHub-Request-Id": "F2F9:7AE6:6C1BD:84A13:5EA1D36C" } }, - "uuid": "6af0c781-30dd-4c9a-bb73-6efa52595ffc", + "uuid": "1b37059d-fd2e-4bf9-91aa-320203aad872", "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testGetProtection-branches-master", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testGetProtection-branches-master-2", "insertionIndex": 3 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json new file mode 100644 index 0000000000..b1c2886381 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-5.json @@ -0,0 +1,48 @@ +{ + "id": "a5a370a5-6d8e-4e98-bdd9-324083d7b521", + "name": "repos_github-api-test-org_temp-testgetprotection_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master-5.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:42:05 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4930", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"dc3ff5ae90ceaed2515f7c337b51a17e\"", + "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": "F2F9:7AE6:6C1D9:84A33:5EA1D36D" + } + }, + "uuid": "a5a370a5-6d8e-4e98-bdd9-324083d7b521", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testGetProtection-branches-master", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testGetProtection-branches-master-2", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testGetProtection-branches-master-3", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json new file mode 100644 index 0000000000..4d4e3f1e1b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master-7.json @@ -0,0 +1,47 @@ +{ + "id": "12d8726c-e383-45d3-8da7-cfec0d043b64", + "name": "repos_github-api-test-org_temp-testgetprotection_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master-7.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:42:06 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4928", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"dc3ff5ae90ceaed2515f7c337b51a17e\"", + "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": "F2F9:7AE6:6C1F9:84A53:5EA1D36D" + } + }, + "uuid": "12d8726c-e383-45d3-8da7-cfec0d043b64", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testGetProtection-branches-master", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testGetProtection-branches-master-3", + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json index 05af0a85ef..d450fbb39b 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json @@ -1,40 +1,52 @@ { - "id": "1d395564-9154-440b-ade4-b18cb8b970cc", + "id": "d52c7355-8eac-4c62-b83d-54ebacfc0c70", "name": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection", "request": { "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", - "method": "GET", + "method": "PUT", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.luke-cage-preview+json" } - } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] }, "response": { - "status": 404, - "body": "{\"message\":\"Branch not protected\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#get-branch-protection\"}", + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection-4.json", "headers": { - "Date": "Mon, 20 Apr 2020 08:15:17 GMT", + "Date": "Thu, 23 Apr 2020 17:42:05 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", - "Status": "404 Not Found", + "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4911", - "X-RateLimit-Reset": "1587370940", - "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-RateLimit-Remaining": "4931", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"028cd5293b7178833f675036daf5ecf7\"", + "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", + "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", "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": "D5CC:4297:AB966:E2BB8:5E9D5A14" + "X-GitHub-Request-Id": "F2F9:7AE6:6C1C8:84A1F:5EA1D36D" } }, - "uuid": "1d395564-9154-440b-ade4-b18cb8b970cc", + "uuid": "d52c7355-8eac-4c62-b83d-54ebacfc0c70", "persistent": true, "insertionIndex": 4 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json deleted file mode 100644 index 3d7d7e47d8..0000000000 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "id": "fc1a35dc-4e0b-42f3-8209-cdcb10c22061", - "name": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection", - "request": { - "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", - "method": "PUT", - "headers": { - "Accept": { - "equalTo": "application/vnd.github.luke-cage-preview+json" - } - }, - "bodyPatterns": [ - { - "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ] - }, - "response": { - "status": 200, - "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection-5.json", - "headers": { - "Date": "Mon, 20 Apr 2020 08:18:47 GMT", - "Content-Type": "application/json; charset=utf-8", - "Server": "GitHub.com", - "Status": "200 OK", - "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4880", - "X-RateLimit-Reset": "1587370940", - "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": [ - "Accept, Authorization, Cookie, X-GitHub-OTP", - "Accept-Encoding, Accept, X-Requested-With" - ], - "ETag": "W/\"85947a574037691379fb4fb191aa311e\"", - "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", - "X-Accepted-OAuth-Scopes": "", - "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", - "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": "D61E:711F:2B87AA:384FE6:5E9D5AE6" - } - }, - "uuid": "fc1a35dc-4e0b-42f3-8209-cdcb10c22061", - "persistent": true, - "insertionIndex": 5 -} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json index 844bd0d55d..4c9265464e 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json @@ -1,9 +1,9 @@ { - "id": "60b50898-f2af-4e49-882e-facd861bd374", + "id": "d15b0d15-1264-481d-9ec5-0e156de6f80a", "name": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection", "request": { "url": "/repos/github-api-test-org/temp-testGetProtection/branches/master/protection", - "method": "DELETE", + "method": "GET", "headers": { "Accept": { "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" @@ -11,17 +11,23 @@ } }, "response": { - "status": 404, - "body": "{\"message\":\"Branch not protected\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#remove-branch-protection\"}", + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testgetprotection_branches_master_protection-6.json", "headers": { - "Date": "Mon, 20 Apr 2020 11:43:08 GMT", + "Date": "Thu, 23 Apr 2020 17:42:05 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", - "Status": "404 Not Found", + "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4845", - "X-RateLimit-Reset": "1587385073", - "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-RateLimit-Remaining": "4929", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"4ae26e8f99ae0fd6e393517e28500f84\"", + "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", @@ -30,11 +36,10 @@ "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": "BB96:659F:3A6383:49C440:5E9D8ACC" + "X-GitHub-Request-Id": "F2F9:7AE6:6C1E5:84A41:5EA1D36D" } }, - "uuid": "60b50898-f2af-4e49-882e-facd861bd374", + "uuid": "d15b0d15-1264-481d-9ec5-0e156de6f80a", "persistent": true, "insertionIndex": 6 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/user-1.json index a3da8d980a..c234d2ead8 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testGetProtection/mappings/user-1.json @@ -1,5 +1,5 @@ { - "id": "63501c5d-4dae-4bdf-8d4f-98d4a2c908ed", + "id": "346a521f-fc2e-488b-bcd0-a2612c647c91", "name": "user", "request": { "url": "/user", @@ -14,21 +14,21 @@ "status": 200, "bodyFileName": "user-1.json", "headers": { - "Date": "Mon, 20 Apr 2020 08:15:08 GMT", + "Date": "Thu, 23 Apr 2020 17:41:58 GMT", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4918", - "X-RateLimit-Reset": "1587370940", + "X-RateLimit-Remaining": "4938", + "X-RateLimit-Reset": "1587666973", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding, Accept, X-Requested-With" ], - "ETag": "W/\"c64535ca0763246449d97ae6f960052c\"", - "Last-Modified": "Mon, 20 Apr 2020 07:32:04 GMT", - "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "ETag": "W/\"ab45a166d7cdaf4738db7876a0b1d296\"", + "Last-Modified": "Sun, 19 Apr 2020 04:18:55 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", @@ -37,10 +37,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": "D5CC:4297:AB8D2:E2B02:5E9D5A0C" + "X-GitHub-Request-Id": "F2F9:7AE6:6C0D2:848EA:5EA1D366" } }, - "uuid": "63501c5d-4dae-4bdf-8d4f-98d4a2c908ed", + "uuid": "346a521f-fc2e-488b-bcd0-a2612c647c91", "persistent": true, "insertionIndex": 1 } \ No newline at end of file From ca76975461e6bc498551f08b0def85a11515603d Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Thu, 23 Apr 2020 10:59:35 -0700 Subject: [PATCH 7/8] Record Disable test --- .../github/GHBranchProtectionTest.java | 1 + ...-org_temp-testdisableprotectiononly-2.json | 126 ++++++++++++++++++ ...sableprotectiononly_branches_master-3.json | 89 +++++++++++++ ...sableprotectiononly_branches_master-5.json | 89 +++++++++++++ ...sableprotectiononly_branches_master-7.json | 89 +++++++++++++ ...tiononly_branches_master_protection-4.json | 16 +++ .../__files/user-1.json | 45 +++++++ ...-org_temp-testdisableprotectiononly-2.json | 46 +++++++ ...sableprotectiononly_branches_master-3.json | 48 +++++++ ...sableprotectiononly_branches_master-5.json | 48 +++++++ ...sableprotectiononly_branches_master-7.json | 47 +++++++ ...tiononly_branches_master_protection-4.json | 52 ++++++++ ...tiononly_branches_master_protection-6.json | 38 ++++++ .../mappings/user-1.json | 46 +++++++ 14 files changed, 780 insertions(+) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-6.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1.json diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 73e117bfe1..142d27492d 100755 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -57,6 +57,7 @@ public void testEnableProtectionOnly() throws Exception { @Test public void testDisableProtectionOnly() throws Exception { GHBranchProtection protection = branch.enableProtection().enable(); + assertTrue(repo.getBranch(BRANCH).isProtected()); branch.disableProtection(); assertFalse(repo.getBranch(BRANCH).isProtected()); } diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-2.json new file mode 100644 index 0000000000..f1b57e821d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly-2.json @@ -0,0 +1,126 @@ +{ + "id": 258288342, + "node_id": "MDEwOlJlcG9zaXRvcnkyNTgyODgzNDI=", + "name": "temp-testDisableProtectionOnly", + "full_name": "github-api-test-org/temp-testDisableProtectionOnly", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly", + "description": "A test repository for testing the github-api project: temp-testDisableProtectionOnly", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/deployments", + "created_at": "2020-04-23T17:59:02Z", + "updated_at": "2020-04-23T17:59:06Z", + "pushed_at": "2020-04-23T17:59:04Z", + "git_url": "git://github.com/github-api-test-org/temp-testDisableProtectionOnly.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testDisableProtectionOnly.git", + "clone_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly.git", + "svn_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "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": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json new file mode 100644 index 0000000000..0bd8857239 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "node_id": "MDY6Q29tbWl0MjU4Mjg4MzQyOmRkOGNlMjUwMzRlODU5NzNhOGNmYWNiMWIzNzk1NzFlYTNiNGE4YTY=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2020-04-23T17:59:03Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2020-04-23T17:59:03Z" + }, + "message": "Initial commit", + "tree": { + "sha": "e0f408fb90498b93fb29f15f65a716d635b935aa", + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees/e0f408fb90498b93fb29f15f65a716d635b935aa" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeoddnCRBK7hj4Ov3rIwAAdHIIAIv1r34nroEHWPNwCvI3P/A7\ng3nDhupwv9OerOc+bvMeovLfsKIkpiHmz3qESI2ei5XL6ZNPffbhe1w7GG8ISF5g\ncJLQ84D+qk/rcOni3PJZj2n/3ChB+//lid6Op2O6TUuZ1omoxIeNzurIUJ7H0gux\nUB0siDrXMc5XXZw5kGQBWwVbc0HVB6lyxQ6s1Ct8w3KgcEGkxv97QsAVR7SvKir2\naI/uu0TB61KnsKh5igvGyT5i+a+fgMXsyV9i/qGSCvoueehSRa5XUHWD8hyDJOBG\nXwOzn696UNyl+0xZo/zHq2fyTeJY8siEyASpAh4KQkGbSHYNakLu+vxzwBB9U28=\n=3X5V\n-----END PGP SIGNATURE-----\n", + "payload": "tree e0f408fb90498b93fb29f15f65a716d635b935aa\nauthor Liam Newman 1587664743 -0700\ncommitter GitHub 1587664743 -0700\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/commit/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json new file mode 100644 index 0000000000..880cd173ea --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "node_id": "MDY6Q29tbWl0MjU4Mjg4MzQyOmRkOGNlMjUwMzRlODU5NzNhOGNmYWNiMWIzNzk1NzFlYTNiNGE4YTY=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2020-04-23T17:59:03Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2020-04-23T17:59:03Z" + }, + "message": "Initial commit", + "tree": { + "sha": "e0f408fb90498b93fb29f15f65a716d635b935aa", + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees/e0f408fb90498b93fb29f15f65a716d635b935aa" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeoddnCRBK7hj4Ov3rIwAAdHIIAIv1r34nroEHWPNwCvI3P/A7\ng3nDhupwv9OerOc+bvMeovLfsKIkpiHmz3qESI2ei5XL6ZNPffbhe1w7GG8ISF5g\ncJLQ84D+qk/rcOni3PJZj2n/3ChB+//lid6Op2O6TUuZ1omoxIeNzurIUJ7H0gux\nUB0siDrXMc5XXZw5kGQBWwVbc0HVB6lyxQ6s1Ct8w3KgcEGkxv97QsAVR7SvKir2\naI/uu0TB61KnsKh5igvGyT5i+a+fgMXsyV9i/qGSCvoueehSRa5XUHWD8hyDJOBG\nXwOzn696UNyl+0xZo/zHq2fyTeJY8siEyASpAh4KQkGbSHYNakLu+vxzwBB9U28=\n=3X5V\n-----END PGP SIGNATURE-----\n", + "payload": "tree e0f408fb90498b93fb29f15f65a716d635b935aa\nauthor Liam Newman 1587664743 -0700\ncommitter GitHub 1587664743 -0700\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/commit/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/tree/master" + }, + "protected": true, + "protection": { + "enabled": true, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json new file mode 100644 index 0000000000..0bd8857239 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "node_id": "MDY6Q29tbWl0MjU4Mjg4MzQyOmRkOGNlMjUwMzRlODU5NzNhOGNmYWNiMWIzNzk1NzFlYTNiNGE4YTY=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2020-04-23T17:59:03Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2020-04-23T17:59:03Z" + }, + "message": "Initial commit", + "tree": { + "sha": "e0f408fb90498b93fb29f15f65a716d635b935aa", + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/trees/e0f408fb90498b93fb29f15f65a716d635b935aa" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/git/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJeoddnCRBK7hj4Ov3rIwAAdHIIAIv1r34nroEHWPNwCvI3P/A7\ng3nDhupwv9OerOc+bvMeovLfsKIkpiHmz3qESI2ei5XL6ZNPffbhe1w7GG8ISF5g\ncJLQ84D+qk/rcOni3PJZj2n/3ChB+//lid6Op2O6TUuZ1omoxIeNzurIUJ7H0gux\nUB0siDrXMc5XXZw5kGQBWwVbc0HVB6lyxQ6s1Ct8w3KgcEGkxv97QsAVR7SvKir2\naI/uu0TB61KnsKh5igvGyT5i+a+fgMXsyV9i/qGSCvoueehSRa5XUHWD8hyDJOBG\nXwOzn696UNyl+0xZo/zHq2fyTeJY8siEyASpAh4KQkGbSHYNakLu+vxzwBB9U28=\n=3X5V\n-----END PGP SIGNATURE-----\n", + "payload": "tree e0f408fb90498b93fb29f15f65a716d635b935aa\nauthor Liam Newman 1587664743 -0700\ncommitter GitHub 1587664743 -0700\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "html_url": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/commit/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/commits/dd8ce25034e85973a8cfacb1b379571ea3b4a8a6/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testDisableProtectionOnly/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json new file mode 100644 index 0000000000..910977f94d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json @@ -0,0 +1,16 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection/enforce_admins", + "enabled": false + }, + "required_linear_history": { + "enabled": false + }, + "allow_force_pushes": { + "enabled": false + }, + "allow_deletions": { + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-1.json new file mode 100644 index 0000000000..c16e56c77f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/__files/user-1.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 182, + "public_gists": 7, + "followers": 158, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2020-04-19T04:18:55Z", + "private_gists": 11, + "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/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2.json new file mode 100644 index 0000000000..9abdf9bceb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly-2.json @@ -0,0 +1,46 @@ +{ + "id": "7fa3e8d5-63ba-4f76-8548-13e9f41f86cf", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly-2.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:59:07 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4908", + "X-RateLimit-Reset": "1587666972", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"8e553a2c680e2cfce12ca4605a3832a9\"", + "Last-Modified": "Thu, 23 Apr 2020 17:59: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": "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'", + "X-GitHub-Request-Id": "F68E:7228:10E85B:149297:5EA1D765" + } + }, + "uuid": "7fa3e8d5-63ba-4f76-8548-13e9f41f86cf", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json new file mode 100644 index 0000000000..f316409f8f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json @@ -0,0 +1,48 @@ +{ + "id": "1b81c7e8-f51d-42f3-bcfe-e0893ea2b29d", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-3.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:59:08 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4907", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"7c45580fa5c0f80cd87da42c36815e58\"", + "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": "F68E:7228:10E86E:1495EB:5EA1D76B" + } + }, + "uuid": "1b81c7e8-f51d-42f3-bcfe-e0893ea2b29d", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testDisableProtectionOnly-branches-master", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testDisableProtectionOnly-branches-master-2", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json new file mode 100644 index 0000000000..21a7a2f4c5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json @@ -0,0 +1,48 @@ +{ + "id": "e5ca49c0-ac4e-4372-a3b7-128ed8ebff41", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-5.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:59:08 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4905", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"e8757475d9b3e089a5a3cd83499a2ceb\"", + "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": "F68E:7228:10E8B0:14962A:5EA1D76C" + } + }, + "uuid": "e5ca49c0-ac4e-4372-a3b7-128ed8ebff41", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testDisableProtectionOnly-branches-master", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testDisableProtectionOnly-branches-master-2", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testDisableProtectionOnly-branches-master-3", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json new file mode 100644 index 0000000000..774e972ee2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json @@ -0,0 +1,47 @@ +{ + "id": "e224c5e4-46a7-4ada-970d-946f4c31c8b4", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master-7.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:59:09 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4903", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"7c45580fa5c0f80cd87da42c36815e58\"", + "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": "F68E:7228:10E8F2:149684:5EA1D76D" + } + }, + "uuid": "e224c5e4-46a7-4ada-970d-946f4c31c8b4", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testDisableProtectionOnly-branches-master", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testDisableProtectionOnly-branches-master-3", + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json new file mode 100644 index 0000000000..c42d9473e2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json @@ -0,0 +1,52 @@ +{ + "id": "9b035670-667b-480f-9a95-29acd553979f", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "method": "PUT", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.luke-cage-preview+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-4.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:59:08 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4906", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"f36d8723d6bf669eda1f3f436c55694e\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", + "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": "F68E:7228:10E886:14960A:5EA1D76C" + } + }, + "uuid": "9b035670-667b-480f-9a95-29acd553979f", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-6.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-6.json new file mode 100644 index 0000000000..1515002c9c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection-6.json @@ -0,0 +1,38 @@ +{ + "id": "8ba747c1-29f2-4096-ad2e-5a148448adc2", + "name": "repos_github-api-test-org_temp-testdisableprotectiononly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testDisableProtectionOnly/branches/master/protection", + "method": "DELETE", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 204, + "headers": { + "Date": "Thu, 23 Apr 2020 17:59:09 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4904", + "X-RateLimit-Reset": "1587666973", + "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": "F68E:7228:10E8C7:14965A:5EA1D76C" + } + }, + "uuid": "8ba747c1-29f2-4096-ad2e-5a148448adc2", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1.json new file mode 100644 index 0000000000..3cae29ce3b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testDisableProtectionOnly/mappings/user-1.json @@ -0,0 +1,46 @@ +{ + "id": "4d428d73-9af7-49af-aadd-cefd9eeefeff", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Date": "Thu, 23 Apr 2020 17:59:01 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4913", + "X-RateLimit-Reset": "1587666973", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"ab45a166d7cdaf4738db7876a0b1d296\"", + "Last-Modified": "Sun, 19 Apr 2020 04:18:55 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": "F68E:7228:10E570:149284:5EA1D765" + } + }, + "uuid": "4d428d73-9af7-49af-aadd-cefd9eeefeff", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From 7069176cf698deb84bf2d55d0bc0539580114325 Mon Sep 17 00:00:00 2001 From: Sladyn Date: Mon, 27 Apr 2020 10:49:57 +0530 Subject: [PATCH 8/8] Apply suggestions from code review Co-Authored-By: Liam Newman --- src/main/java/org/kohsuke/github/GHGist.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHGist.java b/src/main/java/org/kohsuke/github/GHGist.java index 41ec5c66c8..2dfae110ed 100644 --- a/src/main/java/org/kohsuke/github/GHGist.java +++ b/src/main/java/org/kohsuke/github/GHGist.java @@ -172,7 +172,7 @@ String getApiTailUrl(String tail) { * the io exception */ public void star() throws IOException { - root.createRequest().method("PUT").setRawUrlPath(getApiTailUrl("star")).send(); + root.createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send(); } /** @@ -182,7 +182,7 @@ public void star() throws IOException { * the io exception */ public void unstar() throws IOException { - root.createRequest().method("DELETE").setRawUrlPath(getApiTailUrl("star")).send(); + root.createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send(); } /**