From 58c59764882408d8222f58e0d2a087f9e2a76d27 Mon Sep 17 00:00:00 2001 From: Tadas Giniotis <61763026+tginiotis-at-work@users.noreply.github.com> Date: Sun, 16 Jun 2024 01:50:05 +0300 Subject: [PATCH] feat: add ability to add checks with app ids (#1844) * feat: add ability to add checks with app ids as per https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2022-11-28#update-status-check-protection * test: add test to verify new checks are being populated * fix: some post-review changes and test additions * fix: allow null app ids to provide the same behaviour as the deprecated endpoint & post-review changes * test: regenerate some mocks --------- Co-authored-by: Liam Newman --- .../kohsuke/github/GHBranchProtection.java | 62 +++++++ .../github/GHBranchProtectionBuilder.java | 33 +++- .../github/GHBranchProtectionTest.java | 27 +++ .../testChecksWithAppIds/__files/1-user.json | 34 ++++ .../2-r_h_temp-testcheckswithappids.json | 156 ++++++++++++++++++ .../__files/3-r_h_t_branches_main.json | 90 ++++++++++ .../4-r_h_t_branches_main_protection.json | 46 ++++++ .../5-r_h_t_branches_main_protection.json | 51 ++++++ .../6-r_h_t_branches_main_protection.json | 56 +++++++ .../testChecksWithAppIds/mappings/1-user.json | 51 ++++++ .../2-r_h_temp-testcheckswithappids.json | 51 ++++++ .../mappings/3-r_h_t_branches_main.json | 50 ++++++ .../4-r_h_t_branches_main_protection.json | 57 +++++++ .../5-r_h_t_branches_main_protection.json | 57 +++++++ .../6-r_h_t_branches_main_protection.json | 57 +++++++ ...chprotections.json => 2-r_h_temp-tes.json} | 0 .../4-r_h_t_branches_main_protection.json | 2 +- .../5-r_h_t_branches_main_protection.json | 2 +- .../6-r_h_t_branches_main_protection.json | 53 ++++++ ...chprotections.json => 2-r_h_temp-tes.json} | 2 +- .../4-r_h_t_branches_main_protection.json | 2 +- .../6-r_h_t_branches_main_protection.json | 57 +++++++ 22 files changed, 990 insertions(+), 6 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/2-r_h_temp-testcheckswithappids.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/3-r_h_t_branches_main.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/4-r_h_t_branches_main_protection.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/5-r_h_t_branches_main_protection.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/6-r_h_t_branches_main_protection.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/1-user.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/2-r_h_temp-testcheckswithappids.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/3-r_h_t_branches_main.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/4-r_h_t_branches_main_protection.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/5-r_h_t_branches_main_protection.json create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/6-r_h_t_branches_main_protection.json rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/{2-r_h_temp-testenablebranchprotections.json => 2-r_h_temp-tes.json} (100%) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/6-r_h_t_branches_main_protection.json rename src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/{2-r_h_temp-testenablebranchprotections.json => 2-r_h_temp-tes.json} (96%) create mode 100644 src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/6-r_h_t_branches_main_protection.json diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java index 834544944f..bdffc62f5b 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtection.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -221,6 +222,55 @@ public boolean isEnabled() { } } + /** + * The type Check. + */ + public static class Check { + private String context; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer appId; + + /** + * no-arg constructor for the serializer + */ + public Check() { + } + + /** + * Regular constructor for use in user business logic + * + * @param context + * the context string of the check + * @param appId + * the application ID the check is supposed to come from. Pass "-1" to explicitly allow any app to + * set the status. Pass "null" to automatically select the GitHub App that has recently provided this + * check. + */ + public Check(String context, Integer appId) { + this.context = context; + this.appId = appId; + } + + /** + * The context string of the check + * + * @return the string + */ + public String getContext() { + return context; + } + + /** + * The application ID the check is supposed to come from. The value "-1" indicates "any source". + * + * @return the integer + */ + public Integer getAppId() { + return appId; + } + } + /** * The type AllowForcePushes. */ @@ -462,6 +512,9 @@ public static class RequiredStatusChecks { @JsonProperty private Collection contexts; + @JsonProperty + private Collection checks; + @JsonProperty private boolean strict; @@ -477,6 +530,15 @@ public Collection getContexts() { return Collections.unmodifiableCollection(contexts); } + /** + * Gets checks. + * + * @return the checks + */ + public Collection getChecks() { + return Collections.unmodifiableCollection(checks); + } + /** * Gets url. * diff --git a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java index ec21b3168c..a496cbb0c3 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import static org.kohsuke.github.internal.Previews.LUKE_CAGE; @@ -50,8 +51,23 @@ public class GHBranchProtectionBuilder { * the checks * @return the gh branch protection builder */ + public GHBranchProtectionBuilder addRequiredStatusChecks(Collection checks) { + getStatusChecks().checks.addAll(checks); + return this; + } + + /** + * Add required checks gh branch protection builder. + * + * @param checks + * the checks + * @return the gh branch protection builder + */ + @Deprecated public GHBranchProtectionBuilder addRequiredChecks(Collection checks) { - getStatusChecks().contexts.addAll(checks); + getStatusChecks().checks.addAll(checks.stream() + .map(context -> new GHBranchProtection.Check(context, null)) + .collect(Collectors.toList())); return this; } @@ -62,11 +78,24 @@ public GHBranchProtectionBuilder addRequiredChecks(Collection checks) { * the checks * @return the gh branch protection builder */ + @Deprecated public GHBranchProtectionBuilder addRequiredChecks(String... checks) { addRequiredChecks(Arrays.asList(checks)); return this; } + /** + * Add required checks gh branch protection builder. + * + * @param checks + * the checks + * @return the gh branch protection builder + */ + public GHBranchProtectionBuilder addRequiredChecks(GHBranchProtection.Check... checks) { + addRequiredStatusChecks(Arrays.asList(checks)); + return this; + } + /** * Allow deletion of the protected branch. * @@ -547,7 +576,7 @@ private static class Restrictions { } private static class StatusChecks { - final List contexts = new ArrayList(); + final List checks = new ArrayList<>(); boolean strict; } } diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 5254b3a707..bee19e8e0c 100755 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -13,6 +13,8 @@ import org.kohsuke.github.GHBranchProtection.RequiredReviews; import org.kohsuke.github.GHBranchProtection.RequiredStatusChecks; +import java.util.ArrayList; + import static org.hamcrest.Matchers.*; // TODO: Auto-generated Javadoc @@ -189,6 +191,31 @@ public void testSignedCommits() throws Exception { assertThat(protection.getRequiredSignatures(), is(false)); } + /** + * Checks with app ids are being populated + * + * @throws Exception + * the exception + */ + @Test + public void testChecksWithAppIds() throws Exception { + GHBranchProtection protection = branch.enableProtection() + .addRequiredChecks(new GHBranchProtection.Check("context", -1), + new GHBranchProtection.Check("context2", 123), + new GHBranchProtection.Check("context3", null)) + .enable(); + + ArrayList resultChecks = new ArrayList<>( + protection.getRequiredStatusChecks().getChecks()); + + assertThat(resultChecks.size(), is(3)); + assertThat(resultChecks.get(0).getContext(), is("context")); + assertThat(resultChecks.get(0).getAppId(), nullValue()); + assertThat(resultChecks.get(1).getContext(), is("context2")); + assertThat(resultChecks.get(1).getAppId(), is(123)); + assertThat(resultChecks.get(2).getContext(), is("context3")); + } + /** * Test get protection. * diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/1-user.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/1-user.json new file mode 100644 index 0000000000..fa8689bad8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/1-user.json @@ -0,0 +1,34 @@ +{ + "login": "tginiotis-at-work", + "id": 61763026, + "node_id": "MDQ6VXNlcjYxNzYzMDI2", + "avatar_url": "https://avatars.githubusercontent.com/u/61763026?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/tginiotis-at-work", + "html_url": "https://github.com/tginiotis-at-work", + "followers_url": "https://api.github.com/users/tginiotis-at-work/followers", + "following_url": "https://api.github.com/users/tginiotis-at-work/following{/other_user}", + "gists_url": "https://api.github.com/users/tginiotis-at-work/gists{/gist_id}", + "starred_url": "https://api.github.com/users/tginiotis-at-work/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/tginiotis-at-work/subscriptions", + "organizations_url": "https://api.github.com/users/tginiotis-at-work/orgs", + "repos_url": "https://api.github.com/users/tginiotis-at-work/repos", + "events_url": "https://api.github.com/users/tginiotis-at-work/events{/privacy}", + "received_events_url": "https://api.github.com/users/tginiotis-at-work/received_events", + "type": "User", + "site_admin": false, + "name": "Tadas Giniotis", + "company": "IBM Lietuva", + "blog": "", + "location": null, + "email": null, + "hireable": null, + "bio": null, + "twitter_username": null, + "public_repos": 12, + "public_gists": 0, + "followers": 0, + "following": 0, + "created_at": "2020-03-03T23:04:00Z", + "updated_at": "2024-05-15T15:03:51Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/2-r_h_temp-testcheckswithappids.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/2-r_h_temp-testcheckswithappids.json new file mode 100644 index 0000000000..4f8ad7ebdc --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/2-r_h_temp-testcheckswithappids.json @@ -0,0 +1,156 @@ +{ + "id": 802086844, + "node_id": "R_kgDOL87fvA", + "name": "temp-testChecksWithAppIds", + "full_name": "hub4j-test-org/temp-testChecksWithAppIds", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/temp-testChecksWithAppIds", + "description": "A test repository for testing the github-api project: temp-testChecksWithAppIds", + "fork": false, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds", + "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/deployments", + "created_at": "2024-05-17T13:51:56Z", + "updated_at": "2024-05-17T13:52:00Z", + "pushed_at": "2024-05-17T13:51:57Z", + "git_url": "git://github.com/hub4j-test-org/temp-testChecksWithAppIds.git", + "ssh_url": "git@github.com:hub4j-test-org/temp-testChecksWithAppIds.git", + "clone_url": "https://github.com/hub4j-test-org/temp-testChecksWithAppIds.git", + "svn_url": "https://github.com/hub4j-test-org/temp-testChecksWithAppIds", + "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, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "permissions": { + "admin": true, + "maintain": true, + "push": true, + "triage": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE", + "custom_properties": {}, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "security_and_analysis": { + "secret_scanning": { + "status": "disabled" + }, + "secret_scanning_push_protection": { + "status": "disabled" + }, + "dependabot_security_updates": { + "status": "disabled" + }, + "secret_scanning_validity_checks": { + "status": "disabled" + } + }, + "network_count": 0, + "subscribers_count": 22 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/3-r_h_t_branches_main.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/3-r_h_t_branches_main.json new file mode 100644 index 0000000000..b51cb35137 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/3-r_h_t_branches_main.json @@ -0,0 +1,90 @@ +{ + "name": "main", + "commit": { + "sha": "301c76278622d97be24c9e6bf37306eb91984505", + "node_id": "C_kwDOL87fvNoAKDMwMWM3NjI3ODYyMmQ5N2JlMjRjOWU2YmYzNzMwNmViOTE5ODQ1MDU", + "commit": { + "author": { + "name": "Tadas Giniotis", + "email": "61763026+tginiotis-at-work@users.noreply.github.com", + "date": "2024-05-17T13:51:57Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2024-05-17T13:51:57Z" + }, + "message": "Initial commit", + "tree": { + "sha": "c53290e965014088d71812a1a0ef5453d5671047", + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/git/trees/c53290e965014088d71812a1a0ef5453d5671047" + }, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/git/commits/301c76278622d97be24c9e6bf37306eb91984505", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJmR2D9CRC1aQ7uu5UhlAAAiboQADXa0dYfU4xR7N7c1cq5KsqP\nK8v1iaP1CxfbZSqZQSt3TNA+Jtc9TJ505M+6b8Ex3RpNBmQX4YG+kGvs0sa4vdMD\nHxbR8HOW6J+ht8BaV829iu4eVwI4N+hABhSTHJv6EhZg2wgPqX72zQV9k4QZw/uL\nSONyFJgFmX+kU/YVr+ax0yLnjQLfBIAR4Q4/f7afG1p5e3a8oOxucnptQBEW86wK\n0aNN1VWhP0IA8+D7ftgubClHu+/RFH3DRXdjPU5cvphLvNUM5Ime9Xktm5cFkv32\nOtjet8GUesT/cJiAkSEMU9C5nCIaJXgjchnp/yA2l6Z31tXaEik/UhqizE3EQMeP\nVPZMhCIeh69JGOerpflqP0/os3THF57x054RaFN6KxG7I158ClsfmyGp5WzkLFJ4\nkqiPrFltZm2k9MvUQ2r8Ewd3/OkDt/bAV8B34qAa/xhJUF4D5iq15gKsHNZsCBw5\nddz0dOO2YWmF0eMGv+iV25qu/xwdRrPbrPDb7NHcbZdAoBlNJm/07YAVkG3x3qBn\nPelfba5XjD6RPke5jRejhukV8PGFNfKQ3m7zYflqay2H6e2a0RCdtuSzLiIhkgP8\nvXxd4+xRvMC6aLDd1f0Z60G72ATCFsZ2H60yRcS6uMcufdbAt9h5B0UcKw6xT4Zi\nKILbAvfbDMtXdTVfeeWM\n=p3Ka\n-----END PGP SIGNATURE-----\n", + "payload": "tree c53290e965014088d71812a1a0ef5453d5671047\nauthor Tadas Giniotis <61763026+tginiotis-at-work@users.noreply.github.com> 1715953917 +0300\ncommitter GitHub 1715953917 +0300\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/commits/301c76278622d97be24c9e6bf37306eb91984505", + "html_url": "https://github.com/hub4j-test-org/temp-testChecksWithAppIds/commit/301c76278622d97be24c9e6bf37306eb91984505", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/commits/301c76278622d97be24c9e6bf37306eb91984505/comments", + "author": { + "login": "tginiotis-at-work", + "id": 61763026, + "node_id": "MDQ6VXNlcjYxNzYzMDI2", + "avatar_url": "https://avatars.githubusercontent.com/u/61763026?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/tginiotis-at-work", + "html_url": "https://github.com/tginiotis-at-work", + "followers_url": "https://api.github.com/users/tginiotis-at-work/followers", + "following_url": "https://api.github.com/users/tginiotis-at-work/following{/other_user}", + "gists_url": "https://api.github.com/users/tginiotis-at-work/gists{/gist_id}", + "starred_url": "https://api.github.com/users/tginiotis-at-work/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/tginiotis-at-work/subscriptions", + "organizations_url": "https://api.github.com/users/tginiotis-at-work/orgs", + "repos_url": "https://api.github.com/users/tginiotis-at-work/repos", + "events_url": "https://api.github.com/users/tginiotis-at-work/events{/privacy}", + "received_events_url": "https://api.github.com/users/tginiotis-at-work/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars.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/hub4j-test-org/temp-testChecksWithAppIds/branches/main", + "html": "https://github.com/hub4j-test-org/temp-testChecksWithAppIds/tree/main" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [], + "checks": [] + } + }, + "protection_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/4-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/4-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..ded18db0fd --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/4-r_h_t_branches_main_protection.json @@ -0,0 +1,46 @@ +{ + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection", + "required_status_checks": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_status_checks", + "strict": false, + "contexts": [ + "context" + ], + "contexts_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_status_checks/contexts", + "checks": [ + { + "context": "context", + "app_id": null + } + ] + }, + "required_signatures": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_signatures", + "enabled": false + }, + "enforce_admins": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/enforce_admins", + "enabled": false + }, + "required_linear_history": { + "enabled": false + }, + "allow_force_pushes": { + "enabled": false + }, + "allow_deletions": { + "enabled": false + }, + "block_creations": { + "enabled": false + }, + "required_conversation_resolution": { + "enabled": false + }, + "lock_branch": { + "enabled": false + }, + "allow_fork_syncing": { + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/5-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/5-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..47cafad876 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/5-r_h_t_branches_main_protection.json @@ -0,0 +1,51 @@ +{ + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection", + "required_status_checks": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_status_checks", + "strict": false, + "contexts": [ + "context", + "context2" + ], + "contexts_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_status_checks/contexts", + "checks": [ + { + "context": "context", + "app_id": null + }, + { + "context": "context2", + "app_id": 123 + } + ] + }, + "required_signatures": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_signatures", + "enabled": false + }, + "enforce_admins": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/enforce_admins", + "enabled": false + }, + "required_linear_history": { + "enabled": false + }, + "allow_force_pushes": { + "enabled": false + }, + "allow_deletions": { + "enabled": false + }, + "block_creations": { + "enabled": false + }, + "required_conversation_resolution": { + "enabled": false + }, + "lock_branch": { + "enabled": false + }, + "allow_fork_syncing": { + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/6-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/6-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..264fb82da6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/__files/6-r_h_t_branches_main_protection.json @@ -0,0 +1,56 @@ +{ + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection", + "required_status_checks": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_status_checks", + "strict": false, + "contexts": [ + "context", + "context2", + "context3" + ], + "contexts_url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_status_checks/contexts", + "checks": [ + { + "context": "context", + "app_id": null + }, + { + "context": "context2", + "app_id": 123 + }, + { + "context": "context3", + "app_id": null + } + ] + }, + "required_signatures": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/required_signatures", + "enabled": false + }, + "enforce_admins": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection/enforce_admins", + "enabled": false + }, + "required_linear_history": { + "enabled": false + }, + "allow_force_pushes": { + "enabled": false + }, + "allow_deletions": { + "enabled": false + }, + "block_creations": { + "enabled": false + }, + "required_conversation_resolution": { + "enabled": false + }, + "lock_branch": { + "enabled": false + }, + "allow_fork_syncing": { + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/1-user.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/1-user.json new file mode 100644 index 0000000000..87b2ae222d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/1-user.json @@ -0,0 +1,51 @@ +{ + "id": "16ba959e-4ca0-4045-96d7-b674c75257cc", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "1-user.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 17 May 2024 13:42:18 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"ed6f9c0f0f69bfb3fe7121d8e7818b048619df4a2345915b7caadb8ca02e8531\"", + "Last-Modified": "Wed, 15 May 2024 15:03:51 GMT", + "X-OAuth-Scopes": "admin:org, repo", + "X-Accepted-OAuth-Scopes": "", + "github-authentication-token-expiration": "2024-06-16 12:56:36 UTC", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4896", + "X-RateLimit-Reset": "1715954309", + "X-RateLimit-Used": "104", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, 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": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "B8F4:2F7818:126699EC:128021C0:66475EBA" + } + }, + "uuid": "16ba959e-4ca0-4045-96d7-b674c75257cc", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/2-r_h_temp-testcheckswithappids.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/2-r_h_temp-testcheckswithappids.json new file mode 100644 index 0000000000..f126b906b0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/2-r_h_temp-testcheckswithappids.json @@ -0,0 +1,51 @@ +{ + "id": "f6e4620b-0ff9-4a0a-b356-fe1235bf6775", + "name": "repos_hub4j-test-org_temp-testcheckswithappids", + "request": { + "url": "/repos/hub4j-test-org/temp-testChecksWithAppIds", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "2-r_h_temp-testcheckswithappids.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 17 May 2024 13:52:00 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"41998d4abee4f59befaff51b16f2fe7a5437119b7f5ba4eef222ee7455281ed1\"", + "Last-Modified": "Fri, 17 May 2024 13:52:00 GMT", + "X-OAuth-Scopes": "admin:org, repo", + "X-Accepted-OAuth-Scopes": "repo", + "github-authentication-token-expiration": "2024-06-16 12:56:36 UTC", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4868", + "X-RateLimit-Reset": "1715954309", + "X-RateLimit-Used": "132", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, 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": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "8A9E:0EA0:12FE6324:1317F7B9:66476100" + } + }, + "uuid": "f6e4620b-0ff9-4a0a-b356-fe1235bf6775", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/3-r_h_t_branches_main.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/3-r_h_t_branches_main.json new file mode 100644 index 0000000000..4a9e5aca28 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/3-r_h_t_branches_main.json @@ -0,0 +1,50 @@ +{ + "id": "63418037-ee6f-474c-8421-8828326c5fe5", + "name": "repos_hub4j-test-org_temp-testcheckswithappids_branches_main", + "request": { + "url": "/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.v3+json" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "3-r_h_t_branches_main.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 17 May 2024 13:52:01 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"ba95d66b4b3df8cd1dc17e866dc5d33585db49b9ed203b4a1aa18d8a8f2335d3\"", + "X-OAuth-Scopes": "admin:org, repo", + "X-Accepted-OAuth-Scopes": "", + "github-authentication-token-expiration": "2024-06-16 12:56:36 UTC", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4867", + "X-RateLimit-Reset": "1715954309", + "X-RateLimit-Used": "133", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, 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": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "8AAA:92EDF:130BCF1D:132597F0:66476101" + } + }, + "uuid": "63418037-ee6f-474c-8421-8828326c5fe5", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/4-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/4-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..593e01fa10 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/4-r_h_t_branches_main_protection.json @@ -0,0 +1,57 @@ +{ + "id": "963b8abe-5ece-4aaa-aeaa-18351841d6c2", + "name": "repos_hub4j-test-org_temp-testcheckswithappids_branches_main_protection", + "request": { + "url": "/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection", + "method": "PUT", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.luke-cage-preview+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":{\"strict\":false,\"checks\":[{\"context\":\"context\",\"app_id\":-1}]},\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "4-r_h_t_branches_main_protection.json", + "headers": { + "Server": "GitHub.com", + "Date": "Fri, 17 May 2024 13:52:01 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"05863b1a6c94ea9ceb3ef880c0b211bcdb5fb42c1aca535ec48bdadacd6a542b\"", + "X-OAuth-Scopes": "admin:org, repo", + "X-Accepted-OAuth-Scopes": "", + "github-authentication-token-expiration": "2024-06-16 12:56:36 UTC", + "X-GitHub-Media-Type": "github.v3; param=luke-cage-preview; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4866", + "X-RateLimit-Reset": "1715954309", + "X-RateLimit-Used": "134", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, 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": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "8AAC:0F85:813058E:81FDA8B:66476101" + } + }, + "uuid": "963b8abe-5ece-4aaa-aeaa-18351841d6c2", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/5-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/5-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..c97634d170 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/5-r_h_t_branches_main_protection.json @@ -0,0 +1,57 @@ +{ + "id": "630402b5-486c-41df-83e7-f9f1a715ea08", + "name": "repos_hub4j-test-org_temp-testcheckswithappids_branches_main_protection", + "request": { + "url": "/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection", + "method": "PUT", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.luke-cage-preview+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":{\"strict\":false,\"checks\":[{\"context\":\"context\",\"app_id\":-1},{\"context\":\"context2\",\"app_id\":123}]},\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "5-r_h_t_branches_main_protection.json", + "headers": { + "Server": "GitHub.com", + "Date": "Thu, 06 Jun 2024 08:33:48 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"eae3686ecc99456a89d4b1209c91dc3fefb1139da4cf8a9afbbd5c46ca4bb44c\"", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, copilot, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "github-authentication-token-expiration": "2024-06-16 12:56:36 UTC", + "X-GitHub-Media-Type": "github.v3; param=luke-cage-preview; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4995", + "X-RateLimit-Reset": "1717666423", + "X-RateLimit-Used": "5", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, 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": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "B950:2575A0:9D3C7A6:9E339B3:6661746C" + } + }, + "uuid": "630402b5-486c-41df-83e7-f9f1a715ea08", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/6-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/6-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..c020cf1cae --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testChecksWithAppIds/mappings/6-r_h_t_branches_main_protection.json @@ -0,0 +1,57 @@ +{ + "id": "9f6f5be6-b5c5-4840-865c-ba84ad262118", + "name": "repos_hub4j-test-org_temp-testcheckswithappids_branches_main_protection", + "request": { + "url": "/repos/hub4j-test-org/temp-testChecksWithAppIds/branches/main/protection", + "method": "PUT", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.luke-cage-preview+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":{\"checks\":[{\"context\":\"context\",\"app_id\":-1},{\"context\":\"context2\",\"app_id\":123},{\"context\":\"context3\"}],\"strict\":false},\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "6-r_h_t_branches_main_protection.json", + "headers": { + "Server": "GitHub.com", + "Date": "Thu, 13 Jun 2024 14:46:41 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"59d4b1a76c2903c6f8950aecee97ded98e0a0704a6ec06aebd22434d63b3a19c\"", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, copilot, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "github-authentication-token-expiration": "2024-06-16 12:56:36 UTC", + "X-GitHub-Media-Type": "github.v3; param=luke-cage-preview; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4966", + "X-RateLimit-Reset": "1718293429", + "X-RateLimit-Used": "34", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, 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": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C8E4:2DA98F:90511D4:9134847:666B0651" + } + }, + "uuid": "9f6f5be6-b5c5-4840-865c-ba84ad262118", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/2-r_h_temp-testenablebranchprotections.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/2-r_h_temp-tes.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/2-r_h_temp-testenablebranchprotections.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/2-r_h_temp-tes.json diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/4-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/4-r_h_t_branches_main_protection.json index a793b4cefa..65e419eb00 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/4-r_h_t_branches_main_protection.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/4-r_h_t_branches_main_protection.json @@ -40,4 +40,4 @@ "required_linear_history": { "enabled": true } -} +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/5-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/5-r_h_t_branches_main_protection.json index a793b4cefa..65e419eb00 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/5-r_h_t_branches_main_protection.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/5-r_h_t_branches_main_protection.json @@ -40,4 +40,4 @@ "required_linear_history": { "enabled": true } -} +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/6-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/6-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..34ceb65785 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/6-r_h_t_branches_main_protection.json @@ -0,0 +1,53 @@ +{ + "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection", + "required_status_checks": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/required_status_checks", + "strict": true, + "contexts": [ + "test-status-check" + ], + "contexts_url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/required_status_checks/contexts", + "checks": [ + { + "context": "test-status-check", + "app_id": null + } + ] + }, + "required_pull_request_reviews": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/required_pull_request_reviews", + "dismiss_stale_reviews": true, + "require_code_owner_reviews": true, + "require_last_push_approval": true, + "required_approving_review_count": 2 + }, + "required_signatures": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/required_signatures", + "enabled": false + }, + "enforce_admins": { + "url": "https://api.github.com/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection/enforce_admins", + "enabled": true + }, + "required_linear_history": { + "enabled": true + }, + "allow_force_pushes": { + "enabled": true + }, + "allow_deletions": { + "enabled": true + }, + "block_creations": { + "enabled": true + }, + "required_conversation_resolution": { + "enabled": true + }, + "lock_branch": { + "enabled": true + }, + "allow_fork_syncing": { + "enabled": true + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/2-r_h_temp-testenablebranchprotections.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/2-r_h_temp-tes.json similarity index 96% rename from src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/2-r_h_temp-testenablebranchprotections.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/2-r_h_temp-tes.json index 996bf7ece3..5c4d1b7a76 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/2-r_h_temp-testenablebranchprotections.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/2-r_h_temp-tes.json @@ -12,7 +12,7 @@ }, "response": { "status": 200, - "bodyFileName": "2-r_h_temp-testenablebranchprotections.json", + "bodyFileName": "2-r_h_temp-tes.json", "headers": { "Server": "GitHub.com", "Date": "Fri, 17 Jul 2020 17:40:28 GMT", diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/4-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/4-r_h_t_branches_main_protection.json index 4b4fdd00e6..0aa47d3f62 100644 --- a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/4-r_h_t_branches_main_protection.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/4-r_h_t_branches_main_protection.json @@ -49,4 +49,4 @@ "uuid": "3cdd44cf-a62c-43f6-abad-de7c8b65bfe3", "persistent": true, "insertionIndex": 4 -} +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/6-r_h_t_branches_main_protection.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/6-r_h_t_branches_main_protection.json new file mode 100644 index 0000000000..aee127f71c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/6-r_h_t_branches_main_protection.json @@ -0,0 +1,57 @@ +{ + "id": "854850d0-da4c-42f1-bfbd-01d8459b0639", + "name": "repos_hub4j-test-org_temp-testenablebranchprotections_branches_main_protection", + "request": { + "url": "/repos/hub4j-test-org/temp-testEnableBranchProtections/branches/main/protection", + "method": "PUT", + "headers": { + "Accept": { + "equalTo": "application/vnd.github.luke-cage-preview+json" + } + }, + "bodyPatterns": [ + { + "equalToJson": "{\"lock_branch\":true,\"required_pull_request_reviews\":{\"required_approving_review_count\":2,\"require_code_owner_reviews\":true,\"dismiss_stale_reviews\":true,\"require_last_push_approval\":true},\"block_creations\":true,\"required_conversation_resolution\":true,\"required_status_checks\":{\"checks\":[{\"context\":\"test-status-check\"}],\"strict\":true},\"allow_fork_syncing\":true,\"required_linear_history\":true,\"restrictions\":null,\"enforce_admins\":true,\"allow_deletions\":true,\"allow_force_pushes\":true}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "6-r_h_t_branches_main_protection.json", + "headers": { + "Server": "GitHub.com", + "Date": "Thu, 13 Jun 2024 15:15:26 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding, Accept, X-Requested-With" + ], + "ETag": "W/\"3a215bcd41d91bb045d01c04c1161c991f2b6588d859b06479dae7d4da689c3c\"", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, copilot, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "github-authentication-token-expiration": "2024-06-16 12:56:36 UTC", + "X-GitHub-Media-Type": "github.v3; param=luke-cage-preview; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4814", + "X-RateLimit-Reset": "1718293429", + "X-RateLimit-Used": "186", + "X-RateLimit-Resource": "core", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, 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": "0", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "DA76:1147A1:89C7F36:8AAE569:666B0D0E" + } + }, + "uuid": "854850d0-da4c-42f1-bfbd-01d8459b0639", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file