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 1/9] :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 +} From f62d998dd623913cf063419e266edb89833b5498 Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:31:41 -0500 Subject: [PATCH 2/9] :art: Fix formatting AutomatedSecurityFixes --- .../java/org/kohsuke/github/GHRepository.java | 6 +++++ .../org/kohsuke/github/GHRepositoryTest.java | 27 +++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 5c4f14e1cf..c9557bc5f5 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -765,6 +765,9 @@ public boolean isDeleteBranchOnMerge() { /** * Shows whether automated security fixes are enabled or disabled. * + * @link Check + * if automated security fixes are enabled for a repository * @return the boolean */ public boolean isAutomatedSecurityFixesEnabled() throws IOException { @@ -774,6 +777,9 @@ public boolean isAutomatedSecurityFixesEnabled() throws IOException { /** * Shows whether automated security fixes are paused or not. * + * @link Check + * if automated security fixes are enabled for a repository * @return the boolean */ public boolean isAutomatedSecurityFixesPaused() throws IOException { diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 591ea04e5a..a8f90f56e5 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -1,13 +1,14 @@ 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; @@ -15,15 +16,13 @@ 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 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 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; // TODO: Auto-generated Javadoc /** From c0eff1f54b4c47b6363722c8b0ec81c340556a40 Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:33:12 -0500 Subject: [PATCH 3/9] :white_check_mark: Fix test AutomatedSecurityFixes --- src/test/java/org/kohsuke/github/GHRepositoryTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index a8f90f56e5..00135fb3dc 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -1944,9 +1944,9 @@ private void verifyPluralResult(PagedSearchIterable searchResult, @Test public void testAutomatedSecurityFixSettings() throws IOException { GHRepository repo = getTempRepository(); - var initialEnabled = repo.isAutomatedSecurityFixesEnabled(); + Object initialEnabled = repo.isAutomatedSecurityFixesEnabled(); assertThat(initialEnabled, is(instanceOf(Boolean.class))); - var initialPaused = repo.isAutomatedSecurityFixesPaused(); + Object initialPaused = repo.isAutomatedSecurityFixesPaused(); assertThat(initialPaused, is(instanceOf(Boolean.class))); repo.enableAutomatedSecurityFixes(true); From a1de71972cefd143f88ef752af3516e84ff68cf7 Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:37:01 -0500 Subject: [PATCH 4/9] :white_check_mark: Fix test AutomatedSecurityFixes --- .../__files/1-get_user.json | 26 ++-- .../__files/2-get_repo.json | 112 +++++++++--------- ...get_automated-security-fixes_disabled.json | 2 +- .../mappings/2-get_repo.json | 2 +- ...-get_automated-security-fixes_enabled.json | 2 +- ...-get_automated-security-fixes_enabled.json | 2 +- .../5-put_automated-security-fixes.json | 2 +- ...-get_automated-security-fixes_enabled.json | 2 +- ...-get_automated-security-fixes_enabled.json | 2 +- .../8-delete_automated-security-fixes.json | 2 +- ...get_automated-security-fixes_disabled.json | 2 +- 11 files changed, 78 insertions(+), 78 deletions(-) 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 index c165350182..42157d8b53 100644 --- 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 @@ -1,20 +1,20 @@ { - "login": "ranma2913", + "login": "hub4j-test-org", "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", + "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": "User", "site_admin": false, "name": "Joel Sticha", @@ -32,4 +32,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 index 3287be3c9b..48844df4d4 100644 --- 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 @@ -2,75 +2,75 @@ "id": 848964146, "node_id": "R_kgDOMpoqMg", "name": "temp-testAutomatedSecurityFixSettings", - "full_name": "ranma2913/temp-testAutomatedSecurityFixSettings", + "full_name": "hub4j-test-org/temp-testAutomatedSecurityFixSettings", "private": false, "owner": { - "login": "ranma2913", + "login": "hub4j-test-org", "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", + "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": "User", "site_admin": false }, - "html_url": "https://github.com/ranma2913/temp-testAutomatedSecurityFixSettings", + "html_url": "https://github.com/hub4j-test-org/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", + "url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings", + "forks_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/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", + "git_url": "git://github.com/hub4j-test-org/temp-testAutomatedSecurityFixSettings.git", + "ssh_url": "git@github.com:hub4j-test-org/temp-testAutomatedSecurityFixSettings.git", + "clone_url": "https://github.com/hub4j-test-org/temp-testAutomatedSecurityFixSettings.git", + "svn_url": "https://github.com/hub4j-test-org/temp-testAutomatedSecurityFixSettings", "homepage": "http://github-api.kohsuke.org/", "size": 0, "stargazers_count": 0, @@ -135,4 +135,4 @@ }, "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/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 index 318de30b46..580be69127 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "GET" }, "response": { 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 index 6530fc1fc2..ff6c190a61 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings", "method": "GET" }, "response": { 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 index 6cf88caed3..c8106503a3 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "GET" }, "response": { 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 index 154d37607b..b57c16ee95 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "GET" }, "response": { 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 index 70b64e5d22..ba118c7f84 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "PUT" }, "response": { 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 index 3efc70c5f7..c2a7b97a2d 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "GET" }, "response": { 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 index 48872adf6d..d3dfeb0f66 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "GET" }, "response": { 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 index 5ed17b024c..c7fea3c741 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "DELETE" }, "response": { 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 index 4efdc79544..6780aa5770 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/ranma2913/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", "method": "GET" }, "response": { From 513a8eb1678eed44c82d3acf3f265b412d45f4c6 Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:11:14 -0500 Subject: [PATCH 5/9] :white_check_mark: Add scenario configs for AutomatedSecurityFixes Wiremock mappings. --- .../mappings/1-get_user.json | 4 +++- .../10-get_automated-security-fixes_disabled.json | 6 ++++-- .../mappings/2-get_repo.json | 4 +++- .../mappings/3-get_automated-security-fixes_enabled.json | 7 +++++-- .../mappings/4-get_automated-security-fixes_enabled.json | 7 +++++-- .../mappings/5-put_automated-security-fixes.json | 7 +++++-- .../mappings/6-get_automated-security-fixes_enabled.json | 7 +++++-- .../mappings/7-get_automated-security-fixes_enabled.json | 7 +++++-- .../mappings/8-delete_automated-security-fixes.json | 7 +++++-- .../9-get_automated-security-fixes_disabled.json | 9 ++++++--- 10 files changed, 46 insertions(+), 19 deletions(-) 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 index deb851594a..b3b5dc0346 100644 --- 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 @@ -35,5 +35,7 @@ "Server": "github.com" } }, - "insertionIndex": 1 + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "Started", + "newScenarioState": "Started" } 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 index 580be69127..eece38c19c 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes.*", "method": "GET" }, "response": { @@ -10,5 +10,7 @@ "wiremock-mapping-file": "10-get_automated-security-fixes_disabled.json" } }, - "insertionIndex": 10 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "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 index ff6c190a61..291d247a35 100644 --- 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 @@ -35,5 +35,7 @@ "Server": "github.com" } }, - "insertionIndex": 2 + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "Started", + "newScenarioState": "3" } 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 index c8106503a3..1f20cc6ef3 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes.*", "method": "GET" }, "response": { @@ -10,5 +10,8 @@ "wiremock-mapping-file": "3-get_automated-security-fixes_enabled.json" } }, - "insertionIndex": 3 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "3", + "newScenarioState": "4" } 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 index b57c16ee95..e775d87bb9 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes.*", "method": "GET" }, "response": { @@ -10,5 +10,8 @@ "wiremock-mapping-file": "4-get_automated-security-fixes_enabled.json" } }, - "insertionIndex": 4 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "4", + "newScenarioState": "5" } 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 index ba118c7f84..8438bcf731 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes.*", "method": "PUT" }, "response": { @@ -9,5 +9,8 @@ "wiremock-mapping-file": "5-put_automated-security-fixes.json" } }, - "insertionIndex": 5 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "5", + "newScenarioState": "6" } 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 index c2a7b97a2d..ce02e4bf13 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes.*", "method": "GET" }, "response": { @@ -10,5 +10,8 @@ "wiremock-mapping-file": "6-get_automated-security-fixes_enabled.json" } }, - "insertionIndex": 6 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "6", + "newScenarioState": "7" } 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 index d3dfeb0f66..c4a87d83ed 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes.*", "method": "GET" }, "response": { @@ -10,5 +10,8 @@ "wiremock-mapping-file": "7-get_automated-security-fixes_enabled.json" } }, - "insertionIndex": 7 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "7", + "newScenarioState": "8" } 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 index c7fea3c741..d597e4c58a 100644 --- 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 @@ -1,6 +1,6 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes.*", "method": "DELETE" }, "response": { @@ -9,5 +9,8 @@ "wiremock-mapping-file": "8-delete_automated-security-fixes.json" } }, - "insertionIndex": 8 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "8", + "newScenarioState": "9" } 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 index 6780aa5770..7c0b3664f5 100644 --- 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 @@ -1,14 +1,17 @@ { "request": { - "url": "/repos/hub4j-test-org/temp-testAutomatedSecurityFixSettings/automated-security-fixes", + "urlPattern": "/repos/hub4j-test-org/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" + "wiremock-mapping-file": "9-get_automated-security-fixes_disabled.json" } }, - "insertionIndex": 9 + "persistent": true, + "scenarioName": "testAutomatedSecurityFixSettings", + "requiredScenarioState": "9", + "newScenarioState": "10" } From 9687a9e5281c26030e6639c2e6bf4836e2bf6360 Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:16:45 -0500 Subject: [PATCH 6/9] :white_check_mark: AutomatedSecurityFixes :: use `assertThat()` instead of shorthand assertTrue or assertFalse because checks say so. --- src/test/java/org/kohsuke/github/GHRepositoryTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 00135fb3dc..8aebf62188 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -1950,11 +1950,11 @@ public void testAutomatedSecurityFixSettings() throws IOException { assertThat(initialPaused, is(instanceOf(Boolean.class))); repo.enableAutomatedSecurityFixes(true); - assertTrue("isAutomatedSecurityFixesEnabled should be true", repo.isAutomatedSecurityFixesEnabled()); - assertFalse("isAutomatedSecurityFixesPaused should be false", repo.isAutomatedSecurityFixesPaused()); + assertThat(repo.isAutomatedSecurityFixesEnabled(), is(true)); + assertThat(repo.isAutomatedSecurityFixesPaused(), is(false)); repo.enableAutomatedSecurityFixes(false); - assertFalse("isAutomatedSecurityFixesEnabled should be true", repo.isAutomatedSecurityFixesEnabled()); - assertFalse("isAutomatedSecurityFixesPaused should be false", repo.isAutomatedSecurityFixesPaused()); + assertThat(repo.isAutomatedSecurityFixesEnabled(), is(false)); + assertThat(repo.isAutomatedSecurityFixesPaused(), is(false)); } } From d9120c01a5e3b61a344b2bd594bc1144c280110f Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:25:02 -0500 Subject: [PATCH 7/9] :memo: AutomatedSecurityFixes :: fix javadoc errors --- .../java/org/kohsuke/github/GHRepository.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index c9557bc5f5..8e6880f1e8 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -23,15 +23,14 @@ */ package org.kohsuke.github; +import static java.util.Arrays.asList; +import static java.util.Objects.requireNonNull; + import com.fasterxml.jackson.annotation.JsonProperty; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.apache.commons.lang3.StringUtils; -import org.kohsuke.github.function.InputStreamFunction; -import org.kohsuke.github.internal.EnumUtils; - import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -55,12 +54,11 @@ import java.util.Set; import java.util.TreeMap; import java.util.WeakHashMap; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - -import static java.util.Arrays.asList; -import static java.util.Objects.requireNonNull; +import org.apache.commons.lang3.StringUtils; +import org.kohsuke.github.function.InputStreamFunction; +import org.kohsuke.github.internal.EnumUtils; // TODO: Auto-generated Javadoc /** @@ -764,10 +762,7 @@ public boolean isDeleteBranchOnMerge() { /** * Shows whether automated security fixes are enabled or disabled. - * - * @link Check - * if automated security fixes are enabled for a repository + * ... * @return the boolean */ public boolean isAutomatedSecurityFixesEnabled() throws IOException { @@ -776,10 +771,7 @@ public boolean isAutomatedSecurityFixesEnabled() throws IOException { /** * Shows whether automated security fixes are paused or not. - * - * @link Check - * if automated security fixes are enabled for a repository + * ... * @return the boolean */ public boolean isAutomatedSecurityFixesPaused() throws IOException { From 9179f612fd27e56c3b9ef1089194c99413199f6c Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:26:52 -0500 Subject: [PATCH 8/9] :art: Spotless Format --- .../java/org/kohsuke/github/GHRepository.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 8e6880f1e8..46668b01a4 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -23,14 +23,15 @@ */ package org.kohsuke.github; -import static java.util.Arrays.asList; -import static java.util.Objects.requireNonNull; - import com.fasterxml.jackson.annotation.JsonProperty; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.apache.commons.lang3.StringUtils; +import org.kohsuke.github.function.InputStreamFunction; +import org.kohsuke.github.internal.EnumUtils; + import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -54,11 +55,12 @@ import java.util.Set; import java.util.TreeMap; import java.util.WeakHashMap; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.apache.commons.lang3.StringUtils; -import org.kohsuke.github.function.InputStreamFunction; -import org.kohsuke.github.internal.EnumUtils; + +import static java.util.Arrays.asList; +import static java.util.Objects.requireNonNull; // TODO: Auto-generated Javadoc /** @@ -761,8 +763,9 @@ public boolean isDeleteBranchOnMerge() { } /** - * Shows whether automated security fixes are enabled or disabled. - * ... + * Shows whether automated security fixes are enabled or disabled. ... + * * @return the boolean */ public boolean isAutomatedSecurityFixesEnabled() throws IOException { @@ -770,8 +773,9 @@ public boolean isAutomatedSecurityFixesEnabled() throws IOException { } /** - * Shows whether automated security fixes are paused or not. - * ... + * Shows whether automated security fixes are paused or not. ... + * * @return the boolean */ public boolean isAutomatedSecurityFixesPaused() throws IOException { From b3c4d124f17c8731eb2af83dfc23a2d879a462be Mon Sep 17 00:00:00 2001 From: "Joel Sticha (ranma2913)" <4295880+ranma2913@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:10:14 -0500 Subject: [PATCH 9/9] :white_check_mark: remove unused uncovered methods src/main/java/org/kohsuke/github/GHRepository.java --- src/main/java/org/kohsuke/github/GHRepository.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 46668b01a4..2975608300 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -147,17 +147,9 @@ 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; - } } /**