From 37ab9a997969d1d12475166882e1a7e1881eee81 Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:27:01 -0500 Subject: [PATCH] :sparkles: Support setting & checking AutomatedSecurityFixes. https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#check-if-automated-security-fixes-are-enabled-for-a-repository. --- .../java/org/kohsuke/github/GHRepository.java | 107 +++++++++++--- .../org/kohsuke/github/GHRepositoryTest.java | 47 ++++-- .../__files/1-get_user.json | 35 +++++ .../__files/2-get_repo.json | 138 ++++++++++++++++++ .../mappings/1-get_user.json | 39 +++++ ...get_automated-security-fixes_disabled.json | 14 ++ .../mappings/2-get_repo.json | 39 +++++ ...-get_automated-security-fixes_enabled.json | 14 ++ ...-get_automated-security-fixes_enabled.json | 14 ++ .../5-put_automated-security-fixes.json | 13 ++ ...-get_automated-security-fixes_enabled.json | 14 ++ ...-get_automated-security-fixes_enabled.json | 14 ++ .../8-delete_automated-security-fixes.json | 13 ++ ...get_automated-security-fixes_disabled.json | 14 ++ 14 files changed, 482 insertions(+), 33 deletions(-) create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/1-get_user.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/2-get_repo.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/1-get_user.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/10-get_automated-security-fixes_disabled.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/2-get_repo.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/3-get_automated-security-fixes_enabled.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/4-get_automated-security-fixes_enabled.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/5-put_automated-security-fixes.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/6-get_automated-security-fixes_enabled.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/7-get_automated-security-fixes_enabled.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/8-delete_automated-security-fixes.json create mode 100644 src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/9-get_automated-security-fixes_disabled.json diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 44bf41d30b..5c4f14e1cf 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -125,6 +125,41 @@ public class GHRepository extends GHObject { private Boolean isTemplate; private boolean compareUsePaginatedCommits; + /** + * Extra API call to /automated-security-fixes to get the status of automated security fixes. + * + * @return GHAutomatedSecurityFixes + * @throws IOException + */ + public GHAutomatedSecurityFixes getAutomatedSecurityFixes() throws IOException { + return root().createRequest() + .method("GET") + .with("name", name) + .withUrlPath(getApiTailUrl("/automated-security-fixes")) + .fetch(GHAutomatedSecurityFixes.class); + } + + public static class GHAutomatedSecurityFixes { + private boolean enabled; + private boolean paused; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public boolean isPaused() { + return paused; + } + + public void setPaused(boolean paused) { + this.paused = paused; + } + } + /** * Read. * @@ -621,7 +656,8 @@ public Map listLanguages() throws IOException { */ public String getOwnerName() { // consistency of the GitHub API is super... some serialized forms of GHRepository populate - // a full GHUser while others populate only the owner and email. This later form is super helpful + // a full GHUser while others populate only the owner and email. This later form is super + // helpful // in putting the login in owner.name not owner.login... thankfully we can easily identify this // second set because owner.login will be null return owner.login != null ? owner.login : owner.name; @@ -726,6 +762,24 @@ public boolean isDeleteBranchOnMerge() { return delete_branch_on_merge; } + /** + * Shows whether automated security fixes are enabled or disabled. + * + * @return the boolean + */ + public boolean isAutomatedSecurityFixesEnabled() throws IOException { + return this.getAutomatedSecurityFixes().isEnabled(); + } + + /** + * Shows whether automated security fixes are paused or not. + * + * @return the boolean + */ + public boolean isAutomatedSecurityFixesPaused() throws IOException { + return this.getAutomatedSecurityFixes().isPaused(); + } + /** * Returns the number of all forks of this repository. This not only counts direct forks, but also forks of forks, * and so on. @@ -766,9 +820,7 @@ public boolean isPrivate() { return _private; } - /** - * Visibility of a repository. - */ + /** Visibility of a repository. */ public enum Visibility { /** The public. */ @@ -783,9 +835,11 @@ public enum Visibility { /** * Placeholder for unexpected data values. * + *

* This avoids throwing exceptions during data binding or reading when the list of allowed values returned from * GitHub is expanded. * + *

* Do not pass this value to any methods. If this value is returned during a request, check the log output and * report an issue for the missing value. */ @@ -927,6 +981,7 @@ public String getDefaultBranch() { /** * Gets default branch. * + *

* Name is an artifact of when "master" was the most common default. * * @return the default branch @@ -956,9 +1011,7 @@ public int getSize() { return size; } - /** - * Affiliation of a repository collaborator. - */ + /** Affiliation of a repository collaborator. */ public enum CollaboratorAffiliation { /** The all. */ @@ -1187,7 +1240,6 @@ public void addCollaborators(GHOrganization.Permission permission, GHUser... use * the permission level * @param users * the users - * * @throws IOException * the io exception */ @@ -1493,6 +1545,22 @@ public void deleteBranchOnMerge(boolean value) throws IOException { set().deleteBranchOnMerge(value); } + public void enableAutomatedSecurityFixes(boolean value) throws IOException { + if (value) { + root().createRequest() + .method("PUT") + .with("name", name) + .withUrlPath(getApiTailUrl("/automated-security-fixes")) + .send(); + } else { + root().createRequest() + .method("DELETE") + .with("name", name) + .withUrlPath(getApiTailUrl("/automated-security-fixes")) + .send(); + } + } + /** * Deletes this repository. * @@ -1551,9 +1619,7 @@ public Setter set() { return new Setter(this); } - /** - * Sort orders for listing forks. - */ + /** Sort orders for listing forks. */ public enum ForkSort { /** The newest. */ @@ -1849,6 +1915,7 @@ public void deleteHook(int id) throws IOException { * Sets {@link #getCompare(String, String)} to return a {@link GHCompare} that uses a paginated commit list instead * of limiting to 250 results. * + *

* By default, {@link GHCompare} returns all commits in the comparison as part of the request, limited to 250 * results. More recently GitHub added the ability to return the commits as a paginated query allowing for more than * 250 results. @@ -1861,8 +1928,8 @@ public void setCompareUsePaginatedCommits(boolean value) { } /** - * Gets a comparison between 2 points in the repository. This would be similar to calling - * git log id1...id2 against a local repository. + * Gets a comparison between 2 points in the repository. This would be similar to calling + * git log id1...id2 against a local repository. * * @param id1 * an identifier for the first point to compare from, this can be a sha1 ID (for a commit, tag etc) or a @@ -2160,7 +2227,6 @@ public PagedIterable listCommitComments() { * * @param commitSha * the hash of the commit - * * @return the paged iterable */ public PagedIterable listCommitComments(String commitSha) { @@ -2364,6 +2430,7 @@ public PagedIterable listEvents() throws IOException { /** * Lists labels in this repository. + * *

* https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository * @@ -2433,6 +2500,7 @@ public PagedIterable listInvitations() { /** * Lists all the subscribers (aka watchers.) + * *

* https://developer.github.com/v3/activity/watching/ * @@ -2541,9 +2609,7 @@ public Set getPostCommitHooks() { } } - /** - * Live set view of the post-commit hook. - */ + /** Live set view of the post-commit hook. */ @SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "It causes a performance degradation, but we have already exposed it to the API") @SkipFromToString @@ -3080,9 +3146,7 @@ public PagedIterable listContributors() throws IOException { return root().createRequest().withUrlPath(getApiTailUrl("contributors")).toIterable(Contributor[].class, null); } - /** - * The type Contributor. - */ + /** The type Contributor. */ public static class Contributor extends GHUser { private int contributions; @@ -3181,6 +3245,7 @@ public PagedIterable listProjects() throws IOException { /** * Render a Markdown document. + * *

* In {@linkplain MarkdownMode#GFM GFM mode}, issue numbers and user mentions are linked accordingly. * @@ -3597,6 +3662,7 @@ void populate() throws IOException { /** * A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request. * + *

* Consumer must call {@link #done()} to commit changes. */ @BetaApi @@ -3688,6 +3754,7 @@ public PagedIterable listRulesForBranch(String branch) throws /** * A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request. * + *

* Consumer must call {@link #done()} to commit changes. */ @BetaApi diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index bb737dbb83..591ea04e5a 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -1,14 +1,13 @@ package org.kohsuke.github; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.core.IsInstanceOf.instanceOf; +import static org.junit.Assert.*; +import static org.kohsuke.github.GHVerification.Reason.GPGVERIFY_ERROR; +import static org.kohsuke.github.GHVerification.Reason.UNKNOWN_SIGNATURE_TYPE; + import com.fasterxml.jackson.databind.JsonMappingException; import com.google.common.collect.Sets; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Test; -import org.kohsuke.github.GHCheckRun.Conclusion; -import org.kohsuke.github.GHOrganization.RepositoryRole; -import org.kohsuke.github.GHRepository.Visibility; - import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -16,13 +15,15 @@ import java.net.URL; import java.time.LocalDate; import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.stream.Collectors; - -import static org.hamcrest.Matchers.*; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertThrows; -import static org.kohsuke.github.GHVerification.Reason.GPGVERIFY_ERROR; -import static org.kohsuke.github.GHVerification.Reason.UNKNOWN_SIGNATURE_TYPE; +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; +import org.kohsuke.github.GHCheckRun.Conclusion; +import org.kohsuke.github.GHOrganization.RepositoryRole; +import org.kohsuke.github.GHRepository.Visibility; // TODO: Auto-generated Javadoc /** @@ -1937,4 +1938,24 @@ private void verifyPluralResult(PagedSearchIterable searchResult, assertThat(searchResult.toList().get(0).getNumber(), is(expectedPR1.getNumber())); assertThat(searchResult.toList().get(1).getNumber(), is(expectedPR2.getNumber())); } + + /** + * Test repository automated security fix settings. + */ + @Test + public void testAutomatedSecurityFixSettings() throws IOException { + GHRepository repo = getTempRepository(); + var initialEnabled = repo.isAutomatedSecurityFixesEnabled(); + assertThat(initialEnabled, is(instanceOf(Boolean.class))); + var initialPaused = repo.isAutomatedSecurityFixesPaused(); + assertThat(initialPaused, is(instanceOf(Boolean.class))); + + repo.enableAutomatedSecurityFixes(true); + assertTrue("isAutomatedSecurityFixesEnabled should be true", repo.isAutomatedSecurityFixesEnabled()); + assertFalse("isAutomatedSecurityFixesPaused should be false", repo.isAutomatedSecurityFixesPaused()); + + repo.enableAutomatedSecurityFixes(false); + assertFalse("isAutomatedSecurityFixesEnabled should be true", repo.isAutomatedSecurityFixesEnabled()); + assertFalse("isAutomatedSecurityFixesPaused should be false", repo.isAutomatedSecurityFixesPaused()); + } } diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/1-get_user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/1-get_user.json new file mode 100644 index 0000000000..c165350182 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/1-get_user.json @@ -0,0 +1,35 @@ +{ + "login": "ranma2913", + "id": 4295880, + "node_id": "MDQ6VXNlcjQyOTU4ODA=", + "avatar_url": "https://avatars.githubusercontent.com/u/4295880?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ranma2913", + "html_url": "https://github.com/ranma2913", + "followers_url": "https://api.github.com/users/ranma2913/followers", + "following_url": "https://api.github.com/users/ranma2913/following{/other_user}", + "gists_url": "https://api.github.com/users/ranma2913/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ranma2913/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ranma2913/subscriptions", + "organizations_url": "https://api.github.com/users/ranma2913/orgs", + "repos_url": "https://api.github.com/users/ranma2913/repos", + "events_url": "https://api.github.com/users/ranma2913/events{/privacy}", + "received_events_url": "https://api.github.com/users/ranma2913/received_events", + "type": "User", + "site_admin": false, + "name": "Joel Sticha", + "company": "Optum Technology", + "blog": "", + "location": "MN, USA", + "email": null, + "hireable": null, + "bio": null, + "twitter_username": null, + "notification_email": null, + "public_repos": 51, + "public_gists": 2, + "followers": 4, + "following": 5, + "created_at": "2013-04-29T20:05:40Z", + "updated_at": "2024-08-28T16:13:33Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/2-get_repo.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/2-get_repo.json new file mode 100644 index 0000000000..3287be3c9b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/__files/2-get_repo.json @@ -0,0 +1,138 @@ +{ + "id": 848964146, + "node_id": "R_kgDOMpoqMg", + "name": "temp-testAutomatedSecurityFixSettings", + "full_name": "ranma2913/temp-testAutomatedSecurityFixSettings", + "private": false, + "owner": { + "login": "ranma2913", + "id": 4295880, + "node_id": "MDQ6VXNlcjQyOTU4ODA=", + "avatar_url": "https://avatars.githubusercontent.com/u/4295880?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ranma2913", + "html_url": "https://github.com/ranma2913", + "followers_url": "https://api.github.com/users/ranma2913/followers", + "following_url": "https://api.github.com/users/ranma2913/following{/other_user}", + "gists_url": "https://api.github.com/users/ranma2913/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ranma2913/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ranma2913/subscriptions", + "organizations_url": "https://api.github.com/users/ranma2913/orgs", + "repos_url": "https://api.github.com/users/ranma2913/repos", + "events_url": "https://api.github.com/users/ranma2913/events{/privacy}", + "received_events_url": "https://api.github.com/users/ranma2913/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/ranma2913/temp-testAutomatedSecurityFixSettings", + "description": "A test repository for testing the github-api project: temp-testAutomatedSecurityFixSettings", + "fork": false, + "url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings", + "forks_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/forks", + "keys_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/teams", + "hooks_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/hooks", + "issue_events_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/issues/events{/number}", + "events_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/events", + "assignees_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/assignees{/user}", + "branches_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/branches{/branch}", + "tags_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/tags", + "blobs_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/statuses/{sha}", + "languages_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/languages", + "stargazers_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/stargazers", + "contributors_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/contributors", + "subscribers_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/subscribers", + "subscription_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/subscription", + "commits_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/contents/{+path}", + "compare_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/merges", + "archive_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/downloads", + "issues_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/issues{/number}", + "pulls_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/pulls{/number}", + "milestones_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/milestones{/number}", + "notifications_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/labels{/name}", + "releases_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/releases{/id}", + "deployments_url": "https://api.github.com/repos/ranma2913/temp-testAutomatedSecurityFixSettings/deployments", + "created_at": "2024-08-28T18:17:07Z", + "updated_at": "2024-08-28T18:17:10Z", + "pushed_at": "2024-08-28T18:17:07Z", + "git_url": "git://github.com/ranma2913/temp-testAutomatedSecurityFixSettings.git", + "ssh_url": "git@github.com:ranma2913/temp-testAutomatedSecurityFixSettings.git", + "clone_url": "https://github.com/ranma2913/temp-testAutomatedSecurityFixSettings.git", + "svn_url": "https://github.com/ranma2913/temp-testAutomatedSecurityFixSettings", + "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": "master", + "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", + "security_and_analysis": { + "secret_scanning": { + "status": "enabled" + }, + "secret_scanning_push_protection": { + "status": "enabled" + }, + "dependabot_security_updates": { + "status": "enabled" + }, + "secret_scanning_non_provider_patterns": { + "status": "disabled" + }, + "secret_scanning_validity_checks": { + "status": "disabled" + } + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/1-get_user.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/1-get_user.json new file mode 100644 index 0000000000..deb851594a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/1-get_user.json @@ -0,0 +1,39 @@ +{ + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "1-get_user.json", + "headers": { + "Date": "Wed, 28 Aug 2024 18:17:05 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/\"f5a5fb07ec32c145ebc5cef6327b7da5202d3c921381f77bcb6c1a9f3732f8c2\"", + "Last-Modified": "Wed, 28 Aug 2024 16:13:33 GMT", + "X-OAuth-Scopes": "delete_repo, gist, read:org, repo, workflow", + "X-Accepted-OAuth-Scopes": "", + "github-authentication-token-expiration": "2024-12-31 06:00:00 UTC", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4900", + "X-RateLimit-Reset": "1724870853", + "X-RateLimit-Used": "100", + "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": "1263:37AFC7:1EE77A:3B55A1:66CF69A1", + "Server": "github.com" + } + }, + "insertionIndex": 1 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/10-get_automated-security-fixes_disabled.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/10-get_automated-security-fixes_disabled.json new file mode 100644 index 0000000000..318de30b46 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/10-get_automated-security-fixes_disabled.json @@ -0,0 +1,14 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"enabled\":false,\"paused\":false}", + "headers": { + "wiremock-mapping-file": "10-get_automated-security-fixes_disabled.json" + } + }, + "insertionIndex": 10 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/2-get_repo.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/2-get_repo.json new file mode 100644 index 0000000000..6530fc1fc2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/2-get_repo.json @@ -0,0 +1,39 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "2-get_repo.json", + "headers": { + "Date": "Wed, 28 Aug 2024 18:17:11 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/\"c9990a203dca16e283e3c517f171ab4828ea076103db2178d896323fad8613c7\"", + "Last-Modified": "Wed, 28 Aug 2024 18:17:10 GMT", + "X-OAuth-Scopes": "delete_repo, gist, read:org, repo, workflow", + "X-Accepted-OAuth-Scopes": "repo", + "github-authentication-token-expiration": "2024-12-31 06:00:00 UTC", + "X-GitHub-Media-Type": "github.v3; format=json", + "x-github-api-version-selected": "2022-11-28", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4895", + "X-RateLimit-Reset": "1724870853", + "X-RateLimit-Used": "105", + "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": "38EA:F19DF:14542C:26D2D3:66CF69A7", + "Server": "github.com" + } + }, + "insertionIndex": 2 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/3-get_automated-security-fixes_enabled.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/3-get_automated-security-fixes_enabled.json new file mode 100644 index 0000000000..6cf88caed3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/3-get_automated-security-fixes_enabled.json @@ -0,0 +1,14 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"enabled\":true,\"paused\":false}", + "headers": { + "wiremock-mapping-file": "3-get_automated-security-fixes_enabled.json" + } + }, + "insertionIndex": 3 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/4-get_automated-security-fixes_enabled.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/4-get_automated-security-fixes_enabled.json new file mode 100644 index 0000000000..154d37607b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/4-get_automated-security-fixes_enabled.json @@ -0,0 +1,14 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"enabled\":true,\"paused\":false}", + "headers": { + "wiremock-mapping-file": "4-get_automated-security-fixes_enabled.json" + } + }, + "insertionIndex": 4 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/5-put_automated-security-fixes.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/5-put_automated-security-fixes.json new file mode 100644 index 0000000000..70b64e5d22 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/5-put_automated-security-fixes.json @@ -0,0 +1,13 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "PUT" + }, + "response": { + "status": 204, + "headers": { + "wiremock-mapping-file": "5-put_automated-security-fixes.json" + } + }, + "insertionIndex": 5 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/6-get_automated-security-fixes_enabled.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/6-get_automated-security-fixes_enabled.json new file mode 100644 index 0000000000..3efc70c5f7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/6-get_automated-security-fixes_enabled.json @@ -0,0 +1,14 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"enabled\":true,\"paused\":false}", + "headers": { + "wiremock-mapping-file": "6-get_automated-security-fixes_enabled.json" + } + }, + "insertionIndex": 6 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/7-get_automated-security-fixes_enabled.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/7-get_automated-security-fixes_enabled.json new file mode 100644 index 0000000000..48872adf6d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/7-get_automated-security-fixes_enabled.json @@ -0,0 +1,14 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"enabled\":true,\"paused\":false}", + "headers": { + "wiremock-mapping-file": "7-get_automated-security-fixes_enabled.json" + } + }, + "insertionIndex": 7 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/8-delete_automated-security-fixes.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/8-delete_automated-security-fixes.json new file mode 100644 index 0000000000..5ed17b024c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/8-delete_automated-security-fixes.json @@ -0,0 +1,13 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "DELETE" + }, + "response": { + "status": 204, + "headers": { + "wiremock-mapping-file": "8-delete_automated-security-fixes.json" + } + }, + "insertionIndex": 8 +} diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/9-get_automated-security-fixes_disabled.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/9-get_automated-security-fixes_disabled.json new file mode 100644 index 0000000000..4efdc79544 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testAutomatedSecurityFixSettings/mappings/9-get_automated-security-fixes_disabled.json @@ -0,0 +1,14 @@ +{ + "request": { + "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"enabled\":false,\"paused\":false}", + "headers": { + "wiremock-mapping-file": "9-get_automated-security-fixes_disabled.json" + } + }, + "insertionIndex": 9 +}