diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..5edb406183 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..48254dd93f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ +# Description +** Describe your change here** + +# Before submitting a PR: +We love getting PRs, but we hate asking people for the same basic changes every time. + +- [ ] Push your changes to a branch other than `master`. Create your PR from that branch. +- [ ] Add JavaDocs and other comments +- [ ] Write tests that run and pass in CI. See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to capture snapshot data. +- [ ] Run `mvn install site` locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI. diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index f009de37cb..849d046a51 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -19,4 +19,4 @@ jobs: - name: Maven Download all dependencies run: mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline - name: Maven Build - run: mvn -B install site --file pom.xml + run: mvn -B install site -P ci --file pom.xml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..151a5f6da2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,1174 @@ +# Changelog + +## [github-api-1.100](https://github.com/github-api/github-api/tree/github-api-1.100) (2019-11-27) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.99...github-api-1.100) + +### Features and Fixes + +- Add method to set repository topics @martinvanzijl (#594) +- Adjust GHRateLimit to system time instead of depending on synchronization @bitwiseman (#595) +- Add Functionality of OTP to support user 2fa @madhephaestus (#603) +- Implement Meta endpoint @PauloMigAlmeida (#611) +- fix and unit tests for issue #504 @siordache (#620) +- Fixed GHContent to allow spaces in path @bitwiseman (#625) + +### Internals + +- Clean up Requester interface a bit @bitwiseman (#614) +- Javadoc fail on warning during CI build @bitwiseman (#613) +- Code style fixes @bitwiseman (#609) +- Re-enable Lifecycle test @bitwiseman (#621) +- Removed permission field in createTeam. It is deprecated in the API @asthinasthi (#619) +- Cleanup imports @bitwiseman (#616) +- Branch missing @alexanderrtaylor (#615) +- jackson 2.10.1 @sullis (#604) +- Bump okhttp from 3.14.2 to 4.2.2 @dependabot-preview (#593) + + +## [github-api-1.99](https://github.com/github-api/github-api/tree/github-api-1.99) (2019-11-04) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.95...github-api-1.99) + +**Closed issues:** + +- Support all available endpoints for Github App with preview request [\#570](https://github.com/github-api/github-api/issues/570) +- Login details [\#560](https://github.com/github-api/github-api/issues/560) +- GHRepository.listReleases\(\) return empty always [\#535](https://github.com/github-api/github-api/issues/535) +- Unable to get deployment by id [\#529](https://github.com/github-api/github-api/issues/529) +- Malformed URL exception while accessing Enterprise Repository and fetching data [\#526](https://github.com/github-api/github-api/issues/526) +- Allow getting a repository by ID [\#515](https://github.com/github-api/github-api/issues/515) +- Methods to update milestones [\#512](https://github.com/github-api/github-api/issues/512) +- Add ETAG support to minimize API requests [\#505](https://github.com/github-api/github-api/issues/505) +- GitHub.connectUsingOAuth\(\) suddenly taking a really long time to connect [\#493](https://github.com/github-api/github-api/issues/493) +- GHTeam.add does not due to GHTeam.Role\(s\) been capitalized [\#489](https://github.com/github-api/github-api/issues/489) +- Reading file's content through GHContent.read\(\) returns previous version of file. [\#487](https://github.com/github-api/github-api/issues/487) +- Implement archive/unarchive functionality [\#472](https://github.com/github-api/github-api/issues/472) +- \[Gists\] Edit Gists Support [\#466](https://github.com/github-api/github-api/issues/466) +- Missing description field in GHTeam [\#460](https://github.com/github-api/github-api/issues/460) +- Bug: GHOrganization::createTeam does not regard argument repositories [\#457](https://github.com/github-api/github-api/issues/457) +- Null value for GHPullRequestReview created date and updated date [\#450](https://github.com/github-api/github-api/issues/450) +- Support for repository Projects [\#425](https://github.com/github-api/github-api/issues/425) +- create a little MockGitHub class for tests mocking out the github REST API [\#382](https://github.com/github-api/github-api/issues/382) +- Branch name is not being correctly URL encoded [\#381](https://github.com/github-api/github-api/issues/381) +- Issue events [\#376](https://github.com/github-api/github-api/issues/376) +- Not able to get the right file content [\#371](https://github.com/github-api/github-api/issues/371) +- Updating file is not possible [\#354](https://github.com/github-api/github-api/issues/354) +- Missing repository statistics [\#330](https://github.com/github-api/github-api/issues/330) +- Is there a way to make this library more test friendly? [\#316](https://github.com/github-api/github-api/issues/316) +- GitHub 2 factor login [\#292](https://github.com/github-api/github-api/issues/292) +- Unable to resolve github-api artifacts from Maven Central [\#195](https://github.com/github-api/github-api/issues/195) + +**Merged pull requests:** + +- Bump maven-source-plugin from 3.1.0 to 3.2.0 [\#590](https://github.com/github-api/github-api/pull/590) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Fix site errors [\#587](https://github.com/github-api/github-api/pull/587) ([bitwiseman](https://github.com/bitwiseman)) +- \[Documentation\] :: Add GitHub App Developer Guide [\#586](https://github.com/github-api/github-api/pull/586) ([PauloMigAlmeida](https://github.com/PauloMigAlmeida)) +- Create CODE\_OF\_CONDUCT.md [\#585](https://github.com/github-api/github-api/pull/585) ([bitwiseman](https://github.com/bitwiseman)) +- Convenience method to auth with app installation token && documentation examples [\#583](https://github.com/github-api/github-api/pull/583) ([PauloMigAlmeida](https://github.com/PauloMigAlmeida)) +- Add method to list repository topics [\#581](https://github.com/github-api/github-api/pull/581) ([martinvanzijl](https://github.com/martinvanzijl)) +- Fix for getting deployment by id [\#580](https://github.com/github-api/github-api/pull/580) ([martinvanzijl](https://github.com/martinvanzijl)) +- Add methods to update and delete milestones. [\#579](https://github.com/github-api/github-api/pull/579) ([martinvanzijl](https://github.com/martinvanzijl)) +- GHOrganization.createTeam now adds team to specified repositories [\#578](https://github.com/github-api/github-api/pull/578) ([martinvanzijl](https://github.com/martinvanzijl)) +- bump jackson-databind to 2.10.0 to avoid security alert [\#575](https://github.com/github-api/github-api/pull/575) ([romani](https://github.com/romani)) +- Bump wiremock-jre8-standalone from 2.25.0 to 2.25.1 [\#574](https://github.com/github-api/github-api/pull/574) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump hamcrest.version from 2.1 to 2.2 [\#573](https://github.com/github-api/github-api/pull/573) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- GitHub workflow: add JDK 13 to build matrix [\#572](https://github.com/github-api/github-api/pull/572) ([sullis](https://github.com/sullis)) +- More tests [\#568](https://github.com/github-api/github-api/pull/568) ([bitwiseman](https://github.com/bitwiseman)) +- Add merge options to GHRepository [\#567](https://github.com/github-api/github-api/pull/567) ([jberglund-BSFT](https://github.com/jberglund-BSFT)) +- Bump gson from 2.8.5 to 2.8.6 [\#565](https://github.com/github-api/github-api/pull/565) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump okio from 2.4.0 to 2.4.1 [\#564](https://github.com/github-api/github-api/pull/564) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Simplify creation of PagedIterables from requests [\#563](https://github.com/github-api/github-api/pull/563) ([bitwiseman](https://github.com/bitwiseman)) +- GitHub workflow: enable Java matrix \[ '1.8.0', '11.0.x' \] [\#562](https://github.com/github-api/github-api/pull/562) ([sullis](https://github.com/sullis)) +- Bump org.eclipse.jgit from 5.5.0.201909110433-r to 5.5.1.201910021850-r [\#561](https://github.com/github-api/github-api/pull/561) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump okio from 2.2.2 to 2.4.0 [\#558](https://github.com/github-api/github-api/pull/558) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump mockito-core from 3.0.0 to 3.1.0 [\#557](https://github.com/github-api/github-api/pull/557) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump wiremock-jre8-standalone from 2.24.1 to 2.25.0 [\#556](https://github.com/github-api/github-api/pull/556) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump commons-io from 1.4 to 2.6 [\#555](https://github.com/github-api/github-api/pull/555) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump maven-surefire-plugin from 2.22.1 to 2.22.2 [\#554](https://github.com/github-api/github-api/pull/554) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump commons-lang3 from 3.7 to 3.9 [\#552](https://github.com/github-api/github-api/pull/552) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump commons-codec from 1.7 to 1.13 [\#551](https://github.com/github-api/github-api/pull/551) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump spotbugs-maven-plugin from 3.1.11 to 3.1.12.2 [\#550](https://github.com/github-api/github-api/pull/550) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump bridge-method-annotation from 1.17 to 1.18 [\#549](https://github.com/github-api/github-api/pull/549) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Bump org.eclipse.jgit from 4.9.0.201710071750-r to 5.5.0.201909110433-r [\#547](https://github.com/github-api/github-api/pull/547) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Support for projects [\#545](https://github.com/github-api/github-api/pull/545) ([gskjold](https://github.com/gskjold)) +- Adding possiblity to get ssh keys [\#544](https://github.com/github-api/github-api/pull/544) ([arngrimur-seal](https://github.com/arngrimur-seal)) +- Grammar [\#543](https://github.com/github-api/github-api/pull/543) ([jsoref](https://github.com/jsoref)) +- Improved OkHttpConnector caching behavior [\#542](https://github.com/github-api/github-api/pull/542) ([bitwiseman](https://github.com/bitwiseman)) +- Add GitHubApiWireMockRule [\#541](https://github.com/github-api/github-api/pull/541) ([bitwiseman](https://github.com/bitwiseman)) +- Add support for team pr review requests [\#532](https://github.com/github-api/github-api/pull/532) ([farmdawgnation](https://github.com/farmdawgnation)) +- Add GitHub API requests logging [\#530](https://github.com/github-api/github-api/pull/530) ([bozaro](https://github.com/bozaro)) +- Add support for draft pull requests [\#525](https://github.com/github-api/github-api/pull/525) ([vbehar](https://github.com/vbehar)) +- Implement GitHub App API methods [\#522](https://github.com/github-api/github-api/pull/522) ([PauloMigAlmeida](https://github.com/PauloMigAlmeida)) +- Added getUserPublicOrganizations method [\#510](https://github.com/github-api/github-api/pull/510) ([awittha](https://github.com/awittha)) +- Add support for editing Gists [\#484](https://github.com/github-api/github-api/pull/484) ([martinvanzijl](https://github.com/martinvanzijl)) +- Add method to invite user to organization [\#482](https://github.com/github-api/github-api/pull/482) ([martinvanzijl](https://github.com/martinvanzijl)) +- Added method to list authorizations [\#481](https://github.com/github-api/github-api/pull/481) ([martinvanzijl](https://github.com/martinvanzijl)) +- Escape special characters in branch URLs [\#480](https://github.com/github-api/github-api/pull/480) ([martinvanzijl](https://github.com/martinvanzijl)) +- Add issue events API [\#479](https://github.com/github-api/github-api/pull/479) ([martinvanzijl](https://github.com/martinvanzijl)) +- Added description field to GHTeam class. [\#478](https://github.com/github-api/github-api/pull/478) ([martinvanzijl](https://github.com/martinvanzijl)) +- Add statistics API. [\#477](https://github.com/github-api/github-api/pull/477) ([martinvanzijl](https://github.com/martinvanzijl)) +- Adding Label description property [\#475](https://github.com/github-api/github-api/pull/475) ([immanuelqrw](https://github.com/immanuelqrw)) +- Implemented GitHub.doArchive [\#473](https://github.com/github-api/github-api/pull/473) ([joaoe](https://github.com/joaoe)) + +## [github-api-1.95](https://github.com/github-api/github-api/tree/github-api-1.95) (2018-11-06) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.94...github-api-1.95) + +**Closed issues:** + +- Add ability to attach/detach issue label w/o side effects to other labels [\#456](https://github.com/github-api/github-api/issues/456) +- \[feature request\] Add support to list commits that only affect a file path [\#454](https://github.com/github-api/github-api/issues/454) +- Rate limit - catch the exception [\#447](https://github.com/github-api/github-api/issues/447) +- GHRepository.listCommits\(\) returns java.net.SocketTimeoutException: Read timed out [\#433](https://github.com/github-api/github-api/issues/433) +- java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.deser.SettableBeanProperty.\ [\#419](https://github.com/github-api/github-api/issues/419) +- mvn test fails to start on HEAD [\#415](https://github.com/github-api/github-api/issues/415) +- NullPointerException in org.kohsuke.github.GHContent.read [\#414](https://github.com/github-api/github-api/issues/414) + +**Merged pull requests:** + +- Added archived attribute in GHRepository [\#470](https://github.com/github-api/github-api/pull/470) ([recena](https://github.com/recena)) +- Fix memory leak. [\#468](https://github.com/github-api/github-api/pull/468) ([KostyaSha](https://github.com/KostyaSha)) +- add request reviewers as attribute of GHPullRequest [\#464](https://github.com/github-api/github-api/pull/464) ([xeric](https://github.com/xeric)) +- Add methods for adding/removing labels to GHIssue [\#461](https://github.com/github-api/github-api/pull/461) ([evenh](https://github.com/evenh)) + +## [github-api-1.94](https://github.com/github-api/github-api/tree/github-api-1.94) (2018-08-30) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.93...github-api-1.94) + +**Closed issues:** + +- Attachment download from issues [\#451](https://github.com/github-api/github-api/issues/451) +- GHEventPayload.Issue [\#442](https://github.com/github-api/github-api/issues/442) +- GHRelease.uploadAsset\(\) that takes InputStream instead of File [\#434](https://github.com/github-api/github-api/issues/434) +- Implement the new invitations API [\#374](https://github.com/github-api/github-api/issues/374) + +**Merged pull requests:** + +- Fix for issue \#426. Fix null pointer when deleting refs. [\#449](https://github.com/github-api/github-api/pull/449) ([martinvanzijl](https://github.com/martinvanzijl)) +- Fix pagination for APIs that supported it ad hoc [\#446](https://github.com/github-api/github-api/pull/446) ([daniel-beck](https://github.com/daniel-beck)) +- Adds the GHEventPayload.Issue class [\#443](https://github.com/github-api/github-api/pull/443) ([Arrow768](https://github.com/Arrow768)) +- support update content through createContent, passing sha of existing file [\#441](https://github.com/github-api/github-api/pull/441) ([shirdoo](https://github.com/shirdoo)) +- Add support for repository searching by "topic" [\#439](https://github.com/github-api/github-api/pull/439) ([l3ender](https://github.com/l3ender)) +- - added overloaded 'uploadAsset' method [\#438](https://github.com/github-api/github-api/pull/438) ([jgangemi](https://github.com/jgangemi)) +- \[feature\] implement Repository Invitations API [\#437](https://github.com/github-api/github-api/pull/437) ([Rechi](https://github.com/Rechi)) +- - remove unthrown IOException [\#436](https://github.com/github-api/github-api/pull/436) ([jgangemi](https://github.com/jgangemi)) +- - branch protection enhancements [\#435](https://github.com/github-api/github-api/pull/435) ([jgangemi](https://github.com/jgangemi)) +- Added release payload. [\#417](https://github.com/github-api/github-api/pull/417) ([twcurrie](https://github.com/twcurrie)) +- Add GHRepository.getRelease and GHRepository.getReleaseByTagName [\#411](https://github.com/github-api/github-api/pull/411) ([tadfisher](https://github.com/tadfisher)) + +## [github-api-1.93](https://github.com/github-api/github-api/tree/github-api-1.93) (2018-05-01) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.92...github-api-1.93) + +**Closed issues:** + +- InvalidFormatException parsing GHEventPayload.PullRequestReview [\#421](https://github.com/github-api/github-api/issues/421) +- https://api.github.com/user response code -1 [\#418](https://github.com/github-api/github-api/issues/418) +- Update commons-lang version [\#409](https://github.com/github-api/github-api/issues/409) +- add a comment to a pull Request [\#380](https://github.com/github-api/github-api/issues/380) + +**Merged pull requests:** + +- \[fix\] fetch labels with HTTP GET method [\#431](https://github.com/github-api/github-api/pull/431) ([Rechi](https://github.com/Rechi)) +- Added request reviewers function within GHPullRequest. [\#430](https://github.com/github-api/github-api/pull/430) ([twcurrie](https://github.com/twcurrie)) +- Add support for previous\_filename for file details in PR. [\#427](https://github.com/github-api/github-api/pull/427) ([itepikin-smartling](https://github.com/itepikin-smartling)) +- Fixes \#421 - Enum case doesn't match for Pull Request Reviews [\#422](https://github.com/github-api/github-api/pull/422) ([ggrell](https://github.com/ggrell)) +- OkHttpConnector: Enforce use of TLSv1.2 to match current Github and Github Enterprise TLS support. [\#420](https://github.com/github-api/github-api/pull/420) ([randomvariable](https://github.com/randomvariable)) +- Update commons-lang to 3.7 [\#410](https://github.com/github-api/github-api/pull/410) ([Limess](https://github.com/Limess)) + +## [github-api-1.92](https://github.com/github-api/github-api/tree/github-api-1.92) (2018-01-13) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.91...github-api-1.92) + +## [github-api-1.91](https://github.com/github-api/github-api/tree/github-api-1.91) (2018-01-13) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.90...github-api-1.91) + +**Closed issues:** + +- How to authenticate using oauth in code? [\#405](https://github.com/github-api/github-api/issues/405) +- It is possible to read a github project wiki ? [\#404](https://github.com/github-api/github-api/issues/404) +- gitHttpTransportUrl Rename [\#403](https://github.com/github-api/github-api/issues/403) +- Do not throw new Error\(\) [\#400](https://github.com/github-api/github-api/issues/400) +- GHPullRequest.getMergeable\(\) never returns True [\#399](https://github.com/github-api/github-api/issues/399) +- NPE in GHPerson.populate [\#395](https://github.com/github-api/github-api/issues/395) +- 64-bit id support [\#393](https://github.com/github-api/github-api/issues/393) +- Numeric value out of range of int [\#387](https://github.com/github-api/github-api/issues/387) +- Diff URL with auth [\#386](https://github.com/github-api/github-api/issues/386) + +**Merged pull requests:** + +- Adding merge settings to GHCreateRepositoryBuilder [\#407](https://github.com/github-api/github-api/pull/407) ([notsudo](https://github.com/notsudo)) +- Improved Pull Request review and comments support [\#406](https://github.com/github-api/github-api/pull/406) ([sns-seb](https://github.com/sns-seb)) +- Add GHIssue\#setMilestone [\#397](https://github.com/github-api/github-api/pull/397) ([mizoguche](https://github.com/mizoguche)) +- \[fix\] GHPerson: check if root is null [\#396](https://github.com/github-api/github-api/pull/396) ([Rechi](https://github.com/Rechi)) +- Add get for all organizations [\#391](https://github.com/github-api/github-api/pull/391) ([scotty-g](https://github.com/scotty-g)) +- Add support for pr review/review comment events [\#384](https://github.com/github-api/github-api/pull/384) ([mattnelson](https://github.com/mattnelson)) +- Roles for team members [\#379](https://github.com/github-api/github-api/pull/379) ([amberovsky](https://github.com/amberovsky)) + +## [github-api-1.90](https://github.com/github-api/github-api/tree/github-api-1.90) (2017-10-28) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.89...github-api-1.90) + +**Closed issues:** + +- \ fields yeld NPE on getX operations. [\#372](https://github.com/github-api/github-api/issues/372) +- Add support for committing multiple files. [\#360](https://github.com/github-api/github-api/issues/360) +- Update compiler [\#357](https://github.com/github-api/github-api/issues/357) +- Extension mechanism? [\#356](https://github.com/github-api/github-api/issues/356) +- Update GHPullRequest with missing properties [\#355](https://github.com/github-api/github-api/issues/355) +- Refactor to allow for additional HTTP headers [\#353](https://github.com/github-api/github-api/issues/353) +- Building failing due problematic repository server [\#344](https://github.com/github-api/github-api/issues/344) +- Pull Request Reviews API [\#305](https://github.com/github-api/github-api/issues/305) + +**Merged pull requests:** + +- Labels: add method to update color [\#390](https://github.com/github-api/github-api/pull/390) ([batmat](https://github.com/batmat)) +- Fixed OAuth connection to enterprise API [\#389](https://github.com/github-api/github-api/pull/389) ([dorian808080](https://github.com/dorian808080)) +- Fix for \#387: numeric value out of range of int [\#388](https://github.com/github-api/github-api/pull/388) ([aburmeis](https://github.com/aburmeis)) + +## [github-api-1.89](https://github.com/github-api/github-api/tree/github-api-1.89) (2017-09-09) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.88...github-api-1.89) + +**Closed issues:** + +- OkHttpConnector is broken [\#335](https://github.com/github-api/github-api/issues/335) +- Support new merge methods \(squash/rebase\) for Github Pull Requests [\#326](https://github.com/github-api/github-api/issues/326) +- Expose OAuth headers [\#303](https://github.com/github-api/github-api/issues/303) + +**Merged pull requests:** + +- Added support for traffic statistics \(number of views and clones\) [\#368](https://github.com/github-api/github-api/pull/368) ([adw1n](https://github.com/adw1n)) +- issue \#360: Add support for committing multiple files [\#361](https://github.com/github-api/github-api/pull/361) ([siordache](https://github.com/siordache)) +- Expose Headers [\#339](https://github.com/github-api/github-api/pull/339) ([KostyaSha](https://github.com/KostyaSha)) +- Remove unused imports [\#337](https://github.com/github-api/github-api/pull/337) ([sebkur](https://github.com/sebkur)) +- Add support for MergeMethod on GHPullRequest [\#333](https://github.com/github-api/github-api/pull/333) ([greggian](https://github.com/greggian)) +- Add some level of synchronization to the root of the API [\#283](https://github.com/github-api/github-api/pull/283) ([mmitche](https://github.com/mmitche)) + +## [github-api-1.88](https://github.com/github-api/github-api/tree/github-api-1.88) (2017-09-09) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.87...github-api-1.88) + +## [github-api-1.87](https://github.com/github-api/github-api/tree/github-api-1.87) (2017-09-09) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.86...github-api-1.87) + +**Closed issues:** + +- Cannot merge newly created GHPullRequest [\#367](https://github.com/github-api/github-api/issues/367) +- Unable to search thru search API [\#365](https://github.com/github-api/github-api/issues/365) +- Unable to find documentation for issue search [\#364](https://github.com/github-api/github-api/issues/364) +- Commit Search API implemented or not? [\#345](https://github.com/github-api/github-api/issues/345) +- How can I get Latest Release of Repository? [\#341](https://github.com/github-api/github-api/issues/341) + +**Merged pull requests:** + +- bridge-method-annotation should be an optional dep [\#378](https://github.com/github-api/github-api/pull/378) ([jglick](https://github.com/jglick)) +- Add basic support for tag objects [\#375](https://github.com/github-api/github-api/pull/375) ([stephenc](https://github.com/stephenc)) +- - improve branch protection support [\#369](https://github.com/github-api/github-api/pull/369) ([jgangemi](https://github.com/jgangemi)) +- Add missing event types used by repository webhooks [\#363](https://github.com/github-api/github-api/pull/363) ([PauloMigAlmeida](https://github.com/PauloMigAlmeida)) +- Add ping hook method [\#362](https://github.com/github-api/github-api/pull/362) ([KostyaSha](https://github.com/KostyaSha)) +- \[JENKINS-36240\] /repos/:owner/:repo/collaborators/:username/permission no longer requires korra preview [\#358](https://github.com/github-api/github-api/pull/358) ([jglick](https://github.com/jglick)) +- Add support for PR reviews preview [\#352](https://github.com/github-api/github-api/pull/352) ([stephenc](https://github.com/stephenc)) +- Add the Commit search API [\#351](https://github.com/github-api/github-api/pull/351) ([mdeverdelhan](https://github.com/mdeverdelhan)) +- add latest release [\#343](https://github.com/github-api/github-api/pull/343) ([kamontat](https://github.com/kamontat)) +- Ignore eclipse files [\#338](https://github.com/github-api/github-api/pull/338) ([sebkur](https://github.com/sebkur)) +- Fix a bug in the Javadocs \(due to copy and paste\) [\#332](https://github.com/github-api/github-api/pull/332) ([sebkur](https://github.com/sebkur)) + +## [github-api-1.86](https://github.com/github-api/github-api/tree/github-api-1.86) (2017-07-03) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.85...github-api-1.86) + +**Merged pull requests:** + +- \[JENKINS-45142\] Retry connections after getting SocketTimeoutException [\#359](https://github.com/github-api/github-api/pull/359) ([jglick](https://github.com/jglick)) + +## [github-api-1.85](https://github.com/github-api/github-api/tree/github-api-1.85) (2017-03-01) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.84...github-api-1.85) + +**Closed issues:** + +- getPusher\(\) returns null in call to getPusher\(\) [\#342](https://github.com/github-api/github-api/issues/342) + +**Merged pull requests:** + +- Ensure that connections are closed for error responses [\#346](https://github.com/github-api/github-api/pull/346) ([stephenc](https://github.com/stephenc)) +- Correct algebra in \#327 [\#329](https://github.com/github-api/github-api/pull/329) ([stephenc](https://github.com/stephenc)) + +## [github-api-1.84](https://github.com/github-api/github-api/tree/github-api-1.84) (2017-01-10) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.83...github-api-1.84) + +## [github-api-1.83](https://github.com/github-api/github-api/tree/github-api-1.83) (2017-01-10) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.82...github-api-1.83) + +**Closed issues:** + +- Webhook creation response error [\#328](https://github.com/github-api/github-api/issues/328) + +**Merged pull requests:** + +- Expose Rate Limit Headers [\#327](https://github.com/github-api/github-api/pull/327) ([stephenc](https://github.com/stephenc)) +- Branch protection attrs [\#325](https://github.com/github-api/github-api/pull/325) ([jeffnelson](https://github.com/jeffnelson)) +- \[JENKINS-36240\] Added GHRepository.getPermission\(String\) [\#324](https://github.com/github-api/github-api/pull/324) ([jglick](https://github.com/jglick)) + +## [github-api-1.82](https://github.com/github-api/github-api/tree/github-api-1.82) (2016-12-17) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.81...github-api-1.82) + +**Closed issues:** + +- API response time [\#322](https://github.com/github-api/github-api/issues/322) +- getLabels\(\) call for a pull request results in downstream 404s [\#319](https://github.com/github-api/github-api/issues/319) +- Gist Searching [\#318](https://github.com/github-api/github-api/issues/318) +- Adding users to organization-owned repos not possible [\#317](https://github.com/github-api/github-api/issues/317) +- GHSearchBuilder terms are cumulative when I expected them to overwrite previous one [\#314](https://github.com/github-api/github-api/issues/314) +- Support ordering in searches [\#313](https://github.com/github-api/github-api/issues/313) +- Update OkHttp usage [\#312](https://github.com/github-api/github-api/issues/312) +- github.getRepository does not work for Enterprise github instance [\#263](https://github.com/github-api/github-api/issues/263) + +**Merged pull requests:** + +- Fix syntactically malformed test JSON [\#323](https://github.com/github-api/github-api/pull/323) ([jglick](https://github.com/jglick)) +- Added ghRepo.getBlob\(String\) method [\#320](https://github.com/github-api/github-api/pull/320) ([KostyaSha](https://github.com/KostyaSha)) +- Fix typos in javadocs [\#315](https://github.com/github-api/github-api/pull/315) ([davidxia](https://github.com/davidxia)) + +## [github-api-1.81](https://github.com/github-api/github-api/tree/github-api-1.81) (2016-11-21) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.80...github-api-1.81) + +**Closed issues:** + +- Multiple assignee support [\#294](https://github.com/github-api/github-api/issues/294) +- Missing support for determining if authenticated user is organization owner [\#293](https://github.com/github-api/github-api/issues/293) + +## [github-api-1.80](https://github.com/github-api/github-api/tree/github-api-1.80) (2016-11-17) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.79...github-api-1.80) + +**Closed issues:** + +- Testing reaction [\#311](https://github.com/github-api/github-api/issues/311) +- Is there a way to update contents in bulk? [\#310](https://github.com/github-api/github-api/issues/310) +- GitHub\#listAllUsers\(\) demanded \(enterprise use-case\) [\#309](https://github.com/github-api/github-api/issues/309) +- Delete OAuth Token [\#308](https://github.com/github-api/github-api/issues/308) +- How to find a pull request using the Search API and get its details? [\#298](https://github.com/github-api/github-api/issues/298) + +**Merged pull requests:** + +- Add portion of auth/application API. [\#307](https://github.com/github-api/github-api/pull/307) ([KostyaSha](https://github.com/KostyaSha)) +- Add offline support to the API to make parsing events easier [\#306](https://github.com/github-api/github-api/pull/306) ([stephenc](https://github.com/stephenc)) +- Fix fields of GHRepository [\#304](https://github.com/github-api/github-api/pull/304) ([wolfogre](https://github.com/wolfogre)) + +## [github-api-1.79](https://github.com/github-api/github-api/tree/github-api-1.79) (2016-10-25) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.78...github-api-1.79) + +**Merged pull requests:** + +- url encode hashes in ref names [\#299](https://github.com/github-api/github-api/pull/299) ([bsheats](https://github.com/bsheats)) + +## [github-api-1.78](https://github.com/github-api/github-api/tree/github-api-1.78) (2016-10-24) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.77...github-api-1.78) + +**Closed issues:** + +- Allow edit for maintainer support [\#297](https://github.com/github-api/github-api/issues/297) +- run mvn install fail! Failure to find org.jenkins-ci:jenkins:pom:1.26 ?? [\#296](https://github.com/github-api/github-api/issues/296) + +**Merged pull requests:** + +- Expose the commit dates [\#300](https://github.com/github-api/github-api/pull/300) ([stephenc](https://github.com/stephenc)) +- Use maximum permitted page size [\#295](https://github.com/github-api/github-api/pull/295) ([jglick](https://github.com/jglick)) + +## [github-api-1.77](https://github.com/github-api/github-api/tree/github-api-1.77) (2016-08-06) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.76...github-api-1.77) + +**Closed issues:** + +- weird format for get list of organizations [\#291](https://github.com/github-api/github-api/issues/291) +- OkHttp is out of date [\#290](https://github.com/github-api/github-api/issues/290) +- 400 from OKHttp getInputStream [\#288](https://github.com/github-api/github-api/issues/288) +- pagination support search APIs [\#287](https://github.com/github-api/github-api/issues/287) +- significant more API calls for same code [\#286](https://github.com/github-api/github-api/issues/286) +- Excessive concurrent request rate limit not handled [\#285](https://github.com/github-api/github-api/issues/285) +- team.add\(repo\) should accept permission flag [\#279](https://github.com/github-api/github-api/issues/279) +- Pull request mergeability is boolean but should be trinary [\#275](https://github.com/github-api/github-api/issues/275) +- Webhook with content type "application/json" [\#274](https://github.com/github-api/github-api/issues/274) +- Disable rate\_limit check on GitHub Enterprise completely [\#273](https://github.com/github-api/github-api/issues/273) +- java.lang.IllegalArgumentException: byteString == null [\#265](https://github.com/github-api/github-api/issues/265) +- Failed to deserialize list of contributors when repo is empty [\#261](https://github.com/github-api/github-api/issues/261) +- github-api does not distinguish between user and organisation [\#260](https://github.com/github-api/github-api/issues/260) +- API Rate Limit Exceeding [\#258](https://github.com/github-api/github-api/issues/258) + +**Merged pull requests:** + +- Implement an abuse handler [\#289](https://github.com/github-api/github-api/pull/289) ([mmitche](https://github.com/mmitche)) + +## [github-api-1.76](https://github.com/github-api/github-api/tree/github-api-1.76) (2016-06-03) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.75...github-api-1.76) + +**Closed issues:** + +- GitHub.getRateLimit hangs inside SocketInputStream.socketRead0 [\#271](https://github.com/github-api/github-api/issues/271) +- \(re\)open method on GHMilestone [\#269](https://github.com/github-api/github-api/issues/269) +- More meaning toString implementations [\#268](https://github.com/github-api/github-api/issues/268) +- GHRepository.fork\(\) does not block on the async operation until it's complete [\#264](https://github.com/github-api/github-api/issues/264) +- Add Support for the Protected Branches API [\#262](https://github.com/github-api/github-api/issues/262) + +**Merged pull requests:** + +- related to JENKINS-34834. updating test for similar condition [\#282](https://github.com/github-api/github-api/pull/282) ([apemberton](https://github.com/apemberton)) +- Add Slug to GHTeam per v3 API: https://developer.github.com/v3/orgs/t… [\#281](https://github.com/github-api/github-api/pull/281) ([apemberton](https://github.com/apemberton)) +- Fixed broken link [\#278](https://github.com/github-api/github-api/pull/278) ([jglick](https://github.com/jglick)) +- Updated Date was wrong [\#277](https://github.com/github-api/github-api/pull/277) ([KondaReddyR](https://github.com/KondaReddyR)) +- Add support to delete a team [\#276](https://github.com/github-api/github-api/pull/276) ([thug-gamer](https://github.com/thug-gamer)) +- Added support for the extended stargazers API in Github V3 API [\#272](https://github.com/github-api/github-api/pull/272) ([noctarius](https://github.com/noctarius)) +- \[\#269\] Add reopen method on GHMilestone [\#270](https://github.com/github-api/github-api/pull/270) ([szpak](https://github.com/szpak)) + +## [github-api-1.75](https://github.com/github-api/github-api/tree/github-api-1.75) (2016-04-13) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.74...github-api-1.75) + +## [github-api-1.74](https://github.com/github-api/github-api/tree/github-api-1.74) (2016-03-19) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.73...github-api-1.74) + +**Closed issues:** + +- missing maven central dependencies in 1.72 [\#257](https://github.com/github-api/github-api/issues/257) +- Not able to specify client Id and client secret to connect using OAuth [\#256](https://github.com/github-api/github-api/issues/256) +- Stuck in Github connect [\#255](https://github.com/github-api/github-api/issues/255) +- Infinite loop in `GHNotificationStream$1.fetch\(\)` [\#252](https://github.com/github-api/github-api/issues/252) +- How to get statistics using this library [\#241](https://github.com/github-api/github-api/issues/241) + +**Merged pull requests:** + +- Animal sniffer [\#259](https://github.com/github-api/github-api/pull/259) ([Shredder121](https://github.com/Shredder121)) +- Better error messages [\#254](https://github.com/github-api/github-api/pull/254) ([cyrille-leclerc](https://github.com/cyrille-leclerc)) +- Fix \#252: infinite loop because the "hypertext engine" generates invalid URLs [\#253](https://github.com/github-api/github-api/pull/253) ([cyrille-leclerc](https://github.com/cyrille-leclerc)) +- Improve checkApiUrlValidity\(\) method [\#251](https://github.com/github-api/github-api/pull/251) ([recena](https://github.com/recena)) + +## [github-api-1.73](https://github.com/github-api/github-api/tree/github-api-1.73) (2016-03-01) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.72...github-api-1.73) + +**Closed issues:** + +- traceback if webhook set to "send me everything". [\#250](https://github.com/github-api/github-api/issues/250) +- Error on github pull request populate [\#246](https://github.com/github-api/github-api/issues/246) +- How to avoid connection timeout while using github.listallpublicrepositories [\#243](https://github.com/github-api/github-api/issues/243) +- myissues [\#242](https://github.com/github-api/github-api/issues/242) +- Question - Stargazers and stars release. [\#239](https://github.com/github-api/github-api/issues/239) +- GHEventInfo getPayload [\#238](https://github.com/github-api/github-api/issues/238) + +**Merged pull requests:** + +- Added getHtmlUrl\(\) to GHCommit [\#249](https://github.com/github-api/github-api/pull/249) ([zapelin](https://github.com/zapelin)) +- Populate commit with data for getCommitShortInfo [\#248](https://github.com/github-api/github-api/pull/248) ([daniel-beck](https://github.com/daniel-beck)) +- Fix error when creating email service hook [\#245](https://github.com/github-api/github-api/pull/245) ([daniel-beck](https://github.com/daniel-beck)) +- Minor amendment to the documentation [\#244](https://github.com/github-api/github-api/pull/244) ([benbek](https://github.com/benbek)) +- Support for auto\_init [\#240](https://github.com/github-api/github-api/pull/240) ([dlovera](https://github.com/dlovera)) + +## [github-api-1.72](https://github.com/github-api/github-api/tree/github-api-1.72) (2015-12-10) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.71...github-api-1.72) + +**Fixed bugs:** + +- GHRepository.getCompare\(GHBranch, GHBranch\) does not allow for cross-fork compares [\#218](https://github.com/github-api/github-api/issues/218) + +**Closed issues:** + +- Access to raw JSON for issues? [\#235](https://github.com/github-api/github-api/issues/235) +- GHRepository.getPullRequests\(\) / listPullRequests\(\) does not support the sort parameter [\#234](https://github.com/github-api/github-api/issues/234) +- Commit obtained by queryCommits does not contain files [\#230](https://github.com/github-api/github-api/issues/230) +- get starred projects by the user [\#228](https://github.com/github-api/github-api/issues/228) +- update of file in github [\#227](https://github.com/github-api/github-api/issues/227) +- Add per\_page paramter to the search builders [\#221](https://github.com/github-api/github-api/issues/221) +- RateLimitHandler Bug [\#220](https://github.com/github-api/github-api/issues/220) +- Followers and following pagination [\#213](https://github.com/github-api/github-api/issues/213) +- Some features of this plugin no longer work with the recent changes to api.github.com [\#202](https://github.com/github-api/github-api/issues/202) +- Add an option to get the id of an event [\#199](https://github.com/github-api/github-api/issues/199) +- Need documentation for how to clone a git repo to the disk [\#196](https://github.com/github-api/github-api/issues/196) +- JDK Version [\#188](https://github.com/github-api/github-api/issues/188) +- Obtain Pushed Commit using GitHub API [\#186](https://github.com/github-api/github-api/issues/186) +- @WithBridgeMethods decorator in GHObject has no value adapterMethod [\#171](https://github.com/github-api/github-api/issues/171) + +## [github-api-1.71](https://github.com/github-api/github-api/tree/github-api-1.71) (2015-12-01) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.70...github-api-1.71) + +**Fixed bugs:** + +- \#218 enable cross fork compare [\#219](https://github.com/github-api/github-api/pull/219) ([if6was9](https://github.com/if6was9)) +- \#215 fix read\(\) failure with private repos [\#216](https://github.com/github-api/github-api/pull/216) ([if6was9](https://github.com/if6was9)) + +**Closed issues:** + +- Push to repo [\#229](https://github.com/github-api/github-api/issues/229) +- Can not find the .github file [\#223](https://github.com/github-api/github-api/issues/223) +- Can not find the .github file [\#222](https://github.com/github-api/github-api/issues/222) +- GHContent.read\(\) is broken due to incorrect HTTP Method [\#215](https://github.com/github-api/github-api/issues/215) + +**Merged pull requests:** + +- Use default timeouts for URLConnections [\#237](https://github.com/github-api/github-api/pull/237) ([olivergondza](https://github.com/olivergondza)) +- Findbugs plugin has been upgraded [\#236](https://github.com/github-api/github-api/pull/236) ([recena](https://github.com/recena)) +- Add information about mirror url if it exist. [\#233](https://github.com/github-api/github-api/pull/233) ([vparfonov](https://github.com/vparfonov)) +- Added a new method to validate the GitHub API URL [\#232](https://github.com/github-api/github-api/pull/232) ([recena](https://github.com/recena)) +- Support for merge\_commit\_sha [\#231](https://github.com/github-api/github-api/pull/231) ([recena](https://github.com/recena)) +- Check builder result to either be a token or a user [\#226](https://github.com/github-api/github-api/pull/226) ([Shredder121](https://github.com/Shredder121)) +- Overzealous FindBugs changes. [\#225](https://github.com/github-api/github-api/pull/225) ([Shredder121](https://github.com/Shredder121)) +- Remove trailing slash when requesting directory content [\#224](https://github.com/github-api/github-api/pull/224) ([Shredder121](https://github.com/Shredder121)) +- Support Milestone closed\_at date [\#217](https://github.com/github-api/github-api/pull/217) ([dblevins](https://github.com/dblevins)) + +## [github-api-1.70](https://github.com/github-api/github-api/tree/github-api-1.70) (2015-08-15) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.69...github-api-1.70) + +**Closed issues:** + +- How to search all repos based on a keyword? [\#211](https://github.com/github-api/github-api/issues/211) +- Missing: List private organizations a user belongs [\#209](https://github.com/github-api/github-api/issues/209) + +**Merged pull requests:** + +- Added option to edit GitHub release once it is created [\#212](https://github.com/github-api/github-api/pull/212) ([umajeric](https://github.com/umajeric)) +- Cleanup issues discovered by FindBugs [\#210](https://github.com/github-api/github-api/pull/210) ([oleg-nenashev](https://github.com/oleg-nenashev)) + +## [github-api-1.69](https://github.com/github-api/github-api/tree/github-api-1.69) (2015-07-17) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.68...github-api-1.69) + +**Closed issues:** + +- NullPointerException in Requester.java [\#194](https://github.com/github-api/github-api/issues/194) +- Dependency problems [\#191](https://github.com/github-api/github-api/issues/191) +- Enable this to work with GitHub Enterprise [\#184](https://github.com/github-api/github-api/issues/184) +- no way to list forks of a repository [\#183](https://github.com/github-api/github-api/issues/183) +- Nothing is Fetched when calling repo.listNotifications\(\); [\#181](https://github.com/github-api/github-api/issues/181) +- java.net.ProtocolException: DELETE does not support writing [\#180](https://github.com/github-api/github-api/issues/180) + +**Merged pull requests:** + +- Fix potential NPE in the code [\#208](https://github.com/github-api/github-api/pull/208) ([oleg-nenashev](https://github.com/oleg-nenashev)) +- Enable FindBugs in the repo [\#207](https://github.com/github-api/github-api/pull/207) ([oleg-nenashev](https://github.com/oleg-nenashev)) +- Specified the GET [\#206](https://github.com/github-api/github-api/pull/206) ([torodev](https://github.com/torodev)) +- Fix NPE found when resolving issues from search api [\#205](https://github.com/github-api/github-api/pull/205) ([stephenc](https://github.com/stephenc)) +- add ping event to GH events enum [\#204](https://github.com/github-api/github-api/pull/204) ([lanwen](https://github.com/lanwen)) +- GitHub API have changed the semantics of /user/repos API [\#203](https://github.com/github-api/github-api/pull/203) ([lucamilanesio](https://github.com/lucamilanesio)) +- Add support for update/delete operations on issue comments [\#201](https://github.com/github-api/github-api/pull/201) ([henryju](https://github.com/henryju)) +- fix for unused json map when method with body, but body is null [\#200](https://github.com/github-api/github-api/pull/200) ([lanwen](https://github.com/lanwen)) +- fix for GH Enterprise which does not have rate limit reset field [\#198](https://github.com/github-api/github-api/pull/198) ([lanwen](https://github.com/lanwen)) +- added Page Build [\#197](https://github.com/github-api/github-api/pull/197) ([treeduck](https://github.com/treeduck)) +- Enable creation and retrieval of org webhooks [\#192](https://github.com/github-api/github-api/pull/192) ([chrisrhut](https://github.com/chrisrhut)) +- allow default branch to be set [\#190](https://github.com/github-api/github-api/pull/190) ([if6was9](https://github.com/if6was9)) +- fixed regression that caused POST operations to be sent as GET [\#189](https://github.com/github-api/github-api/pull/189) ([if6was9](https://github.com/if6was9)) +- Recognize previous\_file field in GHCommit.File [\#187](https://github.com/github-api/github-api/pull/187) ([yegorius](https://github.com/yegorius)) +- Fixes \#183: added a method listForks\(\) to GHRepository [\#185](https://github.com/github-api/github-api/pull/185) ([marc-guenther](https://github.com/marc-guenther)) +- Fix invalid URL for pull request comments update/delete [\#182](https://github.com/github-api/github-api/pull/182) ([henryju](https://github.com/henryju)) + +## [github-api-1.68](https://github.com/github-api/github-api/tree/github-api-1.68) (2015-04-20) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.67...github-api-1.68) + +**Closed issues:** + +- Merging with SHA1 [\#176](https://github.com/github-api/github-api/issues/176) + +**Merged pull requests:** + +- Fix NullPointerException on RateLimitHandler when handling API errors. [\#179](https://github.com/github-api/github-api/pull/179) ([lskillen](https://github.com/lskillen)) + +## [github-api-1.67](https://github.com/github-api/github-api/tree/github-api-1.67) (2015-04-14) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.66...github-api-1.67) + +**Merged pull requests:** + +- Added getters for the objects notifications refer to [\#177](https://github.com/github-api/github-api/pull/177) ([syniuhin](https://github.com/syniuhin)) +- Added the source attribute to GHRepository [\#175](https://github.com/github-api/github-api/pull/175) ([kickroot](https://github.com/kickroot)) +- Improvements [\#170](https://github.com/github-api/github-api/pull/170) ([KostyaSha](https://github.com/KostyaSha)) +- Throw error for bad creds [\#169](https://github.com/github-api/github-api/pull/169) ([KostyaSha](https://github.com/KostyaSha)) + +## [github-api-1.66](https://github.com/github-api/github-api/tree/github-api-1.66) (2015-03-24) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.64...github-api-1.66) + +**Closed issues:** + +- Rate limiting causes silent freezing failures [\#172](https://github.com/github-api/github-api/issues/172) +- Pluggable persistent cache support [\#168](https://github.com/github-api/github-api/issues/168) +- Implement /search [\#158](https://github.com/github-api/github-api/issues/158) +- Support notifications api [\#119](https://github.com/github-api/github-api/issues/119) +- Consider committing to using OkHttp in preference to HttpURLConnection [\#104](https://github.com/github-api/github-api/issues/104) + +## [github-api-1.64](https://github.com/github-api/github-api/tree/github-api-1.64) (2015-03-22) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.63...github-api-1.64) + +**Closed issues:** + +- SBT build is broken from version 1.53 [\#167](https://github.com/github-api/github-api/issues/167) +- Reading a gist in anonymonous mode causes error [\#166](https://github.com/github-api/github-api/issues/166) +- Add support for the Markdown API [\#165](https://github.com/github-api/github-api/issues/165) +- GHContent\#content always returns master version [\#162](https://github.com/github-api/github-api/issues/162) +- infinite Thread usage loop with handleApiError [\#159](https://github.com/github-api/github-api/issues/159) +- /repositories? [\#157](https://github.com/github-api/github-api/issues/157) +- 502 Bad Gateway error from GHRelease.uploadAsset [\#135](https://github.com/github-api/github-api/issues/135) + +**Merged pull requests:** + +- Add method to get the list of languages using in repository [\#161](https://github.com/github-api/github-api/pull/161) ([khoa-nd](https://github.com/khoa-nd)) +- Picking endpoint from the properties file and environment variables [\#156](https://github.com/github-api/github-api/pull/156) ([ashwanthkumar](https://github.com/ashwanthkumar)) +- Implementing github trees [\#155](https://github.com/github-api/github-api/pull/155) ([ddtxra](https://github.com/ddtxra)) + +## [github-api-1.63](https://github.com/github-api/github-api/tree/github-api-1.63) (2015-03-02) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.62...github-api-1.63) + +**Closed issues:** + +- Github Trees support [\#153](https://github.com/github-api/github-api/issues/153) +- getEvents fails periodically with odd exception [\#92](https://github.com/github-api/github-api/issues/92) + +## [github-api-1.62](https://github.com/github-api/github-api/tree/github-api-1.62) (2015-02-15) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.61...github-api-1.62) + +**Closed issues:** + +- "Stars" and "Forks" parameters for Gist [\#154](https://github.com/github-api/github-api/issues/154) +- NPE during tag.getCommit\(\).getLastStatus\(\) [\#152](https://github.com/github-api/github-api/issues/152) +- Incorrect behavior of GHRepository.getReadme [\#150](https://github.com/github-api/github-api/issues/150) +- Make public GHRepository.getOwnerName [\#149](https://github.com/github-api/github-api/issues/149) +- Add information about thread-safety in Javadoc [\#148](https://github.com/github-api/github-api/issues/148) +- Add API to retrieve list of contributors [\#147](https://github.com/github-api/github-api/issues/147) +- Parsing a push event payload doesn't get the repository [\#144](https://github.com/github-api/github-api/issues/144) +- GHRelease issue [\#138](https://github.com/github-api/github-api/issues/138) +- GHRepository.getIssues\(GHIssueState.CLOSED\) also return pull requests [\#134](https://github.com/github-api/github-api/issues/134) +- Feature: watched Repositories [\#130](https://github.com/github-api/github-api/issues/130) +- Cannot create repository in organisation [\#118](https://github.com/github-api/github-api/issues/118) +- Different ways of getting issue.getClosedby\(\) return different results. [\#113](https://github.com/github-api/github-api/issues/113) +- NullPointerException in GHPerson [\#111](https://github.com/github-api/github-api/issues/111) +- Suggested enhancement: GHPerson\#getAllRepositories\(\) [\#110](https://github.com/github-api/github-api/issues/110) +- add support for proxy [\#109](https://github.com/github-api/github-api/issues/109) +- Error while accessing rate limit API - No subject alternative DNS name matching api.github.com found. [\#108](https://github.com/github-api/github-api/issues/108) +- Add support for retrieving repository available labels [\#105](https://github.com/github-api/github-api/issues/105) +- getReadme its outdated [\#99](https://github.com/github-api/github-api/issues/99) + +## [github-api-1.61](https://github.com/github-api/github-api/tree/github-api-1.61) (2015-02-14) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.60...github-api-1.61) + +## [github-api-1.60](https://github.com/github-api/github-api/tree/github-api-1.60) (2015-02-14) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.59...github-api-1.60) + +**Closed issues:** + +- GHTeam.getMembers\(\) response does not include all users if user count \>30 [\#145](https://github.com/github-api/github-api/issues/145) + +**Merged pull requests:** + +- fix \#145 GHTeam.getMembers\(\) does not page properly [\#146](https://github.com/github-api/github-api/pull/146) ([if6was9](https://github.com/if6was9)) +- Complete api implementation for the new github deployment api [\#143](https://github.com/github-api/github-api/pull/143) ([suryagaddipati](https://github.com/suryagaddipati)) +- Add code for creating deployments for a repo [\#142](https://github.com/github-api/github-api/pull/142) ([suryagaddipati](https://github.com/suryagaddipati)) +- Trivial change to enable creating/updating binary content \(files\). [\#141](https://github.com/github-api/github-api/pull/141) ([alvaro1728](https://github.com/alvaro1728)) +- Put mockito in the test scope. [\#139](https://github.com/github-api/github-api/pull/139) ([farmdawgnation](https://github.com/farmdawgnation)) +- added 'diverged' constant to GHCompare.Status enum [\#137](https://github.com/github-api/github-api/pull/137) ([simonecarriero](https://github.com/simonecarriero)) +- Add paging support for Team's Repositories [\#136](https://github.com/github-api/github-api/pull/136) ([rtyley](https://github.com/rtyley)) + +## [github-api-1.59](https://github.com/github-api/github-api/tree/github-api-1.59) (2014-10-08) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.58...github-api-1.59) + +**Merged pull requests:** + +- Add GHCompare.getFiles\(\) method to be able to see the precise files chan... [\#132](https://github.com/github-api/github-api/pull/132) ([mocleiri](https://github.com/mocleiri)) +- Modify GitHubBuilder to resolve user credentials from the system environ... [\#131](https://github.com/github-api/github-api/pull/131) ([mocleiri](https://github.com/mocleiri)) +- Allow pullRequest.getHead\(\).getRepository\(\).getCommit\(headSha1\) to work [\#129](https://github.com/github-api/github-api/pull/129) ([mocleiri](https://github.com/mocleiri)) +- Update github scopes according to https://developer.github.com/v3/oauth/\#scopes [\#128](https://github.com/github-api/github-api/pull/128) ([ndeloof](https://github.com/ndeloof)) +- Allow to use custom HttpConnector when only OAuth token is given [\#124](https://github.com/github-api/github-api/pull/124) ([ohtake](https://github.com/ohtake)) +- Use issues endpoints for pull requests [\#123](https://github.com/github-api/github-api/pull/123) ([rtyley](https://github.com/rtyley)) +- Add missing field browser\_download\_url in GHAsset [\#122](https://github.com/github-api/github-api/pull/122) ([tbruyelle](https://github.com/tbruyelle)) + +## [github-api-1.58](https://github.com/github-api/github-api/tree/github-api-1.58) (2014-08-30) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.57...github-api-1.58) + +**Merged pull requests:** + +- All the refs worth knowing: Implementation of ref updating and deleting. [\#117](https://github.com/github-api/github-api/pull/117) ([farmdawgnation](https://github.com/farmdawgnation)) +- Remove getPath\(\) [\#116](https://github.com/github-api/github-api/pull/116) ([DavidTanner](https://github.com/DavidTanner)) +- Add missing GitHub event types. [\#115](https://github.com/github-api/github-api/pull/115) ([bernd](https://github.com/bernd)) +- get repository full name \(including owner\) [\#114](https://github.com/github-api/github-api/pull/114) ([ndeloof](https://github.com/ndeloof)) +- General pagination [\#107](https://github.com/github-api/github-api/pull/107) ([msperisen](https://github.com/msperisen)) + +## [github-api-1.57](https://github.com/github-api/github-api/tree/github-api-1.57) (2014-08-19) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.56...github-api-1.57) + +**Merged pull requests:** + +- Get all orgs/teams/permissions in a single GitHub API call [\#112](https://github.com/github-api/github-api/pull/112) ([lucamilanesio](https://github.com/lucamilanesio)) +- Implement pagination on list of private+public repos of a user. [\#106](https://github.com/github-api/github-api/pull/106) ([lucamilanesio](https://github.com/lucamilanesio)) + +## [github-api-1.56](https://github.com/github-api/github-api/tree/github-api-1.56) (2014-07-03) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.55...github-api-1.56) + +**Closed issues:** + +- Unable to access commit date through api. [\#100](https://github.com/github-api/github-api/issues/100) +- Add support for commit status contexts. [\#96](https://github.com/github-api/github-api/issues/96) + +**Merged pull requests:** + +- Update to OkHttp 2.0.0, which has a new OkUrlFactory [\#103](https://github.com/github-api/github-api/pull/103) ([rtyley](https://github.com/rtyley)) +- Better FNFE from delete\(\) [\#102](https://github.com/github-api/github-api/pull/102) ([jglick](https://github.com/jglick)) +- Un-finalize a handful of classes. [\#101](https://github.com/github-api/github-api/pull/101) ([farmdawgnation](https://github.com/farmdawgnation)) + +## [github-api-1.55](https://github.com/github-api/github-api/tree/github-api-1.55) (2014-06-08) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.54...github-api-1.55) + +**Merged pull requests:** + +- Add support for adding context to commit status. [\#97](https://github.com/github-api/github-api/pull/97) ([suryagaddipati](https://github.com/suryagaddipati)) + +## [github-api-1.54](https://github.com/github-api/github-api/tree/github-api-1.54) (2014-06-05) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.53...github-api-1.54) + +**Closed issues:** + +- Version 1.8 of bridge-method-annotation not available in maven central [\#91](https://github.com/github-api/github-api/issues/91) +- Ability to specify both branch and sha parameters at same time in GHCommitQueryBuilder [\#90](https://github.com/github-api/github-api/issues/90) + +**Merged pull requests:** + +- Add support for retriving a single ref [\#95](https://github.com/github-api/github-api/pull/95) ([suryagaddipati](https://github.com/suryagaddipati)) +- Add support for adding deploykeys to repo [\#94](https://github.com/github-api/github-api/pull/94) ([suryagaddipati](https://github.com/suryagaddipati)) +- Upgrading to 1.12 version for bridge-method-annotation and bridge-method-injector - fix for \#91 [\#93](https://github.com/github-api/github-api/pull/93) ([vr100](https://github.com/vr100)) + +## [github-api-1.53](https://github.com/github-api/github-api/tree/github-api-1.53) (2014-05-10) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.52...github-api-1.53) + +**Closed issues:** + +- GHUser.getRepositories\(\) does not pull private repositories [\#88](https://github.com/github-api/github-api/issues/88) +- create pull requests? [\#79](https://github.com/github-api/github-api/issues/79) +- getRateLimit\(\) fails for GitHub Enterprise [\#78](https://github.com/github-api/github-api/issues/78) +- GHRepository assumes public github.com, won't work with github enterprise [\#64](https://github.com/github-api/github-api/issues/64) +- Getting private repositories for a private organization [\#62](https://github.com/github-api/github-api/issues/62) +- ClosedBy returns nothing for closed issues [\#60](https://github.com/github-api/github-api/issues/60) +- class file for com.infradna.tool.bridge\_method\_injector.WithBridgeMethods not found [\#54](https://github.com/github-api/github-api/issues/54) +- add support of Gists [\#53](https://github.com/github-api/github-api/issues/53) +- GHUser is missing a getHTMLURL\(\) method [\#52](https://github.com/github-api/github-api/issues/52) +- \[Feature Request\] get tags [\#40](https://github.com/github-api/github-api/issues/40) +- GitHub.connectAnonymously\(\) fails because of a lack of credentials. [\#39](https://github.com/github-api/github-api/issues/39) + +**Merged pull requests:** + +- create a Release & Branch [\#84](https://github.com/github-api/github-api/pull/84) ([fanfansama](https://github.com/fanfansama)) + +## [github-api-1.52](https://github.com/github-api/github-api/tree/github-api-1.52) (2014-05-10) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.51...github-api-1.52) + +**Closed issues:** + +- File size limited to 1MB [\#85](https://github.com/github-api/github-api/issues/85) + +**Merged pull requests:** + +- Fix bug in GHMyself.getEmails due to API change [\#87](https://github.com/github-api/github-api/pull/87) ([kellycampbell](https://github.com/kellycampbell)) +- Using builder pattern to list commits in a repo by author, branch, etc [\#86](https://github.com/github-api/github-api/pull/86) ([vr100](https://github.com/vr100)) +- add tarball\_url and zipball\_url to GHRelease [\#83](https://github.com/github-api/github-api/pull/83) ([antonkrasov](https://github.com/antonkrasov)) + +## [github-api-1.51](https://github.com/github-api/github-api/tree/github-api-1.51) (2014-04-13) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.50...github-api-1.51) + +**Closed issues:** + +- Add support for setting explicit connection timeouts [\#81](https://github.com/github-api/github-api/issues/81) +- Throwing an Error when an IOException occurs is overly fatal [\#65](https://github.com/github-api/github-api/issues/65) + +**Merged pull requests:** + +- Cast url.openConnection\(\) to HttpURLConnection instead of HttpsURLConnec... [\#82](https://github.com/github-api/github-api/pull/82) ([prazanna](https://github.com/prazanna)) +- Add support for removing a user from an Organisation [\#80](https://github.com/github-api/github-api/pull/80) ([rtyley](https://github.com/rtyley)) + +## [github-api-1.50](https://github.com/github-api/github-api/tree/github-api-1.50) (2014-03-28) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.49...github-api-1.50) + +**Closed issues:** + +- publish 1.49 version to jenkins maven repo [\#63](https://github.com/github-api/github-api/issues/63) + +**Merged pull requests:** + +- Add org public-members call, to complement the full members list [\#76](https://github.com/github-api/github-api/pull/76) ([rtyley](https://github.com/rtyley)) +- Support the check-user-team-membership API call [\#75](https://github.com/github-api/github-api/pull/75) ([rtyley](https://github.com/rtyley)) +- Fix GHIssue.setLabels\(\) [\#73](https://github.com/github-api/github-api/pull/73) ([rtyley](https://github.com/rtyley)) +- Un-finalize GHContent. [\#72](https://github.com/github-api/github-api/pull/72) ([farmdawgnation](https://github.com/farmdawgnation)) +- Created new method to automate the merge [\#69](https://github.com/github-api/github-api/pull/69) ([vanjikumaran](https://github.com/vanjikumaran)) +- Enable org member filtering [\#68](https://github.com/github-api/github-api/pull/68) ([lindseydew](https://github.com/lindseydew)) +- Support paging when fetching organization members [\#66](https://github.com/github-api/github-api/pull/66) ([ryankennedy](https://github.com/ryankennedy)) + +## [github-api-1.49](https://github.com/github-api/github-api/tree/github-api-1.49) (2014-01-06) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.48...github-api-1.49) + +## [github-api-1.48](https://github.com/github-api/github-api/tree/github-api-1.48) (2014-01-06) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.47...github-api-1.48) + +**Closed issues:** + +- Implement Contents API [\#46](https://github.com/github-api/github-api/issues/46) + +**Merged pull requests:** + +- Fetching of user's verified keys through standard OAuth scope. [\#61](https://github.com/github-api/github-api/pull/61) ([lucamilanesio](https://github.com/lucamilanesio)) +- Contents API [\#59](https://github.com/github-api/github-api/pull/59) ([farmdawgnation](https://github.com/farmdawgnation)) + +## [github-api-1.47](https://github.com/github-api/github-api/tree/github-api-1.47) (2013-11-27) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.46...github-api-1.47) + +**Closed issues:** + +- github /user/orgs fails [\#57](https://github.com/github-api/github-api/issues/57) +- GHRepository.getIssues\(\) limited to 30 issues [\#55](https://github.com/github-api/github-api/issues/55) + +**Merged pull requests:** + +- Add support for PULL\_REQUEST\_REVIEW\_COMMENT event types. [\#58](https://github.com/github-api/github-api/pull/58) ([rtholmes](https://github.com/rtholmes)) +- Use `PagedIterator\` to retrieve repository issues [\#56](https://github.com/github-api/github-api/pull/56) ([endeavor85](https://github.com/endeavor85)) + +## [github-api-1.46](https://github.com/github-api/github-api/tree/github-api-1.46) (2013-11-13) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.45...github-api-1.46) + +## [github-api-1.45](https://github.com/github-api/github-api/tree/github-api-1.45) (2013-11-09) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.44...github-api-1.45) + +**Closed issues:** + +- Issue labels have multiple fields now [\#48](https://github.com/github-api/github-api/issues/48) + +**Merged pull requests:** + +- add support \(most of\) the release-related endpoints [\#51](https://github.com/github-api/github-api/pull/51) ([evanchooly](https://github.com/evanchooly)) +- Updates Jackson to 2.2.3 [\#50](https://github.com/github-api/github-api/pull/50) ([pescuma](https://github.com/pescuma)) +- Use a proper Label in GHIssues [\#49](https://github.com/github-api/github-api/pull/49) ([pescuma](https://github.com/pescuma)) +- Allows to define page size for repository lists and other API enhancements [\#45](https://github.com/github-api/github-api/pull/45) ([lucamilanesio](https://github.com/lucamilanesio)) + +## [github-api-1.44](https://github.com/github-api/github-api/tree/github-api-1.44) (2013-09-07) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.43...github-api-1.44) + +**Closed issues:** + +- getMergeableState in GHPullRequest doesn't work [\#41](https://github.com/github-api/github-api/issues/41) + +**Merged pull requests:** + +- GHMyself should allow accessing the private repos and orgs too [\#43](https://github.com/github-api/github-api/pull/43) ([stephenc](https://github.com/stephenc)) +- Commit's short info model [\#42](https://github.com/github-api/github-api/pull/42) ([paulbutenko](https://github.com/paulbutenko)) + +## [github-api-1.43](https://github.com/github-api/github-api/tree/github-api-1.43) (2013-07-07) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.42...github-api-1.43) + +## [github-api-1.42](https://github.com/github-api/github-api/tree/github-api-1.42) (2013-05-07) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.41...github-api-1.42) + +**Merged pull requests:** + +- add repository to Pull Request payload and wrap the PR with the repository [\#38](https://github.com/github-api/github-api/pull/38) ([janinko](https://github.com/janinko)) +- Force issues-based API route for PR comments [\#37](https://github.com/github-api/github-api/pull/37) ([spiffxp](https://github.com/spiffxp)) +- Allow oauthToken to be used without login [\#36](https://github.com/github-api/github-api/pull/36) ([spiffxp](https://github.com/spiffxp)) + +## [github-api-1.41](https://github.com/github-api/github-api/tree/github-api-1.41) (2013-04-23) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.40...github-api-1.41) + +**Closed issues:** + +- Closing pull request using Github API return FileNotFoundException [\#34](https://github.com/github-api/github-api/issues/34) + +**Merged pull requests:** + +- Stop using deprecated API tokens for Enterprise [\#33](https://github.com/github-api/github-api/pull/33) ([watsonian](https://github.com/watsonian)) + +## [github-api-1.40](https://github.com/github-api/github-api/tree/github-api-1.40) (2013-04-16) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.39...github-api-1.40) + +## [github-api-1.39](https://github.com/github-api/github-api/tree/github-api-1.39) (2013-04-16) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.38...github-api-1.39) + +**Merged pull requests:** + +- Provide a way to determine if the connection is anonymous [\#44](https://github.com/github-api/github-api/pull/44) ([stephenc](https://github.com/stephenc)) +- Implement GHEventPayload.IssueComment [\#32](https://github.com/github-api/github-api/pull/32) ([janinko](https://github.com/janinko)) +- implement retrieving of access token [\#31](https://github.com/github-api/github-api/pull/31) ([janinko](https://github.com/janinko)) + +## [github-api-1.38](https://github.com/github-api/github-api/tree/github-api-1.38) (2013-04-07) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.37...github-api-1.38) + +**Closed issues:** + +- Error 500 - No Protocol [\#29](https://github.com/github-api/github-api/issues/29) + +## [github-api-1.37](https://github.com/github-api/github-api/tree/github-api-1.37) (2013-03-15) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.36...github-api-1.37) + +**Merged pull requests:** + +- Adding Compare and Refs commands to API [\#30](https://github.com/github-api/github-api/pull/30) ([mc1arke](https://github.com/mc1arke)) + +## [github-api-1.36](https://github.com/github-api/github-api/tree/github-api-1.36) (2013-01-24) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.35...github-api-1.36) + +## [github-api-1.35](https://github.com/github-api/github-api/tree/github-api-1.35) (2013-01-07) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.34...github-api-1.35) + +**Closed issues:** + +- Support for organization check mebership [\#23](https://github.com/github-api/github-api/issues/23) + +**Merged pull requests:** + +- Password is no longer required for api usage and fix for broken base64 encoding. [\#27](https://github.com/github-api/github-api/pull/27) ([johnou](https://github.com/johnou)) +- Removed web client and proprietary api usage. [\#26](https://github.com/github-api/github-api/pull/26) ([johnou](https://github.com/johnou)) + +## [github-api-1.34](https://github.com/github-api/github-api/tree/github-api-1.34) (2013-01-06) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.33...github-api-1.34) + +**Closed issues:** + +- Enterprise Github without HTTPS not supported [\#12](https://github.com/github-api/github-api/issues/12) + +**Merged pull requests:** + +- JENKINS-13726: Github plugin should work with Github enterprise by allowing for overriding the github URL. [\#24](https://github.com/github-api/github-api/pull/24) ([johnou](https://github.com/johnou)) +- Retrieve repository directly. [\#22](https://github.com/github-api/github-api/pull/22) ([janinko](https://github.com/janinko)) + +## [github-api-1.33](https://github.com/github-api/github-api/tree/github-api-1.33) (2012-09-13) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.32...github-api-1.33) + +**Closed issues:** + +- GHIssue.getComments\(\) throws NoSuchElementException when there are no comments [\#20](https://github.com/github-api/github-api/issues/20) +- scm in pom.xml is incorrect [\#14](https://github.com/github-api/github-api/issues/14) +- support for: Create an issue POST /repos/:user/:repo/issues [\#13](https://github.com/github-api/github-api/issues/13) + +**Merged pull requests:** + +- PagedIterable dosn't use authentication [\#19](https://github.com/github-api/github-api/pull/19) ([janinko](https://github.com/janinko)) +- When using lazy population, this is not deprecated [\#18](https://github.com/github-api/github-api/pull/18) ([janinko](https://github.com/janinko)) + +## [github-api-1.32](https://github.com/github-api/github-api/tree/github-api-1.32) (2012-09-06) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.31...github-api-1.32) + +**Merged pull requests:** + +- Issues pull requests apiv3 [\#17](https://github.com/github-api/github-api/pull/17) ([janinko](https://github.com/janinko)) + +## [github-api-1.31](https://github.com/github-api/github-api/tree/github-api-1.31) (2012-08-28) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.30...github-api-1.31) + +**Merged pull requests:** + +- Fixes for github api v3 [\#16](https://github.com/github-api/github-api/pull/16) ([janinko](https://github.com/janinko)) + +## [github-api-1.30](https://github.com/github-api/github-api/tree/github-api-1.30) (2012-08-28) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.29...github-api-1.30) + +**Merged pull requests:** + +- Using pagination when getting Pull Requests from a repository [\#15](https://github.com/github-api/github-api/pull/15) ([athieriot](https://github.com/athieriot)) + +## [github-api-1.29](https://github.com/github-api/github-api/tree/github-api-1.29) (2012-06-18) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.28...github-api-1.29) + +**Closed issues:** + +- NPE Crash on 1.27 [\#11](https://github.com/github-api/github-api/issues/11) +- Github API V2 shuts down [\#8](https://github.com/github-api/github-api/issues/8) + +## [github-api-1.28](https://github.com/github-api/github-api/tree/github-api-1.28) (2012-06-13) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.27...github-api-1.28) + +## [github-api-1.27](https://github.com/github-api/github-api/tree/github-api-1.27) (2012-06-12) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.26...github-api-1.27) + +## [github-api-1.26](https://github.com/github-api/github-api/tree/github-api-1.26) (2012-06-04) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.25...github-api-1.26) + +## [github-api-1.25](https://github.com/github-api/github-api/tree/github-api-1.25) (2012-05-22) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.24...github-api-1.25) + +## [github-api-1.24](https://github.com/github-api/github-api/tree/github-api-1.24) (2012-05-22) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.23...github-api-1.24) + +## [github-api-1.23](https://github.com/github-api/github-api/tree/github-api-1.23) (2012-04-25) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.22...github-api-1.23) + +## [github-api-1.22](https://github.com/github-api/github-api/tree/github-api-1.22) (2012-04-12) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.21...github-api-1.22) + +## [github-api-1.21](https://github.com/github-api/github-api/tree/github-api-1.21) (2012-04-12) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.20...github-api-1.21) + +**Closed issues:** + +- Link to Javadoc incorrect at http://github-api.kohsuke.org/ [\#4](https://github.com/github-api/github-api/issues/4) + +## [github-api-1.20](https://github.com/github-api/github-api/tree/github-api-1.20) (2012-04-11) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.19...github-api-1.20) + +## [github-api-1.19](https://github.com/github-api/github-api/tree/github-api-1.19) (2012-04-06) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.18...github-api-1.19) + +**Merged pull requests:** + +- Listing of branches in a repository [\#7](https://github.com/github-api/github-api/pull/7) ([derfred](https://github.com/derfred)) + +## [github-api-1.18](https://github.com/github-api/github-api/tree/github-api-1.18) (2012-03-08) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.17...github-api-1.18) + +**Merged pull requests:** + +- milestone api via v3 [\#6](https://github.com/github-api/github-api/pull/6) ([YusukeKokubo](https://github.com/YusukeKokubo)) + +## [github-api-1.17](https://github.com/github-api/github-api/tree/github-api-1.17) (2012-02-12) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.16...github-api-1.17) + +**Closed issues:** + +- error on getRepositories\(\) [\#5](https://github.com/github-api/github-api/issues/5) + +## [github-api-1.16](https://github.com/github-api/github-api/tree/github-api-1.16) (2012-01-03) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.15...github-api-1.16) + +**Merged pull requests:** + +- Fix for finding private repos on organizations [\#3](https://github.com/github-api/github-api/pull/3) ([jkrall](https://github.com/jkrall)) + +## [github-api-1.15](https://github.com/github-api/github-api/tree/github-api-1.15) (2012-01-01) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.14...github-api-1.15) + +## [github-api-1.14](https://github.com/github-api/github-api/tree/github-api-1.14) (2011-10-27) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.13...github-api-1.14) + +## [github-api-1.13](https://github.com/github-api/github-api/tree/github-api-1.13) (2011-09-15) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.12...github-api-1.13) + +**Merged pull requests:** + +- expose issue\_updated\_at. It looks like a better representation of update [\#2](https://github.com/github-api/github-api/pull/2) ([lacostej](https://github.com/lacostej)) + +## [github-api-1.12](https://github.com/github-api/github-api/tree/github-api-1.12) (2011-08-27) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.11...github-api-1.12) + +## [github-api-1.11](https://github.com/github-api/github-api/tree/github-api-1.11) (2011-08-27) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.10...github-api-1.11) + +## [github-api-1.10](https://github.com/github-api/github-api/tree/github-api-1.10) (2011-07-11) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.9...github-api-1.10) + +**Merged pull requests:** + +- Add support for oauth token and a way to see my organizations [\#1](https://github.com/github-api/github-api/pull/1) ([mocleiri](https://github.com/mocleiri)) + +## [github-api-1.9](https://github.com/github-api/github-api/tree/github-api-1.9) (2011-06-28) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.8...github-api-1.9) + +## [github-api-1.8](https://github.com/github-api/github-api/tree/github-api-1.8) (2011-06-17) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.7...github-api-1.8) + +## [github-api-1.7](https://github.com/github-api/github-api/tree/github-api-1.7) (2011-05-28) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.6...github-api-1.7) + +## [github-api-1.6](https://github.com/github-api/github-api/tree/github-api-1.6) (2011-03-16) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.5...github-api-1.6) + +## [github-api-1.5](https://github.com/github-api/github-api/tree/github-api-1.5) (2011-02-23) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.4...github-api-1.5) + +## [github-api-1.4](https://github.com/github-api/github-api/tree/github-api-1.4) (2010-12-14) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.3...github-api-1.4) + +## [github-api-1.3](https://github.com/github-api/github-api/tree/github-api-1.3) (2010-11-24) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.2...github-api-1.3) + +## [github-api-1.2](https://github.com/github-api/github-api/tree/github-api-1.2) (2010-04-19) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.1...github-api-1.2) + +## [github-api-1.1](https://github.com/github-api/github-api/tree/github-api-1.1) (2010-04-19) + +[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.0...github-api-1.1) + +## [github-api-1.0](https://github.com/github-api/github-api/tree/github-api-1.0) (2010-04-19) + +[Full Changelog](https://github.com/github-api/github-api/compare/ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396...github-api-1.0) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/README.md b/README.md index e3f7a64105..790494c72d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ -Java API for GitHub +# Java API for GitHub + +[![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/org.kohsuke/github-api?server=https%3A%2F%2Foss.sonatype.org)](https://mvnrepository.com/artifact/org.kohsuke/github-api) +[![Join the chat at https://gitter.im/github-api/github-api](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/github-api/github-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + See https://github-api.kohsuke.org/ for more details diff --git a/pom.xml b/pom.xml index ff4e21fbfb..f5e1fb4e77 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ github-api - 1.99 + 1.100 GitHub API for Java https://github-api.kohsuke.org/ GitHub API for Java @@ -17,7 +17,7 @@ scm:git:git@github.com/github-api/${project.artifactId}.git scm:git:ssh://git@github.com/github-api/${project.artifactId}.git https://${project.artifactId}.kohsuke.org/ - github-api-1.99 + github-api-1.100 @@ -33,8 +33,10 @@ 3.1.12 true 2.2 - 3.12.3 + 4.2.2 2.4.1 + format + sort .80 0.20 0.50 @@ -78,6 +80,7 @@ 3.1.1 8 + true @@ -152,17 +155,49 @@ - - com.infradna.tool - bridge-method-injector - 1.18 - - - - process - - - + + com.infradna.tool + bridge-method-injector + 1.18 + + + + process + + + + + + net.revelc.code.formatter + formatter-maven-plugin + 2.11.0 + + + + ${formatter-maven-plugin.goal} + + + src/main/resources/eclipse/formatter.xml + + + + + + net.revelc.code + impsort-maven-plugin + 1.3.2 + + *,java.,javax. + true + true + + + + + ${impsort-maven-plugin.goal} + + + com.github.spotbugs @@ -243,7 +278,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.0 + 2.10.1 commons-io @@ -280,10 +315,12 @@ ${okhttp3.version} true + + com.squareup.okhttp3 okhttp-urlconnection - ${okhttp3.version} + 3.12.3 true @@ -336,6 +373,15 @@ + + ci + + validate + check + + + + jacoco @@ -379,44 +425,44 @@ - - - - + + + + METHOD COVEREDRATIO ${jacoco.coverage.target.method} - - - - - + + + + + org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.** @@ -434,7 +480,7 @@ - release + release diff --git a/src/main/java/org/kohsuke/github/AbuseLimitHandler.java b/src/main/java/org/kohsuke/github/AbuseLimitHandler.java index 2c21cdaf9c..44847c3c30 100644 --- a/src/main/java/org/kohsuke/github/AbuseLimitHandler.java +++ b/src/main/java/org/kohsuke/github/AbuseLimitHandler.java @@ -8,7 +8,7 @@ * Pluggable strategy to determine what to do when the API abuse limit is hit. * * @author Kohsuke Kawaguchi - * @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) + * @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) * @see documentation * @see RateLimitHandler */ @@ -17,17 +17,18 @@ public abstract class AbuseLimitHandler { * Called when the library encounters HTTP error indicating that the API abuse limit is reached. * *

- * Any exception thrown from this method will cause the request to fail, and the caller of github-api - * will receive an exception. If this method returns normally, another request will be attempted. - * For that to make sense, the implementation needs to wait for some time. + * Any exception thrown from this method will cause the request to fail, and the caller of github-api will receive + * an exception. If this method returns normally, another request will be attempted. For that to make sense, the + * implementation needs to wait for some time. * - * @see API documentation from GitHub * @param e - * Exception from Java I/O layer. If you decide to fail the processing, you can throw - * this exception (or wrap this exception into another exception and throw it). + * Exception from Java I/O layer. If you decide to fail the processing, you can throw this exception (or + * wrap this exception into another exception and throw it). * @param uc - * Connection that resulted in an error. Useful for accessing other response headers. + * Connection that resulted in an error. Useful for accessing other response headers. * @throws IOException + * on failure + * @see API documentation from GitHub */ public abstract void onError(IOException e, HttpURLConnection uc) throws IOException; @@ -40,15 +41,16 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException { try { Thread.sleep(parseWaitTime(uc)); } catch (InterruptedException ex) { - throw (InterruptedIOException)new InterruptedIOException().initCause(e); + throw (InterruptedIOException) new InterruptedIOException().initCause(e); } } private long parseWaitTime(HttpURLConnection uc) { String v = uc.getHeaderField("Retry-After"); - if (v==null) return 60 * 1000; // can't tell, return 1 min + if (v == null) + return 60 * 1000; // can't tell, return 1 min - return Math.max(1000, Long.parseLong(v)*1000); + return Math.max(1000, Long.parseLong(v) * 1000); } }; @@ -58,7 +60,7 @@ private long parseWaitTime(HttpURLConnection uc) { public static final AbuseLimitHandler FAIL = new AbuseLimitHandler() { @Override public void onError(IOException e, HttpURLConnection uc) throws IOException { - throw (IOException)new IOException("Abuse limit reached").initCause(e); + throw (IOException) new IOException("Abuse limit reached").initCause(e); } }; } diff --git a/src/main/java/org/kohsuke/github/DeleteToken.java b/src/main/java/org/kohsuke/github/DeleteToken.java index d9d4724eb9..30079d0a21 100644 --- a/src/main/java/org/kohsuke/github/DeleteToken.java +++ b/src/main/java/org/kohsuke/github/DeleteToken.java @@ -28,7 +28,7 @@ /** * @author Kohsuke Kawaguchi */ -@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", +@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "Being constructed by JSON deserialization") class DeleteToken { public String delete_token; diff --git a/src/main/java/org/kohsuke/github/GHApp.java b/src/main/java/org/kohsuke/github/GHApp.java index d3a73354b2..affdf9eca1 100644 --- a/src/main/java/org/kohsuke/github/GHApp.java +++ b/src/main/java/org/kohsuke/github/GHApp.java @@ -1,7 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonProperty; - import java.io.IOException; import java.net.URL; import java.util.List; @@ -13,70 +11,130 @@ * A Github App. * * @author Paulo Miguel Almeida - * - * @see GitHub#getApp() + * @see GitHub#getApp() GitHub#getApp() */ - public class GHApp extends GHObject { private GitHub root; private GHUser owner; private String name; private String description; - @JsonProperty("external_url") private String externalUrl; - private Map permissions; + private Map permissions; private List events; - @JsonProperty("installations_count") private long installationsCount; - @JsonProperty("html_url") private String htmlUrl; - + /** + * Gets owner. + * + * @return the owner + */ public GHUser getOwner() { return owner; } + /** + * Sets owner. + * + * @param owner + * the owner + */ public void setOwner(GHUser owner) { this.owner = owner; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Sets name. + * + * @param name + * the name + */ public void setName(String name) { this.name = name; } + /** + * Gets description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Sets description. + * + * @param description + * the description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets external url. + * + * @return the external url + */ public String getExternalUrl() { return externalUrl; } + /** + * Sets external url. + * + * @param externalUrl + * the external url + */ public void setExternalUrl(String externalUrl) { this.externalUrl = externalUrl; } + /** + * Gets events. + * + * @return the events + */ public List getEvents() { return events; } + /** + * Sets events. + * + * @param events + * the events + */ public void setEvents(List events) { this.events = events; } + /** + * Gets installations count. + * + * @return the installations count + */ public long getInstallationsCount() { return installationsCount; } + /** + * Sets installations count. + * + * @param installationsCount + * the installations count + */ public void setInstallationsCount(long installationsCount) { this.installationsCount = installationsCount; } @@ -85,88 +143,132 @@ public URL getHtmlUrl() { return GitHub.parseURL(htmlUrl); } + /** + * Gets permissions. + * + * @return the permissions + */ public Map getPermissions() { return permissions; } + /** + * Sets permissions. + * + * @param permissions + * the permissions + */ public void setPermissions(Map permissions) { this.permissions = permissions; } - /*package*/ GHApp wrapUp(GitHub root) { + GHApp wrapUp(GitHub root) { this.root = root; return this; } /** * Obtains all the installations associated with this app. - * + *

* You must use a JWT to access this endpoint. * - * @see List installations * @return a list of App installations + * @see List installations */ - @Preview @Deprecated + @Preview + @Deprecated public PagedIterable listInstallations() { - return root.retrieve().withPreview(MACHINE_MAN) - .asPagedIterable( - "/app/installations", - GHAppInstallation[].class, - item -> item.wrapUp(root) ); + return root.retrieve() + .withPreview(MACHINE_MAN) + .asPagedIterable("/app/installations", GHAppInstallation[].class, item -> item.wrapUp(root)); } /** - * Obtain an installation associated with this app - * @param id - Installation Id - * + * Obtain an installation associated with this app. + *

* You must use a JWT to access this endpoint. * + * @param id + * Installation Id + * @return a GHAppInstallation + * @throws IOException + * on error * @see Get an installation */ - @Preview @Deprecated + @Preview + @Deprecated public GHAppInstallation getInstallationById(long id) throws IOException { - return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/app/installations/%d", id), GHAppInstallation.class).wrapUp(root); + return root.retrieve() + .withPreview(MACHINE_MAN) + .to(String.format("/app/installations/%d", id), GHAppInstallation.class) + .wrapUp(root); } /** - * Obtain an organization installation associated with this app - * @param name - Organization name - * + * Obtain an organization installation associated with this app. + *

* You must use a JWT to access this endpoint. * - * @see Get an organization installation + * @param name + * Organization name + * @return a GHAppInstallation + * @throws IOException + * on error + * @see Get an organization + * installation */ - @Preview @Deprecated + @Preview + @Deprecated public GHAppInstallation getInstallationByOrganization(String name) throws IOException { - return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/orgs/%s/installation", name), GHAppInstallation.class).wrapUp(root); + return root.retrieve() + .withPreview(MACHINE_MAN) + .to(String.format("/orgs/%s/installation", name), GHAppInstallation.class) + .wrapUp(root); } /** - * Obtain an repository installation associated with this app - * @param ownerName - Organization or user name - * @param repositoryName - Repository name - * + * Obtain an repository installation associated with this app. + *

* You must use a JWT to access this endpoint. * - * @see Get a repository installation + * @param ownerName + * Organization or user name + * @param repositoryName + * Repository name + * @return a GHAppInstallation + * @throws IOException + * on error + * @see Get a repository + * installation */ - @Preview @Deprecated + @Preview + @Deprecated public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException { - return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class).wrapUp(root); + return root.retrieve() + .withPreview(MACHINE_MAN) + .to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class) + .wrapUp(root); } /** - * Obtain a user installation associated with this app - * @param name - user name - * + * Obtain a user installation associated with this app. + *

* You must use a JWT to access this endpoint. * + * @param name + * user name + * @return a GHAppInstallation + * @throws IOException + * on error * @see Get a user installation */ - @Preview @Deprecated + @Preview + @Deprecated public GHAppInstallation getInstallationByUser(String name) throws IOException { - return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/users/%s/installation", name), GHAppInstallation.class).wrapUp(root); + return root.retrieve() + .withPreview(MACHINE_MAN) + .to(String.format("/users/%s/installation", name), GHAppInstallation.class) + .wrapUp(root); } } - diff --git a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java index 807ebcf102..29830425ba 100644 --- a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java +++ b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java @@ -1,6 +1,7 @@ package org.kohsuke.github; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -10,20 +11,20 @@ * Creates a access token for a GitHub App Installation * * @author Paulo Miguel Almeida - * - * @see GHAppInstallation#createToken(Map) + * @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map) */ public class GHAppCreateTokenBuilder { private final GitHub root; protected final Requester builder; private final String apiUrlTail; - @Preview @Deprecated - /*package*/ GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map permissions) { + @Preview + @Deprecated + GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map permissions) { this.root = root; this.apiUrlTail = apiUrlTail; this.builder = new Requester(root); - this.builder.withPermissions("permissions",permissions); + withPermissions(builder, permissions); } /** @@ -31,23 +32,41 @@ public class GHAppCreateTokenBuilder { * the access to specific repositories, you can provide the repository_ids when creating the token. When you omit * repository_ids, the response does not contain neither the repositories nor the permissions key. * - * @param repositoryIds - Array containing the repositories Ids - * + * @param repositoryIds + * Array containing the repositories Ids + * @return a GHAppCreateTokenBuilder */ - @Preview @Deprecated + @Preview + @Deprecated public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) { - this.builder.with("repository_ids",repositoryIds); + this.builder.with("repository_ids", repositoryIds); return this; } /** * Creates an app token with all the parameters. - * + *

* You must use a JWT to access this endpoint. + * + * @return a GHAppInstallationToken + * @throws IOException + * on error */ - @Preview @Deprecated + @Preview + @Deprecated public GHAppInstallationToken create() throws IOException { - return builder.method("POST").withPreview(MACHINE_MAN).to(apiUrlTail, GHAppInstallationToken.class).wrapUp(root); + return builder.method("POST") + .withPreview(MACHINE_MAN) + .to(apiUrlTail, GHAppInstallationToken.class) + .wrapUp(root); + } + + private static Requester withPermissions(Requester builder, Map value) { + Map retMap = new HashMap(); + for (Map.Entry entry : value.entrySet()) { + retMap.put(entry.getKey(), Requester.transformEnum(entry.getValue())); + } + return builder.with("permissions", retMap); } } diff --git a/src/main/java/org/kohsuke/github/GHAppInstallation.java b/src/main/java/org/kohsuke/github/GHAppInstallation.java index 3925742162..a9f2043c31 100644 --- a/src/main/java/org/kohsuke/github/GHAppInstallation.java +++ b/src/main/java/org/kohsuke/github/GHAppInstallation.java @@ -13,14 +13,12 @@ * A Github App Installation. * * @author Paulo Miguel Almeida - * - * @see GHApp#listInstallations() - * @see GHApp#getInstallationById(long) - * @see GHApp#getInstallationByOrganization(String) - * @see GHApp#getInstallationByRepository(String, String) - * @see GHApp#getInstallationByUser(String) + * @see GHApp#listInstallations() GHApp#listInstallations() + * @see GHApp#getInstallationById(long) GHApp#getInstallationById(long) + * @see GHApp#getInstallationByOrganization(String) GHApp#getInstallationByOrganization(String) + * @see GHApp#getInstallationByRepository(String, String) GHApp#getInstallationByRepository(String, String) + * @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String) */ - public class GHAppInstallation extends GHObject { private GitHub root; private GHUser account; @@ -47,121 +45,249 @@ public URL getHtmlUrl() { return GitHub.parseURL(htmlUrl); } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Sets root. + * + * @param root + * the root + */ public void setRoot(GitHub root) { this.root = root; } + /** + * Gets account. + * + * @return the account + */ public GHUser getAccount() { return account; } + /** + * Sets account. + * + * @param account + * the account + */ public void setAccount(GHUser account) { this.account = account; } + /** + * Gets access token url. + * + * @return the access token url + */ public String getAccessTokenUrl() { return accessTokenUrl; } + /** + * Sets access token url. + * + * @param accessTokenUrl + * the access token url + */ public void setAccessTokenUrl(String accessTokenUrl) { this.accessTokenUrl = accessTokenUrl; } + /** + * Gets repositories url. + * + * @return the repositories url + */ public String getRepositoriesUrl() { return repositoriesUrl; } + /** + * Sets repositories url. + * + * @param repositoriesUrl + * the repositories url + */ public void setRepositoriesUrl(String repositoriesUrl) { this.repositoriesUrl = repositoriesUrl; } + /** + * Gets app id. + * + * @return the app id + */ public long getAppId() { return appId; } + /** + * Sets app id. + * + * @param appId + * the app id + */ public void setAppId(long appId) { this.appId = appId; } + /** + * Gets target id. + * + * @return the target id + */ public long getTargetId() { return targetId; } + /** + * Sets target id. + * + * @param targetId + * the target id + */ public void setTargetId(long targetId) { this.targetId = targetId; } + /** + * Gets target type. + * + * @return the target type + */ public GHTargetType getTargetType() { return targetType; } + /** + * Sets target type. + * + * @param targetType + * the target type + */ public void setTargetType(GHTargetType targetType) { this.targetType = targetType; } + /** + * Gets permissions. + * + * @return the permissions + */ public Map getPermissions() { return permissions; } + /** + * Sets permissions. + * + * @param permissions + * the permissions + */ public void setPermissions(Map permissions) { this.permissions = permissions; } + /** + * Gets events. + * + * @return the events + */ public List getEvents() { return events; } + /** + * Sets events. + * + * @param events + * the events + */ public void setEvents(List events) { this.events = events; } + /** + * Gets single file name. + * + * @return the single file name + */ public String getSingleFileName() { return singleFileName; } + /** + * Sets single file name. + * + * @param singleFileName + * the single file name + */ public void setSingleFileName(String singleFileName) { this.singleFileName = singleFileName; } + /** + * Gets repository selection. + * + * @return the repository selection + */ public GHRepositorySelection getRepositorySelection() { return repositorySelection; } + /** + * Sets repository selection. + * + * @param repositorySelection + * the repository selection + */ public void setRepositorySelection(GHRepositorySelection repositorySelection) { this.repositorySelection = repositorySelection; } - /*package*/ GHAppInstallation wrapUp(GitHub root) { + GHAppInstallation wrapUp(GitHub root) { this.root = root; return this; } /** * Delete a Github App installation - * + *

* You must use a JWT to access this endpoint. * + * @throws IOException + * on error * @see Delete an installation */ - @Preview @Deprecated + @Preview + @Deprecated public void deleteInstallation() throws IOException { root.retrieve().method("DELETE").withPreview(GAMBIT).to(String.format("/app/installations/%d", id)); } - /** * Starts a builder that creates a new App Installation Token. * *

- * You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} - * to finally create an access token. + * You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to + * finally create an access token. + * + * @param permissions + * map of permissions for the created token + * @return a GHAppCreateTokenBuilder on error */ - @Preview @Deprecated - public GHAppCreateTokenBuilder createToken(Map permissions){ - return new GHAppCreateTokenBuilder(root,String.format("/app/installations/%d/access_tokens", id), permissions); + @Preview + @Deprecated + public GHAppCreateTokenBuilder createToken(Map permissions) { + return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", id), permissions); } } diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java index 2b6e78fdee..22acc291c3 100644 --- a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java +++ b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonProperty; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -13,10 +12,8 @@ * A Github App Installation Token. * * @author Paulo Miguel Almeida - * - * @see GHAppInstallation#createToken(Map) + * @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map) */ - public class GHAppInstallationToken { private GitHub root; @@ -24,53 +21,111 @@ public class GHAppInstallationToken { protected String expires_at; private Map permissions; private List repositories; - @JsonProperty("repository_selection") private GHRepositorySelection repositorySelection; + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Sets root. + * + * @param root + * the root + */ public void setRoot(GitHub root) { this.root = root; } + /** + * Gets permissions. + * + * @return the permissions + */ public Map getPermissions() { return permissions; } + /** + * Sets permissions. + * + * @param permissions + * the permissions + */ public void setPermissions(Map permissions) { this.permissions = permissions; } + /** + * Gets token. + * + * @return the token + */ public String getToken() { return token; } + /** + * Sets token. + * + * @param token + * the token + */ public void setToken(String token) { this.token = token; } + /** + * Gets repositories. + * + * @return the repositories + */ public List getRepositories() { return repositories; } + /** + * Sets repositories. + * + * @param repositories + * the repositories + */ public void setRepositories(List repositories) { this.repositories = repositories; } + /** + * Gets repository selection. + * + * @return the repository selection + */ public GHRepositorySelection getRepositorySelection() { return repositorySelection; } + /** + * Sets repository selection. + * + * @param repositorySelection + * the repository selection + */ public void setRepositorySelection(GHRepositorySelection repositorySelection) { this.repositorySelection = repositorySelection; } /** - * When was this tokens expires? + * Gets expires at. + * + * @return date when this token expires + * @throws IOException + * on error */ - @WithBridgeMethods(value=String.class, adapterMethod="expiresAtStr") + @WithBridgeMethods(value = String.class, adapterMethod = "expiresAtStr") public Date getExpiresAt() throws IOException { return GitHub.parseDate(expires_at); } @@ -80,7 +135,7 @@ private Object expiresAtStr(Date id, Class type) { return expires_at; } - /*package*/ GHAppInstallationToken wrapUp(GitHub root) { + GHAppInstallationToken wrapUp(GitHub root) { this.root = root; return this; } diff --git a/src/main/java/org/kohsuke/github/GHAsset.java b/src/main/java/org/kohsuke/github/GHAsset.java index 9f0be15863..0003c9703d 100644 --- a/src/main/java/org/kohsuke/github/GHAsset.java +++ b/src/main/java/org/kohsuke/github/GHAsset.java @@ -6,7 +6,7 @@ /** * Asset in a release. * - * @see GHRelease#getAssets() + * @see GHRelease#getAssets() GHRelease#getAssets() */ public class GHAsset extends GHObject { GitHub root; @@ -19,44 +19,100 @@ public class GHAsset extends GHObject { private long download_count; private String browser_download_url; + /** + * Gets content type. + * + * @return the content type + */ public String getContentType() { return content_type; } + /** + * Sets content type. + * + * @param contentType + * the content type + * @throws IOException + * the io exception + */ public void setContentType(String contentType) throws IOException { edit("content_type", contentType); this.content_type = contentType; } + /** + * Gets download count. + * + * @return the download count + */ public long getDownloadCount() { return download_count; } + /** + * Gets label. + * + * @return the label + */ public String getLabel() { return label; } + /** + * Sets label. + * + * @param label + * the label + * @throws IOException + * the io exception + */ public void setLabel(String label) throws IOException { edit("label", label); this.label = label; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets owner. + * + * @return the owner + */ public GHRepository getOwner() { return owner; } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Gets size. + * + * @return the size + */ public long getSize() { return size; } + /** + * Gets state. + * + * @return the state + */ public String getState() { return state; } @@ -69,19 +125,29 @@ public URL getHtmlUrl() { return null; } + /** + * Gets browser download url. + * + * @return the browser download url + */ public String getBrowserDownloadUrl() { return browser_download_url; } private void edit(String key, Object value) throws IOException { - new Requester(root)._with(key, value).method("PATCH").to(getApiRoute()); + new Requester(root).with(key, value).method("PATCH").to(getApiRoute()); } + /** + * Delete. + * + * @throws IOException + * the io exception + */ public void delete() throws IOException { new Requester(root).method("DELETE").to(getApiRoute()); } - private String getApiRoute() { return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + id; } @@ -92,6 +158,15 @@ GHAsset wrap(GHRelease release) { return this; } + /** + * Wrap gh asset [ ]. + * + * @param assets + * the assets + * @param release + * the release + * @return the gh asset [ ] + */ public static GHAsset[] wrap(GHAsset[] assets, GHRelease release) { for (GHAsset aTo : assets) { aTo.wrap(release); diff --git a/src/main/java/org/kohsuke/github/GHAuthorization.java b/src/main/java/org/kohsuke/github/GHAuthorization.java index bf7e24c7f2..26b5f3d51b 100644 --- a/src/main/java/org/kohsuke/github/GHAuthorization.java +++ b/src/main/java/org/kohsuke/github/GHAuthorization.java @@ -10,7 +10,7 @@ * Generated OAuth token * * @author janinko - * @see GitHub#createToken(Collection, String, String) + * @see GitHub#createToken(Collection, String, String) GitHub#createToken(Collection, String, String) * @see API documentation */ public class GHAuthorization extends GHObject { @@ -42,39 +42,78 @@ public class GHAuthorization extends GHObject { private String note; private String note_url; private String fingerprint; - //TODO add some user class for https://developer.github.com/v3/oauth_authorizations/#check-an-authorization ? - //private GHUser user; + // TODO add some user class for https://developer.github.com/v3/oauth_authorizations/#check-an-authorization ? + // private GHUser user; + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Gets scopes. + * + * @return the scopes + */ public List getScopes() { return scopes; } + /** + * Gets token. + * + * @return the token + */ public String getToken() { return token; } + /** + * Gets token last eight. + * + * @return the token last eight + */ public String getTokenLastEight() { return token_last_eight; } + /** + * Gets hashed token. + * + * @return the hashed token + */ public String getHashedToken() { return hashed_token; } + /** + * Gets app url. + * + * @return the app url + */ public URL getAppUrl() { return GitHub.parseURL(app.url); } + /** + * Gets app name. + * + * @return the app name + */ public String getAppName() { return app.name; } - @SuppressFBWarnings(value = "NM_CONFUSING", - justification = "It's a part of the library API, cannot be changed") + /** + * Gets api url. + * + * @return the api url + */ + @SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed") public URL getApiURL() { return GitHub.parseURL(url); } @@ -87,25 +126,40 @@ public URL getHtmlUrl() { return null; } + /** + * Gets note. + * + * @return the note + */ public String getNote() { return note; } + /** + * Gets note url. + * + * @return the note url + */ public URL getNoteUrl() { return GitHub.parseURL(note_url); } + /** + * Gets fingerprint. + * + * @return the fingerprint + */ public String getFingerprint() { return fingerprint; } - /*package*/ GHAuthorization wrap(GitHub root) { + GHAuthorization wrap(GitHub root) { this.root = root; return this; } - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"}, - justification = "JSON API") + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" }, + justification = "JSON API") private static class App { private String url; private String name; diff --git a/src/main/java/org/kohsuke/github/GHBlob.java b/src/main/java/org/kohsuke/github/GHBlob.java index a38a18219c..f2f80d8dc5 100644 --- a/src/main/java/org/kohsuke/github/GHBlob.java +++ b/src/main/java/org/kohsuke/github/GHBlob.java @@ -8,10 +8,12 @@ import java.net.URL; /** + * The type GHBlob. + * * @author Kanstantsin Shautsou * @author Kohsuke Kawaguchi - * @see GHTreeEntry#asBlob() - * @see GHRepository#getBlob(String) + * @see GHTreeEntry#asBlob() GHTreeEntry#asBlob() + * @see GHRepository#getBlob(String) GHRepository#getBlob(String) * @see Get a blob */ public class GHBlob { @@ -19,46 +21,64 @@ public class GHBlob { private long size; /** - * API URL of this blob. + * Gets url. + * + * @return API URL of this blob. */ public URL getUrl() { return GitHub.parseURL(url); } + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } /** - * Number of bytes in this blob. + * Gets size. + * + * @return Number of bytes in this blob. */ public long getSize() { return size; } + /** + * Gets encoding. + * + * @return the encoding + */ public String getEncoding() { return encoding; } /** - * Encoded content. You probably want {@link #read()} + * Gets content. + * + * @return Encoded content. You probably want {@link #read()} */ public String getContent() { return content; } /** - * Retrieves the actual bytes of the blob. + * Read input stream. + * + * @return the actual bytes of the blob. */ public InputStream read() { if (encoding.equals("base64")) { try { return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false); } catch (UnsupportedEncodingException e) { - throw new AssertionError(e); // US-ASCII is mandatory + throw new AssertionError(e); // US-ASCII is mandatory } } - throw new UnsupportedOperationException("Unrecognized encoding: "+encoding); + throw new UnsupportedOperationException("Unrecognized encoding: " + encoding); } } diff --git a/src/main/java/org/kohsuke/github/GHBlobBuilder.java b/src/main/java/org/kohsuke/github/GHBlobBuilder.java index a6259e5b6d..6326525dc3 100644 --- a/src/main/java/org/kohsuke/github/GHBlobBuilder.java +++ b/src/main/java/org/kohsuke/github/GHBlobBuilder.java @@ -5,8 +5,7 @@ import java.io.IOException; /** - * Builder pattern for creating a new blob. - * Based on https://developer.github.com/v3/git/blobs/#create-a-blob + * Builder pattern for creating a new blob. Based on https://developer.github.com/v3/git/blobs/#create-a-blob */ public class GHBlobBuilder { private final GHRepository repo; @@ -19,6 +18,10 @@ public class GHBlobBuilder { /** * Configures a blob with the specified text {@code content}. + * + * @param content + * string text of the blob + * @return a GHBlobBuilder */ public GHBlobBuilder textContent(String content) { req.with("content", content); @@ -28,6 +31,10 @@ public GHBlobBuilder textContent(String content) { /** * Configures a blob with the specified binary {@code content}. + * + * @param content + * byte array of the blob + * @return a GHBlobBuilder */ public GHBlobBuilder binaryContent(byte[] content) { String base64Content = Base64.encodeBase64String(content); @@ -42,6 +49,10 @@ private String getApiTail() { /** * Creates a blob based on the parameters specified thus far. + * + * @return a GHBlob + * @throws IOException + * if the blob cannot be created. */ public GHBlob create() throws IOException { return req.method("POST").to(getApiTail(), GHBlob.class); diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index e457fc243d..7e1ff1a4f7 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -1,11 +1,13 @@ package org.kohsuke.github; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.net.URL; import java.util.Collection; +import java.util.Objects; import static org.kohsuke.github.Previews.*; @@ -14,8 +16,10 @@ * * @author Yusuke Kokubo */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD"}, justification = "JSON API") +@SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "URF_UNREAD_FIELD" }, + justification = "JSON API") public class GHBranch { private GitHub root; private GHRepository owner; @@ -26,7 +30,15 @@ public class GHBranch { private boolean protection; private String protection_url; + @JsonCreator + GHBranch(@JsonProperty(value = "name", required = true) String name) throws Exception { + Objects.requireNonNull(name); + this.name = name; + } + /** + * The type Commit. + */ public static class Commit { String sha; @@ -34,43 +46,70 @@ public static class Commit { String url; } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } /** - * Repository that this branch is in. + * Gets owner. + * + * @return the repository that this branch is in. */ public GHRepository getOwner() { return owner; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } /** - * Returns true if the push to this branch is restricted via branch protection. + * Is protected boolean. + * + * @return true if the push to this branch is restricted via branch protection. */ - @Preview @Deprecated + @Preview + @Deprecated public boolean isProtected() { return protection; } /** - * Returns API URL that deals with the protection of this branch. + * Gets protection url. + * + * @return API URL that deals with the protection of this branch. */ - @Preview @Deprecated + @Preview + @Deprecated public URL getProtectionUrl() { return GitHub.parseURL(protection_url); } + /** + * Gets protection. + * + * @return the protection + * @throws IOException + * the io exception + */ public GHBranchProtection getProtection() throws IOException { return root.retrieve().to(protection_url, GHBranchProtection.class).wrap(this); } /** - * The commit that this branch currently points to. + * Gets sha 1. + * + * @return The SHA1 of the commit that this branch currently points to. */ public String getSHA1() { return commit.sha; @@ -78,6 +117,9 @@ public String getSHA1() { /** * Disables branch protection and allows anyone with push access to push changes. + * + * @throws IOException + * if disabling protection fails */ public void disableProtection() throws IOException { new Requester(root).method("DELETE").to(protection_url); @@ -86,32 +128,43 @@ public void disableProtection() throws IOException { /** * Enables branch protection to control what commit statuses are required to push. * - * @see GHCommitStatus#getContext() + * @return GHBranchProtectionBuilder for enabling protection + * @see GHCommitStatus#getContext() GHCommitStatus#getContext() */ - @Preview @Deprecated + @Preview + @Deprecated public GHBranchProtectionBuilder enableProtection() { return new GHBranchProtectionBuilder(this); } + /** + * Enable protection. + * + * @param level + * the level + * @param contexts + * the contexts + * @throws IOException + * the io exception + */ // backward compatibility with previous signature @Deprecated public void enableProtection(EnforcementLevel level, Collection contexts) throws IOException { switch (level) { - case OFF: - disableProtection(); - break; - case NON_ADMINS: - case EVERYONE: - enableProtection() - .addRequiredChecks(contexts) - .includeAdmins(level==EnforcementLevel.EVERYONE) - .enable(); - break; + case OFF : + disableProtection(); + break; + case NON_ADMINS : + case EVERYONE : + enableProtection().addRequiredChecks(contexts) + .includeAdmins(level == EnforcementLevel.EVERYONE) + .enable(); + break; } } String getApiRoute() { - return owner.getApiTailUrl("/branches/"+name); + return owner.getApiTailUrl("/branches/" + name); } @Override @@ -120,7 +173,7 @@ public String toString() { return "Branch:" + name + " in " + url; } - /*package*/ GHBranch wrap(GHRepository repo) { + GHBranch wrap(GHRepository repo) { this.owner = repo; this.root = repo.root; return this; diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java index 8420a531ad..4c9246d9de 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtection.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java @@ -3,17 +3,22 @@ import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import static org.kohsuke.github.Previews.ZZZAX; - import java.io.IOException; import java.util.Collection; -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", - "URF_UNREAD_FIELD"}, justification = "JSON API") +import static org.kohsuke.github.Previews.ZZZAX; + +/** + * The type GHBranchProtection. + */ +@SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "URF_UNREAD_FIELD" }, + justification = "JSON API") public class GHBranchProtection { private static final String REQUIRE_SIGNATURES_URI = "/required_signatures"; - @JsonProperty("enforce_admins") + @JsonProperty private EnforceAdmins enforceAdmins; private GitHub root; @@ -21,7 +26,7 @@ public class GHBranchProtection { @JsonProperty("required_pull_request_reviews") private RequiredReviews requiredReviews; - @JsonProperty("required_status_checks") + @JsonProperty private RequiredStatusChecks requiredStatusChecks; @JsonProperty @@ -30,40 +35,84 @@ public class GHBranchProtection { @JsonProperty private String url; - @Preview @Deprecated + /** + * Enabled signed commits. + * + * @throws IOException + * the io exception + */ + @Preview + @Deprecated public void enabledSignedCommits() throws IOException { - requester().method("POST") - .to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class); + requester().method("POST").to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class); } - @Preview @Deprecated + /** + * Disable signed commits. + * + * @throws IOException + * the io exception + */ + @Preview + @Deprecated public void disableSignedCommits() throws IOException { - requester().method("DELETE") - .to(url + REQUIRE_SIGNATURES_URI); + requester().method("DELETE").to(url + REQUIRE_SIGNATURES_URI); } + /** + * Gets enforce admins. + * + * @return the enforce admins + */ public EnforceAdmins getEnforceAdmins() { return enforceAdmins; } + /** + * Gets required reviews. + * + * @return the required reviews + */ public RequiredReviews getRequiredReviews() { return requiredReviews; } - @Preview @Deprecated + /** + * Gets required signatures. + * + * @return the required signatures + * @throws IOException + * the io exception + */ + @Preview + @Deprecated public boolean getRequiredSignatures() throws IOException { - return requester().method("GET") - .to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class).enabled; + return requester().method("GET").to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class).enabled; } + /** + * Gets required status checks. + * + * @return the required status checks + */ public RequiredStatusChecks getRequiredStatusChecks() { return requiredStatusChecks; } + /** + * Gets restrictions. + * + * @return the restrictions + */ public Restrictions getRestrictions() { return restrictions; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } @@ -77,6 +126,9 @@ private Requester requester() { return new Requester(root).withPreview(ZZZAX); } + /** + * The type EnforceAdmins. + */ public static class EnforceAdmins { @JsonProperty private boolean enabled; @@ -84,23 +136,34 @@ public static class EnforceAdmins { @JsonProperty private String url; + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Is enabled boolean. + * + * @return the boolean + */ public boolean isEnabled() { return enabled; } } + /** + * The type RequiredReviews. + */ public static class RequiredReviews { @JsonProperty("dismissal_restrictions") private Restrictions dismissalRestriction; - @JsonProperty("dismiss_stale_reviews") private boolean dismissStaleReviews; - @JsonProperty("require_code_owner_reviews") private boolean requireCodeOwnerReviews; @JsonProperty("required_approving_review_count") @@ -109,22 +172,47 @@ public static class RequiredReviews { @JsonProperty private String url; + /** + * Gets dismissal restrictions. + * + * @return the dismissal restrictions + */ public Restrictions getDismissalRestrictions() { return dismissalRestriction; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Is dismiss stale reviews boolean. + * + * @return the boolean + */ public boolean isDismissStaleReviews() { return dismissStaleReviews; } + /** + * Is require code owner reviews boolean. + * + * @return the boolean + */ public boolean isRequireCodeOwnerReviews() { return requireCodeOwnerReviews; } + /** + * Gets required reviewers. + * + * @return the required reviewers + */ public int getRequiredReviewers() { return requiredReviewers; } @@ -137,15 +225,28 @@ private static class RequiredSignatures { @JsonProperty private String url; + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Is enabled boolean. + * + * @return the boolean + */ public boolean isEnabled() { return enabled; } } + /** + * The type RequiredStatusChecks. + */ public static class RequiredStatusChecks { @JsonProperty private Collection contexts; @@ -156,24 +257,41 @@ public static class RequiredStatusChecks { @JsonProperty private String url; + /** + * Gets contexts. + * + * @return the contexts + */ public Collection getContexts() { return contexts; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Is requires branch up to date boolean. + * + * @return the boolean + */ public boolean isRequiresBranchUpToDate() { return strict; } } + /** + * The type Restrictions. + */ public static class Restrictions { @JsonProperty private Collection teams; - @JsonProperty("teams_url") private String teamsUrl; @JsonProperty @@ -182,25 +300,49 @@ public static class Restrictions { @JsonProperty private Collection users; - @JsonProperty("users_url") private String usersUrl; + /** + * Gets teams. + * + * @return the teams + */ public Collection getTeams() { return teams; } + /** + * Gets teams url. + * + * @return the teams url + */ public String getTeamsUrl() { return teamsUrl; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets users. + * + * @return the users + */ public Collection getUsers() { return users; } + /** + * Gets users url. + * + * @return the users url + */ public String getUsersUrl() { return usersUrl; } diff --git a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java index 822541a14d..c94020b306 100644 --- a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java +++ b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java @@ -17,10 +17,12 @@ /** * Builder to configure the branch protection settings. * - * @see GHBranch#enableProtection() + * @see GHBranch#enableProtection() GHBranch#enableProtection() */ -@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", - "URF_UNREAD_FIELD" }, justification = "JSON API") +@SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "URF_UNREAD_FIELD" }, + justification = "JSON API") public class GHBranchProtectionBuilder { private final GHBranch branch; @@ -33,25 +35,58 @@ public class GHBranchProtectionBuilder { this.branch = branch; } + /** + * Add required checks gh branch protection builder. + * + * @param checks + * the checks + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder addRequiredChecks(Collection checks) { getStatusChecks().contexts.addAll(checks); return this; } - + + /** + * Add required checks gh branch protection builder. + * + * @param checks + * the checks + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder addRequiredChecks(String... checks) { addRequiredChecks(Arrays.asList(checks)); return this; } + /** + * Dismiss stale reviews gh branch protection builder. + * + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder dismissStaleReviews() { return dismissStaleReviews(true); } + /** + * Dismiss stale reviews gh branch protection builder. + * + * @param v + * the v + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder dismissStaleReviews(boolean v) { getPrReviews().put("dismiss_stale_reviews", v); return this; } + /** + * Enable gh branch protection. + * + * @return the gh branch protection + * @throws IOException + * the io exception + */ public GHBranchProtection enable() throws IOException { return requester().method("PUT") .withNullable("required_status_checks", statusChecks) @@ -62,43 +97,96 @@ public GHBranchProtection enable() throws IOException { .wrap(branch); } + /** + * Include admins gh branch protection builder. + * + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder includeAdmins() { return includeAdmins(true); } + /** + * Include admins gh branch protection builder. + * + * @param v + * the v + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder includeAdmins(boolean v) { enforceAdmins = v; return this; } + /** + * Required reviewers gh branch protection builder. + * + * @param v + * the v + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder requiredReviewers(int v) { getPrReviews().put("required_approving_review_count", v); return this; } + /** + * Require branch is up to date gh branch protection builder. + * + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder requireBranchIsUpToDate() { return requireBranchIsUpToDate(true); } + /** + * Require branch is up to date gh branch protection builder. + * + * @param v + * the v + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder requireBranchIsUpToDate(boolean v) { getStatusChecks().strict = v; return this; } + /** + * Require code own reviews gh branch protection builder. + * + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder requireCodeOwnReviews() { return requireCodeOwnReviews(true); } + /** + * Require code own reviews gh branch protection builder. + * + * @param v + * the v + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder requireCodeOwnReviews(boolean v) { getPrReviews().put("require_code_owner_reviews", v); return this; } + /** + * Require reviews gh branch protection builder. + * + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder requireReviews() { getPrReviews(); return this; } + /** + * Restrict review dismissals gh branch protection builder. + * + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder restrictReviewDismissals() { getPrReviews(); @@ -109,11 +197,23 @@ public GHBranchProtectionBuilder restrictReviewDismissals() { return this; } + /** + * Restrict push access gh branch protection builder. + * + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder restrictPushAccess() { getRestrictions(); return this; } + /** + * Team push access gh branch protection builder. + * + * @param teams + * the teams + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder teamPushAccess(Collection teams) { for (GHTeam team : teams) { teamPushAccess(team); @@ -121,6 +221,13 @@ public GHBranchProtectionBuilder teamPushAccess(Collection teams) { return this; } + /** + * Team push access gh branch protection builder. + * + * @param teams + * the teams + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder teamPushAccess(GHTeam... teams) { for (GHTeam team : teams) { getRestrictions().teams.add(team.getSlug()); @@ -128,6 +235,13 @@ public GHBranchProtectionBuilder teamPushAccess(GHTeam... teams) { return this; } + /** + * Team review dismissals gh branch protection builder. + * + * @param teams + * the teams + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder teamReviewDismissals(Collection teams) { for (GHTeam team : teams) { teamReviewDismissals(team); @@ -135,6 +249,13 @@ public GHBranchProtectionBuilder teamReviewDismissals(Collection teams) return this; } + /** + * Team review dismissals gh branch protection builder. + * + * @param teams + * the teams + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder teamReviewDismissals(GHTeam... teams) { for (GHTeam team : teams) { addReviewRestriction(team.getSlug(), true); @@ -142,13 +263,27 @@ public GHBranchProtectionBuilder teamReviewDismissals(GHTeam... teams) { return this; } + /** + * User push access gh branch protection builder. + * + * @param users + * the users + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder userPushAccess(Collection users) { for (GHUser user : users) { userPushAccess(user); } return this; } - + + /** + * User push access gh branch protection builder. + * + * @param users + * the users + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder userPushAccess(GHUser... users) { for (GHUser user : users) { getRestrictions().users.add(user.getLogin()); @@ -156,6 +291,13 @@ public GHBranchProtectionBuilder userPushAccess(GHUser... users) { return this; } + /** + * User review dismissals gh branch protection builder. + * + * @param users + * the users + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder userReviewDismissals(Collection users) { for (GHUser team : users) { userReviewDismissals(team); @@ -163,6 +305,13 @@ public GHBranchProtectionBuilder userReviewDismissals(Collection users) return this; } + /** + * User review dismissals gh branch protection builder. + * + * @param users + * the users + * @return the gh branch protection builder + */ public GHBranchProtectionBuilder userReviewDismissals(GHUser... users) { for (GHUser user : users) { addReviewRestriction(user.getLogin(), false); @@ -173,7 +322,7 @@ public GHBranchProtectionBuilder userReviewDismissals(GHUser... users) { private void addReviewRestriction(String restriction, boolean isTeam) { restrictReviewDismissals(); Restrictions restrictions = (Restrictions) prReviews.get("dismissal_restrictions"); - + if (isTeam) { restrictions.teams.add(restriction); } else { diff --git a/src/main/java/org/kohsuke/github/GHCommit.java b/src/main/java/org/kohsuke/github/GHCommit.java index 4891065ad5..b1e7b7dc06 100644 --- a/src/main/java/org/kohsuke/github/GHCommit.java +++ b/src/main/java/org/kohsuke/github/GHCommit.java @@ -15,27 +15,28 @@ * A commit in a repository. * * @author Kohsuke Kawaguchi - * @see GHRepository#getCommit(String) - * @see GHCommitComment#getCommit() + * @see GHRepository#getCommit(String) GHRepository#getCommit(String) + * @see GHCommitComment#getCommit() GHCommitComment#getCommit() */ -@SuppressFBWarnings(value = {"NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD"}, - justification = "JSON API") +@SuppressFBWarnings(value = { "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") public class GHCommit { private GHRepository owner; - + private ShortInfo commit; /** * Short summary of this commit. */ - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD"}, justification = "JSON API") + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "UWF_UNWRITTEN_FIELD" }, + justification = "JSON API") public static class ShortInfo { private GHAuthor author; private GHAuthor committer; - + private String message; - + private int comment_count; static class Tree { @@ -44,88 +45,129 @@ static class Tree { private Tree tree; + /** + * Gets author. + * + * @return the author + */ @WithBridgeMethods(value = GHAuthor.class, castRequired = true) public GitUser getAuthor() { return author; } + /** + * Gets authored date. + * + * @return the authored date + */ public Date getAuthoredDate() { return GitHub.parseDate(author.date); } + /** + * Gets committer. + * + * @return the committer + */ @WithBridgeMethods(value = GHAuthor.class, castRequired = true) public GitUser getCommitter() { return committer; } + /** + * Gets commit date. + * + * @return the commit date + */ public Date getCommitDate() { return GitHub.parseDate(committer.date); } /** - * Commit message. + * Gets message. + * + * @return Commit message. */ public String getMessage() { return message; } + /** + * Gets comment count. + * + * @return the comment count + */ public int getCommentCount() { return comment_count; } } /** + * The type GHAuthor. + * * @deprecated Use {@link GitUser} instead. */ public static class GHAuthor extends GitUser { private String date; } + /** + * The type Stats. + */ public static class Stats { - int total,additions,deletions; + int total, additions, deletions; } /** * A file that was modified. */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", - justification = "It's being initilized by JSON deserialization") + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "It's being initilized by JSON deserialization") public static class File { String status; - int changes,additions,deletions; + int changes, additions, deletions; String raw_url, blob_url, sha, patch; String filename, previous_filename; /** - * Number of lines added + removed. + * Gets lines changed. + * + * @return Number of lines added + removed. */ public int getLinesChanged() { return changes; } /** - * Number of lines added. + * Gets lines added. + * + * @return Number of lines added. */ public int getLinesAdded() { return additions; } /** - * Number of lines removed. + * Gets lines deleted. + * + * @return Number of lines removed. */ public int getLinesDeleted() { return deletions; } /** - * "modified", "added", or "removed" + * Gets status. + * + * @return "modified", "added", or "removed" */ public String getStatus() { return status; } /** - * Full path in the repository. + * Gets file name. + * + * @return Full path in the repository. */ @SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library's API and cannot be renamed") @@ -134,81 +176,108 @@ public String getFileName() { } /** - * Previous path, in case file has moved. + * Gets previous filename. + * + * @return Previous path, in case file has moved. */ public String getPreviousFilename() { return previous_filename; } /** - * The actual change. + * Gets patch. + * + * @return The actual change. */ public String getPatch() { return patch; } /** - * URL like 'https://raw.github.com/jenkinsci/jenkins/4eb17c197dfdcf8ef7ff87eb160f24f6a20b7f0e/core/pom.xml' - * that resolves to the actual content of the file. + * Gets raw url. + * + * @return URL like + * 'https://raw.github.com/jenkinsci/jenkins/4eb17c197dfdcf8ef7ff87eb160f24f6a20b7f0e/core/pom.xml' that + * resolves to the actual content of the file. */ public URL getRawUrl() { return GitHub.parseURL(raw_url); } /** - * URL like 'https://github.com/jenkinsci/jenkins/blob/1182e2ebb1734d0653142bd422ad33c21437f7cf/core/pom.xml' - * that resolves to the HTML page that describes this file. + * Gets blob url. + * + * @return URL like + * 'https://github.com/jenkinsci/jenkins/blob/1182e2ebb1734d0653142bd422ad33c21437f7cf/core/pom.xml' + * that resolves to the HTML page that describes this file. */ public URL getBlobUrl() { return GitHub.parseURL(blob_url); } /** - * [0-9a-f]{40} SHA1 checksum. + * Gets sha. + * + * @return [0 -9a-f]{40} SHA1 checksum. */ public String getSha() { return sha; } } + /** + * The type Parent. + */ public static class Parent { @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now") - String url; + String url; String sha; } static class User { // TODO: what if someone who doesn't have an account on GitHub makes a commit? @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now") - String url,avatar_url,gravatar_id; + String url, avatar_url, gravatar_id; @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now") int id; - + String login; } - String url,html_url,sha; + String url, html_url, sha; List files; Stats stats; List parents; - User author,committer; - + User author, committer; + /** + * Gets commit short info. + * + * @return the commit short info + * @throws IOException + * the io exception + */ public ShortInfo getCommitShortInfo() throws IOException { - if (commit==null) + if (commit == null) populate(); return commit; } /** - * The repository that contains the commit. + * Gets owner. + * + * @return the repository that contains the commit. */ public GHRepository getOwner() { return owner; } /** - * Number of lines added + removed. + * Gets lines changed. + * + * @return the number of lines added + removed. + * @throws IOException + * if the field was not populated and refresh fails */ public int getLinesChanged() throws IOException { populate(); @@ -216,7 +285,11 @@ public int getLinesChanged() throws IOException { } /** - * Number of lines added. + * Gets lines added. + * + * @return Number of lines added. + * @throws IOException + * if the field was not populated and refresh fails */ public int getLinesAdded() throws IOException { populate(); @@ -224,7 +297,11 @@ public int getLinesAdded() throws IOException { } /** - * Number of lines removed. + * Gets lines deleted. + * + * @return Number of lines removed. + * @throws IOException + * if the field was not populated and refresh fails */ public int getLinesDeleted() throws IOException { populate(); @@ -232,21 +309,30 @@ public int getLinesDeleted() throws IOException { } /** - * Use this method to walk the tree + * Use this method to walk the tree. + * + * @return a GHTree to walk + * @throws IOException + * on error */ public GHTree getTree() throws IOException { return owner.getTree(getCommitShortInfo().tree.sha); } /** - * URL of this commit like "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000" + * Gets html url. + * + * @return URL of this commit like + * "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000" */ public URL getHtmlUrl() { return GitHub.parseURL(html_url); } /** - * [0-9a-f]{40} SHA1 checksum. + * Gets sha 1. + * + * @return [0 -9a-f]{40} SHA1 checksum. */ public String getSHA1() { return sha; @@ -255,19 +341,23 @@ public String getSHA1() { /** * List of files changed/added/removed in this commit. * - * @return - * Can be empty but never null. + * @return Can be empty but never null. + * @throws IOException + * on error */ public List getFiles() throws IOException { populate(); - return files!=null ? Collections.unmodifiableList(files) : Collections.emptyList(); + return files != null ? Collections.unmodifiableList(files) : Collections.emptyList(); } /** - * Returns the SHA1 of parent commit objects. + * Gets parent sha 1 s. + * + * @return SHA1 of parent commit objects. */ public List getParentSHA1s() { - if (parents==null) return Collections.emptyList(); + if (parents == null) + return Collections.emptyList(); return new AbstractList() { @Override public String get(int index) { @@ -283,6 +373,10 @@ public int size() { /** * Resolves the parent commit objects and return them. + * + * @return parent commit objects + * @throws IOException + * on error */ public List getParents() throws IOException { List r = new ArrayList(); @@ -291,19 +385,35 @@ public List getParents() throws IOException { return r; } + /** + * Gets author. + * + * @return the author + * @throws IOException + * the io exception + */ public GHUser getAuthor() throws IOException { return resolveUser(author); } /** * Gets the date the change was authored on. + * * @return the date the change was authored on. - * @throws IOException if the information was not already fetched and an attempt at fetching the information failed. + * @throws IOException + * if the information was not already fetched and an attempt at fetching the information failed. */ public Date getAuthoredDate() throws IOException { return getCommitShortInfo().getAuthoredDate(); } + /** + * Gets committer. + * + * @return the committer + * @throws IOException + * the io exception + */ public GHUser getCommitter() throws IOException { return resolveUser(committer); } @@ -312,56 +422,89 @@ public GHUser getCommitter() throws IOException { * Gets the date the change was committed on. * * @return the date the change was committed on. - * @throws IOException if the information was not already fetched and an attempt at fetching the information failed. + * @throws IOException + * if the information was not already fetched and an attempt at fetching the information failed. */ public Date getCommitDate() throws IOException { return getCommitShortInfo().getCommitDate(); } private GHUser resolveUser(User author) throws IOException { - if (author==null || author.login==null) return null; + if (author == null || author.login == null) + return null; return owner.root.getUser(author.login); } /** - * Lists up all the commit comments in this repository. + * List comments paged iterable. + * + * @return {@link PagedIterable} with all the commit comments in this repository. */ public PagedIterable listComments() { return owner.root.retrieve() - .asPagedIterable( - String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha), - GHCommitComment[].class, - item -> item.wrap(owner) ); + .asPagedIterable( + String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha), + GHCommitComment[].class, + item -> item.wrap(owner)); } /** * Creates a commit comment. - * + *

* I'm not sure how path/line/position parameters interact with each other. + * + * @param body + * body of the comment + * @param path + * path of file being commented on + * @param line + * target line for comment + * @param position + * position on line + * @return created GHCommitComment + * @throws IOException + * if comment is not created */ public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException { - GHCommitComment r = new Requester(owner.root) - .with("body",body) - .with("path",path) - .with("line",line) - .with("position",position) - .to(String.format("/repos/%s/%s/commits/%s/comments",owner.getOwnerName(),owner.getName(),sha),GHCommitComment.class); + GHCommitComment r = new Requester(owner.root).with("body", body) + .with("path", path) + .with("line", line) + .with("position", position) + .to(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha), + GHCommitComment.class); return r.wrap(owner); } + /** + * Create comment gh commit comment. + * + * @param body + * the body + * @return the gh commit comment + * @throws IOException + * the io exception + */ public GHCommitComment createComment(String body) throws IOException { return createComment(body, null, null, null); } /** - * Gets the status of this commit, newer ones first. + * List statuses paged iterable. + * + * @return status of this commit, newer ones first. + * @throws IOException + * if statuses cannot be read */ public PagedIterable listStatuses() throws IOException { return owner.listCommitStatuses(sha); } /** - * Gets the last status of this commit, which is what gets shown in the UI. + * Gets last status. + * + * @return the last status of this commit, which is what gets shown in the UI. + * @throws IOException + * on error */ public GHCommitStatus getLastStatus() throws IOException { return owner.getLastCommitStatus(sha); @@ -369,9 +512,12 @@ public GHCommitStatus getLastStatus() throws IOException { /** * Some of the fields are not always filled in when this object is retrieved as a part of another API call. + * + * @throws IOException + * on error */ void populate() throws IOException { - if (files==null && stats==null) + if (files == null && stats == null) owner.root.retrieve().to(owner.getApiTailUrl("commits/" + sha), this); } diff --git a/src/main/java/org/kohsuke/github/GHCommitBuilder.java b/src/main/java/org/kohsuke/github/GHCommitBuilder.java index 76e846a7d7..71335ee02a 100644 --- a/src/main/java/org/kohsuke/github/GHCommitBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCommitBuilder.java @@ -9,8 +9,7 @@ import java.util.TimeZone; /** - * Builder pattern for creating a new commit. - * Based on https://developer.github.com/v3/git/commits/#create-a-commit + * Builder pattern for creating a new commit. Based on https://developer.github.com/v3/git/commits/#create-a-commit */ public class GHCommitBuilder { private final GHRepository repo; @@ -39,7 +38,11 @@ private UserInfo(String name, String email, Date date) { } /** - * @param message the commit message + * Message gh commit builder. + * + * @param message + * the commit message + * @return the gh commit builder */ public GHCommitBuilder message(String message) { req.with("message", message); @@ -47,7 +50,11 @@ public GHCommitBuilder message(String message) { } /** - * @param tree the SHA of the tree object this commit points to + * Tree gh commit builder. + * + * @param tree + * the SHA of the tree object this commit points to + * @return the gh commit builder */ public GHCommitBuilder tree(String tree) { req.with("tree", tree); @@ -55,7 +62,11 @@ public GHCommitBuilder tree(String tree) { } /** - * @param parent the SHA of a parent commit. + * Parent gh commit builder. + * + * @param parent + * the SHA of a parent commit. + * @return the gh commit builder */ public GHCommitBuilder parent(String parent) { parents.add(parent); @@ -64,17 +75,33 @@ public GHCommitBuilder parent(String parent) { /** * Configures the author of this commit. + * + * @param name + * the name + * @param email + * the email + * @param date + * the date + * @return the gh commit builder */ public GHCommitBuilder author(String name, String email, Date date) { - req._with("author", new UserInfo(name, email, date)); + req.with("author", new UserInfo(name, email, date)); return this; } /** * Configures the committer of this commit. + * + * @param name + * the name + * @param email + * the email + * @param date + * the date + * @return the gh commit builder */ public GHCommitBuilder committer(String name, String email, Date date) { - req._with("committer", new UserInfo(name, email, date)); + req.with("committer", new UserInfo(name, email, date)); return this; } @@ -84,9 +111,13 @@ private String getApiTail() { /** * Creates a blob based on the parameters specified thus far. + * + * @return the gh commit + * @throws IOException + * the io exception */ public GHCommit create() throws IOException { - req._with("parents", parents); + req.with("parents", parents); return req.method("POST").to(getApiTail(), GHCommit.class).wrapUp(repo); } } diff --git a/src/main/java/org/kohsuke/github/GHCommitComment.java b/src/main/java/org/kohsuke/github/GHCommitComment.java index a0047c3d15..e53e8607f0 100644 --- a/src/main/java/org/kohsuke/github/GHCommitComment.java +++ b/src/main/java/org/kohsuke/github/GHCommitComment.java @@ -11,61 +11,83 @@ * A comment attached to a commit (or a specific line in a specific file of a commit.) * * @author Kohsuke Kawaguchi - * @see GHRepository#listCommitComments() - * @see GHCommit#listComments() - * @see GHCommit#createComment(String, String, Integer, Integer) + * @see GHRepository#listCommitComments() GHRepository#listCommitComments() + * @see GHCommit#listComments() GHCommit#listComments() + * @see GHCommit#createComment(String, String, Integer, Integer) GHCommit#createComment(String, String, Integer, + * Integer) */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHCommitComment extends GHObject implements Reactable { private GHRepository owner; String body, html_url, commit_id; Integer line; String path; - GHUser user; // not fully populated. beware. + GHUser user; // not fully populated. beware. + /** + * Gets owner. + * + * @return the owner + */ public GHRepository getOwner() { return owner; } /** - * URL like 'https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000#commitcomment-1252827' to + * URL like + * 'https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000#commitcomment-1252827' to * show this commit comment in a browser. */ public URL getHtmlUrl() { return GitHub.parseURL(html_url); } + /** + * Gets sha 1. + * + * @return the sha 1 + */ public String getSHA1() { return commit_id; } /** * Commit comment in the GitHub flavored markdown format. + * + * @return the body */ public String getBody() { return body; } /** - * A commit comment can be on a specific line of a specific file, if so, this field points to a file. - * Otherwise null. + * A commit comment can be on a specific line of a specific file, if so, this field points to a file. Otherwise + * null. + * + * @return the path */ public String getPath() { return path; } /** - * A commit comment can be on a specific line of a specific file, if so, this field points to the line number in the file. - * Otherwise -1. + * A commit comment can be on a specific line of a specific file, if so, this field points to the line number in the + * file. Otherwise -1. + * + * @return the line */ public int getLine() { - return line!=null ? line : -1; + return line != null ? line : -1; } /** * Gets the user who put this comment. + * + * @return the user + * @throws IOException + * the io exception */ public GHUser getUser() throws IOException { return owner == null || owner.root.isOffline() ? user : owner.root.getUser(user.login); @@ -73,6 +95,10 @@ public GHUser getUser() throws IOException { /** * Gets the commit to which this comment is associated with. + * + * @return the commit + * @throws IOException + * the io exception */ public GHCommit getCommit() throws IOException { return getOwner().getCommit(getSHA1()); @@ -80,43 +106,48 @@ public GHCommit getCommit() throws IOException { /** * Updates the body of the commit message. + * + * @param body + * the body + * @throws IOException + * the io exception */ public void update(String body) throws IOException { - new Requester(owner.root) - .with("body", body) - .method("PATCH").to(getApiTail(), GHCommitComment.class); + new Requester(owner.root).with("body", body).method("PATCH").to(getApiTail(), GHCommitComment.class); this.body = body; } - @Preview @Deprecated + @Preview + @Deprecated public GHReaction createReaction(ReactionContent content) throws IOException { - return new Requester(owner.root) - .withPreview(SQUIRREL_GIRL) + return new Requester(owner.root).withPreview(SQUIRREL_GIRL) .with("content", content.getContent()) - .to(getApiTail()+"/reactions", GHReaction.class).wrap(owner.root); + .to(getApiTail() + "/reactions", GHReaction.class) + .wrap(owner.root); } - @Preview @Deprecated + @Preview + @Deprecated public PagedIterable listReactions() { - return owner.root.retrieve().withPreview(SQUIRREL_GIRL) - .asPagedIterable( - getApiTail()+"/reactions", - GHReaction[].class, - item -> item.wrap(owner.root) ); + return owner.root.retrieve() + .withPreview(SQUIRREL_GIRL) + .asPagedIterable(getApiTail() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root)); } /** * Deletes this comment. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { new Requester(owner.root).method("DELETE").to(getApiTail()); } private String getApiTail() { - return String.format("/repos/%s/%s/comments/%s",owner.getOwnerName(),owner.getName(),id); + return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), id); } - GHCommitComment wrap(GHRepository owner) { this.owner = owner; if (owner.root.isOffline()) { diff --git a/src/main/java/org/kohsuke/github/GHCommitPointer.java b/src/main/java/org/kohsuke/github/GHCommitPointer.java index b6c347864e..15ed6b9369 100644 --- a/src/main/java/org/kohsuke/github/GHCommitPointer.java +++ b/src/main/java/org/kohsuke/github/GHCommitPointer.java @@ -36,16 +36,22 @@ public class GHCommitPointer { private GHRepository repo; /** - * This points to the user who owns - * the {@link #getRepository()}. + * This points to the user who owns the {@link #getRepository()}. + * + * @return the user + * @throws IOException + * the io exception */ public GHUser getUser() throws IOException { - if (user != null) return user.root.intern(user); + if (user != null) + return user.root.intern(user); return user; } /** * The repository that contains the commit. + * + * @return the repository */ public GHRepository getRepository() { return repo; @@ -53,6 +59,8 @@ public GHRepository getRepository() { /** * Named ref to the commit. This appears to be a "short ref" that doesn't include "refs/heads/" portion. + * + * @return the ref */ public String getRef() { return ref; @@ -60,6 +68,8 @@ public String getRef() { /** * SHA1 of the commit. + * + * @return the sha */ public String getSha() { return sha; @@ -67,6 +77,8 @@ public String getSha() { /** * String that looks like "USERNAME:REF". + * + * @return the label */ public String getLabel() { return label; @@ -74,13 +86,19 @@ public String getLabel() { /** * Obtains the commit that this pointer is referring to. + * + * @return the commit + * @throws IOException + * the io exception */ public GHCommit getCommit() throws IOException { return getRepository().getCommit(getSha()); } void wrapUp(GitHub root) { - if (user!=null) user.root = root; - if (repo!=null) repo.wrap(root); + if (user != null) + user.root = root; + if (repo != null) + repo.wrap(root); } } diff --git a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java index 64b3a0e935..dc544b390e 100644 --- a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java @@ -16,57 +16,83 @@ * * * @author Kohsuke Kawaguchi - * @see GHRepository#queryCommits() -*/ + * @see GHRepository#queryCommits() GHRepository#queryCommits() + */ public class GHCommitQueryBuilder { private final Requester req; private final GHRepository repo; - /*package*/ GHCommitQueryBuilder(GHRepository repo) { + GHCommitQueryBuilder(GHRepository repo) { this.repo = repo; - this.req = repo.root.retrieve(); // requester to build up + this.req = repo.root.retrieve(); // requester to build up } /** * GItHub login or email address by which to filter by commit author. + * + * @param author + * the author + * @return the gh commit query builder */ public GHCommitQueryBuilder author(String author) { - req.with("author",author); + req.with("author", author); return this; } /** * Only commits containing this file path will be returned. + * + * @param path + * the path + * @return the gh commit query builder */ public GHCommitQueryBuilder path(String path) { - req.with("path",path); + req.with("path", path); return this; } /** * Specifies the SHA1 commit / tag / branch / etc to start listing commits from. * + * @param ref + * the ref + * @return the gh commit query builder */ public GHCommitQueryBuilder from(String ref) { - req.with("sha",ref); + req.with("sha", ref); return this; } + /** + * Page size gh commit query builder. + * + * @param pageSize + * the page size + * @return the gh commit query builder + */ public GHCommitQueryBuilder pageSize(int pageSize) { - req.with("per_page",pageSize); + req.with("per_page", pageSize); return this; } /** * Only commits after this date will be returned + * + * @param dt + * the dt + * @return the gh commit query builder */ public GHCommitQueryBuilder since(Date dt) { - req.with("since",GitHub.printDate(dt)); + req.with("since", GitHub.printDate(dt)); return this; } /** * Only commits after this date will be returned + * + * @param timestamp + * the timestamp + * @return the gh commit query builder */ public GHCommitQueryBuilder since(long timestamp) { return since(new Date(timestamp)); @@ -74,14 +100,22 @@ public GHCommitQueryBuilder since(long timestamp) { /** * Only commits before this date will be returned + * + * @param dt + * the dt + * @return the gh commit query builder */ public GHCommitQueryBuilder until(Date dt) { - req.with("until",GitHub.printDate(dt)); + req.with("until", GitHub.printDate(dt)); return this; } /** * Only commits before this date will be returned + * + * @param timestamp + * the timestamp + * @return the gh commit query builder */ public GHCommitQueryBuilder until(long timestamp) { return until(new Date(timestamp)); @@ -89,12 +123,10 @@ public GHCommitQueryBuilder until(long timestamp) { /** * Lists up the commits with the criteria built so far. + * + * @return the paged iterable */ public PagedIterable list() { - return req - .asPagedIterable( - repo.getApiTailUrl("commits"), - GHCommit[].class, - item -> item.wrapUp(repo) ); + return req.asPagedIterable(repo.getApiTailUrl("commits"), GHCommit[].class, item -> item.wrapUp(repo)); } } diff --git a/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java b/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java index 3d29aa80fd..b62bc2b1b2 100644 --- a/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java @@ -8,12 +8,13 @@ * Search commits. * * @author Marc de Verdelhan - * @see GitHub#searchCommits() + * @see GitHub#searchCommits() GitHub#searchCommits() */ -@Preview @Deprecated +@Preview +@Deprecated public class GHCommitSearchBuilder extends GHSearchBuilder { - /*package*/ GHCommitSearchBuilder(GitHub root) { - super(root,CommitSearchResult.class); + GHCommitSearchBuilder(GitHub root) { + super(root, CommitSearchResult.class); req.withPreview(Previews.CLOAK); } @@ -25,100 +26,233 @@ public GHCommitSearchBuilder q(String term) { return this; } + /** + * Author gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder author(String v) { - return q("author:"+v); + return q("author:" + v); } + /** + * Committer gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder committer(String v) { - return q("committer:"+v); + return q("committer:" + v); } + /** + * Author name gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder authorName(String v) { - return q("author-name:"+v); + return q("author-name:" + v); } + /** + * Committer name gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder committerName(String v) { - return q("committer-name:"+v); + return q("committer-name:" + v); } + /** + * Author email gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder authorEmail(String v) { - return q("author-email:"+v); + return q("author-email:" + v); } + /** + * Committer email gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder committerEmail(String v) { - return q("committer-email:"+v); + return q("committer-email:" + v); } + /** + * Author date gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder authorDate(String v) { - return q("author-date:"+v); + return q("author-date:" + v); } + /** + * Committer date gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder committerDate(String v) { - return q("committer-date:"+v); + return q("committer-date:" + v); } + /** + * Merge gh commit search builder. + * + * @param merge + * the merge + * @return the gh commit search builder + */ public GHCommitSearchBuilder merge(boolean merge) { - return q("merge:"+Boolean.valueOf(merge).toString().toLowerCase()); + return q("merge:" + Boolean.valueOf(merge).toString().toLowerCase()); } + /** + * Hash gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder hash(String v) { - return q("hash:"+v); + return q("hash:" + v); } + /** + * Parent gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder parent(String v) { - return q("parent:"+v); + return q("parent:" + v); } + /** + * Tree gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder tree(String v) { - return q("tree:"+v); + return q("tree:" + v); } + /** + * Is gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder is(String v) { - return q("is:"+v); + return q("is:" + v); } + /** + * User gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder user(String v) { - return q("user:"+v); + return q("user:" + v); } + /** + * Org gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder org(String v) { - return q("org:"+v); + return q("org:" + v); } + /** + * Repo gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder repo(String v) { - return q("repo:"+v); + return q("repo:" + v); } + /** + * Order gh commit search builder. + * + * @param v + * the v + * @return the gh commit search builder + */ public GHCommitSearchBuilder order(GHDirection v) { - req.with("order",v); + req.with("order", v); return this; } + /** + * Sort gh commit search builder. + * + * @param sort + * the sort + * @return the gh commit search builder + */ public GHCommitSearchBuilder sort(Sort sort) { - req.with("sort",sort); + req.with("sort", sort); return this; } - public enum Sort { AUTHOR_DATE, COMMITTER_DATE } + /** + * The enum Sort. + */ + public enum Sort { + AUTHOR_DATE, COMMITTER_DATE + } private static class CommitSearchResult extends SearchResult { private GHCommit[] items; @Override - /*package*/ GHCommit[] getItems(GitHub root) { + GHCommit[] getItems(GitHub root) { for (GHCommit commit : items) { String repoName = getRepoName(commit.url); try { GHRepository repo = root.getRepository(repoName); commit.wrapUp(repo); - } catch (IOException ioe) {} + } catch (IOException ioe) { + } } return items; } } - + /** - * @param commitUrl a commit URL + * @param commitUrl + * a commit URL * @return the repo name ("username/reponame") */ private static String getRepoName(String commitUrl) { diff --git a/src/main/java/org/kohsuke/github/GHCommitStatus.java b/src/main/java/org/kohsuke/github/GHCommitStatus.java index 63a62ae8d0..d1ac12bba2 100644 --- a/src/main/java/org/kohsuke/github/GHCommitStatus.java +++ b/src/main/java/org/kohsuke/github/GHCommitStatus.java @@ -7,49 +7,75 @@ * Represents a status of a commit. * * @author Kohsuke Kawaguchi - * @see GHRepository#getLastCommitStatus(String) - * @see GHCommit#getLastStatus() - * @see GHRepository#createCommitStatus(String, GHCommitState, String, String) + * @see GHRepository#getLastCommitStatus(String) GHRepository#getLastCommitStatus(String) + * @see GHCommit#getLastStatus() GHCommit#getLastStatus() + * @see GHRepository#createCommitStatus(String, GHCommitState, String, String) GHRepository#createCommitStatus(String, + * GHCommitState, String, String) */ public class GHCommitStatus extends GHObject { String state; - String target_url,description; + String target_url, description; String context; GHUser creator; private GitHub root; - /*package*/ GHCommitStatus wrapUp(GitHub root) { - if (creator!=null) creator.wrapUp(root); + GHCommitStatus wrapUp(GitHub root) { + if (creator != null) + creator.wrapUp(root); this.root = root; return this; } + /** + * Gets state. + * + * @return the state + */ public GHCommitState getState() { for (GHCommitState s : GHCommitState.values()) { if (s.name().equalsIgnoreCase(state)) return s; } - throw new IllegalStateException("Unexpected state: "+state); + throw new IllegalStateException("Unexpected state: " + state); } /** * The URL that this status is linked to. - * + *

* This is the URL specified when creating a commit status. + * + * @return the target url */ public String getTargetUrl() { return target_url; } + /** + * Gets description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Gets creator. + * + * @return the creator + * @throws IOException + * the io exception + */ public GHUser getCreator() throws IOException { return root.intern(creator); } + /** + * Gets context. + * + * @return the context + */ public String getContext() { return context; } diff --git a/src/main/java/org/kohsuke/github/GHCompare.java b/src/main/java/org/kohsuke/github/GHCompare.java index 100753db01..430e9fc46f 100644 --- a/src/main/java/org/kohsuke/github/GHCompare.java +++ b/src/main/java/org/kohsuke/github/GHCompare.java @@ -21,52 +21,108 @@ public class GHCompare { private GHRepository owner; + /** + * Gets url. + * + * @return the url + */ public URL getUrl() { return GitHub.parseURL(url); } + /** + * Gets html url. + * + * @return the html url + */ public URL getHtmlUrl() { return GitHub.parseURL(html_url); } + /** + * Gets permalink url. + * + * @return the permalink url + */ public URL getPermalinkUrl() { return GitHub.parseURL(permalink_url); } + /** + * Gets diff url. + * + * @return the diff url + */ public URL getDiffUrl() { return GitHub.parseURL(diff_url); } + /** + * Gets patch url. + * + * @return the patch url + */ public URL getPatchUrl() { return GitHub.parseURL(patch_url); } + /** + * Gets status. + * + * @return the status + */ public Status getStatus() { return status; } + /** + * Gets ahead by. + * + * @return the ahead by + */ public int getAheadBy() { return ahead_by; } + /** + * Gets behind by. + * + * @return the behind by + */ public int getBehindBy() { return behind_by; } + /** + * Gets total commits. + * + * @return the total commits + */ public int getTotalCommits() { return total_commits; } + /** + * Gets base commit. + * + * @return the base commit + */ public Commit getBaseCommit() { return base_commit; } + /** + * Gets merge base commit. + * + * @return the merge base commit + */ public Commit getMergeBaseCommit() { return merge_base_commit; } /** * Gets an array of commits. + * * @return A copy of the array being stored in the class. */ public Commit[] getCommits() { @@ -74,9 +130,10 @@ public Commit[] getCommits() { System.arraycopy(commits, 0, newValue, 0, commits.length); return newValue; } - + /** * Gets an array of commits. + * * @return A copy of the array being stored in the class. */ public GHCommit.File[] getFiles() { @@ -85,6 +142,13 @@ public GHCommit.File[] getFiles() { return newValue; } + /** + * Wrap gh compare. + * + * @param owner + * the owner + * @return the gh compare + */ public GHCompare wrap(GHRepository owner) { this.owner = owner; for (Commit commit : commits) { @@ -96,71 +160,126 @@ public GHCompare wrap(GHRepository owner) { } /** - * Compare commits had a child commit element with additional details we want to capture. - * This extenstion of GHCommit provides that. + * Compare commits had a child commit element with additional details we want to capture. This extenstion of + * GHCommit provides that. */ - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"}, + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") public static class Commit extends GHCommit { private InnerCommit commit; + /** + * Gets commit. + * + * @return the commit + */ public InnerCommit getCommit() { return commit; } } - + /** + * The type InnerCommit. + */ public static class InnerCommit { private String url, sha, message; private User author, committer; private Tree tree; + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } + /** + * Gets message. + * + * @return the message + */ public String getMessage() { return message; } - @WithBridgeMethods(value=User.class,castRequired=true) + /** + * Gets author. + * + * @return the author + */ + @WithBridgeMethods(value = User.class, castRequired = true) public GitUser getAuthor() { return author; } - @WithBridgeMethods(value=User.class,castRequired=true) + /** + * Gets committer. + * + * @return the committer + */ + @WithBridgeMethods(value = User.class, castRequired = true) public GitUser getCommitter() { return committer; } + /** + * Gets tree. + * + * @return the tree + */ public Tree getTree() { return tree; } } + /** + * The type Tree. + */ public static class Tree { private String url, sha; + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } } /** + * The type User. + * * @deprecated use {@link GitUser} instead. */ public static class User extends GitUser { } + /** + * The enum Status. + */ public static enum Status { behind, ahead, identical, diverged } diff --git a/src/main/java/org/kohsuke/github/GHContent.java b/src/main/java/org/kohsuke/github/GHContent.java index 9b9f787a67..8683e6c2fb 100644 --- a/src/main/java/org/kohsuke/github/GHContent.java +++ b/src/main/java/org/kohsuke/github/GHContent.java @@ -13,13 +13,13 @@ * A Content of a repository. * * @author Alexandre COLLIGNON - * @see GHRepository#getFileContent(String) + * @see GHRepository#getFileContent(String) GHRepository#getFileContent(String) */ -@SuppressWarnings({"UnusedDeclaration"}) +@SuppressWarnings({ "UnusedDeclaration" }) public class GHContent implements Refreshable { /* - In normal use of this class, repository field is set via wrap(), - but in the code search API, there's a nested 'repository' field that gets populated from JSON. + * In normal use of this class, repository field is set via wrap(), but in the code search API, there's a nested + * 'repository' field that gets populated from JSON. */ private GHRepository repository; @@ -33,34 +33,69 @@ In normal use of this class, repository field is set via wrap(), private String path; private String content; private String url; // this is the API url - private String git_url; // this is the Blob url - private String html_url; // this is the UI + private String git_url; // this is the Blob url + private String html_url; // this is the UI private String download_url; + /** + * Gets owner. + * + * @return the owner + */ public GHRepository getOwner() { return repository; } + /** + * Gets type. + * + * @return the type + */ public String getType() { return type; } + /** + * Gets encoding. + * + * @return the encoding + */ public String getEncoding() { return encoding; } + /** + * Gets size. + * + * @return the size + */ public long getSize() { return size; } + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets path. + * + * @return the path + */ public String getPath() { return path; } @@ -69,12 +104,13 @@ public String getPath() { * Retrieve the decoded content that is stored at this location. * *

- * Due to the nature of GitHub's API, you're not guaranteed that - * the content will already be populated, so this may trigger - * network activity, and can throw an IOException. + * Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may + * trigger network activity, and can throw an IOException. * - * @deprecated - * Use {@link #read()} + * @return the content + * @throws IOException + * the io exception + * @deprecated Use {@link #read()} */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public String getContent() throws IOException { @@ -85,26 +121,42 @@ public String getContent() throws IOException { * Retrieve the base64-encoded content that is stored at this location. * *

- * Due to the nature of GitHub's API, you're not guaranteed that - * the content will already be populated, so this may trigger - * network activity, and can throw an IOException. + * Due to the nature of GitHub's API, you're not guaranteed that the content will already be populated, so this may + * trigger network activity, and can throw an IOException. * - * @deprecated - * Use {@link #read()} + * @return the encoded content + * @throws IOException + * the io exception + * @deprecated Use {@link #read()} */ public String getEncodedContent() throws IOException { refresh(content); return content; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets git url. + * + * @return the git url + */ public String getGitUrl() { return git_url; } + /** + * Gets html url. + * + * @return the html url + */ public String getHtmlUrl() { return html_url; } @@ -114,6 +166,10 @@ public String getHtmlUrl() { */ /** * Retrieves the actual bytes of the blob. + * + * @return the input stream + * @throws IOException + * the io exception */ public InputStream read() throws IOException { refresh(content); @@ -121,33 +177,50 @@ public InputStream read() throws IOException { try { return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false); } catch (UnsupportedEncodingException e) { - throw new AssertionError(e); // US-ASCII is mandatory + throw new AssertionError(e); // US-ASCII is mandatory } } - throw new UnsupportedOperationException("Unrecognized encoding: "+encoding); + throw new UnsupportedOperationException("Unrecognized encoding: " + encoding); } /** * URL to retrieve the raw content of the file. Null if this is a directory. + * + * @return the download url + * @throws IOException + * the io exception */ public String getDownloadUrl() throws IOException { refresh(download_url); return download_url; } + /** + * Is file boolean. + * + * @return the boolean + */ public boolean isFile() { return "file".equals(type); } + /** + * Is directory boolean. + * + * @return the boolean + */ public boolean isDirectory() { return "dir".equals(type); } /** * Fully populate the data by retrieving missing data. - * + *

* Depending on the original API call where this object is created, it may not contain everything. + * + * @throws IOException + * the io exception */ protected synchronized void populate() throws IOException { root.retrieve().to(url, this); @@ -155,47 +228,95 @@ protected synchronized void populate() throws IOException { /** * List immediate children of this directory. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listDirectoryContent() throws IOException { if (!isDirectory()) - throw new IllegalStateException(path+" is not a directory"); + throw new IllegalStateException(path + " is not a directory"); - return root.retrieve() - .asPagedIterable( - url, - GHContent[].class, - item -> item.wrap(repository) ); + return root.retrieve().asPagedIterable(url, GHContent[].class, item -> item.wrap(repository)); } + /** + * Update gh content update response. + * + * @param newContent + * the new content + * @param commitMessage + * the commit message + * @return the gh content update response + * @throws IOException + * the io exception + */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException { return update(newContent.getBytes(), commitMessage, null); } + /** + * Update gh content update response. + * + * @param newContent + * the new content + * @param commitMessage + * the commit message + * @param branch + * the branch + * @return the gh content update response + * @throws IOException + * the io exception + */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException { return update(newContent.getBytes(), commitMessage, branch); } + /** + * Update gh content update response. + * + * @param newContentBytes + * the new content bytes + * @param commitMessage + * the commit message + * @return the gh content update response + * @throws IOException + * the io exception + */ public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException { return update(newContentBytes, commitMessage, null); } - public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch) throws IOException { + /** + * Update gh content update response. + * + * @param newContentBytes + * the new content bytes + * @param commitMessage + * the commit message + * @param branch + * the branch + * @return the gh content update response + * @throws IOException + * the io exception + */ + public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch) + throws IOException { String encodedContent = Base64.encodeBase64String(newContentBytes); - Requester requester = new Requester(root) - .with("path", path) - .with("message", commitMessage) - .with("sha", sha) - .with("content", encodedContent) - .method("PUT"); + Requester requester = new Requester(root).with("path", path) + .with("message", commitMessage) + .with("sha", sha) + .with("content", encodedContent) + .method("PUT"); if (branch != null) { requester.with("branch", branch); } - GHContentUpdateResponse response = requester.to(getApiRoute(), GHContentUpdateResponse.class); + GHContentUpdateResponse response = requester.to(getApiRoute(repository, path), GHContentUpdateResponse.class); response.getContent().wrap(repository); response.getCommit().wrapUp(repository); @@ -204,29 +325,48 @@ public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessa return response; } + /** + * Delete gh content update response. + * + * @param message + * the message + * @return the gh content update response + * @throws IOException + * the io exception + */ public GHContentUpdateResponse delete(String message) throws IOException { return delete(message, null); } + /** + * Delete gh content update response. + * + * @param commitMessage + * the commit message + * @param branch + * the branch + * @return the gh content update response + * @throws IOException + * the io exception + */ public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException { - Requester requester = new Requester(root) - .with("path", path) - .with("message", commitMessage) - .with("sha", sha) - .method("DELETE"); + Requester requester = new Requester(root).with("path", path) + .with("message", commitMessage) + .with("sha", sha) + .method("DELETE"); if (branch != null) { requester.with("branch", branch); } - GHContentUpdateResponse response = requester.to(getApiRoute(), GHContentUpdateResponse.class); + GHContentUpdateResponse response = requester.to(getApiRoute(repository, path), GHContentUpdateResponse.class); response.getCommit().wrapUp(repository); return response; } - private String getApiRoute() { - return "/repos/" + repository.getOwnerName() + "/" + repository.getName() + "/contents/" + path; + static String getApiRoute(GHRepository repository, String path) { + return repository.getApiTailUrl("contents/" + path); } GHContent wrap(GHRepository owner) { @@ -234,14 +374,23 @@ GHContent wrap(GHRepository owner) { this.root = owner.root; return this; } + GHContent wrap(GitHub root) { this.root = root; - if (repository!=null) + if (repository != null) repository.wrap(root); return this; } - + /** + * Wrap gh content [ ]. + * + * @param contents + * the contents + * @param repository + * the repository + * @return the gh content [ ] + */ public static GHContent[] wrap(GHContent[] contents, GHRepository repository) { for (GHContent unwrappedContent : contents) { unwrappedContent.wrap(repository); diff --git a/src/main/java/org/kohsuke/github/GHContentBuilder.java b/src/main/java/org/kohsuke/github/GHContentBuilder.java index cdc019f6d1..b50a7e257b 100644 --- a/src/main/java/org/kohsuke/github/GHContentBuilder.java +++ b/src/main/java/org/kohsuke/github/GHContentBuilder.java @@ -12,7 +12,7 @@ * Call various methods to build up parameters, then call {@link #commit()} to make the change effective. * * @author Kohsuke Kawaguchi - * @see GHRepository#createContent() + * @see GHRepository#createContent() GHRepository#createContent() */ public final class GHContentBuilder { private final GHRepository repo; @@ -24,31 +24,62 @@ public final class GHContentBuilder { this.req = new Requester(repo.root).method("PUT"); } + /** + * Path gh content builder. + * + * @param path + * the path + * @return the gh content builder + */ public GHContentBuilder path(String path) { this.path = path; - req.with("path",path); + req.with("path", path); return this; } + /** + * Branch gh content builder. + * + * @param branch + * the branch + * @return the gh content builder + */ public GHContentBuilder branch(String branch) { req.with("branch", branch); return this; } /** - * Used when updating (but not creating a new content) to specify - * Thetblob SHA of the file being replaced. + * Used when updating (but not creating a new content) to specify Thetblob SHA of the file being replaced. + * + * @param sha + * the sha + * @return the gh content builder */ public GHContentBuilder sha(String sha) { req.with("sha", sha); return this; } + /** + * Content gh content builder. + * + * @param content + * the content + * @return the gh content builder + */ public GHContentBuilder content(byte[] content) { req.with("content", Base64.encodeBase64String(content)); return this; } + /** + * Content gh content builder. + * + * @param content + * the content + * @return the gh content builder + */ public GHContentBuilder content(String content) { try { return content(content.getBytes("UTF-8")); @@ -57,6 +88,13 @@ public GHContentBuilder content(String content) { } } + /** + * Message gh content builder. + * + * @param commitMessage + * the commit message + * @return the gh content builder + */ public GHContentBuilder message(String commitMessage) { req.with("message", commitMessage); return this; @@ -64,9 +102,13 @@ public GHContentBuilder message(String commitMessage) { /** * Commits a new content. + * + * @return the gh content update response + * @throws IOException + * the io exception */ public GHContentUpdateResponse commit() throws IOException { - GHContentUpdateResponse response = req.to(repo.getApiTailUrl("contents/" + path), GHContentUpdateResponse.class); + GHContentUpdateResponse response = req.to(GHContent.getApiRoute(repo, path), GHContentUpdateResponse.class); response.getContent().wrap(repo); response.getCommit().wrapUp(repo); diff --git a/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java b/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java index 47e5a46f52..b4b93880f5 100644 --- a/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java @@ -4,11 +4,11 @@ * Search code for {@link GHContent}. * * @author Kohsuke Kawaguchi - * @see GitHub#searchContent() + * @see GitHub#searchContent() GitHub#searchContent() */ public class GHContentSearchBuilder extends GHSearchBuilder { - /*package*/ GHContentSearchBuilder(GitHub root) { - super(root,ContentSearchResult.class); + GHContentSearchBuilder(GitHub root) { + super(root, ContentSearchResult.class); } /** @@ -19,48 +19,110 @@ public GHContentSearchBuilder q(String term) { return this; } + /** + * In gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder in(String v) { - return q("in:"+v); + return q("in:" + v); } + /** + * Language gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder language(String v) { - return q("language:"+v); + return q("language:" + v); } + /** + * Fork gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder fork(String v) { - return q("fork:"+v); + return q("fork:" + v); } + /** + * Size gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder size(String v) { - return q("size:"+v); + return q("size:" + v); } + /** + * Path gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder path(String v) { - return q("path:"+v); + return q("path:" + v); } + /** + * Filename gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder filename(String v) { - return q("filename:"+v); + return q("filename:" + v); } + /** + * Extension gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder extension(String v) { - return q("extension:"+v); + return q("extension:" + v); } + /** + * User gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder user(String v) { - return q("user:"+v); + return q("user:" + v); } - + /** + * Repo gh content search builder. + * + * @param v + * the v + * @return the gh content search builder + */ public GHContentSearchBuilder repo(String v) { - return q("repo:"+v); + return q("repo:" + v); } private static class ContentSearchResult extends SearchResult { private GHContent[] items; @Override - /*package*/ GHContent[] getItems(GitHub root) { + GHContent[] getItems(GitHub root) { for (GHContent item : items) item.wrap(root); return items; diff --git a/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java b/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java index 07f10d710c..d53bce50e5 100644 --- a/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java +++ b/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java @@ -1,17 +1,26 @@ package org.kohsuke.github; /** - * The response that is returned when updating - * repository content. -**/ + * The response that is returned when updating repository content. + */ public class GHContentUpdateResponse { private GHContent content; private GHCommit commit; + /** + * Gets content. + * + * @return the content + */ public GHContent getContent() { return content; } + /** + * Gets commit. + * + * @return the commit + */ public GHCommit getCommit() { return commit; } diff --git a/src/main/java/org/kohsuke/github/GHContentWithLicense.java b/src/main/java/org/kohsuke/github/GHContentWithLicense.java index c067d5a037..c5e6e37753 100644 --- a/src/main/java/org/kohsuke/github/GHContentWithLicense.java +++ b/src/main/java/org/kohsuke/github/GHContentWithLicense.java @@ -13,7 +13,7 @@ class GHContentWithLicense extends GHContent { @Override GHContentWithLicense wrap(GHRepository owner) { super.wrap(owner); - if (license!=null) + if (license != null) license.wrap(owner.root); return this; } diff --git a/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java b/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java index a11fc4493f..268bfa8ef3 100644 --- a/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java @@ -13,123 +13,187 @@ public class GHCreateRepositoryBuilder { protected final Requester builder; private final String apiUrlTail; - /*package*/ GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) { + GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) { this.root = root; this.apiUrlTail = apiUrlTail; this.builder = new Requester(root); - this.builder.with("name",name); + this.builder.with("name", name); } + /** + * Description for repository + * + * @param description + * description of repository + * @return a builder to continue with building + */ public GHCreateRepositoryBuilder description(String description) { - this.builder.with("description",description); + this.builder.with("description", description); return this; } + /** + * Homepage for repository + * + * @param homepage + * homepage of repository + * @return a builder to continue with building + */ public GHCreateRepositoryBuilder homepage(URL homepage) { return homepage(homepage.toExternalForm()); } + /** + * Homepage for repository + * + * @param homepage + * homepage of repository + * @return a builder to continue with building + */ public GHCreateRepositoryBuilder homepage(String homepage) { - this.builder.with("homepage",homepage); + this.builder.with("homepage", homepage); return this; } /** * Creates a private repository + * + * @param enabled + * private if true + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder private_(boolean b) { - this.builder.with("private",b); + public GHCreateRepositoryBuilder private_(boolean enabled) { + this.builder.with("private", enabled); return this; } /** * Enables issue tracker + * + * @param enabled + * true if enabled + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder issues(boolean b) { - this.builder.with("has_issues",b); + public GHCreateRepositoryBuilder issues(boolean enabled) { + this.builder.with("has_issues", enabled); return this; } /** * Enables wiki + * + * @param enabled + * true if enabled + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder wiki(boolean b) { - this.builder.with("has_wiki",b); + public GHCreateRepositoryBuilder wiki(boolean enabled) { + this.builder.with("has_wiki", enabled); return this; } /** * Enables downloads + * + * @param enabled + * true if enabled + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder downloads(boolean b) { - this.builder.with("has_downloads",b); + public GHCreateRepositoryBuilder downloads(boolean enabled) { + this.builder.with("has_downloads", enabled); return this; } /** * If true, create an initial commit with empty README. + * + * @param enabled + * true if enabled + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder autoInit(boolean b) { - this.builder.with("auto_init",b); + public GHCreateRepositoryBuilder autoInit(boolean enabled) { + this.builder.with("auto_init", enabled); return this; } /** * Allow or disallow squash-merging pull requests. + * + * @param enabled + * true if enabled + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder allowSquashMerge(boolean b) { - this.builder.with("allow_squash_merge",b); + public GHCreateRepositoryBuilder allowSquashMerge(boolean enabled) { + this.builder.with("allow_squash_merge", enabled); return this; } /** * Allow or disallow merging pull requests with a merge commit. + * + * @param enabled + * true if enabled + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder allowMergeCommit(boolean b) { - this.builder.with("allow_merge_commit",b); + public GHCreateRepositoryBuilder allowMergeCommit(boolean enabled) { + this.builder.with("allow_merge_commit", enabled); return this; } /** * Allow or disallow rebase-merging pull requests. + * + * @param enabled + * true if enabled + * @return a builder to continue with building */ - public GHCreateRepositoryBuilder allowRebaseMerge(boolean b) { - this.builder.with("allow_rebase_merge",b); + public GHCreateRepositoryBuilder allowRebaseMerge(boolean enabled) { + this.builder.with("allow_rebase_merge", enabled); return this; } /** * Creates a default .gitignore * - * See https://developer.github.com/v3/repos/#create + * @param language + * template to base the ignore file on + * @return a builder to continue with building See https://developer.github.com/v3/repos/#create */ public GHCreateRepositoryBuilder gitignoreTemplate(String language) { - this.builder.with("gitignore_template",language); + this.builder.with("gitignore_template", language); return this; } /** * Desired license template to apply * - * See https://developer.github.com/v3/repos/#create + * @param license + * template to base the license file on + * @return a builder to continue with building See https://developer.github.com/v3/repos/#create */ public GHCreateRepositoryBuilder licenseTemplate(String license) { - this.builder.with("license_template",license); + this.builder.with("license_template", license); return this; } /** - * The team that gets granted access to this repository. Only valid for creating a repository in - * an organization. + * The team that gets granted access to this repository. Only valid for creating a repository in an organization. + * + * @param team + * team to grant access to + * @return a builder to continue with building */ public GHCreateRepositoryBuilder team(GHTeam team) { - if (team!=null) - this.builder.with("team_id",team.getId()); + if (team != null) + this.builder.with("team_id", team.getId()); return this; } /** * Creates a repository with all the parameters. + * + * @return the gh repository + * @throws IOException + * if repsitory cannot be created */ public GHRepository create() throws IOException { return builder.method("POST").to(apiUrlTail, GHRepository.class).wrap(root); diff --git a/src/main/java/org/kohsuke/github/GHDeployKey.java b/src/main/java/org/kohsuke/github/GHDeployKey.java index f5d0f9de6d..f9bd1acd52 100644 --- a/src/main/java/org/kohsuke/github/GHDeployKey.java +++ b/src/main/java/org/kohsuke/github/GHDeployKey.java @@ -4,6 +4,9 @@ import java.io.IOException; +/** + * The type GHDeployKey. + */ public class GHDeployKey { protected String url, key, title; @@ -11,36 +14,75 @@ public class GHDeployKey { protected long id; private GHRepository owner; + /** + * Gets id. + * + * @return the id + */ public long getId() { return id; } + /** + * Gets key. + * + * @return the key + */ public String getKey() { return key; } + /** + * Gets title. + * + * @return the title + */ public String getTitle() { return title; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Is verified boolean. + * + * @return the boolean + */ public boolean isVerified() { return verified; } + /** + * Wrap gh deploy key. + * + * @param repo + * the repo + * @return the gh deploy key + */ public GHDeployKey wrap(GHRepository repo) { this.owner = repo; return this; } public String toString() { - return new ToStringBuilder(this).append("title",title).append("id",id).append("key",key).toString(); + return new ToStringBuilder(this).append("title", title).append("id", id).append("key", key).toString(); } - + + /** + * Delete. + * + * @throws IOException + * the io exception + */ public void delete() throws IOException { - new Requester(owner.root).method("DELETE").to(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id)); + new Requester(owner.root).method("DELETE") + .to(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id)); } } diff --git a/src/main/java/org/kohsuke/github/GHDeployment.java b/src/main/java/org/kohsuke/github/GHDeployment.java index 7a7febf6ce..601bf258d6 100644 --- a/src/main/java/org/kohsuke/github/GHDeployment.java +++ b/src/main/java/org/kohsuke/github/GHDeployment.java @@ -7,8 +7,9 @@ * Represents a deployment * * @see documentation - * @see GHRepository#listDeployments(String, String, String, String) - * @see GHRepository#getDeployment(long) + * @see GHRepository#listDeployments(String, String, String, String) GHRepository#listDeployments(String, String, + * String, String) + * @see GHRepository#getDeployment(long) GHRepository#getDeployment(long) */ public class GHDeployment extends GHObject { private GHRepository owner; @@ -23,38 +24,85 @@ public class GHDeployment extends GHObject { protected String repository_url; protected GHUser creator; - GHDeployment wrap(GHRepository owner) { this.owner = owner; this.root = owner.root; - if(creator != null) creator.wrapUp(root); + if (creator != null) + creator.wrapUp(root); return this; } + /** + * Gets statuses url. + * + * @return the statuses url + */ public URL getStatusesUrl() { return GitHub.parseURL(statuses_url); } + /** + * Gets repository url. + * + * @return the repository url + */ public URL getRepositoryUrl() { return GitHub.parseURL(repository_url); } + /** + * Gets task. + * + * @return the task + */ public String getTask() { return task; } + + /** + * Gets payload. + * + * @return the payload + */ public String getPayload() { return (String) payload; } + + /** + * Gets environment. + * + * @return the environment + */ public String getEnvironment() { return environment; } + + /** + * Gets creator. + * + * @return the creator + * @throws IOException + * the io exception + */ public GHUser getCreator() throws IOException { return root.intern(creator); } + + /** + * Gets ref. + * + * @return the ref + */ public String getRef() { return ref; } - public String getSha(){ + + /** + * Gets sha. + * + * @return the sha + */ + public String getSha() { return sha; } @@ -66,16 +114,24 @@ public URL getHtmlUrl() { return null; } + /** + * Create status gh deployment status builder. + * + * @param state + * the state + * @return the gh deployment status builder + */ public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) { - return new GHDeploymentStatusBuilder(owner,id,state); + return new GHDeploymentStatusBuilder(owner, id, state); } + /** + * List statuses paged iterable. + * + * @return the paged iterable + */ public PagedIterable listStatuses() { - return root.retrieve() - .asPagedIterable( - statuses_url, - GHDeploymentStatus[].class, - item -> item.wrap(owner) ); + return root.retrieve().asPagedIterable(statuses_url, GHDeploymentStatus[].class, item -> item.wrap(owner)); } } diff --git a/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java b/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java index 00d10fad1b..c041538069 100644 --- a/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java +++ b/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java @@ -3,53 +3,130 @@ import java.io.IOException; import java.util.List; -//Based on https://developer.github.com/v3/repos/deployments/#create-a-deployment +/** + * The type GHDeploymentBuilder. + */ +// Based on https://developer.github.com/v3/repos/deployments/#create-a-deployment public class GHDeploymentBuilder { private final GHRepository repo; private final Requester builder; + /** + * Instantiates a new Gh deployment builder. + * + * @param repo + * the repo + */ public GHDeploymentBuilder(GHRepository repo) { this.repo = repo; this.builder = new Requester(repo.root); } + /** + * Instantiates a new Gh deployment builder. + * + * @param repo + * the repo + * @param ref + * the ref + */ public GHDeploymentBuilder(GHRepository repo, String ref) { this(repo); ref(ref); } + /** + * Ref gh deployment builder. + * + * @param branch + * the branch + * @return the gh deployment builder + */ public GHDeploymentBuilder ref(String branch) { - builder.with("ref",branch); + builder.with("ref", branch); return this; } + + /** + * Task gh deployment builder. + * + * @param task + * the task + * @return the gh deployment builder + */ public GHDeploymentBuilder task(String task) { - builder.with("task",task); + builder.with("task", task); return this; } + + /** + * Auto merge gh deployment builder. + * + * @param autoMerge + * the auto merge + * @return the gh deployment builder + */ public GHDeploymentBuilder autoMerge(boolean autoMerge) { - builder.with("auto_merge",autoMerge); + builder.with("auto_merge", autoMerge); return this; } + /** + * Required contexts gh deployment builder. + * + * @param requiredContexts + * the required contexts + * @return the gh deployment builder + */ public GHDeploymentBuilder requiredContexts(List requiredContexts) { - builder.with("required_contexts",requiredContexts); + builder.with("required_contexts", requiredContexts); return this; } + + /** + * Payload gh deployment builder. + * + * @param payload + * the payload + * @return the gh deployment builder + */ public GHDeploymentBuilder payload(String payload) { - builder.with("payload",payload); + builder.with("payload", payload); return this; } + /** + * Environment gh deployment builder. + * + * @param environment + * the environment + * @return the gh deployment builder + */ public GHDeploymentBuilder environment(String environment) { - builder.with("environment",environment); + builder.with("environment", environment); return this; } + + /** + * Description gh deployment builder. + * + * @param description + * the description + * @return the gh deployment builder + */ public GHDeploymentBuilder description(String description) { - builder.with("description",description); + builder.with("description", description); return this; } + /** + * Create gh deployment. + * + * @return the gh deployment + * @throws IOException + * the io exception + */ public GHDeployment create() throws IOException { - return builder.to(repo.getApiTailUrl("deployments"),GHDeployment.class).wrap(repo); + return builder.to(repo.getApiTailUrl("deployments"), GHDeployment.class).wrap(repo); } } diff --git a/src/main/java/org/kohsuke/github/GHDeploymentStatus.java b/src/main/java/org/kohsuke/github/GHDeploymentStatus.java index a058b8a447..c20657368e 100644 --- a/src/main/java/org/kohsuke/github/GHDeploymentStatus.java +++ b/src/main/java/org/kohsuke/github/GHDeploymentStatus.java @@ -3,6 +3,9 @@ import java.net.URL; import java.util.Locale; +/** + * The type GHDeploymentStatus. + */ public class GHDeploymentStatus extends GHObject { private GHRepository owner; private GitHub root; @@ -12,24 +15,54 @@ public class GHDeploymentStatus extends GHObject { protected String target_url; protected String deployment_url; protected String repository_url; + + /** + * Wrap gh deployment status. + * + * @param owner + * the owner + * @return the gh deployment status + */ public GHDeploymentStatus wrap(GHRepository owner) { this.owner = owner; this.root = owner.root; - if(creator != null) creator.wrapUp(root); + if (creator != null) + creator.wrapUp(root); return this; } + + /** + * Gets target url. + * + * @return the target url + */ public URL getTargetUrl() { return GitHub.parseURL(target_url); } + /** + * Gets deployment url. + * + * @return the deployment url + */ public URL getDeploymentUrl() { return GitHub.parseURL(deployment_url); } + /** + * Gets repository url. + * + * @return the repository url + */ public URL getRepositoryUrl() { return GitHub.parseURL(repository_url); } - + + /** + * Gets state. + * + * @return the state + */ public GHDeploymentState getState() { return GHDeploymentState.valueOf(state.toUpperCase(Locale.ENGLISH)); } diff --git a/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java b/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java index 821a3e744e..31e54e64b1 100644 --- a/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java +++ b/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java @@ -5,8 +5,7 @@ /** * Creates a new deployment status. * - * @see - * GHDeployment#createStatus(GHDeploymentState) + * @see GHDeployment#createStatus(GHDeploymentState) GHDeployment#createStatus(GHDeploymentState) */ public class GHDeploymentStatusBuilder { private final Requester builder; @@ -14,31 +13,60 @@ public class GHDeploymentStatusBuilder { private long deploymentId; /** - * @deprecated - * Use {@link GHDeployment#createStatus(GHDeploymentState)} + * Instantiates a new Gh deployment status builder. + * + * @param repo + * the repo + * @param deploymentId + * the deployment id + * @param state + * the state + * @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)} */ public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) { - this(repo,(long)deploymentId,state); + this(repo, (long) deploymentId, state); } - /*package*/ GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) { + GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) { this.repo = repo; this.deploymentId = deploymentId; this.builder = new Requester(repo.root); - this.builder.with("state",state); + this.builder.with("state", state); } + /** + * Description gh deployment status builder. + * + * @param description + * the description + * @return the gh deployment status builder + */ public GHDeploymentStatusBuilder description(String description) { - this.builder.with("description",description); - return this; + this.builder.with("description", description); + return this; } + /** + * Target url gh deployment status builder. + * + * @param targetUrl + * the target url + * @return the gh deployment status builder + */ public GHDeploymentStatusBuilder targetUrl(String targetUrl) { - this.builder.with("target_url",targetUrl); + this.builder.with("target_url", targetUrl); return this; } + /** + * Create gh deployment status. + * + * @return the gh deployment status + * @throws IOException + * the io exception + */ public GHDeploymentStatus create() throws IOException { - return builder.to(repo.getApiTailUrl("deployments/"+deploymentId+"/statuses"),GHDeploymentStatus.class).wrap(repo); + return builder.to(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"), GHDeploymentStatus.class) + .wrap(repo); } } diff --git a/src/main/java/org/kohsuke/github/GHEmail.java b/src/main/java/org/kohsuke/github/GHEmail.java index 9eeac04336..e1b892f007 100644 --- a/src/main/java/org/kohsuke/github/GHEmail.java +++ b/src/main/java/org/kohsuke/github/GHEmail.java @@ -25,36 +25,51 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * Represents an email of GitHub. * * @author Kelly Campbell */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD", "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"}, justification = "JSON API") +@SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" }, + justification = "JSON API") public class GHEmail { protected String email; protected boolean primary; protected boolean verified; + /** + * Gets email. + * + * @return the email + */ public String getEmail() { return email; } + /** + * Is primary boolean. + * + * @return the boolean + */ public boolean isPrimary() { return primary; } + /** + * Is verified boolean. + * + * @return the boolean + */ public boolean isVerified() { return verified; } - @Override public String toString() { - return "Email:"+email; + return "Email:" + email; } @Override diff --git a/src/main/java/org/kohsuke/github/GHEvent.java b/src/main/java/org/kohsuke/github/GHEvent.java index 8ad6368fe5..c82584096a 100644 --- a/src/main/java/org/kohsuke/github/GHEvent.java +++ b/src/main/java/org/kohsuke/github/GHEvent.java @@ -44,7 +44,11 @@ public enum GHEvent { PULL_REQUEST_REVIEW_COMMENT, PUSH, RELEASE, - REPOSITORY, // only valid for org hooks + REPOSITORY, // only + // valid + // for + // org + // hooks STATUS, TEAM, TEAM_ADD, @@ -55,12 +59,12 @@ public enum GHEvent { */ ALL; - /** * Returns GitHub's internal representation of this event. */ String symbol() { - if (this==ALL) return "*"; + if (this == ALL) + return "*"; return name().toLowerCase(Locale.ENGLISH); } } diff --git a/src/main/java/org/kohsuke/github/GHEventInfo.java b/src/main/java/org/kohsuke/github/GHEventInfo.java index ca7e3d4f04..de150e2823 100644 --- a/src/main/java/org/kohsuke/github/GHEventInfo.java +++ b/src/main/java/org/kohsuke/github/GHEventInfo.java @@ -30,73 +30,118 @@ public class GHEventInfo { /** * Inside the event JSON model, GitHub uses a slightly different format. */ - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "JSON API") + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", + "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, + justification = "JSON API") public static class GHEventRepository { @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now") private long id; @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now") - private String url; // repository API URL - private String name; // owner/repo + private String url; // repository API URL + private String name; // owner/repo } + /** + * Gets type. + * + * @return the type + */ public GHEvent getType() { String t = type; - if (t.endsWith("Event")) t=t.substring(0,t.length()-5); + if (t.endsWith("Event")) + t = t.substring(0, t.length() - 5); for (GHEvent e : GHEvent.values()) { - if (e.name().replace("_","").equalsIgnoreCase(t)) + if (e.name().replace("_", "").equalsIgnoreCase(t)) return e; } - return null; // unknown event type + return null; // unknown event type } - /*package*/ GHEventInfo wrapUp(GitHub root) { + GHEventInfo wrapUp(GitHub root) { this.root = root; return this; } + /** + * Gets id. + * + * @return the id + */ public long getId() { return id; } + /** + * Gets created at. + * + * @return the created at + */ public Date getCreatedAt() { return GitHub.parseDate(created_at); } /** - * Repository where the change was made. + * Gets repository. + * + * @return Repository where the change was made. + * @throws IOException + * on error */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "The field comes from JSON deserialization") public GHRepository getRepository() throws IOException { return root.getRepository(repo.name); } - - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, + + /** + * Gets actor. + * + * @return the {@link GHUser} actor for this event. + * @throws IOException + * on error + */ + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "The field comes from JSON deserialization") public GHUser getActor() throws IOException { return root.getUser(actor.getLogin()); } /** - * Quick way to just get the actor of the login. + * Gets actor login. + * + * @return the login of the actor. + * @throws IOException + * on error */ public String getActorLogin() throws IOException { return actor.getLogin(); } - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, + /** + * Gets organization. + * + * @return the organization + * @throws IOException + * the io exception + */ + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "The field comes from JSON deserialization") public GHOrganization getOrganization() throws IOException { - return (org==null || org.getLogin()==null) ? null : root.getOrganization(org.getLogin()); + return (org == null || org.getLogin() == null) ? null : root.getOrganization(org.getLogin()); } /** * Retrieves the payload. - * + * + * @param + * the type parameter * @param type - * Specify one of the {@link GHEventPayload} subtype that defines a type-safe access to the payload. - * This must match the {@linkplain #getType() event type}. + * Specify one of the {@link GHEventPayload} subtype that defines a type-safe access to the payload. This + * must match the {@linkplain #getType() event type}. + * @return parsed event payload + * @throws IOException + * if payload cannot be parsed */ public T getPayload(Class type) throws IOException { T v = GitHub.MAPPER.readValue(payload.traverse(), type); diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index acdf5c74e9..7c18ae7d61 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -9,9 +8,9 @@ /** * Base type for types used in databinding of the event payload. - * - * @see GitHub#parseEventPayload(Reader, Class) - * @see GHEventInfo#getPayload(Class) + * + * @see GitHub#parseEventPayload(Reader, Class) GitHub#parseEventPayload(Reader, Class) + * @see GHEventInfo#getPayload(Class) GHEventInfo#getPayload(Class) */ @SuppressWarnings("UnusedDeclaration") public abstract class GHEventPayload { @@ -19,22 +18,29 @@ public abstract class GHEventPayload { private GHUser sender; - /*package*/ GHEventPayload() { + GHEventPayload() { } /** * Gets the sender or {@code null} if accessed via the events API. + * * @return the sender or {@code null} if accessed via the events API. */ public GHUser getSender() { return sender; } + /** + * Sets sender. + * + * @param sender + * the sender + */ public void setSender(GHUser sender) { this.sender = sender; } - /*package*/ void wrapUp(GitHub root) { + void wrapUp(GitHub root) { this.root = root; if (sender != null) { sender.wrapUp(root); @@ -46,27 +52,48 @@ public void setSender(GHUser sender) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public static class PullRequest extends GHEventPayload { private String action; private int number; private GHPullRequest pull_request; private GHRepository repository; + /** + * Gets action. + * + * @return the action + */ public String getAction() { return action; } + /** + * Gets number. + * + * @return the number + */ public int getNumber() { return number; } + /** + * Gets pull request. + * + * @return the pull request + */ public GHPullRequest getPullRequest() { pull_request.root = root; return pull_request; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } @@ -74,9 +101,10 @@ public GHRepository getRepository() { @Override void wrapUp(GitHub root) { super.wrapUp(root); - if (pull_request==null) - throw new IllegalStateException("Expected pull_request payload, but got something else. Maybe we've got another type of event?"); - if (repository!=null) { + if (pull_request == null) + throw new IllegalStateException( + "Expected pull_request payload, but got something else. Maybe we've got another type of event?"); + if (repository != null) { repository.wrap(root); pull_request.wrapUp(repository); } else { @@ -85,11 +113,11 @@ void wrapUp(GitHub root) { } } - /** * A review was added to a pull request * - * @see authoritative source + * @see authoritative + * source */ public static class PullRequestReview extends GHEventPayload { private String action; @@ -97,18 +125,38 @@ public static class PullRequestReview extends GHEventPayload { private GHPullRequest pull_request; private GHRepository repository; + /** + * Gets action. + * + * @return the action + */ public String getAction() { return action; } - + + /** + * Gets review. + * + * @return the review + */ public GHPullRequestReview getReview() { return review; } + /** + * Gets pull request. + * + * @return the pull request + */ public GHPullRequest getPullRequest() { return pull_request; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } @@ -116,12 +164,13 @@ public GHRepository getRepository() { @Override void wrapUp(GitHub root) { super.wrapUp(root); - if (review==null) - throw new IllegalStateException("Expected pull_request_review payload, but got something else. Maybe we've got another type of event?"); - + if (review == null) + throw new IllegalStateException( + "Expected pull_request_review payload, but got something else. Maybe we've got another type of event?"); + review.wrapUp(pull_request); - - if (repository!=null) { + + if (repository != null) { repository.wrap(root); pull_request.wrapUp(repository); } else { @@ -129,11 +178,12 @@ void wrapUp(GitHub root) { } } } - + /** * A review comment was added to a pull request * - * @see authoritative source + * @see authoritative + * source */ public static class PullRequestReviewComment extends GHEventPayload { private String action; @@ -141,18 +191,38 @@ public static class PullRequestReviewComment extends GHEventPayload { private GHPullRequest pull_request; private GHRepository repository; + /** + * Gets action. + * + * @return the action + */ public String getAction() { return action; } - + + /** + * Gets comment. + * + * @return the comment + */ public GHPullRequestReviewComment getComment() { return comment; } + /** + * Gets pull request. + * + * @return the pull request + */ public GHPullRequest getPullRequest() { return pull_request; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } @@ -160,12 +230,13 @@ public GHRepository getRepository() { @Override void wrapUp(GitHub root) { super.wrapUp(root); - if (comment==null) - throw new IllegalStateException("Expected pull_request_review_comment payload, but got something else. Maybe we've got another type of event?"); - + if (comment == null) + throw new IllegalStateException( + "Expected pull_request_review_comment payload, but got something else. Maybe we've got another type of event?"); + comment.wrapUp(pull_request); - - if (repository!=null) { + + if (repository != null) { repository.wrap(root); pull_request.wrapUp(repository); } else { @@ -175,34 +246,62 @@ void wrapUp(GitHub root) { } /** - * A Issue has been assigned, unassigned, labeled, unlabeled, opened, edited, milestoned, demilestoned, closed, or reopened. + * A Issue has been assigned, unassigned, labeled, unlabeled, opened, edited, milestoned, demilestoned, closed, or + * reopened. * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class Issue extends GHEventPayload { private String action; private GHIssue issue; private GHRepository repository; + /** + * Gets action. + * + * @return the action + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getAction() { return action; } + /** + * Gets issue. + * + * @return the issue + */ public GHIssue getIssue() { return issue; } + /** + * Sets issue. + * + * @param issue + * the issue + */ public void setIssue(GHIssue issue) { this.issue = issue; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -224,7 +323,7 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class IssueComment extends GHEventPayload { private String action; @@ -232,31 +331,69 @@ public static class IssueComment extends GHEventPayload { private GHIssue issue; private GHRepository repository; + /** + * Gets action. + * + * @return the action + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getAction() { return action; } + /** + * Gets comment. + * + * @return the comment + */ public GHIssueComment getComment() { return comment; } + /** + * Sets comment. + * + * @param comment + * the comment + */ public void setComment(GHIssueComment comment) { this.comment = comment; } + /** + * Gets issue. + * + * @return the issue + */ public GHIssue getIssue() { return issue; } + /** + * Sets issue. + * + * @param issue + * the issue + */ public void setIssue(GHIssue issue) { this.issue = issue; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -279,30 +416,57 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class CommitComment extends GHEventPayload { private String action; private GHCommitComment comment; private GHRepository repository; + /** + * Gets action. + * + * @return the action + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getAction() { return action; } + /** + * Gets comment. + * + * @return the comment + */ public GHCommitComment getComment() { return comment; } + /** + * Sets comment. + * + * @param comment + * the comment + */ public void setComment(GHCommitComment comment) { this.comment = comment; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -322,41 +486,70 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class Create extends GHEventPayload { private String ref; - @JsonProperty("ref_type") private String refType; - @JsonProperty("master_branch") private String masterBranch; private String description; private GHRepository repository; + /** + * Gets ref. + * + * @return the ref + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getRef() { return ref; } + /** + * Gets ref type. + * + * @return the ref type + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getRefType() { return refType; } + /** + * Gets master branch. + * + * @return the master branch + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getMasterBranch() { return masterBranch; } + /** + * Gets description. + * + * @return the description + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getDescription() { return description; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -375,28 +568,48 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class Delete extends GHEventPayload { private String ref; - @JsonProperty("ref_type") private String refType; private GHRepository repository; + /** + * Gets ref. + * + * @return the ref + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getRef() { return ref; } + /** + * Gets ref type. + * + * @return the ref type + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getRefType() { return refType; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -415,24 +628,46 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class Deployment extends GHEventPayload { private GHDeployment deployment; private GHRepository repository; + /** + * Gets deployment. + * + * @return the deployment + */ public GHDeployment getDeployment() { return deployment; } + /** + * Sets deployment. + * + * @param deployment + * the deployment + */ public void setDeployment(GHDeployment deployment) { this.deployment = deployment; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -450,36 +685,69 @@ void wrapUp(GitHub root) { /** * A deployment * - * @see authoritative source + * @see authoritative + * source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class DeploymentStatus extends GHEventPayload { - @JsonProperty("deployment_status") private GHDeploymentStatus deploymentStatus; private GHDeployment deployment; private GHRepository repository; + /** + * Gets deployment status. + * + * @return the deployment status + */ public GHDeploymentStatus getDeploymentStatus() { return deploymentStatus; } + /** + * Sets deployment status. + * + * @param deploymentStatus + * the deployment status + */ public void setDeploymentStatus(GHDeploymentStatus deploymentStatus) { this.deploymentStatus = deploymentStatus; } + /** + * Gets deployment. + * + * @return the deployment + */ public GHDeployment getDeployment() { return deployment; } + /** + * Sets deployment. + * + * @param deployment + * the deployment + */ public void setDeployment(GHDeployment deployment) { this.deployment = deployment; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -500,25 +768,46 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class Fork extends GHEventPayload { private GHRepository forkee; private GHRepository repository; - + /** + * Gets forkee. + * + * @return the forkee + */ public GHRepository getForkee() { return forkee; } + /** + * Sets forkee. + * + * @param forkee + * the forkee + */ public void setForkee(GHRepository forkee) { this.forkee = forkee; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -540,18 +829,40 @@ public static class Ping extends GHEventPayload { private GHRepository repository; private GHOrganization organization; + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Gets organization. + * + * @return the organization + */ public GHOrganization getOrganization() { return organization; } + /** + * Sets organization. + * + * @param organization + * the organization + */ public void setOrganization(GHOrganization organization) { this.organization = organization; } @@ -559,7 +870,7 @@ public void setOrganization(GHOrganization organization) { @Override void wrapUp(GitHub root) { super.wrapUp(root); - if (repository!=null) + if (repository != null) repository.wrap(root); if (organization != null) { organization.wrapUp(root); @@ -576,10 +887,21 @@ void wrapUp(GitHub root) { public static class Public extends GHEventPayload { private GHRepository repository; + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } @@ -587,7 +909,7 @@ public GHRepository getRepository() { @Override void wrapUp(GitHub root) { super.wrapUp(root); - if (repository!=null) + if (repository != null) repository.wrap(root); } @@ -598,8 +920,9 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD", "UUF_UNUSED_FIELD"}, - justification = "Constructed by JSON deserialization") + @SuppressFBWarnings( + value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD", "UUF_UNUSED_FIELD" }, + justification = "Constructed by JSON deserialization") public static class Push extends GHEventPayload { private String head, before; private boolean created, deleted, forced; @@ -611,14 +934,18 @@ public static class Push extends GHEventPayload { /** * The SHA of the HEAD commit on the repository + * + * @return the head */ public String getHead() { return head; } /** - * This is undocumented, but it looks like this captures the commit that the ref was pointing to - * before the push. + * This is undocumented, but it looks like this captures the commit that the ref was pointing to before the + * push. + * + * @return the before */ public String getBefore() { return before; @@ -631,46 +958,82 @@ private void setAfter(String after) { /** * The full Git ref that was pushed. Example: “refs/heads/master” + * + * @return the ref */ public String getRef() { return ref; } /** - * The number of commits in the push. - * Is this always the same as {@code getCommits().size()}? + * The number of commits in the push. Is this always the same as {@code getCommits().size()}? + * + * @return the size */ public int getSize() { return size; } + /** + * Is created boolean. + * + * @return the boolean + */ public boolean isCreated() { return created; } + /** + * Is deleted boolean. + * + * @return the boolean + */ public boolean isDeleted() { return deleted; } + /** + * Is forced boolean. + * + * @return the boolean + */ public boolean isForced() { return forced; } /** * The list of pushed commits. + * + * @return the commits */ public List getCommits() { return commits; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Gets pusher. + * + * @return the pusher + */ public Pusher getPusher() { return pusher; } + /** + * Sets pusher. + * + * @param pusher + * the pusher + */ public void setPusher(Pusher pusher) { this.pusher = pusher; } @@ -678,25 +1041,50 @@ public void setPusher(Pusher pusher) { @Override void wrapUp(GitHub root) { super.wrapUp(root); - if (repository!=null) + if (repository != null) repository.wrap(root); } + /** + * The type Pusher. + */ public static class Pusher { private String name, email; + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Sets name. + * + * @param name + * the name + */ public void setName(String name) { this.name = name; } + /** + * Gets email. + * + * @return the email + */ public String getEmail() { return email; } + /** + * Sets email. + * + * @param email + * the email + */ public void setEmail(String email) { this.email = email; } @@ -712,21 +1100,38 @@ public static class PushCommit { private boolean distinct; private List added, removed, modified; + /** + * Gets author. + * + * @return the author + */ public GitUser getAuthor() { return author; } + /** + * Gets committer. + * + * @return the committer + */ public GitUser getCommitter() { return committer; } /** * Points to the commit API resource. + * + * @return the url */ public String getUrl() { return url; } + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } @@ -736,25 +1141,47 @@ private void setId(String id) { sha = id; } + /** + * Gets message. + * + * @return the message + */ public String getMessage() { return message; } /** * Whether this commit is distinct from any that have been pushed before. + * + * @return the boolean */ public boolean isDistinct() { return distinct; } + /** + * Gets added. + * + * @return the added + */ public List getAdded() { return added; } + /** + * Gets removed. + * + * @return the removed + */ public List getRemoved() { return removed; } + /** + * Gets modified. + * + * @return the modified + */ public List getModified() { return modified; } @@ -766,30 +1193,57 @@ public List getModified() { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, + @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization") public static class Release extends GHEventPayload { private String action; private GHRelease release; private GHRepository repository; + /** + * Gets action. + * + * @return the action + */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Comes from JSON deserialization") public String getAction() { return action; } + /** + * Gets release. + * + * @return the release + */ public GHRelease getRelease() { return release; } + /** + * Sets release. + * + * @param release + * the release + */ public void setRelease(GHRelease release) { this.release = release; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } @@ -808,29 +1262,57 @@ void wrapUp(GitHub root) { * * @see authoritative source */ - @SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD"}, - justification = "Constructed by JSON deserialization") + @SuppressFBWarnings( + value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, + justification = "Constructed by JSON deserialization") public static class Repository extends GHEventPayload { private String action; private GHRepository repository; private GHOrganization organization; + /** + * Gets action. + * + * @return the action + */ public String getAction() { return action; } + /** + * Sets repository. + * + * @param repository + * the repository + */ public void setRepository(GHRepository repository) { this.repository = repository; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } + /** + * Gets organization. + * + * @return the organization + */ public GHOrganization getOrganization() { return organization; } + /** + * Sets organization. + * + * @param organization + * the organization + */ public void setOrganization(GHOrganization organization) { this.organization = organization; } diff --git a/src/main/java/org/kohsuke/github/GHException.java b/src/main/java/org/kohsuke/github/GHException.java index c238e53c9e..32534d40d6 100644 --- a/src/main/java/org/kohsuke/github/GHException.java +++ b/src/main/java/org/kohsuke/github/GHException.java @@ -1,13 +1,29 @@ package org.kohsuke.github; /** + * The type GHException. + * * @author Kohsuke Kawaguchi */ public class GHException extends RuntimeException { + /** + * Instantiates a new Gh exception. + * + * @param message + * the message + */ public GHException(String message) { super(message); } + /** + * Instantiates a new Gh exception. + * + * @param message + * the message + * @param cause + * the cause + */ public GHException(String message, Throwable cause) { super(message, cause); } diff --git a/src/main/java/org/kohsuke/github/GHFileNotFoundException.java b/src/main/java/org/kohsuke/github/GHFileNotFoundException.java index 9f4b37c560..6475515929 100644 --- a/src/main/java/org/kohsuke/github/GHFileNotFoundException.java +++ b/src/main/java/org/kohsuke/github/GHFileNotFoundException.java @@ -1,27 +1,41 @@ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.FileNotFoundException; import java.net.HttpURLConnection; import java.util.List; import java.util.Map; +import javax.annotation.CheckForNull; + /** - * Request/responce contains useful metadata. - * Custom exception allows store info for next diagnostics. + * Request/responce contains useful metadata. Custom exception allows store info for next diagnostics. * * @author Kanstantsin Shautsou */ public class GHFileNotFoundException extends FileNotFoundException { protected Map> responseHeaderFields; + /** + * Instantiates a new Gh file not found exception. + */ public GHFileNotFoundException() { } + /** + * Instantiates a new Gh file not found exception. + * + * @param s + * the s + */ public GHFileNotFoundException(String s) { super(s); } + /** + * Gets response header fields. + * + * @return the response header fields + */ @CheckForNull public Map> getResponseHeaderFields() { return responseHeaderFields; diff --git a/src/main/java/org/kohsuke/github/GHGist.java b/src/main/java/org/kohsuke/github/GHGist.java index 19a2b626f2..d772d3dd77 100644 --- a/src/main/java/org/kohsuke/github/GHGist.java +++ b/src/main/java/org/kohsuke/github/GHGist.java @@ -14,14 +14,14 @@ * Gist * * @author Kohsuke Kawaguchi - * @see GHUser#listGists() - * @see GitHub#getGist(String) - * @see GitHub#createGist() + * @see GHUser#listGists() GHUser#listGists() + * @see GitHub#getGist(String) GitHub#getGist(String) + * @see GitHub#createGist() GitHub#createGist() * @see documentation */ public class GHGist extends GHObject { - /*package almost final*/ GHUser owner; - /*package almost final*/ GitHub root; + /* package almost final */ GHUser owner; + /* package almost final */ GitHub root; private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url; @@ -34,30 +34,51 @@ public class GHGist extends GHObject { private String comments_url; - private Map files = new HashMap(); + private Map files = new HashMap(); /** - * User that owns this Gist. + * Gets owner. + * + * @return User that owns this Gist. + * @throws IOException + * the io exception */ public GHUser getOwner() throws IOException { return root.intern(owner); } + /** + * Gets forks url. + * + * @return the forks url + */ public String getForksUrl() { return forks_url; } + /** + * Gets commits url. + * + * @return the commits url + */ public String getCommitsUrl() { return commits_url; } /** - * URL like https://gist.github.com/gists/12345.git + * Gets git pull url. + * + * @return URL like https://gist.github.com/gists/12345.git */ public String getGitPullUrl() { return git_pull_url; } + /** + * Gets git push url. + * + * @return the git push url + */ public String getGitPushUrl() { return git_push_url; } @@ -66,34 +87,63 @@ public URL getHtmlUrl() { return GitHub.parseURL(html_url); } + /** + * Is public boolean. + * + * @return the boolean + */ public boolean isPublic() { return _public; } + /** + * Gets description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Gets comment count. + * + * @return the comment count + */ public int getCommentCount() { return comments; } /** - * API URL of listing comments. + * Gets comments url. + * + * @return API URL of listing comments. */ public String getCommentsUrl() { return comments_url; } + /** + * Gets file. + * + * @param name + * the name + * @return the file + */ public GHGistFile getFile(String name) { return files.get(name); } - public Map getFiles() { + /** + * Gets files. + * + * @return the files + */ + public Map getFiles() { return Collections.unmodifiableMap(files); } - /*package*/ GHGist wrapUp(GHUser owner) { + GHGist wrapUp(GHUser owner) { this.owner = owner; this.root = owner.root; wrapUp(); @@ -101,10 +151,10 @@ public Map getFiles() { } /** - * Used when caller obtains {@link GHGist} without knowing its owner. - * A partially constructed owner object is interned. + * Used when caller obtains {@link GHGist} without knowing its owner. A partially constructed owner object is + * interned. */ - /*package*/ GHGist wrapUp(GitHub root) { + GHGist wrapUp(GitHub root) { this.owner = root.getUser(owner); this.root = root; wrapUp(); @@ -125,35 +175,62 @@ String getApiTailUrl(String tail) { return result; } + /** + * Star. + * + * @throws IOException + * the io exception + */ public void star() throws IOException { new Requester(root).method("PUT").to(getApiTailUrl("star")); } + /** + * Unstar. + * + * @throws IOException + * the io exception + */ public void unstar() throws IOException { new Requester(root).method("DELETE").to(getApiTailUrl("star")); } + /** + * Is starred boolean. + * + * @return the boolean + * @throws IOException + * the io exception + */ public boolean isStarred() throws IOException { - return root.retrieve().asHttpStatusCode(getApiTailUrl("star"))/100==2; + return root.retrieve().asHttpStatusCode(getApiTailUrl("star")) / 100 == 2; } /** * Forks this gist into your own. + * + * @return the gh gist + * @throws IOException + * the io exception */ public GHGist fork() throws IOException { - return new Requester(root).to(getApiTailUrl("forks"),GHGist.class).wrapUp(root); + return new Requester(root).to(getApiTailUrl("forks"), GHGist.class).wrapUp(root); } + /** + * List forks paged iterable. + * + * @return the paged iterable + */ public PagedIterable listForks() { - return root.retrieve() - .asPagedIterable( - getApiTailUrl("forks"), - GHGist[].class, - item -> item.wrapUp(root) ); + return root.retrieve().asPagedIterable(getApiTailUrl("forks"), GHGist[].class, item -> item.wrapUp(root)); } /** * Deletes this gist. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { new Requester(root).method("DELETE").to("/gists/" + id); @@ -161,6 +238,10 @@ public void delete() throws IOException { /** * Updates this gist via a builder. + * + * @return the gh gist updater + * @throws IOException + * the io exception */ public GHGistUpdater update() throws IOException { return new GHGistUpdater(this); @@ -168,8 +249,10 @@ public GHGistUpdater update() throws IOException { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; GHGist ghGist = (GHGist) o; return id.equals(ghGist.id); diff --git a/src/main/java/org/kohsuke/github/GHGistBuilder.java b/src/main/java/org/kohsuke/github/GHGistBuilder.java index 57fd255031..b0d572038e 100644 --- a/src/main/java/org/kohsuke/github/GHGistBuilder.java +++ b/src/main/java/org/kohsuke/github/GHGistBuilder.java @@ -8,30 +8,56 @@ * Builder pattern for creating a new Gist. * * @author Kohsuke Kawaguchi - * @see GitHub#createGist() + * @see GitHub#createGist() GitHub#createGist() */ public class GHGistBuilder { private final GitHub root; private final Requester req; - private final LinkedHashMap files = new LinkedHashMap(); + private final LinkedHashMap files = new LinkedHashMap(); + /** + * Instantiates a new Gh gist builder. + * + * @param root + * the root + */ public GHGistBuilder(GitHub root) { this.root = root; req = new Requester(root); } + /** + * Description gh gist builder. + * + * @param desc + * the desc + * @return the gh gist builder + */ public GHGistBuilder description(String desc) { - req.with("description",desc); + req.with("description", desc); return this; } + /** + * Public gh gist builder. + * + * @param v + * the v + * @return the gh gist builder + */ public GHGistBuilder public_(boolean v) { - req.with("public",v); + req.with("public", v); return this; } /** - * Adds a new file. + * File gh gist builder. + * + * @param fileName + * the file name + * @param content + * the content + * @return Adds a new file. */ public GHGistBuilder file(String fileName, String content) { files.put(fileName, Collections.singletonMap("content", content)); @@ -40,9 +66,13 @@ public GHGistBuilder file(String fileName, String content) { /** * Creates a Gist based on the parameters specified thus far. + * + * @return created Gist + * @throws IOException + * if Gist cannot be created. */ public GHGist create() throws IOException { - req._with("files",files); - return req.to("/gists",GHGist.class).wrapUp(root); + req.with("files", files); + return req.to("/gists", GHGist.class).wrapUp(root); } } diff --git a/src/main/java/org/kohsuke/github/GHGistFile.java b/src/main/java/org/kohsuke/github/GHGistFile.java index 605afc993a..c143bf2a10 100644 --- a/src/main/java/org/kohsuke/github/GHGistFile.java +++ b/src/main/java/org/kohsuke/github/GHGistFile.java @@ -4,23 +4,29 @@ * A file inside {@link GHGist} * * @author Kohsuke Kawaguchi - * @see GHGist#getFile(String) - * @see GHGist#getFiles() + * @see GHGist#getFile(String) GHGist#getFile(String) + * @see GHGist#getFiles() GHGist#getFiles() */ public class GHGistFile { - /*package almost final*/ String fileName; + /* package almost final */ String fileName; private int size; private String raw_url, type, language, content; private boolean truncated; - + /** + * Gets file name. + * + * @return the file name + */ public String getFileName() { return fileName; } /** * File size in bytes. + * + * @return the size */ public int getSize() { return size; @@ -28,6 +34,8 @@ public int getSize() { /** * URL that serves this file as-is. + * + * @return the raw url */ public String getRawUrl() { return raw_url; @@ -35,17 +43,26 @@ public String getRawUrl() { /** * Content type of this Gist, such as "text/plain" + * + * @return the type */ public String getType() { return type; } + /** + * Gets language. + * + * @return the language + */ public String getLanguage() { return language; } /** * Content of this file. + * + * @return the content */ public String getContent() { return content; @@ -53,6 +70,8 @@ public String getContent() { /** * (?) indicates if {@link #getContent()} contains a truncated content. + * + * @return the boolean */ public boolean isTruncated() { return truncated; diff --git a/src/main/java/org/kohsuke/github/GHGistUpdater.java b/src/main/java/org/kohsuke/github/GHGistUpdater.java index 71bff34e22..af5a4876a1 100644 --- a/src/main/java/org/kohsuke/github/GHGistUpdater.java +++ b/src/main/java/org/kohsuke/github/GHGistUpdater.java @@ -12,7 +12,7 @@ public class GHGistUpdater { private final GHGist base; private final Requester builder; - LinkedHashMap files; + LinkedHashMap files; GHGistUpdater(GHGist base) { this.base = base; @@ -21,40 +21,81 @@ public class GHGistUpdater { files = new LinkedHashMap<>(); } + /** + * Add file gh gist updater. + * + * @param fileName + * the file name + * @param content + * the content + * @return the gh gist updater + * @throws IOException + * the io exception + */ public GHGistUpdater addFile(String fileName, String content) throws IOException { updateFile(fileName, content); return this; } -// // This method does not work. -// public GHGistUpdater deleteFile(String fileName) throws IOException { -// files.put(fileName, Collections.singletonMap("filename", null)); -// return this; -// } + // // This method does not work. + // public GHGistUpdater deleteFile(String fileName) throws IOException { + // files.put(fileName, Collections.singletonMap("filename", null)); + // return this; + // } - public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException - { + /** + * Rename file gh gist updater. + * + * @param fileName + * the file name + * @param newFileName + * the new file name + * @return the gh gist updater + * @throws IOException + * the io exception + */ + public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException { files.put(fileName, Collections.singletonMap("filename", newFileName)); return this; } + /** + * Update file gh gist updater. + * + * @param fileName + * the file name + * @param content + * the content + * @return the gh gist updater + * @throws IOException + * the io exception + */ public GHGistUpdater updateFile(String fileName, String content) throws IOException { files.put(fileName, Collections.singletonMap("content", content)); return this; } + /** + * Description gh gist updater. + * + * @param desc + * the desc + * @return the gh gist updater + */ public GHGistUpdater description(String desc) { - builder.with("description",desc); + builder.with("description", desc); return this; } /** * Updates the Gist based on the parameters specified thus far. + * + * @return the gh gist + * @throws IOException + * the io exception */ public GHGist update() throws IOException { - builder._with("files", files); - return builder - .method("PATCH") - .to(base.getApiTailUrl(""), GHGist.class).wrap(base.owner); + builder.with("files", files); + return builder.method("PATCH").to(base.getApiTailUrl(""), GHGist.class).wrap(base.owner); } } diff --git a/src/main/java/org/kohsuke/github/GHHook.java b/src/main/java/org/kohsuke/github/GHHook.java index b7f450307a..a88c9a372c 100644 --- a/src/main/java/org/kohsuke/github/GHHook.java +++ b/src/main/java/org/kohsuke/github/GHHook.java @@ -11,38 +11,66 @@ import java.util.Map; /** + * The type GHHook. + * * @author Kohsuke Kawaguchi */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public abstract class GHHook extends GHObject { String name; List events; boolean active; - Map config; + Map config; + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets events. + * + * @return the events + */ public EnumSet getEvents() { EnumSet s = EnumSet.noneOf(GHEvent.class); for (String e : events) { - if (e.equals("*")) s.add(GHEvent.ALL); - else s.add(Enum.valueOf(GHEvent.class, e.toUpperCase(Locale.ENGLISH))); + if (e.equals("*")) + s.add(GHEvent.ALL); + else + s.add(Enum.valueOf(GHEvent.class, e.toUpperCase(Locale.ENGLISH))); } return s; } + /** + * Is active boolean. + * + * @return the boolean + */ public boolean isActive() { return active; } + /** + * Gets config. + * + * @return the config + */ public Map getConfig() { return Collections.unmodifiableMap(config); } /** + * Ping. + * + * @throws IOException + * the io exception * @see Ping hook */ public void ping() throws IOException { @@ -51,6 +79,9 @@ public void ping() throws IOException { /** * Deletes this hook. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { new Requester(getRoot()).method("DELETE").to(getApiRoute()); diff --git a/src/main/java/org/kohsuke/github/GHHooks.java b/src/main/java/org/kohsuke/github/GHHooks.java index 6ecbb04b6e..7f99de7a77 100644 --- a/src/main/java/org/kohsuke/github/GHHooks.java +++ b/src/main/java/org/kohsuke/github/GHHooks.java @@ -16,37 +16,69 @@ static abstract class Context { private final GitHub root; private Context(GitHub root) { - this.root = root; + this.root = root; } + /** + * Gets hooks. + * + * @return the hooks + * @throws IOException + * the io exception + */ public List getHooks() throws IOException { - - GHHook [] hookArray = root.retrieve().to(collection(),collectionClass()); // jdk/eclipse bug requires this to be on separate line + + GHHook[] hookArray = root.retrieve().to(collection(), collectionClass()); // jdk/eclipse bug requires this + // to be on separate line List list = new ArrayList(Arrays.asList(hookArray)); for (GHHook h : list) - wrap(h); + wrap(h); return list; } + /** + * Gets hook. + * + * @param id + * the id + * @return the hook + * @throws IOException + * the io exception + */ public GHHook getHook(int id) throws IOException { GHHook hook = root.retrieve().to(collection() + "/" + id, clazz()); return wrap(hook); } - public GHHook createHook(String name, Map config, Collection events, boolean active) throws IOException { + /** + * Create hook gh hook. + * + * @param name + * the name + * @param config + * the config + * @param events + * the events + * @param active + * the active + * @return the gh hook + * @throws IOException + * the io exception + */ + public GHHook createHook(String name, Map config, Collection events, boolean active) + throws IOException { List ea = null; - if (events!=null) { - ea = new ArrayList(); - for (GHEvent e : events) - ea.add(e.symbol()); + if (events != null) { + ea = new ArrayList(); + for (GHEvent e : events) + ea.add(e.symbol()); } - GHHook hook = new Requester(root) - .with("name", name) - .with("active", active) - ._with("config", config) - ._with("events", ea) - .to(collection(), clazz()); + GHHook hook = new Requester(root).with("name", name) + .with("active", active) + .with("config", config) + .with("events", ea) + .to(collection(), clazz()); return wrap(hook); } @@ -87,7 +119,7 @@ Class clazz() { @Override GHHook wrap(GHHook hook) { - return ((GHRepoHook)hook).wrap(repository); + return ((GHRepoHook) hook).wrap(repository); } } @@ -116,15 +148,15 @@ Class clazz() { @Override GHHook wrap(GHHook hook) { - return ((GHOrgHook)hook).wrap(organization); + return ((GHOrgHook) hook).wrap(organization); } } - static Context repoContext(GHRepository repository, GHUser owner) { - return new RepoContext(repository, owner); - } + static Context repoContext(GHRepository repository, GHUser owner) { + return new RepoContext(repository, owner); + } - static Context orgContext(GHOrganization organization) { - return new OrgContext(organization); - } + static Context orgContext(GHOrganization organization) { + return new OrgContext(organization); + } } diff --git a/src/main/java/org/kohsuke/github/GHIOException.java b/src/main/java/org/kohsuke/github/GHIOException.java index b07144bcb7..b385968674 100644 --- a/src/main/java/org/kohsuke/github/GHIOException.java +++ b/src/main/java/org/kohsuke/github/GHIOException.java @@ -1,27 +1,41 @@ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.HttpURLConnection; import java.util.List; import java.util.Map; +import javax.annotation.CheckForNull; + /** - * Request/responce contains useful metadata. - * Custom exception allows store info for next diagnostics. + * Request/responce contains useful metadata. Custom exception allows store info for next diagnostics. * * @author Kanstantsin Shautsou */ public class GHIOException extends IOException { protected Map> responseHeaderFields; + /** + * Instantiates a new Ghio exception. + */ public GHIOException() { } + /** + * Instantiates a new Ghio exception. + * + * @param message + * the message + */ public GHIOException(String message) { super(message); } + /** + * Gets response header fields. + * + * @return the response header fields + */ @CheckForNull public Map> getResponseHeaderFields() { return responseHeaderFields; diff --git a/src/main/java/org/kohsuke/github/GHInvitation.java b/src/main/java/org/kohsuke/github/GHInvitation.java index 74619ad6e0..530889841c 100644 --- a/src/main/java/org/kohsuke/github/GHInvitation.java +++ b/src/main/java/org/kohsuke/github/GHInvitation.java @@ -6,13 +6,17 @@ import java.net.URL; /** - * @see GitHub#getMyInvitations() - * @see GHRepository#listInvitations() + * The type GHInvitation. + * + * @see GitHub#getMyInvitations() GitHub#getMyInvitations() + * @see GHRepository#listInvitations() GHRepository#listInvitations() */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD", "UUF_UNUSED_FIELD"}, justification = "JSON API") +@SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "UUF_UNUSED_FIELD" }, + justification = "JSON API") public class GHInvitation extends GHObject { - /*package almost final*/ GitHub root; + /* package almost final */ GitHub root; private int id; private GHRepository repository; @@ -20,13 +24,16 @@ public class GHInvitation extends GHObject { private String permissions; private String html_url; - /*package*/ GHInvitation wrapUp(GitHub root) { + GHInvitation wrapUp(GitHub root) { this.root = root; return this; } /** * Accept a repository invitation. + * + * @throws IOException + * the io exception */ public void accept() throws IOException { root.retrieve().method("PATCH").to("/user/repository_invitations/" + id); @@ -34,6 +41,9 @@ public void accept() throws IOException { /** * Decline a repository invitation. + * + * @throws IOException + * the io exception */ public void decline() throws IOException { root.retrieve().method("DELETE").to("/user/repository_invitations/" + id); diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 20343266b7..ec0620d08f 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -24,10 +24,9 @@ package org.kohsuke.github; -import static org.kohsuke.github.Previews.SQUIRREL_GIRL; - import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.IOException; import java.net.URL; import java.util.ArrayList; @@ -35,28 +34,28 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; -import java.util.HashSet; import java.util.List; import java.util.Locale; -import java.util.Set; + +import static org.kohsuke.github.Previews.SQUIRREL_GIRL; /** * Represents an issue on GitHub. * * @author Eric Maupin * @author Kohsuke Kawaguchi - * @see GHRepository#getIssue(int) - * @see GitHub#searchIssues() + * @see GHRepository#getIssue(int) GHRepository#getIssue(int) + * @see GitHub#searchIssues() GitHub#searchIssues() * @see GHIssueSearchBuilder */ -public class GHIssue extends GHObject implements Reactable{ +public class GHIssue extends GHObject implements Reactable { private static final String ASSIGNEES = "assignees"; GitHub root; GHRepository owner; - + // API v3 - protected GHUser assignee; // not sure what this field is now that 'assignees' exist + protected GHUser assignee; // not sure what this field is now that 'assignees' exist protected GHUser[] assignees; protected String state; protected int number; @@ -74,27 +73,34 @@ public class GHIssue extends GHObject implements Reactable{ protected boolean locked; /** + * The type Label. + * * @deprecated use {@link GHLabel} */ public static class Label extends GHLabel { } - - /*package*/ GHIssue wrap(GHRepository owner) { + + GHIssue wrap(GHRepository owner) { this.owner = owner; - if(milestone != null) milestone.wrap(owner); + if (milestone != null) + milestone.wrap(owner); return wrap(owner.root); } - /*package*/ GHIssue wrap(GitHub root) { + GHIssue wrap(GitHub root) { this.root = root; - if(assignee != null) assignee.wrapUp(root); - if(assignees!=null) GHUser.wrap(assignees,root); - if(user != null) user.wrapUp(root); - if(closed_by != null) closed_by.wrapUp(root); + if (assignee != null) + assignee.wrapUp(root); + if (assignees != null) + GHUser.wrap(assignees, root); + if (user != null) + user.wrapUp(root); + if (closed_by != null) + closed_by.wrapUp(root); return this; } - /*package*/ static GHIssue[] wrap(GHIssue[] issues, GHRepository owner) { + static GHIssue[] wrap(GHIssue[] issues, GHRepository owner) { for (GHIssue i : issues) i.wrap(owner); return issues; @@ -102,6 +108,8 @@ public static class Label extends GHLabel { /** * Repository to which the issue belongs. + * + * @return the repository */ public GHRepository getRepository() { return owner; @@ -109,6 +117,8 @@ public GHRepository getRepository() { /** * The description of this pull request. + * + * @return the body */ public String getBody() { return body; @@ -116,76 +126,128 @@ public String getBody() { /** * ID. + * + * @return the number */ public int getNumber() { return number; } /** - * The HTML page of this issue, - * like https://github.com/jenkinsci/jenkins/issues/100 + * The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100 */ public URL getHtmlUrl() { return GitHub.parseURL(html_url); } + /** + * Gets title. + * + * @return the title + */ public String getTitle() { return title; } + /** + * Is locked boolean. + * + * @return the boolean + */ public boolean isLocked() { return locked; } + /** + * Gets state. + * + * @return the state + */ public GHIssueState getState() { return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH)); } + /** + * Gets labels. + * + * @return the labels + * @throws IOException + * the io exception + */ public Collection getLabels() throws IOException { - if(labels == null){ + if (labels == null) { return Collections.emptyList(); } return Collections.unmodifiableList(labels); } + /** + * Gets closed at. + * + * @return the closed at + */ public Date getClosedAt() { return GitHub.parseDate(closed_at); } - public URL getApiURL(){ + /** + * Gets api url. + * + * @return the api url + */ + public URL getApiURL() { return GitHub.parseURL(url); } + /** + * Lock. + * + * @throws IOException + * the io exception + */ public void lock() throws IOException { - new Requester(root).method("PUT").to(getApiRoute()+"/lock"); + new Requester(root).method("PUT").to(getApiRoute() + "/lock"); } + /** + * Unlock. + * + * @throws IOException + * the io exception + */ public void unlock() throws IOException { - new Requester(root).method("PUT").to(getApiRoute()+"/lock"); + new Requester(root).method("PUT").to(getApiRoute() + "/lock"); } /** * Updates the issue by adding a comment. * - * @return - * Newly posted comment. + * @param message + * the message + * @return Newly posted comment. + * @throws IOException + * the io exception */ @WithBridgeMethods(void.class) public GHIssueComment comment(String message) throws IOException { - GHIssueComment r = new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments", GHIssueComment.class); + GHIssueComment r = new Requester(root).with("body", message) + .to(getIssuesApiRoute() + "/comments", GHIssueComment.class); return r.wrapUp(this); } private void edit(String key, Object value) throws IOException { - new Requester(root)._with(key, value).method("PATCH").to(getApiRoute()); + new Requester(root).with(key, value).method("PATCH").to(getApiRoute()); } private void editIssue(String key, Object value) throws IOException { - new Requester(root)._with(key, value).method("PATCH").to(getIssuesApiRoute()); + new Requester(root).with(key, value).method("PATCH").to(getIssuesApiRoute()); } /** * Closes this issue. + * + * @throws IOException + * the io exception */ public void close() throws IOException { edit("state", "closed"); @@ -193,44 +255,106 @@ public void close() throws IOException { /** * Reopens this issue. + * + * @throws IOException + * the io exception */ public void reopen() throws IOException { edit("state", "open"); } + /** + * Sets title. + * + * @param title + * the title + * @throws IOException + * the io exception + */ public void setTitle(String title) throws IOException { - edit("title",title); + edit("title", title); } + /** + * Sets body. + * + * @param body + * the body + * @throws IOException + * the io exception + */ public void setBody(String body) throws IOException { - edit("body",body); + edit("body", body); } + /** + * Sets milestone. + * + * @param milestone + * the milestone + * @throws IOException + * the io exception + */ public void setMilestone(GHMilestone milestone) throws IOException { - edit("milestone",milestone.getNumber()); + edit("milestone", milestone.getNumber()); } + /** + * Assign to. + * + * @param user + * the user + * @throws IOException + * the io exception + */ public void assignTo(GHUser user) throws IOException { setAssignees(user); } + /** + * Sets labels. + * + * @param labels + * the labels + * @throws IOException + * the io exception + */ public void setLabels(String... labels) throws IOException { - editIssue("labels",labels); + editIssue("labels", labels); } /** * Adds labels to the issue. * - * @param names Names of the label + * @param names + * Names of the label + * @throws IOException + * the io exception */ public void addLabels(String... names) throws IOException { _addLabels(Arrays.asList(names)); } + /** + * Add labels. + * + * @param labels + * the labels + * @throws IOException + * the io exception + */ public void addLabels(GHLabel... labels) throws IOException { addLabels(Arrays.asList(labels)); } + /** + * Add labels. + * + * @param labels + * the labels + * @throws IOException + * the io exception + */ public void addLabels(Collection labels) throws IOException { _addLabels(GHLabel.toNames(labels)); } @@ -251,18 +375,37 @@ private void _addLabels(Collection names) throws IOException { /** * Remove a given label by name from this issue. + * + * @param names + * the names + * @throws IOException + * the io exception */ public void removeLabels(String... names) throws IOException { _removeLabels(Arrays.asList(names)); } /** - * @see #removeLabels(String...) + * Remove labels. + * + * @param labels + * the labels + * @throws IOException + * the io exception + * @see #removeLabels(String...) #removeLabels(String...) */ public void removeLabels(GHLabel... labels) throws IOException { removeLabels(Arrays.asList(labels)); } + /** + * Remove labels. + * + * @param labels + * the labels + * @throws IOException + * the io exception + */ public void removeLabels(Collection labels) throws IOException { _removeLabels(GHLabel.toNames(labels)); } @@ -281,83 +424,170 @@ private void _removeLabels(Collection names) throws IOException { /** * Obtains all the comments associated with this issue. - * - * @see #listComments() + * + * @return the comments + * @throws IOException + * the io exception + * @see #listComments() #listComments() */ public List getComments() throws IOException { return listComments().asList(); } - + /** * Obtains all the comments associated with this issue. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listComments() throws IOException { return root.retrieve() - .asPagedIterable( - getIssuesApiRoute() + "/comments", - GHIssueComment[].class, - item -> item.wrapUp(GHIssue.this) ); + .asPagedIterable(getIssuesApiRoute() + "/comments", + GHIssueComment[].class, + item -> item.wrapUp(GHIssue.this)); } - @Preview @Deprecated + @Preview + @Deprecated public GHReaction createReaction(ReactionContent content) throws IOException { - return new Requester(owner.root) - .withPreview(SQUIRREL_GIRL) + return new Requester(owner.root).withPreview(SQUIRREL_GIRL) .with("content", content.getContent()) - .to(getApiRoute()+"/reactions", GHReaction.class).wrap(root); + .to(getApiRoute() + "/reactions", GHReaction.class) + .wrap(root); } - @Preview @Deprecated + @Preview + @Deprecated public PagedIterable listReactions() { - return owner.root.retrieve().withPreview(SQUIRREL_GIRL) - .asPagedIterable( - getApiRoute()+"/reactions", - GHReaction[].class, - item -> item.wrap(owner.root) ); + return owner.root.retrieve() + .withPreview(SQUIRREL_GIRL) + .asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root)); } + /** + * Add assignees. + * + * @param assignees + * the assignees + * @throws IOException + * the io exception + */ public void addAssignees(GHUser... assignees) throws IOException { addAssignees(Arrays.asList(assignees)); } + /** + * Add assignees. + * + * @param assignees + * the assignees + * @throws IOException + * the io exception + */ public void addAssignees(Collection assignees) throws IOException { - root.retrieve().method("POST").withLogins(ASSIGNEES,assignees).to(getIssuesApiRoute()+"/assignees",this); + root.retrieve() + .method("POST") + .with(ASSIGNEES, getLogins(assignees)) + .to(getIssuesApiRoute() + "/assignees", this); } + /** + * Sets assignees. + * + * @param assignees + * the assignees + * @throws IOException + * the io exception + */ public void setAssignees(GHUser... assignees) throws IOException { setAssignees(Arrays.asList(assignees)); } + /** + * Sets assignees. + * + * @param assignees + * the assignees + * @throws IOException + * the io exception + */ public void setAssignees(Collection assignees) throws IOException { - new Requester(root).withLogins(ASSIGNEES, assignees).method("PATCH").to(getIssuesApiRoute()); + new Requester(root).with(ASSIGNEES, getLogins(assignees)).method("PATCH").to(getIssuesApiRoute()); } + /** + * Remove assignees. + * + * @param assignees + * the assignees + * @throws IOException + * the io exception + */ public void removeAssignees(GHUser... assignees) throws IOException { removeAssignees(Arrays.asList(assignees)); } + /** + * Remove assignees. + * + * @param assignees + * the assignees + * @throws IOException + * the io exception + */ public void removeAssignees(Collection assignees) throws IOException { - root.retrieve().method("DELETE").withLogins(ASSIGNEES,assignees).inBody().to(getIssuesApiRoute()+"/assignees",this); + root.retrieve() + .method("DELETE") + .with(ASSIGNEES, getLogins(assignees)) + .inBody() + .to(getIssuesApiRoute() + "/assignees", this); } + /** + * Gets api route. + * + * @return the api route + */ protected String getApiRoute() { return getIssuesApiRoute(); } + /** + * Gets issues api route. + * + * @return the issues api route + */ protected String getIssuesApiRoute() { - return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/issues/"+number; + return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number; } + /** + * Gets assignee. + * + * @return the assignee + * @throws IOException + * the io exception + */ public GHUser getAssignee() throws IOException { return root.intern(assignee); } + /** + * Gets assignees. + * + * @return the assignees + */ public List getAssignees() { return Collections.unmodifiableList(Arrays.asList(assignees)); } /** * User who submitted the issue. + * + * @return the user + * @throws IOException + * the io exception */ public GHUser getUser() throws IOException { return root.intern(user); @@ -367,67 +597,115 @@ public GHUser getUser() throws IOException { * Reports who has closed the issue. * *

- * Note that GitHub doesn't always seem to report this information - * even for an issue that's already closed. See + * Note that GitHub doesn't always seem to report this information even for an issue that's already closed. See * https://github.com/kohsuke/github-api/issues/60. + * + * @return the closed by + * @throws IOException + * the io exception */ public GHUser getClosedBy() throws IOException { - if(!"closed".equals(state)) return null; + if (!"closed".equals(state)) + return null; - //TODO + // TODO /* - if (closed_by==null) { - closed_by = owner.getIssue(number).getClosed_by(); - } - */ + * if (closed_by==null) { closed_by = owner.getIssue(number).getClosed_by(); } + */ return root.intern(closed_by); } - - public int getCommentsCount(){ + + /** + * Gets comments count. + * + * @return the comments count + */ + public int getCommentsCount() { return comments; } /** * Returns non-null if this issue is a shadow of a pull request. + * + * @return the pull request */ public PullRequest getPullRequest() { return pull_request; } + /** + * Is pull request boolean. + * + * @return the boolean + */ public boolean isPullRequest() { - return pull_request!=null; + return pull_request != null; } + /** + * Gets milestone. + * + * @return the milestone + */ public GHMilestone getMilestone() { return milestone; } - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD"}, - justification = "JSON API") - public static class PullRequest{ + /** + * The type PullRequest. + */ + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" }, + justification = "JSON API") + public static class PullRequest { private String diff_url, patch_url, html_url; - + + /** + * Gets diff url. + * + * @return the diff url + */ public URL getDiffUrl() { return GitHub.parseURL(diff_url); } - + + /** + * Gets patch url. + * + * @return the patch url + */ public URL getPatchUrl() { return GitHub.parseURL(patch_url); } - + + /** + * Gets url. + * + * @return the url + */ public URL getUrl() { return GitHub.parseURL(html_url); } } + protected static List getLogins(Collection users) { + List names = new ArrayList(users.size()); + for (GHUser a : users) { + names.add(a.getLogin()); + } + return names; + } + /** - * Lists events for this issue. - * See https://developer.github.com/v3/issues/events/ + * Lists events for this issue. See https://developer.github.com/v3/issues/events/ + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listEvents() throws IOException { - return root.retrieve().asPagedIterable( - owner.getApiTailUrl(String.format("/issues/%s/events", number)), - GHIssueEvent[].class, - item -> item.wrapUp(GHIssue.this) ); + return root.retrieve() + .asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)), + GHIssueEvent[].class, + item -> item.wrapUp(GHIssue.this)); } } diff --git a/src/main/java/org/kohsuke/github/GHIssueBuilder.java b/src/main/java/org/kohsuke/github/GHIssueBuilder.java index 3a5a532308..766449596e 100644 --- a/src/main/java/org/kohsuke/github/GHIssueBuilder.java +++ b/src/main/java/org/kohsuke/github/GHIssueBuilder.java @@ -5,6 +5,8 @@ import java.util.List; /** + * The type GHIssueBuilder. + * * @author Kohsuke Kawaguchi */ public class GHIssueBuilder { @@ -16,45 +18,84 @@ public class GHIssueBuilder { GHIssueBuilder(GHRepository repo, String title) { this.repo = repo; this.builder = new Requester(repo.root); - builder.with("title",title); + builder.with("title", title); } /** * Sets the main text of an issue, which is arbitrary multi-line text. + * + * @param str + * the str + * @return the gh issue builder */ public GHIssueBuilder body(String str) { - builder.with("body",str); + builder.with("body", str); return this; } + /** + * Assignee gh issue builder. + * + * @param user + * the user + * @return the gh issue builder + */ public GHIssueBuilder assignee(GHUser user) { - if (user!=null) + if (user != null) assignees.add(user.getLogin()); return this; } + /** + * Assignee gh issue builder. + * + * @param user + * the user + * @return the gh issue builder + */ public GHIssueBuilder assignee(String user) { - if (user!=null) + if (user != null) assignees.add(user); return this; } + /** + * Milestone gh issue builder. + * + * @param milestone + * the milestone + * @return the gh issue builder + */ public GHIssueBuilder milestone(GHMilestone milestone) { - if (milestone!=null) - builder.with("milestone",milestone.getNumber()); + if (milestone != null) + builder.with("milestone", milestone.getNumber()); return this; } + /** + * Label gh issue builder. + * + * @param label + * the label + * @return the gh issue builder + */ public GHIssueBuilder label(String label) { - if (label!=null) + if (label != null) labels.add(label); return this; } /** * Creates a new issue. + * + * @return the gh issue + * @throws IOException + * the io exception */ public GHIssue create() throws IOException { - return builder.with("labels",labels).with("assignees",assignees).to(repo.getApiTailUrl("issues"),GHIssue.class).wrap(repo); + return builder.with("labels", labels) + .with("assignees", assignees) + .to(repo.getApiTailUrl("issues"), GHIssue.class) + .wrap(repo); } } diff --git a/src/main/java/org/kohsuke/github/GHIssueComment.java b/src/main/java/org/kohsuke/github/GHIssueComment.java index 258718312c..9c2f1ae587 100644 --- a/src/main/java/org/kohsuke/github/GHIssueComment.java +++ b/src/main/java/org/kohsuke/github/GHIssueComment.java @@ -32,8 +32,8 @@ * Comment to the issue * * @author Kohsuke Kawaguchi - * @see GHIssue#comment(String) - * @see GHIssue#listComments() + * @see GHIssue#comment(String) GHIssue#comment(String) + * @see GHIssue#listComments() GHIssue#listComments() */ public class GHIssueComment extends GHObject implements Reactable { GHIssue owner; @@ -41,13 +41,15 @@ public class GHIssueComment extends GHObject implements Reactable { private String body, gravatar_id, html_url, author_association; private GHUser user; // not fully populated. beware. - /*package*/ GHIssueComment wrapUp(GHIssue owner) { + GHIssueComment wrapUp(GHIssue owner) { this.owner = owner; return this; } /** * Gets the issue to which this comment is associated. + * + * @return the parent */ public GHIssue getParent() { return owner; @@ -55,6 +57,8 @@ public GHIssue getParent() { /** * The comment itself. + * + * @return the body */ public String getBody() { return body; @@ -62,6 +66,8 @@ public String getBody() { /** * Gets the ID of the user who posted this comment. + * + * @return the user name */ @Deprecated public String getUserName() { @@ -70,22 +76,36 @@ public String getUserName() { /** * Gets the user who posted this comment. + * + * @return the user + * @throws IOException + * the io exception */ public GHUser getUser() throws IOException { return owner == null || owner.root.isOffline() ? user : owner.root.getUser(user.getLogin()); } - + @Override public URL getHtmlUrl() { return GitHub.parseURL(html_url); } + /** + * Gets author association. + * + * @return the author association + */ public GHCommentAuthorAssociation getAuthorAssociation() { return GHCommentAuthorAssociation.valueOf(author_association); } - + /** * Updates the body of the issue comment. + * + * @param body + * the body + * @throws IOException + * the io exception */ public void update(String body) throws IOException { new Requester(owner.root).with("body", body).method("PATCH").to(getApiRoute(), GHIssueComment.class); @@ -94,30 +114,33 @@ public void update(String body) throws IOException { /** * Deletes this issue comment. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { new Requester(owner.root).method("DELETE").to(getApiRoute()); } - @Preview @Deprecated + @Preview + @Deprecated public GHReaction createReaction(ReactionContent content) throws IOException { - return new Requester(owner.root) - .withPreview(SQUIRREL_GIRL) + return new Requester(owner.root).withPreview(SQUIRREL_GIRL) .with("content", content.getContent()) - .to(getApiRoute()+"/reactions", GHReaction.class).wrap(owner.root); + .to(getApiRoute() + "/reactions", GHReaction.class) + .wrap(owner.root); } - @Preview @Deprecated + @Preview + @Deprecated public PagedIterable listReactions() { return owner.root.retrieve() - .withPreview(SQUIRREL_GIRL) - .asPagedIterable( - getApiRoute()+"/reactions", - GHReaction[].class, - item -> item.wrap(owner.root) ); + .withPreview(SQUIRREL_GIRL) + .asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root)); } private String getApiRoute() { - return "/repos/"+owner.getRepository().getOwnerName()+"/"+owner.getRepository().getName()+"/issues/comments/" + id; + return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName() + + "/issues/comments/" + id; } } diff --git a/src/main/java/org/kohsuke/github/GHIssueEvent.java b/src/main/java/org/kohsuke/github/GHIssueEvent.java index 089e87a831..83c2204042 100644 --- a/src/main/java/org/kohsuke/github/GHIssueEvent.java +++ b/src/main/java/org/kohsuke/github/GHIssueEvent.java @@ -3,6 +3,8 @@ import java.util.Date; /** + * The type GHIssueEvent. + * * @author Martin van Zijl */ public class GHIssueEvent { @@ -19,42 +21,92 @@ public class GHIssueEvent { private GHIssue issue; + /** + * Gets id. + * + * @return the id + */ public long getId() { return id; } + /** + * Gets node id. + * + * @return the node id + */ public String getNodeId() { return node_id; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets actor. + * + * @return the actor + */ public GHUser getActor() { return actor; } + /** + * Gets event. + * + * @return the event + */ public String getEvent() { return event; } + /** + * Gets commit id. + * + * @return the commit id + */ public String getCommitId() { return commit_id; } + /** + * Gets commit url. + * + * @return the commit url + */ public String getCommitUrl() { return commit_url; } + /** + * Gets created at. + * + * @return the created at + */ public Date getCreatedAt() { return GitHub.parseDate(created_at); } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Gets issue. + * + * @return the issue + */ public GHIssue getIssue() { return issue; } diff --git a/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java b/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java index 6cefc01678..3553ab88aa 100644 --- a/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHIssueSearchBuilder.java @@ -4,11 +4,11 @@ * Search issues. * * @author Kohsuke Kawaguchi - * @see GitHub#searchIssues() + * @see GitHub#searchIssues() GitHub#searchIssues() */ public class GHIssueSearchBuilder extends GHSearchBuilder { - /*package*/ GHIssueSearchBuilder(GitHub root) { - super(root,IssueSearchResult.class); + GHIssueSearchBuilder(GitHub root) { + super(root, IssueSearchResult.class); } /** @@ -19,43 +19,91 @@ public GHIssueSearchBuilder q(String term) { return this; } + /** + * Mentions gh issue search builder. + * + * @param u + * the u + * @return the gh issue search builder + */ public GHIssueSearchBuilder mentions(GHUser u) { return mentions(u.getLogin()); } + /** + * Mentions gh issue search builder. + * + * @param login + * the login + * @return the gh issue search builder + */ public GHIssueSearchBuilder mentions(String login) { - return q("mentions:"+login); + return q("mentions:" + login); } + /** + * Is open gh issue search builder. + * + * @return the gh issue search builder + */ public GHIssueSearchBuilder isOpen() { return q("is:open"); } + /** + * Is closed gh issue search builder. + * + * @return the gh issue search builder + */ public GHIssueSearchBuilder isClosed() { return q("is:closed"); } + /** + * Is merged gh issue search builder. + * + * @return the gh issue search builder + */ public GHIssueSearchBuilder isMerged() { return q("is:merged"); } + /** + * Order gh issue search builder. + * + * @param v + * the v + * @return the gh issue search builder + */ public GHIssueSearchBuilder order(GHDirection v) { - req.with("order",v); + req.with("order", v); return this; } + /** + * Sort gh issue search builder. + * + * @param sort + * the sort + * @return the gh issue search builder + */ public GHIssueSearchBuilder sort(Sort sort) { - req.with("sort",sort); + req.with("sort", sort); return this; } - public enum Sort { COMMENTS, CREATED, UPDATED } + /** + * The enum Sort. + */ + public enum Sort { + COMMENTS, CREATED, UPDATED + } private static class IssueSearchResult extends SearchResult { private GHIssue[] items; @Override - /*package*/ GHIssue[] getItems(GitHub root) { + GHIssue[] getItems(GitHub root) { for (GHIssue i : items) i.wrap(root); return items; diff --git a/src/main/java/org/kohsuke/github/GHIssueState.java b/src/main/java/org/kohsuke/github/GHIssueState.java index ec3cf10d24..6038853650 100644 --- a/src/main/java/org/kohsuke/github/GHIssueState.java +++ b/src/main/java/org/kohsuke/github/GHIssueState.java @@ -25,10 +25,10 @@ package org.kohsuke.github; /** - * @see GHPullRequestQueryBuilder#state(GHIssueState) + * The enum GHIssueState. + * + * @see GHPullRequestQueryBuilder#state(GHIssueState) GHPullRequestQueryBuilder#state(GHIssueState) */ public enum GHIssueState { - OPEN, - CLOSED, - ALL + OPEN, CLOSED, ALL } \ No newline at end of file diff --git a/src/main/java/org/kohsuke/github/GHKey.java b/src/main/java/org/kohsuke/github/GHKey.java index d4c8197dbf..a8e6477bee 100644 --- a/src/main/java/org/kohsuke/github/GHKey.java +++ b/src/main/java/org/kohsuke/github/GHKey.java @@ -10,45 +10,72 @@ */ @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API") public class GHKey { - /*package almost final*/ GitHub root; + /* package almost final */ GitHub root; protected String url, key, title; protected boolean verified; protected int id; + /** + * Gets id. + * + * @return the id + */ public int getId() { return id; } + /** + * Gets key. + * + * @return the key + */ public String getKey() { return key; } + /** + * Gets title. + * + * @return the title + */ public String getTitle() { return title; } /** * Something like "https://api.github.com/user/keys/73593" + * + * @return the url */ public String getUrl() { return url; } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } - + + /** + * Is verified boolean. + * + * @return the boolean + */ public boolean isVerified() { return verified; } - /*package*/ GHKey wrap(GitHub root) { + GHKey wrap(GitHub root) { this.root = root; return this; } public String toString() { - return new ToStringBuilder(this).append("title",title).append("id",id).append("key",key).toString(); + return new ToStringBuilder(this).append("title", title).append("id", id).append("key", key).toString(); } } diff --git a/src/main/java/org/kohsuke/github/GHLabel.java b/src/main/java/org/kohsuke/github/GHLabel.java index 29ab891473..7c6bc38a81 100644 --- a/src/main/java/org/kohsuke/github/GHLabel.java +++ b/src/main/java/org/kohsuke/github/GHLabel.java @@ -7,25 +7,40 @@ import java.util.Objects; import static org.kohsuke.github.Previews.SYMMETRA; + /** + * The type GHLabel. + * * @author Kohsuke Kawaguchi - * @see GHIssue#getLabels() - * @see GHRepository#listLabels() + * @see GHIssue#getLabels() GHIssue#getLabels() + * @see GHRepository#listLabels() GHRepository#listLabels() */ public class GHLabel { private String url, name, color, description; private GHRepository repo; + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } /** * Color code without leading '#', such as 'f29513' + * + * @return the color */ public String getColor() { return color; @@ -33,27 +48,41 @@ public String getColor() { /** * Purpose of Label + * + * @return the description */ - @Preview @Deprecated + @Preview + @Deprecated public String getDescription() { return description; } - /*package*/ GHLabel wrapUp(GHRepository repo) { + GHLabel wrapUp(GHRepository repo) { this.repo = repo; return this; } + /** + * Delete. + * + * @throws IOException + * the io exception + */ public void delete() throws IOException { repo.root.retrieve().method("DELETE").to(url); } /** + * Sets color. + * * @param newColor - * 6-letter hex color code, like "f29513" + * 6-letter hex color code, like "f29513" + * @throws IOException + * the io exception */ public void setColor(String newColor) throws IOException { - repo.root.retrieve().method("PATCH") + repo.root.retrieve() + .method("PATCH") .withPreview(SYMMETRA) .with("name", name) .with("color", newColor) @@ -62,12 +91,18 @@ public void setColor(String newColor) throws IOException { } /** + * Sets description. + * * @param newDescription - * Description of label + * Description of label + * @throws IOException + * the io exception */ - @Preview @Deprecated + @Preview + @Deprecated public void setDescription(String newDescription) throws IOException { - repo.root.retrieve().method("PATCH") + repo.root.retrieve() + .method("PATCH") .withPreview(SYMMETRA) .with("name", name) .with("color", color) @@ -75,7 +110,7 @@ public void setDescription(String newDescription) throws IOException { .to(url); } - /*package*/ static Collection toNames(Collection labels) { + static Collection toNames(Collection labels) { List r = new ArrayList(); for (GHLabel l : labels) { r.add(l.getName()); @@ -85,13 +120,13 @@ public void setDescription(String newDescription) throws IOException { @Override public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; final GHLabel ghLabel = (GHLabel) o; - return Objects.equals(url, ghLabel.url) && - Objects.equals(name, ghLabel.name) && - Objects.equals(color, ghLabel.color) && - Objects.equals(repo, ghLabel.repo); + return Objects.equals(url, ghLabel.url) && Objects.equals(name, ghLabel.name) + && Objects.equals(color, ghLabel.color) && Objects.equals(repo, ghLabel.repo); } @Override diff --git a/src/main/java/org/kohsuke/github/GHLicense.java b/src/main/java/org/kohsuke/github/GHLicense.java index b18e7e9338..e7c4cff56d 100644 --- a/src/main/java/org/kohsuke/github/GHLicense.java +++ b/src/main/java/org/kohsuke/github/GHLicense.java @@ -34,19 +34,19 @@ /** * The GitHub Preview API's license information - *

* * @author Duncan Dickinson - * @see GitHub#getLicense(String) - * @see GHRepository#getLicense() + * @see GitHub#getLicense(String) GitHub#getLicense(String) + * @see GHRepository#getLicense() GHRepository#getLicense() * @see https://developer.github.com/v3/licenses/ */ -@SuppressWarnings({"UnusedDeclaration"}) -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressWarnings({ "UnusedDeclaration" }) +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHLicense extends GHObject { - @SuppressFBWarnings("IS2_INCONSISTENT_SYNC") // root is set before the object is returned to the app - /*package almost final*/ GitHub root; + @SuppressFBWarnings("IS2_INCONSISTENT_SYNC") + // root is set before the object is returned to the app + /* package almost final */ GitHub root; // these fields are always present, even in the short form protected String key, name; @@ -61,6 +61,8 @@ public class GHLicense extends GHObject { protected List forbidden = new ArrayList(); /** + * Gets key. + * * @return a mnemonic for the license */ public String getKey() { @@ -68,6 +70,8 @@ public String getKey() { } /** + * Gets name. + * * @return the license name */ public String getName() { @@ -86,6 +90,8 @@ public URL getUrl() { * Featured licenses are bold in the new repository drop-down * * @return True if the license is featured, false otherwise + * @throws IOException + * the io exception */ public Boolean isFeatured() throws IOException { populate(); @@ -97,36 +103,85 @@ public URL getHtmlUrl() throws IOException { return GitHub.parseURL(html_url); } + /** + * Gets description. + * + * @return the description + * @throws IOException + * the io exception + */ public String getDescription() throws IOException { populate(); return description; } + /** + * Gets category. + * + * @return the category + * @throws IOException + * the io exception + */ public String getCategory() throws IOException { populate(); return category; } + /** + * Gets implementation. + * + * @return the implementation + * @throws IOException + * the io exception + */ public String getImplementation() throws IOException { populate(); return implementation; } + /** + * Gets required. + * + * @return the required + * @throws IOException + * the io exception + */ public List getRequired() throws IOException { populate(); return required; } + /** + * Gets permitted. + * + * @return the permitted + * @throws IOException + * the io exception + */ public List getPermitted() throws IOException { populate(); return permitted; } + /** + * Gets forbidden. + * + * @return the forbidden + * @throws IOException + * the io exception + */ public List getForbidden() throws IOException { populate(); return forbidden; } + /** + * Gets body. + * + * @return the body + * @throws IOException + * the io exception + */ public String getBody() throws IOException { populate(); return body; @@ -134,19 +189,25 @@ public String getBody() throws IOException { /** * Fully populate the data by retrieving missing data. - * + *

* Depending on the original API call where this object is created, it may not contain everything. + * + * @throws IOException + * the io exception */ protected synchronized void populate() throws IOException { - if (description!=null) return; // already populated + if (description != null) + return; // already populated root.retrieve().to(url, this); } @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof GHLicense)) return false; + if (this == o) + return true; + if (!(o instanceof GHLicense)) + return false; GHLicense that = (GHLicense) o; return this.url.equals(that.url); @@ -157,7 +218,7 @@ public int hashCode() { return url.hashCode(); } - /*package*/ GHLicense wrap(GitHub root) { + GHLicense wrap(GitHub root) { this.root = root; return this; } diff --git a/src/main/java/org/kohsuke/github/GHMembership.java b/src/main/java/org/kohsuke/github/GHMembership.java index 2847e1891c..666e229fa3 100644 --- a/src/main/java/org/kohsuke/github/GHMembership.java +++ b/src/main/java/org/kohsuke/github/GHMembership.java @@ -8,7 +8,7 @@ * Represents a membership of a user in an organization. * * @author Kohsuke Kawaguchi - * @see GHMyself#listOrgMemberships() + * @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships() */ public class GHMembership /* extends GHObject --- but it doesn't have id, created_at, etc. */ { GitHub root; @@ -19,22 +19,47 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create GHUser user; GHOrganization organization; + /** + * Gets url. + * + * @return the url + */ public URL getUrl() { return GitHub.parseURL(url); } + /** + * Gets state. + * + * @return the state + */ public State getState() { return Enum.valueOf(State.class, state.toUpperCase(Locale.ENGLISH)); } + /** + * Gets role. + * + * @return the role + */ public Role getRole() { return Enum.valueOf(Role.class, role.toUpperCase(Locale.ENGLISH)); } + /** + * Gets user. + * + * @return the user + */ public GHUser getUser() { return user; } + /** + * Gets organization. + * + * @return the organization + */ public GHOrganization getOrganization() { return organization; } @@ -42,20 +67,24 @@ public GHOrganization getOrganization() { /** * Accepts a pending invitation to an organization. * - * @see GHMyself#getMembership(GHOrganization) + * @throws IOException + * the io exception + * @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization) */ public void activate() throws IOException { - root.retrieve().method("PATCH").with("state",State.ACTIVE).to(url,this); + root.retrieve().method("PATCH").with("state", State.ACTIVE).to(url, this); } - /*package*/ GHMembership wrap(GitHub root) { + GHMembership wrap(GitHub root) { this.root = root; - if (user!=null) user = root.getUser(user.wrapUp(root)); - if (organization!=null) organization.wrapUp(root); + if (user != null) + user = root.getUser(user.wrapUp(root)); + if (organization != null) + organization.wrapUp(root); return this; } - /*package*/ static void wrap(GHMembership[] page, GitHub root) { + static void wrap(GHMembership[] page, GitHub root) { for (GHMembership m : page) m.wrap(root); } @@ -78,7 +107,6 @@ public enum Role { * Whether a role is currently active or waiting for acceptance (pending) */ public enum State { - ACTIVE, - PENDING; + ACTIVE, PENDING; } } diff --git a/src/main/java/org/kohsuke/github/GHMeta.java b/src/main/java/org/kohsuke/github/GHMeta.java new file mode 100644 index 0000000000..dae6eef3cd --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHMeta.java @@ -0,0 +1,89 @@ +package org.kohsuke.github; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Class that wraps the list of GitHub's IP addresses. + * + * @author Paulo Miguel Almeida + * @see GitHub#getMeta() GitHub#getMeta() + * @see Get Meta + */ +public class GHMeta { + + @JsonProperty("verifiable_password_authentication") + private boolean verifiablePasswordAuthentication; + private List hooks; + private List git; + private List web; + private List api; + private List pages; + private List importer = new ArrayList<>(); + + /** + * Is verifiable password authentication boolean. + * + * @return the boolean + */ + public boolean isVerifiablePasswordAuthentication() { + return verifiablePasswordAuthentication; + } + + /** + * Gets hooks. + * + * @return the hooks + */ + public List getHooks() { + return Collections.unmodifiableList(hooks); + } + + /** + * Gets git. + * + * @return the git + */ + public List getGit() { + return Collections.unmodifiableList(git); + } + + /** + * Gets web. + * + * @return the web + */ + public List getWeb() { + return Collections.unmodifiableList(web); + } + + /** + * Gets api. + * + * @return the api + */ + public List getApi() { + return Collections.unmodifiableList(api); + } + + /** + * Gets pages. + * + * @return the pages + */ + public List getPages() { + return Collections.unmodifiableList(pages); + } + + /** + * Gets importer. + * + * @return the importer + */ + public List getImporter() { + return Collections.unmodifiableList(importer); + } +} diff --git a/src/main/java/org/kohsuke/github/GHMilestone.java b/src/main/java/org/kohsuke/github/GHMilestone.java index 3ed54636c7..2126869cbb 100644 --- a/src/main/java/org/kohsuke/github/GHMilestone.java +++ b/src/main/java/org/kohsuke/github/GHMilestone.java @@ -6,9 +6,9 @@ import java.util.Locale; /** - * - * @author Yusuke Kokubo + * The type GHMilestone. * + * @author Yusuke Kokubo */ public class GHMilestone extends GHObject { GitHub root; @@ -19,46 +19,98 @@ public class GHMilestone extends GHObject { private int closed_issues, open_issues, number; protected String closed_at; + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } - + + /** + * Gets owner. + * + * @return the owner + */ public GHRepository getOwner() { return owner; } - + + /** + * Gets creator. + * + * @return the creator + * @throws IOException + * the io exception + */ public GHUser getCreator() throws IOException { return root.intern(creator); } - + + /** + * Gets due on. + * + * @return the due on + */ public Date getDueOn() { - if (due_on == null) return null; + if (due_on == null) + return null; return GitHub.parseDate(due_on); } /** * When was this milestone closed? + * + * @return the closed at + * @throws IOException + * the io exception */ public Date getClosedAt() throws IOException { return GitHub.parseDate(closed_at); } + /** + * Gets title. + * + * @return the title + */ public String getTitle() { return title; } - + + /** + * Gets description. + * + * @return the description + */ public String getDescription() { return description; } - + + /** + * Gets closed issues. + * + * @return the closed issues + */ public int getClosedIssues() { return closed_issues; } - + + /** + * Gets open issues. + * + * @return the open issues + */ public int getOpenIssues() { return open_issues; } - + + /** + * Gets number. + * + * @return the number + */ public int getNumber() { return number; } @@ -66,13 +118,21 @@ public int getNumber() { public URL getHtmlUrl() { return GitHub.parseURL(html_url); } - + + /** + * Gets state. + * + * @return the state + */ public GHMilestoneState getState() { return Enum.valueOf(GHMilestoneState.class, state.toUpperCase(Locale.ENGLISH)); } /** * Closes this milestone. + * + * @throws IOException + * the io exception */ public void close() throws IOException { edit("state", "closed"); @@ -80,6 +140,9 @@ public void close() throws IOException { /** * Reopens this milestone. + * + * @throws IOException + * the io exception */ public void reopen() throws IOException { edit("state", "open"); @@ -87,31 +150,70 @@ public void reopen() throws IOException { /** * Deletes this milestone. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { root.retrieve().method("DELETE").to(getApiRoute()); } private void edit(String key, Object value) throws IOException { - new Requester(root)._with(key, value).method("PATCH").to(getApiRoute()); + new Requester(root).with(key, value).method("PATCH").to(getApiRoute()); } + /** + * Sets title. + * + * @param title + * the title + * @throws IOException + * the io exception + */ public void setTitle(String title) throws IOException { edit("title", title); } + /** + * Sets description. + * + * @param description + * the description + * @throws IOException + * the io exception + */ public void setDescription(String description) throws IOException { edit("description", description); } + /** + * Sets due on. + * + * @param dueOn + * the due on + * @throws IOException + * the io exception + */ public void setDueOn(Date dueOn) throws IOException { edit("due_on", GitHub.printDate(dueOn)); } + /** + * Gets api route. + * + * @return the api route + */ protected String getApiRoute() { - return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/milestones/"+number; + return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/milestones/" + number; } + /** + * Wrap gh milestone. + * + * @param repo + * the repo + * @return the gh milestone + */ public GHMilestone wrap(GHRepository repo) { this.owner = repo; this.root = repo.root; diff --git a/src/main/java/org/kohsuke/github/GHMilestoneState.java b/src/main/java/org/kohsuke/github/GHMilestoneState.java index 92194546cb..4beb5e34c0 100644 --- a/src/main/java/org/kohsuke/github/GHMilestoneState.java +++ b/src/main/java/org/kohsuke/github/GHMilestoneState.java @@ -1,11 +1,10 @@ package org.kohsuke.github; /** - * - * @author Yusuke Kokubo + * The enum GHMilestoneState. * + * @author Yusuke Kokubo */ public enum GHMilestoneState { - OPEN, - CLOSED + OPEN, CLOSED } \ No newline at end of file diff --git a/src/main/java/org/kohsuke/github/GHMyself.java b/src/main/java/org/kohsuke/github/GHMyself.java index e059f58226..0d16f77d4b 100644 --- a/src/main/java/org/kohsuke/github/GHMyself.java +++ b/src/main/java/org/kohsuke/github/GHMyself.java @@ -44,8 +44,12 @@ public enum RepositoryListFilter { } /** - * @deprecated - * Use {@link #getEmails2()} + * Gets emails. + * + * @return the emails + * @throws IOException + * the io exception + * @deprecated Use {@link #getEmails2()} */ public List getEmails() throws IOException { List src = getEmails2(); @@ -58,13 +62,13 @@ public List getEmails() throws IOException { /** * Returns the read-only list of e-mail addresses configured for you. + *

+ * This corresponds to the stuff you configure in https://github.com/settings/emails, and not to be confused with + * {@link #getEmail()} that shows your public e-mail address set in https://github.com/settings/profile * - * This corresponds to the stuff you configure in https://github.com/settings/emails, - * and not to be confused with {@link #getEmail()} that shows your public e-mail address - * set in https://github.com/settings/profile - * - * @return - * Always non-null. + * @return Always non-null. + * @throws IOException + * the io exception */ public List getEmails2() throws IOException { GHEmail[] addresses = root.retrieve().to("/user/emails", GHEmail[].class); @@ -73,12 +77,13 @@ public List getEmails2() throws IOException { /** * Returns the read-only list of all the pulic keys of the current user. + *

+ * NOTE: When using OAuth authenticaiton, the READ/WRITE User scope is required by the GitHub APIs, otherwise you + * will get a 404 NOT FOUND. * - * NOTE: When using OAuth authenticaiton, the READ/WRITE User scope is - * required by the GitHub APIs, otherwise you will get a 404 NOT FOUND. - * - * @return - * Always non-null. + * @return Always non-null. + * @throws IOException + * the io exception */ public List getPublicKeys() throws IOException { return Collections.unmodifiableList(Arrays.asList(root.retrieve().to("/user/keys", GHKey[].class))); @@ -86,27 +91,31 @@ public List getPublicKeys() throws IOException { /** * Returns the read-only list of all the public verified keys of the current user. + *

+ * Differently from the getPublicKeys() method, the retrieval of the user's verified public keys does not require + * any READ/WRITE OAuth Scope to the user's profile. * - * Differently from the getPublicKeys() method, the retrieval of the user's - * verified public keys does not require any READ/WRITE OAuth Scope to the - * user's profile. - * - * @return - * Always non-null. + * @return Always non-null. + * @throws IOException + * the io exception */ - public List getPublicVerifiedKeys() throws IOException { - return Collections.unmodifiableList(Arrays.asList(root.retrieve().to( - "/users/" + getLogin() + "/keys", GHVerifiedKey[].class))); - } + public List getPublicVerifiedKeys() throws IOException { + return Collections.unmodifiableList( + Arrays.asList(root.retrieve().to("/users/" + getLogin() + "/keys", GHVerifiedKey[].class))); + } /** * Gets the organization that this user belongs to. + * + * @return the all organizations + * @throws IOException + * the io exception */ public GHPersonSet getAllOrganizations() throws IOException { GHPersonSet orgs = new GHPersonSet(); Set names = new HashSet(); for (GHOrganization o : root.retrieve().to("/user/orgs", GHOrganization[].class)) { - if (names.add(o.getLogin())) // in case of rumoured duplicates in the data + if (names.add(o.getLogin())) // in case of rumoured duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; @@ -114,11 +123,15 @@ public GHPersonSet getAllOrganizations() throws IOException { /** * Gets the all repositories this user owns (public and private). + * + * @return the all repositories + * @throws IOException + * the io exception */ - public synchronized Map getAllRepositories() throws IOException { - Map repositories = new TreeMap(); + public synchronized Map getAllRepositories() throws IOException { + Map repositories = new TreeMap(); for (GHRepository r : listAllRepositories()) { - repositories.put(r.getName(),r); + repositories.put(r.getName(), r); } return Collections.unmodifiableMap(repositories); } @@ -126,48 +139,53 @@ public synchronized Map getAllRepositories() throws IOExcep /** * Lists up all repositories this user owns (public and private). * - * Unlike {@link #getAllRepositories()}, this does not wait until all the repositories are returned. - * Repositories are returned by GitHub API with a 30 items per page. + * Unlike {@link #getAllRepositories()}, this does not wait until all the repositories are returned. Repositories + * are returned by GitHub API with a 30 items per page. */ @Override public PagedIterable listRepositories() { - return listRepositories(30); + return listRepositories(30); } /** - * List repositories that are accessible to the authenticated user (public and private) using the specified page size. + * List repositories that are accessible to the authenticated user (public and private) using the specified page + * size. * - * This includes repositories owned by the authenticated user, repositories that belong to other users - * where the authenticated user is a collaborator, and other organizations' repositories that the authenticated - * user has access to through an organization membership. + * This includes repositories owned by the authenticated user, repositories that belong to other users where the + * authenticated user is a collaborator, and other organizations' repositories that the authenticated user has + * access to through an organization membership. * - * @param pageSize size for each page of items returned by GitHub. Maximum page size is 100. + * @param pageSize + * size for each page of items returned by GitHub. Maximum page size is 100. * - * Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. + * Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. */ public PagedIterable listRepositories(final int pageSize) { return listRepositories(pageSize, RepositoryListFilter.ALL); } /** - * List repositories of a certain type that are accessible by current authenticated user using the specified page size. + * List repositories of a certain type that are accessible by current authenticated user using the specified page + * size. * - * @param pageSize size for each page of items returned by GitHub. Maximum page size is 100. - * @param repoType type of repository returned in the listing + * @param pageSize + * size for each page of items returned by GitHub. Maximum page size is 100. + * @param repoType + * type of repository returned in the listing + * @return the paged iterable */ public PagedIterable listRepositories(final int pageSize, final RepositoryListFilter repoType) { return root.retrieve() - .with("type",repoType) - .asPagedIterable( - "/user/repos", - GHRepository[].class, - item -> item.wrap(root) - ).withPageSize(pageSize); + .with("type", repoType) + .asPagedIterable("/user/repos", GHRepository[].class, item -> item.wrap(root)) + .withPageSize(pageSize); } /** - * @deprecated - * Use {@link #listRepositories()} + * List all repositories paged iterable. + * + * @return the paged iterable + * @deprecated Use {@link #listRepositories()} */ public PagedIterable listAllRepositories() { return listRepositories(); @@ -175,6 +193,8 @@ public PagedIterable listAllRepositories() { /** * List your organization memberships + * + * @return the paged iterable */ public PagedIterable listOrgMemberships() { return listOrgMemberships(null); @@ -184,26 +204,30 @@ public PagedIterable listOrgMemberships() { * List your organization memberships * * @param state - * Filter by a specific state + * Filter by a specific state + * @return the paged iterable */ public PagedIterable listOrgMemberships(final GHMembership.State state) { return root.retrieve() - .with("state",state) - .asPagedIterable( - "/user/memberships/orgs", - GHMembership[].class, - item -> item.wrap(root) ); + .with("state", state) + .asPagedIterable("/user/memberships/orgs", GHMembership[].class, item -> item.wrap(root)); } /** * Gets your membership in a specific organization. + * + * @param o + * the o + * @return the membership + * @throws IOException + * the io exception */ public GHMembership getMembership(GHOrganization o) throws IOException { - return root.retrieve().to("/user/memberships/orgs/"+o.getLogin(),GHMembership.class).wrap(root); + return root.retrieve().to("/user/memberships/orgs/" + o.getLogin(), GHMembership.class).wrap(root); } -// public void addEmails(Collection emails) throws IOException { -//// new Requester(root,ApiVersion.V3).withCredential().to("/user/emails"); -// root.retrieveWithAuth3() -// } + // public void addEmails(Collection emails) throws IOException { + //// new Requester(root,ApiVersion.V3).withCredential().to("/user/emails"); + // root.retrieveWithAuth3() + // } } diff --git a/src/main/java/org/kohsuke/github/GHNotificationStream.java b/src/main/java/org/kohsuke/github/GHNotificationStream.java index b8f8d7c296..9d62480651 100644 --- a/src/main/java/org/kohsuke/github/GHNotificationStream.java +++ b/src/main/java/org/kohsuke/github/GHNotificationStream.java @@ -9,23 +9,19 @@ * Listens to GitHub notification stream. * *

- * This class supports two modes of retrieving notifications that can - * be controlled via {@link #nonBlocking(boolean)}. + * This class supports two modes of retrieving notifications that can be controlled via {@link #nonBlocking(boolean)}. * *

- * In the blocking mode, which is the default, iterator will be infinite. - * The call to {@link Iterator#next()} will block until a new notification - * arrives. This is useful for application that runs perpetually and reacts - * to notifications. + * In the blocking mode, which is the default, iterator will be infinite. The call to {@link Iterator#next()} will block + * until a new notification arrives. This is useful for application that runs perpetually and reacts to notifications. * *

- * In the non-blocking mode, the iterator will only report the set of - * notifications initially retrieved from GitHub, then quit. This is useful - * for a batch application to process the current set of notifications. + * In the non-blocking mode, the iterator will only report the set of notifications initially retrieved from GitHub, + * then quit. This is useful for a batch application to process the current set of notifications. * * @author Kohsuke Kawaguchi - * @see GitHub#listNotifications() - * @see GHRepository#listNotifications() + * @see GitHub#listNotifications() GitHub#listNotifications() + * @see GHRepository#listNotifications() GHRepository#listNotifications() */ public class GHNotificationStream implements Iterable { private final GitHub root; @@ -35,13 +31,17 @@ public class GHNotificationStream implements Iterable { private String apiUrl; private boolean nonBlocking = false; - /*package*/ GHNotificationStream(GitHub root, String apiUrl) { + GHNotificationStream(GitHub root, String apiUrl) { this.root = root; this.apiUrl = apiUrl; } /** * Should the stream include notifications that are already read? + * + * @param v + * the v + * @return the gh notification stream */ public GHNotificationStream read(boolean v) { all = v; @@ -49,26 +49,47 @@ public GHNotificationStream read(boolean v) { } /** - * Should the stream be restricted to notifications in which the user - * is directly participating or mentioned? + * Should the stream be restricted to notifications in which the user is directly participating or mentioned? + * + * @param v + * the v + * @return the gh notification stream */ public GHNotificationStream participating(boolean v) { participating = v; return this; } + /** + * Since gh notification stream. + * + * @param timestamp + * the timestamp + * @return the gh notification stream + */ public GHNotificationStream since(long timestamp) { return since(new Date(timestamp)); } + /** + * Since gh notification stream. + * + * @param dt + * the dt + * @return the gh notification stream + */ public GHNotificationStream since(Date dt) { since = GitHub.printDate(dt); return this; } /** - * If set to true, {@link #iterator()} will stop iterating instead of blocking and - * waiting for the updates to arrive. + * If set to true, {@link #iterator()} will stop iterating instead of blocking and waiting for the updates to + * arrive. + * + * @param v + * the v + * @return the gh notification stream */ public GHNotificationStream nonBlocking(boolean v) { this.nonBlocking = v; @@ -76,25 +97,25 @@ public GHNotificationStream nonBlocking(boolean v) { } /** - * Returns an infinite blocking {@link Iterator} that returns - * {@link GHThread} as notifications arrive. + * Returns an infinite blocking {@link Iterator} that returns {@link GHThread} as notifications arrive. */ public Iterator iterator() { // capture the configuration setting here final Requester req = new Requester(root).method("GET") - .with("all", all).with("participating", participating).with("since", since); + .with("all", all) + .with("participating", participating) + .with("since", since); return new Iterator() { /** - * Stuff we've fetched but haven't returned to the caller. - * Newer ones first. + * Stuff we've fetched but haven't returned to the caller. Newer ones first. */ private GHThread[] threads = EMPTY_ARRAY; /** * Next element in {@link #threads} to return. This counts down. */ - private int idx=-1; + private int idx = -1; /** * threads whose updated_at is older than this should be ignored. @@ -114,9 +135,9 @@ public Iterator iterator() { private GHThread next; public GHThread next() { - if (next==null) { + if (next == null) { next = fetch(); - if (next==null) + if (next == null) throw new NoSuchElementException(); } @@ -126,9 +147,9 @@ public GHThread next() { } public boolean hasNext() { - if (next==null) + if (next == null) next = fetch(); - return next!=null; + return next != null; } GHThread fetch() { @@ -136,7 +157,7 @@ GHThread fetch() { while (true) {// loop until we get new threads to return // if we have fetched un-returned threads, use them first - while (idx>=0) { + while (idx >= 0) { GHThread n = threads[idx--]; long nt = n.getUpdatedAt().getTime(); if (nt >= lastUpdated) { @@ -145,13 +166,14 @@ GHThread fetch() { } } - if (nonBlocking && nextCheckTime>=0) - return null; // nothing more to report, and we aren't blocking + if (nonBlocking && nextCheckTime >= 0) + return null; // nothing more to report, and we aren't blocking // observe the polling interval before making the call while (true) { long now = System.currentTimeMillis(); - if (nextCheckTime < now) break; + if (nextCheckTime < now) + break; long waitTime = Math.min(Math.max(nextCheckTime - now, 1000), 60 * 1000); Thread.sleep(waitTime); } @@ -159,13 +181,13 @@ GHThread fetch() { req.setHeader("If-Modified-Since", lastModified); threads = req.to(apiUrl, GHThread[].class); - if (threads==null) { - threads = EMPTY_ARRAY; // if unmodified, we get empty array + if (threads == null) { + threads = EMPTY_ARRAY; // if unmodified, we get empty array } else { // we get a new batch, but we want to ignore the ones that we've seen lastUpdated++; } - idx = threads.length-1; + idx = threads.length - 1; nextCheckTime = calcNextCheckTime(); lastModified = req.getResponseHeader("Last-Modified"); @@ -179,9 +201,10 @@ GHThread fetch() { private long calcNextCheckTime() { String v = req.getResponseHeader("X-Poll-Interval"); - if (v==null) v="60"; + if (v == null) + v = "60"; long seconds = Integer.parseInt(v); - return System.currentTimeMillis() + seconds*1000; + return System.currentTimeMillis() + seconds * 1000; } public void remove() { @@ -190,16 +213,27 @@ public void remove() { }; } + /** + * Mark as read. + * + * @throws IOException + * the io exception + */ public void markAsRead() throws IOException { markAsRead(-1); } /** * Marks all the notifications as read. + * + * @param timestamp + * the timestamp + * @throws IOException + * the io exception */ public void markAsRead(long timestamp) throws IOException { final Requester req = new Requester(root).method("PUT"); - if (timestamp>=0) + if (timestamp >= 0) req.with("last_read_at", GitHub.printDate(new Date(timestamp))); req.asHttpStatusCode(apiUrl); } diff --git a/src/main/java/org/kohsuke/github/GHOTPRequiredException.java b/src/main/java/org/kohsuke/github/GHOTPRequiredException.java new file mode 100644 index 0000000000..64e95e3cc9 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHOTPRequiredException.java @@ -0,0 +1,10 @@ +package org.kohsuke.github; + +/** + * This exception is thrown when GitHub is requesting an OTP from the user + * + * @author Kevin Harrington mad.hephaestus@gmail.com + */ +public class GHOTPRequiredException extends GHIOException { + // ... +} diff --git a/src/main/java/org/kohsuke/github/GHObject.java b/src/main/java/org/kohsuke/github/GHObject.java index 2bad0891bc..ae7fd8b51a 100644 --- a/src/main/java/org/kohsuke/github/GHObject.java +++ b/src/main/java/org/kohsuke/github/GHObject.java @@ -5,7 +5,6 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import javax.annotation.CheckForNull; import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; @@ -13,11 +12,13 @@ import java.util.List; import java.util.Map; +import javax.annotation.CheckForNull; + /** * Most (all?) domain objects in GitHub seems to have these 4 properties. */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public abstract class GHObject { /** * Capture response HTTP headers on the state object. @@ -29,28 +30,35 @@ public abstract class GHObject { protected String created_at; protected String updated_at; - /*package*/ GHObject() { + GHObject() { } /** * Returns the HTTP response headers given along with the state of this object. * *

- * Some of the HTTP headers have nothing to do with the object, for example "Cache-Control" - * and others are different depending on how this object was retrieved. + * Some of the HTTP headers have nothing to do with the object, for example "Cache-Control" and others are different + * depending on how this object was retrieved. + *

+ * This method was added as a kind of hack to allow the caller to retrieve OAuth scopes and such. Use with caution. + * The method might be removed in the future. * - * This method was added as a kind of hack to allow the caller to retrieve OAuth scopes and such. - * Use with caution. The method might be removed in the future. + * @return a map of header names to value lists */ - @CheckForNull @Deprecated + @CheckForNull + @Deprecated public Map> getResponseHeaderFields() { return responseHeaderFields; } /** * When was this resource created? + * + * @return date created + * @throws IOException + * on error */ - @WithBridgeMethods(value=String.class, adapterMethod="createdAtStr") + @WithBridgeMethods(value = String.class, adapterMethod = "createdAtStr") public Date getCreatedAt() throws IOException { return GitHub.parseDate(created_at); } @@ -61,51 +69,63 @@ private Object createdAtStr(Date id, Class type) { } /** - * API URL of this object. + * Gets url. + * + * @return API URL of this object. */ - @WithBridgeMethods(value=String.class, adapterMethod="urlToString") + @WithBridgeMethods(value = String.class, adapterMethod = "urlToString") public URL getUrl() { return GitHub.parseURL(url); } /** - * URL of this object for humans, which renders some HTML. + * Gets html url. + * + * @return URL of this object for humans, which renders some HTML. + * @throws IOException + * on error */ - @WithBridgeMethods(value=String.class, adapterMethod="urlToString") + @WithBridgeMethods(value = String.class, adapterMethod = "urlToString") public abstract URL getHtmlUrl() throws IOException; /** * When was this resource last updated? + * + * @return updated date + * @throws IOException + * on error */ public Date getUpdatedAt() throws IOException { return GitHub.parseDate(updated_at); } /** - * Unique ID number of this resource. + * Gets id. + * + * @return Unique ID number of this resource. */ - @WithBridgeMethods(value={String.class,int.class}, adapterMethod="longToStringOrInt") + @WithBridgeMethods(value = { String.class, int.class }, adapterMethod = "longToStringOrInt") public long getId() { return id; } @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getId") private Object longToStringOrInt(long id, Class type) { - if (type==String.class) + if (type == String.class) return String.valueOf(id); - if (type==int.class) - return (int)id; - throw new AssertionError("Unexpected type: "+type); + if (type == int.class) + return (int) id; + throw new AssertionError("Unexpected type: " + type); } @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getHtmlUrl") private Object urlToString(URL url, Class type) { - return url==null ? null : url.toString(); + return url == null ? null : url.toString(); } /** - * String representation to assist debugging and inspection. The output format of this string - * is not a committed part of the API and is subject to change. + * String representation to assist debugging and inspection. The output format of this string is not a committed + * part of the API and is subject to change. */ @Override public String toString() { @@ -134,7 +154,7 @@ public void append(StringBuffer buffer, String fieldName, Object value, Boolean if (value instanceof GitHub) return; - super.append(buffer,fieldName,value,fullDetail); + super.append(buffer, fieldName, value, fullDetail); } }; } diff --git a/src/main/java/org/kohsuke/github/GHOrgHook.java b/src/main/java/org/kohsuke/github/GHOrgHook.java index 58404019bf..d13f766401 100644 --- a/src/main/java/org/kohsuke/github/GHOrgHook.java +++ b/src/main/java/org/kohsuke/github/GHOrgHook.java @@ -8,9 +8,9 @@ class GHOrgHook extends GHHook { /** * Organization that the hook belongs to. */ - /*package*/ transient GHOrganization organization; + transient GHOrganization organization; - /*package*/ GHOrgHook wrap(GHOrganization owner) { + GHOrgHook wrap(GHOrganization owner) { this.organization = owner; return this; } diff --git a/src/main/java/org/kohsuke/github/GHOrganization.java b/src/main/java/org/kohsuke/github/GHOrganization.java index 2b56d02f07..62b38dbe35 100644 --- a/src/main/java/org/kohsuke/github/GHOrganization.java +++ b/src/main/java/org/kohsuke/github/GHOrganization.java @@ -9,80 +9,136 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; + import static org.kohsuke.github.Previews.INERTIA; /** + * The type GHOrganization. + * * @author Kohsuke Kawaguchi */ public class GHOrganization extends GHPerson { - /*package*/ GHOrganization wrapUp(GitHub root) { - return (GHOrganization)super.wrapUp(root); + GHOrganization wrapUp(GitHub root) { + return (GHOrganization) super.wrapUp(root); } /** * Creates a new repository. * - * @return - * Newly created repository. - * @deprecated - * Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect. + * @param name + * the name + * @param description + * the description + * @param homepage + * the homepage + * @param team + * the team + * @param isPublic + * the is public + * @return Newly created repository. + * @throws IOException + * the io exception + * @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect. */ - public GHRepository createRepository(String name, String description, String homepage, String team, boolean isPublic) throws IOException { + public GHRepository createRepository(String name, + String description, + String homepage, + String team, + boolean isPublic) throws IOException { GHTeam t = getTeams().get(team); - if (t==null) - throw new IllegalArgumentException("No such team: "+team); + if (t == null) + throw new IllegalArgumentException("No such team: " + team); return createRepository(name, description, homepage, t, isPublic); } /** - * @deprecated - * Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect. + * Create repository gh repository. + * + * @param name + * the name + * @param description + * the description + * @param homepage + * the homepage + * @param team + * the team + * @param isPublic + * the is public + * @return the gh repository + * @throws IOException + * the io exception + * @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect. */ - public GHRepository createRepository(String name, String description, String homepage, GHTeam team, boolean isPublic) throws IOException { - if (team==null) + public GHRepository createRepository(String name, + String description, + String homepage, + GHTeam team, + boolean isPublic) throws IOException { + if (team == null) throw new IllegalArgumentException("Invalid team"); - return createRepository(name).description(description).homepage(homepage).private_(!isPublic).team(team).create(); + return createRepository(name).description(description) + .homepage(homepage) + .private_(!isPublic) + .team(team) + .create(); } /** * Starts a builder that creates a new repository. * *

- * You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} - * to finally createa repository. + * You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to + * finally createa repository. + * + * @param name + * the name + * @return the gh create repository builder */ public GHCreateRepositoryBuilder createRepository(String name) { - return new GHCreateRepositoryBuilder(root,"/orgs/"+login+"/repos",name); + return new GHCreateRepositoryBuilder(root, "/orgs/" + login + "/repos", name); } /** * Teams by their names. + * + * @return the teams + * @throws IOException + * the io exception */ - public Map getTeams() throws IOException { - Map r = new TreeMap(); + public Map getTeams() throws IOException { + Map r = new TreeMap(); for (GHTeam t : listTeams()) { - r.put(t.getName(),t); + r.put(t.getName(), t); } return r; } /** * List up all the teams. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listTeams() throws IOException { return root.retrieve() - .asPagedIterable( - String.format("/orgs/%s/teams", login), - GHTeam[].class, - item -> item.wrapUp(GHOrganization.this) ); + .asPagedIterable(String.format("/orgs/%s/teams", login), + GHTeam[].class, + item -> item.wrapUp(GHOrganization.this)); } /** * Finds a team that has the given name in its {@link GHTeam#getName()} + * + * @param name + * the name + * @return the team by name + * @throws IOException + * the io exception */ public GHTeam getTeamByName(String name) throws IOException { for (GHTeam t : listTeams()) { - if(t.getName().equals(name)) + if (t.getName().equals(name)) return t; } return null; @@ -90,37 +146,59 @@ public GHTeam getTeamByName(String name) throws IOException { /** * Finds a team that has the given slug in its {@link GHTeam#getSlug()} + * + * @param slug + * the slug + * @return the team by slug + * @throws IOException + * the io exception */ public GHTeam getTeamBySlug(String slug) throws IOException { for (GHTeam t : listTeams()) { - if(t.getSlug().equals(slug)) + if (t.getSlug().equals(slug)) return t; } return null; } - /** Member's role in an organization */ + /** + * Member's role in an organization + */ public enum Role { - ADMIN, /** The user is an owner of the organization. */ + ADMIN, + /** The user is an owner of the organization. */ MEMBER /** The user is a non-owner member of the organization. */ } /** * Adds (invites) a user to the organization. - * @see documentation + * + * @param user + * the user + * @param role + * the role + * @throws IOException + * the io exception + * @see documentation */ public void add(GHUser user, Role role) throws IOException { - root.retrieve().method("PUT") + root.retrieve() + .method("PUT") .with("role", role.name().toLowerCase()) .to("/orgs/" + login + "/memberships/" + user.getLogin()); } /** * Checks if this organization has the specified user as a member. + * + * @param user + * the user + * @return the boolean */ public boolean hasMember(GHUser user) { try { - root.retrieve().to("/orgs/" + login + "/members/" + user.getLogin()); + root.retrieve().to("/orgs/" + login + "/members/" + user.getLogin()); return true; } catch (IOException ignore) { return false; @@ -128,15 +206,24 @@ public boolean hasMember(GHUser user) { } /** - * Remove a member of the organisation - which will remove them from - * all teams, and remove their access to the organization’s repositories. + * Remove a member of the organisation - which will remove them from all teams, and remove their access to the + * organization’s repositories. + * + * @param user + * the user + * @throws IOException + * the io exception */ public void remove(GHUser user) throws IOException { - root.retrieve().method("DELETE").to("/orgs/" + login + "/members/" + user.getLogin()); + root.retrieve().method("DELETE").to("/orgs/" + login + "/members/" + user.getLogin()); } /** * Checks if this organization has the specified user as a public member. + * + * @param user + * the user + * @return the boolean */ public boolean hasPublicMember(GHUser user) { try { @@ -149,12 +236,22 @@ public boolean hasPublicMember(GHUser user) { /** * Publicizes the membership. + * + * @param u + * the u + * @throws IOException + * the io exception */ public void publicize(GHUser u) throws IOException { root.retrieve().method("PUT").to("/orgs/" + login + "/public_members/" + u.getLogin(), null); } /** + * Gets members. + * + * @return the members + * @throws IOException + * the io exception * @deprecated use {@link #listMembers()} */ public List getMembers() throws IOException { @@ -163,6 +260,10 @@ public List getMembers() throws IOException { /** * All the members of this organization. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listMembers() throws IOException { return listMembers("members"); @@ -170,6 +271,10 @@ public PagedIterable listMembers() throws IOException { /** * All the public members of this organization. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listPublicMembers() throws IOException { return listMembers("public_members"); @@ -179,6 +284,15 @@ private PagedIterable listMembers(String suffix) throws IOException { return listMembers(suffix, null); } + /** + * List members with filter paged iterable. + * + * @param filter + * the filter + * @return the paged iterable + * @throws IOException + * the io exception + */ public PagedIterable listMembersWithFilter(String filter) throws IOException { return listMembers("members", filter); } @@ -186,14 +300,18 @@ public PagedIterable listMembersWithFilter(String filter) throws IOExcep private PagedIterable listMembers(final String suffix, final String filter) throws IOException { String filterParams = (filter == null) ? "" : ("?filter=" + filter); return root.retrieve() - .asPagedIterable( - String.format("/orgs/%s/%s%s", login, suffix, filterParams), - GHUser[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(String.format("/orgs/%s/%s%s", login, suffix, filterParams), + GHUser[].class, + item -> item.wrapUp(root)); } /** * Conceals the membership. + * + * @param u + * the u + * @throws IOException + * the io exception */ public void conceal(GHUser u) throws IOException { root.retrieve().method("DELETE").to("/orgs/" + login + "/public_members/" + u.getLogin(), null); @@ -201,19 +319,26 @@ public void conceal(GHUser u) throws IOException { /** * Returns the projects for this organization. - * @param status The status filter (all, open or closed). + * + * @param status + * The status filter (all, open or closed). + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listProjects(final GHProject.ProjectStateFilter status) throws IOException { - return root.retrieve().withPreview(INERTIA) - .with("state", status) - .asPagedIterable( - String.format("/orgs/%s/projects", login), - GHProject[].class, - item -> item.wrap(root) ); + return root.retrieve() + .withPreview(INERTIA) + .with("state", status) + .asPagedIterable(String.format("/orgs/%s/projects", login), GHProject[].class, item -> item.wrap(root)); } /** * Returns all open projects for the organization. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listProjects() throws IOException { return listProjects(GHProject.ProjectStateFilter.OPEN); @@ -221,39 +346,123 @@ public PagedIterable listProjects() throws IOException { /** * Creates a project for the organization. + * + * @param name + * the name + * @param body + * the body + * @return the gh project + * @throws IOException + * the io exception */ public GHProject createProject(String name, String body) throws IOException { - return root.retrieve().method("POST") + return root.retrieve() + .method("POST") .withPreview(INERTIA) .with("name", name) .with("body", body) - .to(String.format("/orgs/%s/projects", login), GHProject.class).wrap(root); + .to(String.format("/orgs/%s/projects", login), GHProject.class) + .wrap(root); } - public enum Permission { ADMIN, PUSH, PULL } + /** + * The enum Permission. + */ + public enum Permission { + ADMIN, PUSH, PULL + } /** * Creates a new team and assigns the repositories. + * + * @param name + * the name + * @param p + * the p + * @param repositories + * the repositories + * @return the gh team + * @throws IOException + * the io exception + * @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use + * {@link #createTeam(String, Collection)} */ + @Deprecated public GHTeam createTeam(String name, Permission p, Collection repositories) throws IOException { Requester post = new Requester(root).with("name", name).with("permission", p); List repo_names = new ArrayList(); for (GHRepository r : repositories) { repo_names.add(login + "/" + r.getName()); } - post.with("repo_names",repo_names); + post.with("repo_names", repo_names); return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this); } + /** + * Create team gh team. + * + * @param name + * the name + * @param p + * the p + * @param repositories + * the repositories + * @return the gh team + * @throws IOException + * the io exception + * @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use + * {@link #createTeam(String, GHRepository...)} + */ + @Deprecated public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException { return createTeam(name, p, Arrays.asList(repositories)); } + /** + * Creates a new team and assigns the repositories. + * + * @param name + * the name + * @param repositories + * the repositories + * @return the gh team + * @throws IOException + * the io exception + */ + public GHTeam createTeam(String name, Collection repositories) throws IOException { + Requester post = new Requester(root).with("name", name); + List repo_names = new ArrayList(); + for (GHRepository r : repositories) { + repo_names.add(login + "/" + r.getName()); + } + post.with("repo_names", repo_names); + return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this); + } + + /** + * Create team gh team. + * + * @param name + * the name + * @param repositories + * the repositories + * @return the gh team + * @throws IOException + * the io exception + */ + public GHTeam createTeam(String name, GHRepository... repositories) throws IOException { + return createTeam(name, Arrays.asList(repositories)); + } + /** * List up repositories that has some open pull requests. + *

+ * This used to be an efficient method that didn't involve traversing every repository, but now it doesn't do any + * optimization. * - * This used to be an efficient method that didn't involve traversing every repository, but now - * it doesn't do any optimization. + * @return the repositories with open pull requests + * @throws IOException + * the io exception */ public List getRepositoriesWithOpenPullRequests() throws IOException { List r = new ArrayList(); @@ -269,6 +478,10 @@ public List getRepositoriesWithOpenPullRequests() throws IOExcepti /** * Gets all the open pull requests in this organizataion. + * + * @return the pull requests + * @throws IOException + * the io exception */ public List getPullRequests() throws IOException { List all = new ArrayList(); @@ -283,60 +496,95 @@ public List getPullRequests() throws IOException { */ public PagedIterable listEvents() throws IOException { return root.retrieve() - .asPagedIterable( - String.format("/orgs/%s/events", login), - GHEventInfo[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(String.format("/orgs/%s/events", login), + GHEventInfo[].class, + item -> item.wrapUp(root)); } /** * Lists up all the repositories using the specified page size. * - * @param pageSize size for each page of items returned by GitHub. Maximum page size is 100. + * @param pageSize + * size for each page of items returned by GitHub. Maximum page size is 100. * - * Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. + * Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. */ @Override public PagedIterable listRepositories(final int pageSize) { return root.retrieve() - .asPagedIterable( - "/orgs/" + login + "/repos", - GHRepository[].class, - item -> item.wrap(root) - ).withPageSize(pageSize); + .asPagedIterable("/orgs/" + login + "/repos", GHRepository[].class, item -> item.wrap(root)) + .withPageSize(pageSize); } /** * Retrieves the currently configured hooks. + * + * @return the hooks + * @throws IOException + * the io exception */ public List getHooks() throws IOException { return GHHooks.orgContext(this).getHooks(); } + /** + * Gets hook. + * + * @param id + * the id + * @return the hook + * @throws IOException + * the io exception + */ public GHHook getHook(int id) throws IOException { return GHHooks.orgContext(this).getHook(id); } /** - * - * See https://api.github.com/hooks for possible names and their configuration scheme. - * TODO: produce type-safe binding + * See https://api.github.com/hooks for possible names and their configuration scheme. TODO: produce type-safe + * binding * * @param name - * Type of the hook to be created. See https://api.github.com/hooks for possible names. + * Type of the hook to be created. See https://api.github.com/hooks for possible names. * @param config - * The configuration hash. + * The configuration hash. * @param events - * Can be null. Types of events to hook into. + * Can be null. Types of events to hook into. + * @param active + * the active + * @return the gh hook + * @throws IOException + * the io exception */ - public GHHook createHook(String name, Map config, Collection events, boolean active) throws IOException { + public GHHook createHook(String name, Map config, Collection events, boolean active) + throws IOException { return GHHooks.orgContext(this).createHook(name, config, events, active); } + /** + * Create web hook gh hook. + * + * @param url + * the url + * @param events + * the events + * @return the gh hook + * @throws IOException + * the io exception + */ public GHHook createWebHook(URL url, Collection events) throws IOException { - return createHook("web", Collections.singletonMap("url", url.toExternalForm()),events,true); + return createHook("web", Collections.singletonMap("url", url.toExternalForm()), events, true); } + /** + * Create web hook gh hook. + * + * @param url + * the url + * @return the gh hook + * @throws IOException + * the io exception + */ public GHHook createWebHook(URL url) throws IOException { return createWebHook(url, null); } diff --git a/src/main/java/org/kohsuke/github/GHPermission.java b/src/main/java/org/kohsuke/github/GHPermission.java index 51a808dfc0..53c5226b8a 100644 --- a/src/main/java/org/kohsuke/github/GHPermission.java +++ b/src/main/java/org/kohsuke/github/GHPermission.java @@ -28,24 +28,37 @@ /** * Permission for a user in a repository. + * * @see API */ -/*package*/ class GHPermission { +class GHPermission { private String permission; private GHUser user; /** + * Gets permission. + * * @return one of {@code admin}, {@code write}, {@code read}, or {@code none} */ public String getPermission() { return permission; } + /** + * Gets permission type. + * + * @return the permission type + */ public GHPermissionType getPermissionType() { return Enum.valueOf(GHPermissionType.class, permission.toUpperCase(Locale.ENGLISH)); } + /** + * Gets user. + * + * @return the user + */ public GHUser getUser() { return user; } diff --git a/src/main/java/org/kohsuke/github/GHPermissionType.java b/src/main/java/org/kohsuke/github/GHPermissionType.java index d3e2bd0909..26892f3f76 100644 --- a/src/main/java/org/kohsuke/github/GHPermissionType.java +++ b/src/main/java/org/kohsuke/github/GHPermissionType.java @@ -1,11 +1,10 @@ package org.kohsuke.github; /** + * The enum GHPermissionType. + * * @author Kohsuke Kawaguchi */ public enum GHPermissionType { - ADMIN, - WRITE, - READ, - NONE + ADMIN, WRITE, READ, NONE } diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java index 137dd5b368..286e97e6f3 100644 --- a/src/main/java/org/kohsuke/github/GHPerson.java +++ b/src/main/java/org/kohsuke/github/GHPerson.java @@ -13,32 +13,35 @@ /** * Common part of {@link GHUser} and {@link GHOrganization}. - * + * * @author Kohsuke Kawaguchi */ public abstract class GHPerson extends GHObject { - /*package almost final*/ GitHub root; + /* package almost final */ GitHub root; // core data fields that exist even for "small" user data (such as the user info in pull request) protected String login, avatar_url, gravatar_id; // other fields (that only show up in full data) - protected String location,blog,email,name,company; + protected String location, blog, email, name, company; protected String html_url; - protected int followers,following,public_repos,public_gists; + protected int followers, following, public_repos, public_gists; - /*package*/ GHPerson wrapUp(GitHub root) { + GHPerson wrapUp(GitHub root) { this.root = root; return this; } /** * Fully populate the data by retrieving missing data. - * + *

* Depending on the original API call where this object is created, it may not contain everything. + * + * @throws IOException + * the io exception */ protected synchronized void populate() throws IOException { - if (created_at!=null) { + if (created_at != null) { return; // already populated } if (root == null || root.isOffline()) { @@ -51,60 +54,66 @@ protected synchronized void populate() throws IOException { * Gets the public repositories this user owns. * *

- * To list your own repositories, including private repositories, - * use {@link GHMyself#listRepositories()} + * To list your own repositories, including private repositories, use {@link GHMyself#listRepositories()} + * + * @return the repositories + * @throws IOException + * the io exception */ - public synchronized Map getRepositories() throws IOException { - Map repositories = new TreeMap(); + public synchronized Map getRepositories() throws IOException { + Map repositories = new TreeMap(); for (GHRepository r : listRepositories(100)) { - repositories.put(r.getName(),r); + repositories.put(r.getName(), r); } return Collections.unmodifiableMap(repositories); } /** * Lists up all the repositories using a 30 items page size. - * + *

* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. + * + * @return the paged iterable */ public PagedIterable listRepositories() { - return listRepositories(30); + return listRepositories(30); } /** * Lists up all the repositories using the specified page size. * - * @param pageSize size for each page of items returned by GitHub. Maximum page size is 100. - * - * Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned. + * @param pageSize + * size for each page of items returned by GitHub. Maximum page size is 100. Unlike + * {@link #getRepositories()}, this does not wait until all the repositories are returned. + * @return the paged iterable */ public PagedIterable listRepositories(final int pageSize) { return root.retrieve() - .asPagedIterable( - "/users/" + login + "/repos", - GHRepository[].class, - item -> item.wrap(root) - ).withPageSize(pageSize); + .asPagedIterable("/users/" + login + "/repos", GHRepository[].class, item -> item.wrap(root)) + .withPageSize(pageSize); } /** * Loads repository list in a paginated fashion. * *

- * For a person with a lot of repositories, GitHub returns the list of repositories in a paginated fashion. - * Unlike {@link #getRepositories()}, this method allows the caller to start processing data as it arrives. - * - * Every {@link Iterator#next()} call results in I/O. Exceptions that occur during the processing is wrapped - * into {@link Error}. + * For a person with a lot of repositories, GitHub returns the list of repositories in a paginated fashion. Unlike + * {@link #getRepositories()}, this method allows the caller to start processing data as it arrives. + *

+ * Every {@link Iterator#next()} call results in I/O. Exceptions that occur during the processing is wrapped into + * {@link Error}. * - * @deprecated - * Use {@link #listRepositories()} + * @param pageSize + * the page size + * @return the iterable + * @deprecated Use {@link #listRepositories()} */ @Deprecated public synchronized Iterable> iterateRepositories(final int pageSize) { return new Iterable>() { public Iterator> iterator() { - final Iterator pager = root.retrieve().asIterator("/users/" + login + "/repos",GHRepository[].class, pageSize); + final Iterator pager = root.retrieve() + .asIterator("/users/" + login + "/repos", GHRepository[].class, pageSize); return new Iterator>() { public boolean hasNext() { @@ -127,9 +136,13 @@ public void remove() { } /** + * Gets repository. * - * @return - * null if the repository was not found + * @param name + * the name + * @return null if the repository was not found + * @throws IOException + * the io exception */ public GHRepository getRepository(String name) throws IOException { try { @@ -141,33 +154,41 @@ public GHRepository getRepository(String name) throws IOException { /** * Lists events for an organization or an user. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public abstract PagedIterable listEvents() throws IOException; /** * Gravatar ID of this user, like 0cb9832a01c22c083390f3c5dcb64105 * - * @deprecated - * No longer available in the v3 API. + * @return the gravatar id + * @deprecated No longer available in the v3 API. */ public String getGravatarId() { return gravatar_id; } /** - * Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' - * that indicates the avatar image URL. + * Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' that indicates the + * avatar image URL. + * + * @return the avatar url */ public String getAvatarUrl() { - if (avatar_url!=null) + if (avatar_url != null) return avatar_url; - if (gravatar_id!=null) - return "https://secure.gravatar.com/avatar/"+gravatar_id; + if (gravatar_id != null) + return "https://secure.gravatar.com/avatar/" + gravatar_id; return null; } /** * Gets the login ID of this user, like 'kohsuke' + * + * @return the login */ public String getLogin() { return login; @@ -175,6 +196,10 @@ public String getLogin() { /** * Gets the human-readable name of the user, like "Kohsuke Kawaguchi" + * + * @return the name + * @throws IOException + * the io exception */ public String getName() throws IOException { populate(); @@ -183,6 +208,10 @@ public String getName() throws IOException { /** * Gets the company name of this user, like "Sun Microsystems, Inc." + * + * @return the company + * @throws IOException + * the io exception */ public String getCompany() throws IOException { populate(); @@ -191,6 +220,10 @@ public String getCompany() throws IOException { /** * Gets the location of this user, like "Santa Clara, California" + * + * @return the location + * @throws IOException + * the io exception */ public String getLocation() throws IOException { populate(); @@ -209,6 +242,10 @@ public Date getUpdatedAt() throws IOException { /** * Gets the blog URL of this user. + * + * @return the blog + * @throws IOException + * the io exception */ public String getBlog() throws IOException { populate(); @@ -222,27 +259,59 @@ public URL getHtmlUrl() { /** * Gets the e-mail address of the user. + * + * @return the email + * @throws IOException + * the io exception */ public String getEmail() throws IOException { populate(); return email; } + /** + * Gets public gist count. + * + * @return the public gist count + * @throws IOException + * the io exception + */ public int getPublicGistCount() throws IOException { populate(); return public_gists; } + /** + * Gets public repo count. + * + * @return the public repo count + * @throws IOException + * the io exception + */ public int getPublicRepoCount() throws IOException { populate(); return public_repos; } + /** + * Gets following count. + * + * @return the following count + * @throws IOException + * the io exception + */ public int getFollowingCount() throws IOException { populate(); return following; } + /** + * Gets followers count. + * + * @return the followers count + * @throws IOException + * the io exception + */ public int getFollowersCount() throws IOException { populate(); return followers; diff --git a/src/main/java/org/kohsuke/github/GHPersonSet.java b/src/main/java/org/kohsuke/github/GHPersonSet.java index eb35b1bf7a..f0cc5d77ab 100644 --- a/src/main/java/org/kohsuke/github/GHPersonSet.java +++ b/src/main/java/org/kohsuke/github/GHPersonSet.java @@ -6,38 +6,73 @@ /** * Set of {@link GHPerson} with helper lookup methods. - * + * + * @param + * the type parameter * @author Kohsuke Kawaguchi */ public class GHPersonSet extends HashSet { private static final long serialVersionUID = 1L; - + + /** + * Instantiates a new Gh person set. + */ public GHPersonSet() { } + /** + * Instantiates a new Gh person set. + * + * @param c + * the c + */ public GHPersonSet(Collection c) { super(c); } + /** + * Instantiates a new Gh person set. + * + * @param c + * the c + */ public GHPersonSet(T... c) { super(Arrays.asList(c)); } + /** + * Instantiates a new Gh person set. + * + * @param initialCapacity + * the initial capacity + * @param loadFactor + * the load factor + */ public GHPersonSet(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } + /** + * Instantiates a new Gh person set. + * + * @param initialCapacity + * the initial capacity + */ public GHPersonSet(int initialCapacity) { super(initialCapacity); } /** * Finds the item by its login. + * + * @param login + * the login + * @return the t */ public T byLogin(String login) { for (T t : this) if (t.getLogin().equals(login)) return t; return null; - } + } } diff --git a/src/main/java/org/kohsuke/github/GHProject.java b/src/main/java/org/kohsuke/github/GHProject.java index 66e347cbc3..03807b795c 100644 --- a/src/main/java/org/kohsuke/github/GHProject.java +++ b/src/main/java/org/kohsuke/github/GHProject.java @@ -32,8 +32,9 @@ /** * A GitHub project. - * @see Projects + * * @author Martin van Zijl + * @see Projects */ public class GHProject extends GHObject { protected GitHub root; @@ -53,18 +54,30 @@ public URL getHtmlUrl() throws IOException { return GitHub.parseURL(html_url); } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Gets owner. + * + * @return the owner + * @throws IOException + * the io exception + */ public GHObject getOwner() throws IOException { - if(owner == null) { + if (owner == null) { try { - if(owner_url.contains("/orgs/")) { + if (owner_url.contains("/orgs/")) { owner = root.retrieve().to(getOwnerUrl().getPath(), GHOrganization.class).wrapUp(root); - } else if(owner_url.contains("/users/")) { + } else if (owner_url.contains("/users/")) { owner = root.retrieve().to(getOwnerUrl().getPath(), GHUser.class).wrapUp(root); - } else if(owner_url.contains("/repos/")) { + } else if (owner_url.contains("/repos/")) { owner = root.retrieve().to(getOwnerUrl().getPath(), GHRepository.class).wrap(root); } } catch (FileNotFoundException e) { @@ -74,110 +87,223 @@ public GHObject getOwner() throws IOException { return owner; } + /** + * Gets owner url. + * + * @return the owner url + */ public URL getOwnerUrl() { return GitHub.parseURL(owner_url); } + /** + * Gets node id. + * + * @return the node id + */ public String getNode_id() { return node_id; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets body. + * + * @return the body + */ public String getBody() { return body; } + /** + * Gets number. + * + * @return the number + */ public int getNumber() { return number; } + /** + * Gets state. + * + * @return the state + */ public ProjectState getState() { return Enum.valueOf(ProjectState.class, state.toUpperCase(Locale.ENGLISH)); } + /** + * Gets creator. + * + * @return the creator + */ public GHUser getCreator() { return creator; } + /** + * Wrap gh project. + * + * @param repo + * the repo + * @return the gh project + */ public GHProject wrap(GHRepository repo) { this.owner = repo; this.root = repo.root; return this; } + /** + * Wrap gh project. + * + * @param root + * the root + * @return the gh project + */ public GHProject wrap(GitHub root) { this.root = root; return this; } private void edit(String key, Object value) throws IOException { - new Requester(root).withPreview(INERTIA)._with(key, value).method("PATCH").to(getApiRoute()); + new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute()); } + /** + * Gets api route. + * + * @return the api route + */ protected String getApiRoute() { return "/projects/" + id; } + /** + * Sets name. + * + * @param name + * the name + * @throws IOException + * the io exception + */ public void setName(String name) throws IOException { edit("name", name); } + /** + * Sets body. + * + * @param body + * the body + * @throws IOException + * the io exception + */ public void setBody(String body) throws IOException { edit("body", body); } + /** + * The enum ProjectState. + */ public enum ProjectState { - OPEN, - CLOSED + OPEN, CLOSED } + /** + * Sets state. + * + * @param state + * the state + * @throws IOException + * the io exception + */ public void setState(ProjectState state) throws IOException { edit("state", state.toString().toLowerCase()); } + /** + * The enum ProjectStateFilter. + */ public static enum ProjectStateFilter { - ALL, - OPEN, - CLOSED + ALL, OPEN, CLOSED } /** - * Set the permission level that all members of the project's organization will have on this project. - * Only applicable for organization-owned projects. + * Set the permission level that all members of the project's organization will have on this project. Only + * applicable for organization-owned projects. + * + * @param permission + * the permission + * @throws IOException + * the io exception */ public void setOrganizationPermission(GHPermissionType permission) throws IOException { edit("organization_permission", permission.toString().toLowerCase()); } /** - * Sets visibility of the project within the organization. - * Only applicable for organization-owned projects. + * Sets visibility of the project within the organization. Only applicable for organization-owned projects. + * + * @param isPublic + * the is public + * @throws IOException + * the io exception */ public void setPublic(boolean isPublic) throws IOException { edit("public", isPublic); } + /** + * Delete. + * + * @throws IOException + * the io exception + */ public void delete() throws IOException { new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute()); } + /** + * List columns paged iterable. + * + * @return the paged iterable + * @throws IOException + * the io exception + */ public PagedIterable listColumns() throws IOException { final GHProject project = this; return root.retrieve() - .withPreview(INERTIA) - .asPagedIterable( - String.format("/projects/%d/columns", id), - GHProjectColumn[].class, - item -> item.wrap(project) ); + .withPreview(INERTIA) + .asPagedIterable(String.format("/projects/%d/columns", id), + GHProjectColumn[].class, + item -> item.wrap(project)); } + /** + * Create column gh project column. + * + * @param name + * the name + * @return the gh project column + * @throws IOException + * the io exception + */ public GHProjectColumn createColumn(String name) throws IOException { - return root.retrieve().method("POST") + return root.retrieve() + .method("POST") .withPreview(INERTIA) .with("name", name) - .to(String.format("/projects/%d/columns", id), GHProjectColumn.class).wrap(this); + .to(String.format("/projects/%d/columns", id), GHProjectColumn.class) + .wrap(this); } } \ No newline at end of file diff --git a/src/main/java/org/kohsuke/github/GHProjectCard.java b/src/main/java/org/kohsuke/github/GHProjectCard.java index d6fb97cd87..2ed518fcce 100644 --- a/src/main/java/org/kohsuke/github/GHProjectCard.java +++ b/src/main/java/org/kohsuke/github/GHProjectCard.java @@ -9,115 +9,214 @@ import static org.kohsuke.github.Previews.INERTIA; /** + * The type GHProjectCard. + * * @author Gunnar Skjold */ public class GHProjectCard extends GHObject { - private GitHub root; - private GHProject project; - private GHProjectColumn column; - - private String note; - private GHUser creator; - private String content_url, project_url, column_url; - private boolean archived; - - public URL getHtmlUrl() throws IOException { - return null; - } - - public GHProjectCard wrap(GitHub root) { - this.root = root; - return this; - } - - public GHProjectCard wrap(GHProjectColumn column) { - this.column = column; - this.project = column.project; - this.root = column.root; - return this; - } - - public GitHub getRoot() { - return root; - } - - public GHProject getProject() throws IOException { - if(project == null) { - try { - project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root); - } catch (FileNotFoundException e) { - return null; - } - } - return project; - } - - public GHProjectColumn getColumn() throws IOException { - if(column == null) { - try { - column = root.retrieve().to(getColumnUrl().getPath(), GHProjectColumn.class).wrap(root); - } catch (FileNotFoundException e) { - return null; - } - } - return column; - } - - public GHIssue getContent() throws IOException { - if(StringUtils.isEmpty(content_url)) - return null; - try { - if(content_url.contains("/pulls")) { - return root.retrieve().to(getContentUrl().getPath(), GHPullRequest.class).wrap(root); - } else { - return root.retrieve().to(getContentUrl().getPath(), GHIssue.class).wrap(root); - } - } catch (FileNotFoundException e) { - return null; - } - } - - public String getNote() { - return note; - } - - public GHUser getCreator() { - return creator; - } - - public URL getContentUrl() { - return GitHub.parseURL(content_url); - } - - public URL getProjectUrl() { - return GitHub.parseURL(project_url); - } - - public URL getColumnUrl() { - return GitHub.parseURL(column_url); - } - - public boolean isArchived() { - return archived; - } - - public void setNote(String note) throws IOException { - edit("note", note); - } - - public void setArchived(boolean archived) throws IOException { - edit("archived", archived); - } - - private void edit(String key, Object value) throws IOException { - new Requester(root).withPreview(INERTIA)._with(key, value).method("PATCH").to(getApiRoute()); - } - - protected String getApiRoute() { - return String.format("/projects/columns/cards/%d", id); - } - - public void delete() throws IOException { - new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute()); - } + private GitHub root; + private GHProject project; + private GHProjectColumn column; + + private String note; + private GHUser creator; + private String content_url, project_url, column_url; + private boolean archived; + + public URL getHtmlUrl() throws IOException { + return null; + } + + /** + * Wrap gh project card. + * + * @param root + * the root + * @return the gh project card + */ + public GHProjectCard wrap(GitHub root) { + this.root = root; + return this; + } + + /** + * Wrap gh project card. + * + * @param column + * the column + * @return the gh project card + */ + public GHProjectCard wrap(GHProjectColumn column) { + this.column = column; + this.project = column.project; + this.root = column.root; + return this; + } + + /** + * Gets root. + * + * @return the root + */ + public GitHub getRoot() { + return root; + } + + /** + * Gets project. + * + * @return the project + * @throws IOException + * the io exception + */ + public GHProject getProject() throws IOException { + if (project == null) { + try { + project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root); + } catch (FileNotFoundException e) { + return null; + } + } + return project; + } + + /** + * Gets column. + * + * @return the column + * @throws IOException + * the io exception + */ + public GHProjectColumn getColumn() throws IOException { + if (column == null) { + try { + column = root.retrieve().to(getColumnUrl().getPath(), GHProjectColumn.class).wrap(root); + } catch (FileNotFoundException e) { + return null; + } + } + return column; + } + + /** + * Gets content. + * + * @return the content + * @throws IOException + * the io exception + */ + public GHIssue getContent() throws IOException { + if (StringUtils.isEmpty(content_url)) + return null; + try { + if (content_url.contains("/pulls")) { + return root.retrieve().to(getContentUrl().getPath(), GHPullRequest.class).wrap(root); + } else { + return root.retrieve().to(getContentUrl().getPath(), GHIssue.class).wrap(root); + } + } catch (FileNotFoundException e) { + return null; + } + } + + /** + * Gets note. + * + * @return the note + */ + public String getNote() { + return note; + } + + /** + * Gets creator. + * + * @return the creator + */ + public GHUser getCreator() { + return creator; + } + + /** + * Gets content url. + * + * @return the content url + */ + public URL getContentUrl() { + return GitHub.parseURL(content_url); + } + + /** + * Gets project url. + * + * @return the project url + */ + public URL getProjectUrl() { + return GitHub.parseURL(project_url); + } + + /** + * Gets column url. + * + * @return the column url + */ + public URL getColumnUrl() { + return GitHub.parseURL(column_url); + } + + /** + * Is archived boolean. + * + * @return the boolean + */ + public boolean isArchived() { + return archived; + } + + /** + * Sets note. + * + * @param note + * the note + * @throws IOException + * the io exception + */ + public void setNote(String note) throws IOException { + edit("note", note); + } + + /** + * Sets archived. + * + * @param archived + * the archived + * @throws IOException + * the io exception + */ + public void setArchived(boolean archived) throws IOException { + edit("archived", archived); + } + + private void edit(String key, Object value) throws IOException { + new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute()); + } + + /** + * Gets api route. + * + * @return the api route + */ + protected String getApiRoute() { + return String.format("/projects/columns/cards/%d", id); + } + + /** + * Delete. + * + * @throws IOException + * the io exception + */ + public void delete() throws IOException { + new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute()); + } } diff --git a/src/main/java/org/kohsuke/github/GHProjectColumn.java b/src/main/java/org/kohsuke/github/GHProjectColumn.java index 3b853962ff..b93f709c36 100644 --- a/src/main/java/org/kohsuke/github/GHProjectColumn.java +++ b/src/main/java/org/kohsuke/github/GHProjectColumn.java @@ -7,92 +7,177 @@ import static org.kohsuke.github.Previews.INERTIA; /** + * The type GHProjectColumn. + * * @author Gunnar Skjold */ public class GHProjectColumn extends GHObject { - protected GitHub root; - protected GHProject project; - - private String name; - private String project_url; - - @Override - public URL getHtmlUrl() throws IOException { - return null; - } - - public GHProjectColumn wrap(GitHub root) { - this.root = root; - return this; - } - - public GHProjectColumn wrap(GHProject project) { - this.project = project; - this.root = project.root; - return this; - } - - public GitHub getRoot() { - return root; - } - - public GHProject getProject() throws IOException { - if(project == null) { - try { - project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root); - } catch (FileNotFoundException e) { - return null; - } - } - return project; - } - - public String getName() { - return name; - } - - public URL getProjectUrl() { - return GitHub.parseURL(project_url); - } - - public void setName(String name) throws IOException { - edit("name", name); - } - - private void edit(String key, Object value) throws IOException { - new Requester(root).withPreview(INERTIA)._with(key, value).method("PATCH").to(getApiRoute()); - } - - protected String getApiRoute() { - return String.format("/projects/columns/%d", id); - } - - public void delete() throws IOException { - new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute()); - } - - public PagedIterable listCards() throws IOException { - final GHProjectColumn column = this; - return root.retrieve() - .withPreview(INERTIA) - .asPagedIterable( - String.format("/projects/columns/%d/cards", id), - GHProjectCard[].class, - item -> item.wrap(column) ); - } - - public GHProjectCard createCard(String note) throws IOException { - return root.retrieve().method("POST") - .withPreview(INERTIA) - .with("note", note) - .to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class).wrap(this); - } - - public GHProjectCard createCard(GHIssue issue) throws IOException { - return root.retrieve().method("POST") - .withPreview(INERTIA) - .with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue") - .with("content_id", issue.getId()) - .to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class).wrap(this); - } + protected GitHub root; + protected GHProject project; + + private String name; + private String project_url; + + @Override + public URL getHtmlUrl() throws IOException { + return null; + } + + /** + * Wrap gh project column. + * + * @param root + * the root + * @return the gh project column + */ + public GHProjectColumn wrap(GitHub root) { + this.root = root; + return this; + } + + /** + * Wrap gh project column. + * + * @param project + * the project + * @return the gh project column + */ + public GHProjectColumn wrap(GHProject project) { + this.project = project; + this.root = project.root; + return this; + } + + /** + * Gets root. + * + * @return the root + */ + public GitHub getRoot() { + return root; + } + + /** + * Gets project. + * + * @return the project + * @throws IOException + * the io exception + */ + public GHProject getProject() throws IOException { + if (project == null) { + try { + project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root); + } catch (FileNotFoundException e) { + return null; + } + } + return project; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets project url. + * + * @return the project url + */ + public URL getProjectUrl() { + return GitHub.parseURL(project_url); + } + + /** + * Sets name. + * + * @param name + * the name + * @throws IOException + * the io exception + */ + public void setName(String name) throws IOException { + edit("name", name); + } + + private void edit(String key, Object value) throws IOException { + new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute()); + } + + /** + * Gets api route. + * + * @return the api route + */ + protected String getApiRoute() { + return String.format("/projects/columns/%d", id); + } + + /** + * Delete. + * + * @throws IOException + * the io exception + */ + public void delete() throws IOException { + new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute()); + } + + /** + * List cards paged iterable. + * + * @return the paged iterable + * @throws IOException + * the io exception + */ + public PagedIterable listCards() throws IOException { + final GHProjectColumn column = this; + return root.retrieve() + .withPreview(INERTIA) + .asPagedIterable(String.format("/projects/columns/%d/cards", id), + GHProjectCard[].class, + item -> item.wrap(column)); + } + + /** + * Create card gh project card. + * + * @param note + * the note + * @return the gh project card + * @throws IOException + * the io exception + */ + public GHProjectCard createCard(String note) throws IOException { + return root.retrieve() + .method("POST") + .withPreview(INERTIA) + .with("note", note) + .to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class) + .wrap(this); + } + + /** + * Create card gh project card. + * + * @param issue + * the issue + * @return the gh project card + * @throws IOException + * the io exception + */ + public GHProjectCard createCard(GHIssue issue) throws IOException { + return root.retrieve() + .method("POST") + .withPreview(INERTIA) + .with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue") + .with("content_id", issue.getId()) + .to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class) + .wrap(this); + } } diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index b4c3ee1645..f8a9bb4bc7 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -23,7 +23,6 @@ */ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.URL; import java.util.ArrayList; @@ -33,15 +32,17 @@ import java.util.Date; import java.util.List; +import javax.annotation.CheckForNull; + import static org.kohsuke.github.Previews.SHADOW_CAT; /** * A pull request. * * @author Kohsuke Kawaguchi - * @see GHRepository#getPullRequest(int) + * @see GHRepository#getPullRequest(int) GHRepository#getPullRequest(int) */ -@SuppressWarnings({"UnusedDeclaration"}) +@SuppressWarnings({ "UnusedDeclaration" }) public class GHPullRequest extends GHIssue implements Refreshable { private static final String COMMENTS_ACTION = "/comments"; @@ -69,52 +70,60 @@ public class GHPullRequest extends GHIssue implements Refreshable { private GHTeam[] requested_teams; /** - * GitHub doesn't return some properties of {@link GHIssue} when requesting the GET on the 'pulls' API - * route as opposed to 'issues' API route. This flag remembers whether we made the GET call on the 'issues' route - * on this object to fill in those missing details + * GitHub doesn't return some properties of {@link GHIssue} when requesting the GET on the 'pulls' API route as + * opposed to 'issues' API route. This flag remembers whether we made the GET call on the 'issues' route on this + * object to fill in those missing details */ private transient boolean fetchedIssueDetails; - GHPullRequest wrapUp(GHRepository owner) { this.wrap(owner); return wrapUp(owner.root); } GHPullRequest wrapUp(GitHub root) { - if (owner != null) owner.wrap(root); - if (base != null) base.wrapUp(root); - if (head != null) head.wrapUp(root); - if (merged_by != null) merged_by.wrapUp(root); - if (requested_reviewers != null) GHUser.wrap(requested_reviewers, root); - if (requested_teams != null) GHTeam.wrapUp(requested_teams, this); + if (owner != null) + owner.wrap(root); + if (base != null) + base.wrapUp(root); + if (head != null) + head.wrapUp(root); + if (merged_by != null) + merged_by.wrapUp(root); + if (requested_reviewers != null) + GHUser.wrap(requested_reviewers, root); + if (requested_teams != null) + GHTeam.wrapUp(requested_teams, this); return this; } @Override protected String getApiRoute() { - return "/repos/"+owner.getOwnerName()+"/"+owner.getName()+"/pulls/"+number; + return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number; } /** - * The URL of the patch file. - * like https://github.com/jenkinsci/jenkins/pull/100.patch + * The URL of the patch file. like https://github.com/jenkinsci/jenkins/pull/100.patch + * + * @return the patch url */ public URL getPatchUrl() { return GitHub.parseURL(patch_url); } /** - * The URL of the patch file. - * like https://github.com/jenkinsci/jenkins/pull/100.patch + * The URL of the patch file. like https://github.com/jenkinsci/jenkins/pull/100.patch + * + * @return the issue url */ public URL getIssueUrl() { return GitHub.parseURL(issue_url); } /** - * This points to where the change should be pulled into, - * but I'm not really sure what exactly it means. + * This points to where the change should be pulled into, but I'm not really sure what exactly it means. + * + * @return the base */ public GHCommitPointer getBase() { return base; @@ -122,24 +131,39 @@ public GHCommitPointer getBase() { /** * The change that should be pulled. The tip of the commits to merge. + * + * @return the head */ public GHCommitPointer getHead() { return head; } + /** + * Gets issue updated at. + * + * @return the issue updated at + * @throws IOException + * the io exception + */ @Deprecated public Date getIssueUpdatedAt() throws IOException { return super.getUpdatedAt(); } /** - * The diff file, - * like https://github.com/jenkinsci/jenkins/pull/100.diff + * The diff file, like https://github.com/jenkinsci/jenkins/pull/100.diff + * + * @return the diff url */ public URL getDiffUrl() { return GitHub.parseURL(diff_url); } + /** + * Gets merged at. + * + * @return the merged at + */ public Date getMergedAt() { return GitHub.parseDate(merged_at); } @@ -164,36 +188,85 @@ public PullRequest getPullRequest() { // details that are only available via get with ID // + /** + * Gets merged by. + * + * @return the merged by + * @throws IOException + * the io exception + */ public GHUser getMergedBy() throws IOException { populate(); return merged_by; } + /** + * Gets review comments. + * + * @return the review comments + * @throws IOException + * the io exception + */ public int getReviewComments() throws IOException { populate(); return review_comments; } + /** + * Gets additions. + * + * @return the additions + * @throws IOException + * the io exception + */ public int getAdditions() throws IOException { populate(); return additions; } + /** + * Gets commits. + * + * @return the commits + * @throws IOException + * the io exception + */ public int getCommits() throws IOException { populate(); return commits; } + /** + * Is merged boolean. + * + * @return the boolean + * @throws IOException + * the io exception + */ public boolean isMerged() throws IOException { populate(); return merged; } + /** + * Can maintainer modify boolean. + * + * @return the boolean + * @throws IOException + * the io exception + */ public boolean canMaintainerModify() throws IOException { populate(); return maintainer_can_modify; } + /** + * Is draft boolean. + * + * @return the boolean + * @throws IOException + * the io exception + */ public boolean isDraft() throws IOException { populate(); return draft; @@ -202,10 +275,11 @@ public boolean isDraft() throws IOException { /** * Is this PR mergeable? * - * @return - * null if the state has not been determined yet, for example when a PR is newly created. - * If this method is called on an instance whose mergeable state is not yet known, - * API call is made to retrieve the latest state. + * @return null if the state has not been determined yet, for example when a PR is newly created. If this method is + * called on an instance whose mergeable state is not yet known, API call is made to retrieve the latest + * state. + * @throws IOException + * the io exception */ public Boolean getMergeable() throws IOException { refresh(mergeable); @@ -220,17 +294,37 @@ Boolean getMergeableNoRefresh() throws IOException { return mergeable; } - + /** + * Gets deletions. + * + * @return the deletions + * @throws IOException + * the io exception + */ public int getDeletions() throws IOException { populate(); return deletions; } + /** + * Gets mergeable state. + * + * @return the mergeable state + * @throws IOException + * the io exception + */ public String getMergeableState() throws IOException { populate(); return mergeable_state; } + /** + * Gets changed files. + * + * @return the changed files + * @throws IOException + * the io exception + */ public int getChangedFiles() throws IOException { populate(); return changed_files; @@ -238,17 +332,35 @@ public int getChangedFiles() throws IOException { /** * See GitHub blog post + * + * @return the merge commit sha + * @throws IOException + * the io exception */ public String getMergeCommitSha() throws IOException { populate(); return merge_commit_sha; } + /** + * Gets requested reviewers. + * + * @return the requested reviewers + * @throws IOException + * the io exception + */ public List getRequestedReviewers() throws IOException { refresh(requested_reviewers); return Collections.unmodifiableList(Arrays.asList(requested_reviewers)); } + /** + * Gets requested teams. + * + * @return the requested teams + * @throws IOException + * the io exception + */ public List getRequestedTeams() throws IOException { refresh(requested_teams); return Collections.unmodifiableList(Arrays.asList(requested_teams)); @@ -260,7 +372,8 @@ public List getRequestedTeams() throws IOException { * Depending on the original API call where this object is created, it may not contain everything. */ private void populate() throws IOException { - if (mergeable_state!=null) return; // already populated + if (mergeable_state != null) + return; // already populated refresh(); } @@ -271,70 +384,94 @@ public void refresh() throws IOException { if (root.isOffline()) { return; // cannot populate, will have to live with what we have } - root.retrieve() - .withPreview(SHADOW_CAT) - .to(url, this).wrapUp(owner); + root.retrieve().withPreview(SHADOW_CAT).to(url, this).wrapUp(owner); } /** * Retrieves all the files associated to this pull request. + * + * @return the paged iterable */ public PagedIterable listFiles() { return root.retrieve() - .asPagedIterable( - String.format("%s/files", getApiRoute()), - GHPullRequestFileDetail[].class, - null); + .asPagedIterable(String.format("%s/files", getApiRoute()), GHPullRequestFileDetail[].class, null); } /** * Retrieves all the reviews associated to this pull request. + * + * @return the paged iterable */ public PagedIterable listReviews() { return root.retrieve() - .asPagedIterable( - String.format("%s/reviews", getApiRoute()), - GHPullRequestReview[].class, - item -> item.wrapUp(GHPullRequest.this)); + .asPagedIterable(String.format("%s/reviews", getApiRoute()), + GHPullRequestReview[].class, + item -> item.wrapUp(GHPullRequest.this)); } /** * Obtains all the review comments associated with this pull request. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listReviewComments() throws IOException { return root.retrieve() - .asPagedIterable( - getApiRoute() + COMMENTS_ACTION, + .asPagedIterable(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment[].class, - item -> item.wrapUp(GHPullRequest.this) ); + item -> item.wrapUp(GHPullRequest.this)); } /** * Retrieves all the commits associated to this pull request. + * + * @return the paged iterable */ public PagedIterable listCommits() { return root.retrieve() - .asPagedIterable( - String.format("%s/commits", getApiRoute()), + .asPagedIterable(String.format("%s/commits", getApiRoute()), GHPullRequestCommitDetail[].class, - item -> item.wrapUp(GHPullRequest.this) ); + item -> item.wrapUp(GHPullRequest.this)); } /** - * @deprecated - * Use {@link #createReview()} + * Create review gh pull request review. + * + * @param body + * the body + * @param event + * the event + * @param comments + * the comments + * @return the gh pull request review + * @throws IOException + * the io exception + * @deprecated Use {@link #createReview()} */ - public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, - GHPullRequestReviewComment... comments) throws IOException { + public GHPullRequestReview createReview(String body, + @CheckForNull GHPullRequestReviewState event, + GHPullRequestReviewComment... comments) throws IOException { return createReview(body, event, Arrays.asList(comments)); } /** - * @deprecated - * Use {@link #createReview()} + * Create review gh pull request review. + * + * @param body + * the body + * @param event + * the event + * @param comments + * the comments + * @return the gh pull request review + * @throws IOException + * the io exception + * @deprecated Use {@link #createReview()} */ - public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, - List comments) throws IOException { + public GHPullRequestReview createReview(String body, + @CheckForNull GHPullRequestReviewState event, + List comments) throws IOException { GHPullRequestReviewBuilder b = createReview().body(body); for (GHPullRequestReviewComment c : comments) { b.comment(c.getBody(), c.getPath(), c.getPosition()); @@ -342,56 +479,96 @@ public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequest return b.create(); } + /** + * Create review gh pull request review builder. + * + * @return the gh pull request review builder + */ public GHPullRequestReviewBuilder createReview() { return new GHPullRequestReviewBuilder(this); } - public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position) throws IOException { + /** + * Create review comment gh pull request review comment. + * + * @param body + * the body + * @param sha + * the sha + * @param path + * the path + * @param position + * the position + * @return the gh pull request review comment + * @throws IOException + * the io exception + */ + public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position) + throws IOException { return new Requester(root).method("POST") .with("body", body) .with("commit_id", sha) .with("path", path) .with("position", position) - .to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class).wrapUp(this); + .to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class) + .wrapUp(this); } + /** + * Request reviewers. + * + * @param reviewers + * the reviewers + * @throws IOException + * the io exception + */ public void requestReviewers(List reviewers) throws IOException { new Requester(root).method("POST") - .withLogins("reviewers", reviewers) + .with("reviewers", getLogins(reviewers)) .to(getApiRoute() + REQUEST_REVIEWERS); } + /** + * Request team reviewers. + * + * @param teams + * the teams + * @throws IOException + * the io exception + */ public void requestTeamReviewers(List teams) throws IOException { List teamReviewers = new ArrayList(teams.size()); for (GHTeam team : teams) { - teamReviewers.add(team.getSlug()); + teamReviewers.add(team.getSlug()); } - new Requester(root).method("POST") - .with("team_reviewers", teamReviewers) - .to(getApiRoute() + REQUEST_REVIEWERS); + new Requester(root).method("POST").with("team_reviewers", teamReviewers).to(getApiRoute() + REQUEST_REVIEWERS); } /** * Merge this pull request. - * + *

* The equivalent of the big green "Merge pull request" button. * * @param msg - * Commit message. If null, the default one will be used. + * Commit message. If null, the default one will be used. + * @throws IOException + * the io exception */ public void merge(String msg) throws IOException { - merge(msg,null); + merge(msg, null); } /** * Merge this pull request. - * + *

* The equivalent of the big green "Merge pull request" button. * * @param msg - * Commit message. If null, the default one will be used. + * Commit message. If null, the default one will be used. * @param sha - * SHA that pull request head must match to allow merge. + * SHA that pull request head must match to allow merge. + * @throws IOException + * the io exception */ public void merge(String msg, String sha) throws IOException { merge(msg, sha, null); @@ -399,13 +576,17 @@ public void merge(String msg, String sha) throws IOException { /** * Merge this pull request, using the specified merge method. - * + *

* The equivalent of the big green "Merge pull request" button. * * @param msg - * Commit message. If null, the default one will be used. + * Commit message. If null, the default one will be used. + * @param sha + * the sha * @param method - * SHA that pull request head must match to allow merge. + * SHA that pull request head must match to allow merge. + * @throws IOException + * the io exception */ public void merge(String msg, String sha, MergeMethod method) throws IOException { new Requester(root).method("PUT") @@ -415,7 +596,12 @@ public void merge(String msg, String sha, MergeMethod method) throws IOException .to(getApiRoute() + "/merge"); } - public enum MergeMethod{ MERGE, SQUASH, REBASE } + /** + * The enum MergeMethod. + */ + public enum MergeMethod { + MERGE, SQUASH, REBASE + } private void fetchIssue() throws IOException { if (!fetchedIssueDetails) { diff --git a/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java b/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java index e6c558b9e1..b80902c553 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java @@ -1,18 +1,18 @@ /* * The MIT License - * + * * Copyright (c) 2013, Luca Milanesio - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -30,38 +30,58 @@ /** * Commit detail inside a {@link GHPullRequest}. - * + * * @author Luca Milanesio - * @see GHPullRequest#listCommits() + * @see GHPullRequest#listCommits() GHPullRequest#listCommits() */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD"}, justification = "JSON API") +@SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "URF_UNREAD_FIELD" }, + justification = "JSON API") public class GHPullRequestCommitDetail { private GHPullRequest owner; - /*package*/ void wrapUp(GHPullRequest owner) { + void wrapUp(GHPullRequest owner) { this.owner = owner; } /** + * The type Authorship. + * * @deprecated Use {@link GitUser} */ public static class Authorship extends GitUser { } + /** + * The type Tree. + */ public static class Tree { String sha; String url; + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } + /** + * Gets url. + * + * @return the url + */ public URL getUrl() { return GitHub.parseURL(url); } } + /** + * The type Commit. + */ public static class Commit { Authorship author; Authorship committer; @@ -70,46 +90,94 @@ public static class Commit { String url; int comment_count; + /** + * Gets author. + * + * @return the author + */ @WithBridgeMethods(value = Authorship.class, castRequired = true) public GitUser getAuthor() { return author; } + /** + * Gets committer. + * + * @return the committer + */ @WithBridgeMethods(value = Authorship.class, castRequired = true) public GitUser getCommitter() { return committer; } + /** + * Gets message. + * + * @return the message + */ public String getMessage() { return message; } + /** + * Gets url. + * + * @return the url + */ public URL getUrl() { return GitHub.parseURL(url); } + /** + * Gets comment count. + * + * @return the comment count + */ public int getComment_count() { return comment_count; } + /** + * Gets tree. + * + * @return the tree + */ public Tree getTree() { return tree; } } + /** + * The type CommitPointer. + */ public static class CommitPointer { String sha; String url; String html_url; + /** + * Gets url. + * + * @return the url + */ public URL getUrl() { return GitHub.parseURL(url); } + /** + * Gets html url. + * + * @return the html url + */ public URL getHtml_url() { return GitHub.parseURL(html_url); } + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } @@ -122,26 +190,56 @@ public String getSha() { String comments_url; CommitPointer[] parents; + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } + /** + * Gets commit. + * + * @return the commit + */ public Commit getCommit() { return commit; } + /** + * Gets api url. + * + * @return the api url + */ public URL getApiUrl() { return GitHub.parseURL(url); } + /** + * Gets url. + * + * @return the url + */ public URL getUrl() { return GitHub.parseURL(html_url); } + /** + * Gets comments url. + * + * @return the comments url + */ public URL getCommentsUrl() { return GitHub.parseURL(comments_url); } + /** + * Get parents commit pointer [ ]. + * + * @return the commit pointer [ ] + */ public CommitPointer[] getParents() { CommitPointer[] newValue = new CommitPointer[parents.length]; System.arraycopy(parents, 0, newValue, 0, parents.length); diff --git a/src/main/java/org/kohsuke/github/GHPullRequestFileDetail.java b/src/main/java/org/kohsuke/github/GHPullRequestFileDetail.java index 35bb86c444..17f5780ea3 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestFileDetail.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestFileDetail.java @@ -1,18 +1,18 @@ /* * The MIT License - * + * * Copyright (c) 2015, Julien Henry - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -27,9 +27,9 @@ /** * File detail inside a {@link GHPullRequest}. - * + * * @author Julien Henry - * @see GHPullRequest#listFiles() + * @see GHPullRequest#listFiles() GHPullRequest#listFiles() */ public class GHPullRequestFileDetail { @@ -45,48 +45,102 @@ public class GHPullRequestFileDetail { String patch; String previous_filename; + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } + /** + * Gets filename. + * + * @return the filename + */ public String getFilename() { return filename; } + /** + * Gets status. + * + * @return the status + */ public String getStatus() { return status; } + /** + * Gets additions. + * + * @return the additions + */ public int getAdditions() { return additions; } + /** + * Gets deletions. + * + * @return the deletions + */ public int getDeletions() { return deletions; } + /** + * Gets changes. + * + * @return the changes + */ public int getChanges() { return changes; } + /** + * Gets blob url. + * + * @return the blob url + */ public URL getBlobUrl() { return GitHub.parseURL(blob_url); } + /** + * Gets raw url. + * + * @return the raw url + */ public URL getRawUrl() { return GitHub.parseURL(raw_url); } + /** + * Gets contents url. + * + * @return the contents url + */ public URL getContentsUrl() { return GitHub.parseURL(contents_url); } + /** + * Gets patch. + * + * @return the patch + */ public String getPatch() { return patch; } - public String getPreviousFilename() - { + /** + * Gets previous filename. + * + * @return the previous filename + */ + public String getPreviousFilename() { return previous_filename; } } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestQueryBuilder.java b/src/main/java/org/kohsuke/github/GHPullRequestQueryBuilder.java index 50b5cbb3ae..d19d88e27e 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestQueryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestQueryBuilder.java @@ -6,53 +6,89 @@ * Lists up pull requests with some filtering and sorting. * * @author Kohsuke Kawaguchi - * @see GHRepository#queryPullRequests() + * @see GHRepository#queryPullRequests() GHRepository#queryPullRequests() */ public class GHPullRequestQueryBuilder extends GHQueryBuilder { private final GHRepository repo; - /*package*/ GHPullRequestQueryBuilder(GHRepository repo) { + GHPullRequestQueryBuilder(GHRepository repo) { super(repo.root); this.repo = repo; } + /** + * State gh pull request query builder. + * + * @param state + * the state + * @return the gh pull request query builder + */ public GHPullRequestQueryBuilder state(GHIssueState state) { - req.with("state",state); + req.with("state", state); return this; } + /** + * Head gh pull request query builder. + * + * @param head + * the head + * @return the gh pull request query builder + */ public GHPullRequestQueryBuilder head(String head) { if (head != null && !head.contains(":")) { head = repo.getOwnerName() + ":" + head; } - req.with("head",head); + req.with("head", head); return this; } + /** + * Base gh pull request query builder. + * + * @param base + * the base + * @return the gh pull request query builder + */ public GHPullRequestQueryBuilder base(String base) { - req.with("base",base); + req.with("base", base); return this; } + /** + * Sort gh pull request query builder. + * + * @param sort + * the sort + * @return the gh pull request query builder + */ public GHPullRequestQueryBuilder sort(Sort sort) { - req.with("sort",sort); + req.with("sort", sort); return this; } - public enum Sort { CREATED, UPDATED, POPULARITY, LONG_RUNNING } + /** + * The enum Sort. + */ + public enum Sort { + CREATED, UPDATED, POPULARITY, LONG_RUNNING + } + /** + * Direction gh pull request query builder. + * + * @param d + * the d + * @return the gh pull request query builder + */ public GHPullRequestQueryBuilder direction(GHDirection d) { - req.with("direction",d); + req.with("direction", d); return this; } @Override public PagedIterable list() { - return req - .withPreview(SHADOW_CAT) - .asPagedIterable( - repo.getApiTailUrl("pulls"), - GHPullRequest[].class, - item -> item.wrapUp(repo) ); + return req.withPreview(SHADOW_CAT) + .asPagedIterable(repo.getApiTailUrl("pulls"), GHPullRequest[].class, item -> item.wrapUp(repo)); } } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReview.java b/src/main/java/org/kohsuke/github/GHPullRequestReview.java index b61a65ca05..65a29d33a7 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReview.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReview.java @@ -25,18 +25,19 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Date; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.URL; +import java.util.Date; + +import javax.annotation.CheckForNull; /** * Review to a pull request. * - * @see GHPullRequest#listReviews() + * @see GHPullRequest#listReviews() GHPullRequest#listReviews() * @see GHPullRequestReviewBuilder */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") public class GHPullRequestReview extends GHObject { GHPullRequest owner; @@ -46,13 +47,15 @@ public class GHPullRequestReview extends GHObject { private GHPullRequestReviewState state; private String submitted_at; - /*package*/ GHPullRequestReview wrapUp(GHPullRequest owner) { + GHPullRequestReview wrapUp(GHPullRequest owner) { this.owner = owner; return this; } /** * Gets the pull request to which this review is associated. + * + * @return the parent */ public GHPullRequest getParent() { return owner; @@ -60,6 +63,8 @@ public GHPullRequest getParent() { /** * The comment itself. + * + * @return the body */ public String getBody() { return body; @@ -67,15 +72,29 @@ public String getBody() { /** * Gets the user who posted this review. + * + * @return the user + * @throws IOException + * the io exception */ public GHUser getUser() throws IOException { return owner.root.getUser(user.getLogin()); } + /** + * Gets commit id. + * + * @return the commit id + */ public String getCommitId() { return commit_id; } + /** + * Gets state. + * + * @return the state + */ @CheckForNull public GHPullRequestReviewState getState() { return state; @@ -86,12 +105,21 @@ public URL getHtmlUrl() { return null; } + /** + * Gets api route. + * + * @return the api route + */ protected String getApiRoute() { - return owner.getApiRoute()+"/reviews/"+id; + return owner.getApiRoute() + "/reviews/" + id; } /** * When was this resource created? + * + * @return the submitted at + * @throws IOException + * the io exception */ public Date getSubmittedAt() throws IOException { return GitHub.parseDate(submitted_at); @@ -106,52 +134,74 @@ public Date getCreatedAt() throws IOException { } /** - * @deprecated - * Former preview method that changed when it got public. Left here for backward compatibility. - * Use {@link #submit(String, GHPullRequestReviewEvent)} + * Submit. + * + * @param body + * the body + * @param state + * the state + * @throws IOException + * the io exception + * @deprecated Former preview method that changed when it got public. Left here for backward compatibility. Use + * {@link #submit(String, GHPullRequestReviewEvent)} */ public void submit(String body, GHPullRequestReviewState state) throws IOException { - submit(body,state.toEvent()); + submit(body, state.toEvent()); } /** * Updates the comment. + * + * @param body + * the body + * @param event + * the event + * @throws IOException + * the io exception */ public void submit(String body, GHPullRequestReviewEvent event) throws IOException { new Requester(owner.root).method("POST") .with("body", body) .with("event", event.action()) - .to(getApiRoute()+"/events",this); + .to(getApiRoute() + "/events", this); this.body = body; this.state = event.toState(); } /** * Deletes this review. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { - new Requester(owner.root).method("DELETE") - .to(getApiRoute()); + new Requester(owner.root).method("DELETE").to(getApiRoute()); } /** * Dismisses this review. + * + * @param message + * the message + * @throws IOException + * the io exception */ public void dismiss(String message) throws IOException { - new Requester(owner.root).method("PUT") - .with("message", message) - .to(getApiRoute()+"/dismissals"); + new Requester(owner.root).method("PUT").with("message", message).to(getApiRoute() + "/dismissals"); state = GHPullRequestReviewState.DISMISSED; } /** * Obtains all the review comments associated with this pull request review. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listReviewComments() throws IOException { return owner.root.retrieve() - .asPagedIterable( - getApiRoute() + "/comments", - GHPullRequestReviewComment[].class, - item -> item.wrapUp(owner) ); + .asPagedIterable(getApiRoute() + "/comments", + GHPullRequestReviewComment[].class, + item -> item.wrapUp(owner)); } } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReviewBuilder.java b/src/main/java/org/kohsuke/github/GHPullRequestReviewBuilder.java index 318daf721f..cf0bf2171d 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReviewBuilder.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReviewBuilder.java @@ -8,59 +8,89 @@ * Builds up a creation of new {@link GHPullRequestReview}. * * @author Kohsuke Kawaguchi - * @see GHPullRequest#createReview() + * @see GHPullRequest#createReview() GHPullRequest#createReview() */ public class GHPullRequestReviewBuilder { private final GHPullRequest pr; private final Requester builder; private final List comments = new ArrayList(); - /*package*/ GHPullRequestReviewBuilder(GHPullRequest pr) { + GHPullRequestReviewBuilder(GHPullRequest pr) { this.pr = pr; this.builder = new Requester(pr.root); } - // public GHPullRequestReview createReview(@Nullable String commitId, String body, GHPullRequestReviewEvent event, - // List comments) throws IOException + // public GHPullRequestReview createReview(@Nullable String commitId, String body, GHPullRequestReviewEvent event, + // List comments) throws IOException /** - * The SHA of the commit that needs a review. Not using the latest commit SHA may render your review comment outdated if a subsequent commit modifies the line you specify as the position. Defaults to the most recent commit in the pull request when you do not specify a value. + * The SHA of the commit that needs a review. Not using the latest commit SHA may render your review comment + * outdated if a subsequent commit modifies the line you specify as the position. Defaults to the most recent commit + * in the pull request when you do not specify a value. + * + * @param commitId + * the commit id + * @return the gh pull request review builder */ public GHPullRequestReviewBuilder commitId(String commitId) { - builder.with("commit_id",commitId); + builder.with("commit_id", commitId); return this; } /** * Required when using REQUEST_CHANGES or COMMENT for the event parameter. The body text of the pull request review. + * + * @param body + * the body + * @return the gh pull request review builder */ public GHPullRequestReviewBuilder body(String body) { - builder.with("body",body); + builder.with("body", body); return this; } /** - * The review action you want to perform. The review actions include: APPROVE, REQUEST_CHANGES, or COMMENT. - * By leaving this blank, you set the review action state to PENDING, - * which means you will need to {@linkplain GHPullRequestReview#submit(String, GHPullRequestReviewEvent) submit the pull request review} when you are ready. + * The review action you want to perform. The review actions include: APPROVE, REQUEST_CHANGES, or COMMENT. By + * leaving this blank, you set the review action state to PENDING, which means you will need to + * {@linkplain GHPullRequestReview#submit(String, GHPullRequestReviewEvent) submit the pull request review} when you + * are ready. + * + * @param event + * the event + * @return the gh pull request review builder */ public GHPullRequestReviewBuilder event(GHPullRequestReviewEvent event) { - builder.with("event",event.action()); + builder.with("event", event.action()); return this; } /** - * @param body The relative path to the file that necessitates a review comment. - * @param path The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note below. - * @param position Text of the review comment. + * Comment gh pull request review builder. + * + * @param body + * The relative path to the file that necessitates a review comment. + * @param path + * The position in the diff where you want to add a review comment. Note this value is not the same as + * the line number in the file. For help finding the position value, read the note below. + * @param position + * Text of the review comment. + * @return the gh pull request review builder */ public GHPullRequestReviewBuilder comment(String body, String path, int position) { - comments.add(new DraftReviewComment(body,path,position)); + comments.add(new DraftReviewComment(body, path, position)); return this; } + /** + * Create gh pull request review. + * + * @return the gh pull request review + * @throws IOException + * the io exception + */ public GHPullRequestReview create() throws IOException { - return builder.method("POST")._with("comments",comments) + return builder.method("POST") + .with("comments", comments) .to(pr.getApiRoute() + "/reviews", GHPullRequestReview.class) .wrapUp(pr); } @@ -76,14 +106,29 @@ private static class DraftReviewComment { this.position = position; } + /** + * Gets body. + * + * @return the body + */ public String getBody() { return body; } + /** + * Gets path. + * + * @return the path + */ public String getPath() { return path; } + /** + * Gets position. + * + * @return the position + */ public int getPosition() { return position; } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java b/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java index 8848c28282..74f9dd8d02 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.net.URL; + import javax.annotation.CheckForNull; import static org.kohsuke.github.Previews.*; @@ -33,8 +34,9 @@ * Review comment to the pull request * * @author Julien Henry - * @see GHPullRequest#listReviewComments() - * @see GHPullRequest#createReviewComment(String, String, String, int) + * @see GHPullRequest#listReviewComments() GHPullRequest#listReviewComments() + * @see GHPullRequest#createReviewComment(String, String, String, int) GHPullRequest#createReviewComment(String, String, + * String, int) */ public class GHPullRequestReviewComment extends GHObject implements Reactable { GHPullRequest owner; @@ -46,10 +48,17 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable { private int original_position = -1; private long in_reply_to_id = -1L; - /** - * @deprecated - * You should be using {@link GHPullRequestReviewBuilder#comment(String, String, int)} + * Draft gh pull request review comment. + * + * @param body + * the body + * @param path + * the path + * @param position + * the position + * @return the gh pull request review comment + * @deprecated You should be using {@link GHPullRequestReviewBuilder#comment(String, String, int)} */ public static GHPullRequestReviewComment draft(String body, String path, int position) { GHPullRequestReviewComment result = new GHPullRequestReviewComment(); @@ -59,13 +68,15 @@ public static GHPullRequestReviewComment draft(String body, String path, int pos return result; } - /*package*/ GHPullRequestReviewComment wrapUp(GHPullRequest owner) { + GHPullRequestReviewComment wrapUp(GHPullRequest owner) { this.owner = owner; return this; } /** * Gets the pull request to which this review comment is associated. + * + * @return the parent */ public GHPullRequest getParent() { return owner; @@ -73,6 +84,8 @@ public GHPullRequest getParent() { /** * The comment itself. + * + * @return the body */ public String getBody() { return body; @@ -80,24 +93,48 @@ public String getBody() { /** * Gets the user who posted this comment. + * + * @return the user + * @throws IOException + * the io exception */ public GHUser getUser() throws IOException { return owner.root.getUser(user.getLogin()); } + /** + * Gets path. + * + * @return the path + */ public String getPath() { return path; } + /** + * Gets position. + * + * @return the position + */ @CheckForNull public int getPosition() { return position; } + /** + * Gets original position. + * + * @return the original position + */ public int getOriginalPosition() { return original_position; } + /** + * Gets in reply to id. + * + * @return the in reply to id + */ @CheckForNull public long getInReplyToId() { return in_reply_to_id; @@ -108,20 +145,33 @@ public URL getHtmlUrl() { return null; } + /** + * Gets api route. + * + * @return the api route + */ protected String getApiRoute() { - return "/repos/"+owner.getRepository().getFullName()+"/pulls/comments/"+id; + return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + id; } /** * Updates the comment. + * + * @param body + * the body + * @throws IOException + * the io exception */ public void update(String body) throws IOException { - new Requester(owner.root).method("PATCH").with("body", body).to(getApiRoute(),this); + new Requester(owner.root).method("PATCH").with("body", body).to(getApiRoute(), this); this.body = body; } /** * Deletes this review comment. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { new Requester(owner.root).method("DELETE").to(getApiRoute()); @@ -129,6 +179,12 @@ public void delete() throws IOException { /** * Create a new comment that replies to this comment. + * + * @param body + * the body + * @return the gh pull request review comment + * @throws IOException + * the io exception */ public GHPullRequestReviewComment reply(String body) throws IOException { return new Requester(owner.root).method("POST") @@ -138,21 +194,20 @@ public GHPullRequestReviewComment reply(String body) throws IOException { .wrapUp(owner); } - @Preview @Deprecated + @Preview + @Deprecated public GHReaction createReaction(ReactionContent content) throws IOException { - return new Requester(owner.root) - .withPreview(SQUIRREL_GIRL) + return new Requester(owner.root).withPreview(SQUIRREL_GIRL) .with("content", content.getContent()) - .to(getApiRoute()+"/reactions", GHReaction.class).wrap(owner.root); + .to(getApiRoute() + "/reactions", GHReaction.class) + .wrap(owner.root); } - @Preview @Deprecated + @Preview + @Deprecated public PagedIterable listReactions() { return owner.root.retrieve() - .withPreview(SQUIRREL_GIRL) - .asPagedIterable( - getApiRoute() + "/reactions", - GHReaction[].class, - item -> item.wrap(owner.root) ); + .withPreview(SQUIRREL_GIRL) + .asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root)); } } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReviewEvent.java b/src/main/java/org/kohsuke/github/GHPullRequestReviewEvent.java index e6537e0f09..0d4e681c38 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReviewEvent.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReviewEvent.java @@ -27,24 +27,25 @@ * Action to perform on {@link GHPullRequestReview}. */ public enum GHPullRequestReviewEvent { - PENDING, - APPROVE, - REQUEST_CHANGES, - COMMENT; + PENDING, APPROVE, REQUEST_CHANGES, COMMENT; - /*package*/ String action() { - return this==PENDING ? null : name(); + String action() { + return this == PENDING ? null : name(); } /** * When a {@link GHPullRequestReview} is submitted with this event, it should transition to this state. */ - /*package*/ GHPullRequestReviewState toState() { + GHPullRequestReviewState toState() { switch (this) { - case PENDING: return GHPullRequestReviewState.PENDING; - case APPROVE: return GHPullRequestReviewState.APPROVED; - case REQUEST_CHANGES: return GHPullRequestReviewState.CHANGES_REQUESTED; - case COMMENT: return GHPullRequestReviewState.COMMENTED; + case PENDING : + return GHPullRequestReviewState.PENDING; + case APPROVE : + return GHPullRequestReviewState.APPROVED; + case REQUEST_CHANGES : + return GHPullRequestReviewState.CHANGES_REQUESTED; + case COMMENT : + return GHPullRequestReviewState.COMMENTED; } throw new IllegalStateException(); } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReviewState.java b/src/main/java/org/kohsuke/github/GHPullRequestReviewState.java index a64a105994..3055cff233 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReviewState.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReviewState.java @@ -8,31 +8,36 @@ public enum GHPullRequestReviewState { APPROVED, CHANGES_REQUESTED, /** - * @deprecated - * This was the thing when this API was in preview, but it changed when it became public. - * Use {@link #CHANGES_REQUESTED}. Left here for compatibility. + * @deprecated This was the thing when this API was in preview, but it changed when it became public. Use + * {@link #CHANGES_REQUESTED}. Left here for compatibility. */ REQUEST_CHANGES, COMMENTED, DISMISSED; /** - * @deprecated - * This was an internal method accidentally exposed. - * Left here for compatibility. + * Action string. + * + * @return the string + * @deprecated This was an internal method accidentally exposed. Left here for compatibility. */ public String action() { GHPullRequestReviewEvent e = toEvent(); - return e==null ? null : e.action(); + return e == null ? null : e.action(); } - /*package*/ GHPullRequestReviewEvent toEvent() { + GHPullRequestReviewEvent toEvent() { switch (this) { - case PENDING: return GHPullRequestReviewEvent.PENDING; - case APPROVED: return GHPullRequestReviewEvent.APPROVE; - case CHANGES_REQUESTED: return GHPullRequestReviewEvent.REQUEST_CHANGES; - case REQUEST_CHANGES: return GHPullRequestReviewEvent.REQUEST_CHANGES; - case COMMENTED: return GHPullRequestReviewEvent.COMMENT; + case PENDING : + return GHPullRequestReviewEvent.PENDING; + case APPROVED : + return GHPullRequestReviewEvent.APPROVE; + case CHANGES_REQUESTED : + return GHPullRequestReviewEvent.REQUEST_CHANGES; + case REQUEST_CHANGES : + return GHPullRequestReviewEvent.REQUEST_CHANGES; + case COMMENTED : + return GHPullRequestReviewEvent.COMMENT; } return null; } diff --git a/src/main/java/org/kohsuke/github/GHQueryBuilder.java b/src/main/java/org/kohsuke/github/GHQueryBuilder.java index bb85fbbe95..be63c7b324 100644 --- a/src/main/java/org/kohsuke/github/GHQueryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHQueryBuilder.java @@ -3,19 +3,23 @@ /** * Used to specify filters, sort order, etc for listing items in a collection. * + * @param + * the type parameter * @author Kohsuke Kawaguchi */ public abstract class GHQueryBuilder { protected final GitHub root; protected final Requester req; - /*package*/ GHQueryBuilder(GitHub root) { + GHQueryBuilder(GitHub root) { this.root = root; this.req = root.retrieve(); } /** * Start listing items by using the settings built up on this object. + * + * @return the paged iterable */ public abstract PagedIterable list(); } diff --git a/src/main/java/org/kohsuke/github/GHRateLimit.java b/src/main/java/org/kohsuke/github/GHRateLimit.java index 9500b0a736..00d788b295 100644 --- a/src/main/java/org/kohsuke/github/GHRateLimit.java +++ b/src/main/java/org/kohsuke/github/GHRateLimit.java @@ -1,43 +1,400 @@ package org.kohsuke.github; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.apache.commons.lang3.StringUtils; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Date; +import java.util.Objects; +import java.util.logging.Logger; + +import javax.annotation.Nonnull; + +import static java.util.logging.Level.FINEST; /** * Rate limit. + * * @author Kohsuke Kawaguchi */ +@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API") public class GHRateLimit { + /** * Remaining calls that can be made. + * + * @deprecated This value should never have been made public. Use {@link #getRemaining()} */ + @Deprecated public int remaining; + /** * Allotted API call per hour. + * + * @deprecated This value should never have been made public. Use {@link #getLimit()} */ + @Deprecated public int limit; /** - * The time at which the current rate limit window resets in UTC epoch seconds. + * The time at which the current rate limit window resets in UTC epoch seconds. NOTE: that means to + * + * @deprecated This value should never have been made public. Use {@link #getResetDate()} */ + @Deprecated public Date reset; + @Nonnull + private final Record core; + + @Nonnull + private final Record search; + + @Nonnull + private final Record graphql; + + @Nonnull + private final Record integrationManifest; + + static GHRateLimit Unknown() { + return new GHRateLimit(new UnknownLimitRecord(), + new UnknownLimitRecord(), + new UnknownLimitRecord(), + new UnknownLimitRecord()); + } + + static GHRateLimit fromHeaderRecord(Record header) { + return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord()); + } + + @JsonCreator + GHRateLimit(@Nonnull @JsonProperty("core") Record core, + @Nonnull @JsonProperty("search") Record search, + @Nonnull @JsonProperty("graphql") Record graphql, + @Nonnull @JsonProperty("integration_manifest") Record integrationManifest) { + this.core = core; + this.search = search; + this.graphql = graphql; + this.integrationManifest = integrationManifest; + + // Deprecated fields + this.remaining = core.getRemaining(); + this.limit = core.getLimit(); + this.reset = new Date(core.getResetEpochSeconds()); + } + /** - * Non-epoch date + * Returns the date at which the Core API rate limit will reset. + * + * @return the calculated date at which the rate limit has or will reset. */ - @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", - justification = "The value comes from JSON deserialization") + @Nonnull public Date getResetDate() { - return new Date(reset.getTime() * 1000); + return getCore().getResetDate(); + } + + /** + * Gets the remaining number of Core APIs requests allowed before this connection will be throttled. + * + * @return an integer + * @since 1.100 + */ + public int getRemaining() { + return getCore().getRemaining(); + } + + /** + * Gets the total number of Core API calls per hour allotted for this connection. + * + * @return an integer + * @since 1.100 + */ + public int getLimit() { + return getCore().getLimit(); + } + + /** + * Gets the time in epoch seconds when the Core API rate limit will reset. + * + * @return a long + * @since 1.100 + */ + public long getResetEpochSeconds() { + return getCore().getResetEpochSeconds(); + } + + /** + * Whether the rate limit reset date for this instance has passed. + * + * @return true if the rate limit reset date has passed. Otherwise false. + * @since 1.100 + */ + public boolean isExpired() { + return getCore().isExpired(); + } + + /** + * The core object provides your rate limit status for all non-search-related resources in the REST API. + * + * @return a rate limit record + * @since 1.100 + */ + @Nonnull + public Record getCore() { + return core; + } + + /** + * The search object provides your rate limit status for the Search API. TODO: integrate with header limit updating. + * Issue #605. + * + * @return a rate limit record + */ + @Nonnull + Record getSearch() { + return search; + } + + /** + * The graphql object provides your rate limit status for the GraphQL API. TODO: integrate with header limit + * updating. Issue #605. + * + * @return a rate limit record + */ + @Nonnull + Record getGraphQL() { + return graphql; + } + + /** + * The integration_manifest object provides your rate limit status for the GitHub App Manifest code conversion + * endpoint. TODO: integrate with header limit updating. Issue #605. + * + * @return a rate limit record + */ + @Nonnull + Record getIntegrationManifest() { + return integrationManifest; } @Override public String toString() { - return "GHRateLimit{" + - "remaining=" + remaining + - ", limit=" + limit + - ", resetDate=" + getResetDate() + - '}'; + return "GHRateLimit {" + "core " + getCore().toString() + "search " + getSearch().toString() + "graphql " + + getGraphQL().toString() + "integrationManifest " + getIntegrationManifest().toString() + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GHRateLimit rateLimit = (GHRateLimit) o; + return getCore().equals(rateLimit.getCore()) && getSearch().equals(rateLimit.getSearch()) + && getGraphQL().equals(rateLimit.getGraphQL()) + && getIntegrationManifest().equals(rateLimit.getIntegrationManifest()); + } + + @Override + public int hashCode() { + return Objects.hash(getCore(), getSearch(), getGraphQL(), getIntegrationManifest()); + } + + /** + * A limit record used as a placeholder when the the actual limit is not known. + *

+ * Has a large limit and long duration so that it will doesn't expire too often. + * + * @since 1.100 + */ + public static class UnknownLimitRecord extends Record { + + // One hour + private static final long unknownLimitResetSeconds = 60L * 60L; + + static final int unknownLimit = 1000000; + static final int unknownRemaining = 999999; + + private UnknownLimitRecord() { + super(unknownLimit, unknownRemaining, System.currentTimeMillis() / 1000L + unknownLimitResetSeconds); + } + } + + /** + * A rate limit record. + * + * @since 1.100 + */ + public static class Record { + /** + * Remaining calls that can be made. + */ + private final int remaining; + + /** + * Allotted API call per hour. + */ + private final int limit; + + /** + * The time at which the current rate limit window resets in UTC epoch seconds. + */ + private final long resetEpochSeconds; + + /** + * EpochSeconds time (UTC) at which this instance was created. + */ + private final long createdAtEpochSeconds = System.currentTimeMillis() / 1000; + + /** + * The calculated time at which the rate limit will reset. Recalculated if {@link #recalculateResetDate} is + * called. + */ + @Nonnull + private Date resetDate; + + /** + * Instantiates a new Record. + * + * @param limit + * the limit + * @param remaining + * the remaining + * @param resetEpochSeconds + * the reset epoch seconds + */ + @JsonCreator + public Record(@JsonProperty("limit") int limit, + @JsonProperty("remaining") int remaining, + @JsonProperty("reset") long resetEpochSeconds) { + this(limit, remaining, resetEpochSeconds, null); + } + + /** + * Instantiates a new Record. + * + * @param limit + * the limit + * @param remaining + * the remaining + * @param resetEpochSeconds + * the reset epoch seconds + * @param updatedAt + * the updated at + */ + @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "Deprecated") + public Record(int limit, int remaining, long resetEpochSeconds, String updatedAt) { + this.limit = limit; + this.remaining = remaining; + this.resetEpochSeconds = resetEpochSeconds; + this.resetDate = recalculateResetDate(updatedAt); + } + + /** + * Recalculates the reset date using the server response date to calculate a time duration and then add that to + * the local created time for this record. + * + * @param updatedAt + * a string date in RFC 1123 + * @return reset date based on the passed date + */ + Date recalculateResetDate(String updatedAt) { + long updatedAtEpochSeconds = createdAtEpochSeconds; + if (!StringUtils.isBlank(updatedAt)) { + try { + // Get the server date and reset data, will always return a time in GMT + updatedAtEpochSeconds = ZonedDateTime.parse(updatedAt, DateTimeFormatter.RFC_1123_DATE_TIME) + .toEpochSecond(); + } catch (DateTimeParseException e) { + if (LOGGER.isLoggable(FINEST)) { + LOGGER.log(FINEST, "Malformed Date header value " + updatedAt, e); + } + } + } + + // This may seem odd but it results in an accurate or slightly pessimistic reset date + // based on system time rather than on the system being in sync with the server + long calculatedSecondsUntilReset = resetEpochSeconds - updatedAtEpochSeconds; + return resetDate = new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000); + } + + /** + * Gets the remaining number of requests allowed before this connection will be throttled. + * + * @return an integer + */ + public int getRemaining() { + return remaining; + } + + /** + * Gets the total number of API calls per hour allotted for this connection. + * + * @return an integer + */ + public int getLimit() { + return limit; + } + + /** + * Gets the time in epoch seconds when the rate limit will reset. + * + * @return a long + */ + public long getResetEpochSeconds() { + return resetEpochSeconds; + } + + /** + * Whether the rate limit reset date indicated by this instance is in the + * + * @return true if the rate limit reset date has passed. Otherwise false. + */ + public boolean isExpired() { + return getResetDate().getTime() < System.currentTimeMillis(); + } + + /** + * Returns the date at which the rate limit will reset. + * + * @return the calculated date at which the rate limit has or will reset. + */ + @Nonnull + public Date getResetDate() { + return new Date(resetDate.getTime()); + } + + @Override + public String toString() { + return "{" + "remaining=" + getRemaining() + ", limit=" + getLimit() + ", resetDate=" + getResetDate() + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Record record = (Record) o; + return getRemaining() == record.getRemaining() && getLimit() == record.getLimit() + && getResetEpochSeconds() == record.getResetEpochSeconds() + && getResetDate().equals(record.getResetDate()); + } + + @Override + public int hashCode() { + return Objects.hash(getRemaining(), getLimit(), getResetEpochSeconds(), getResetDate()); + } } + + private static final Logger LOGGER = Logger.getLogger(Requester.class.getName()); } diff --git a/src/main/java/org/kohsuke/github/GHReaction.java b/src/main/java/org/kohsuke/github/GHReaction.java index 6a00eb305c..ced6792b41 100644 --- a/src/main/java/org/kohsuke/github/GHReaction.java +++ b/src/main/java/org/kohsuke/github/GHReaction.java @@ -11,14 +11,15 @@ * @author Kohsuke Kawaguchi * @see Reactable */ -@Preview @Deprecated +@Preview +@Deprecated public class GHReaction extends GHObject { private GitHub root; private GHUser user; private ReactionContent content; - /*package*/ GHReaction wrap(GitHub root) { + GHReaction wrap(GitHub root) { this.root = root; user.wrapUp(root); return this; @@ -26,6 +27,8 @@ public class GHReaction extends GHObject { /** * The kind of reaction left. + * + * @return the content */ public ReactionContent getContent() { return content; @@ -33,6 +36,8 @@ public ReactionContent getContent() { /** * User who left the reaction. + * + * @return the user */ public GHUser getUser() { return user; @@ -48,8 +53,11 @@ public URL getHtmlUrl() { /** * Removes this reaction. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { - new Requester(root).method("DELETE").withPreview(SQUIRREL_GIRL).to("/reactions/"+id); + new Requester(root).method("DELETE").withPreview(SQUIRREL_GIRL).to("/reactions/" + id); } } diff --git a/src/main/java/org/kohsuke/github/GHRef.java b/src/main/java/org/kohsuke/github/GHRef.java index c8462d3fe6..c450aae080 100644 --- a/src/main/java/org/kohsuke/github/GHRef.java +++ b/src/main/java/org/kohsuke/github/GHRef.java @@ -11,13 +11,15 @@ * @author Michael Clarke */ public class GHRef { - /*package almost final*/ GitHub root; + /* package almost final */ GitHub root; private String ref, url; private GHObject object; /** * Name of the ref, such as "refs/tags/abc" + * + * @return the ref */ public String getRef() { return ref; @@ -25,6 +27,8 @@ public String getRef() { /** * The API URL of this tag, such as https://api.github.com/repos/jenkinsci/jenkins/git/refs/tags/1.312 + * + * @return the url */ public URL getUrl() { return GitHub.parseURL(url); @@ -32,6 +36,8 @@ public URL getUrl() { /** * The object that this ref points to. + * + * @return the object */ public GHObject getObject() { return object; @@ -41,51 +47,63 @@ public GHObject getObject() { * Updates this ref to the specified commit. * * @param sha - * The SHA1 value to set this reference to + * The SHA1 value to set this reference to + * @throws IOException + * the io exception */ public void updateTo(String sha) throws IOException { - updateTo(sha, false); + updateTo(sha, false); } /** * Updates this ref to the specified commit. * * @param sha - * The SHA1 value to set this reference to + * The SHA1 value to set this reference to * @param force - * Whether or not to force this ref update. + * Whether or not to force this ref update. + * @throws IOException + * the io exception */ public void updateTo(String sha, Boolean force) throws IOException { - new Requester(root) - .with("sha", sha).with("force", force).method("PATCH").to(url, GHRef.class).wrap(root); + new Requester(root).with("sha", sha).with("force", force).method("PATCH").to(url, GHRef.class).wrap(root); } /** * Deletes this ref from the repository using the GitHub API. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { - new Requester(root).method("DELETE").to(url); + new Requester(root).method("DELETE").to(url); } - /*package*/ GHRef wrap(GitHub root) { + GHRef wrap(GitHub root) { this.root = root; return this; } - /*package*/ static GHRef[] wrap(GHRef[] in, GitHub root) { + static GHRef[] wrap(GHRef[] in, GitHub root) { for (GHRef r : in) { r.wrap(root); } return in; } - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") + /** + * The type GHObject. + */ + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public static class GHObject { - private String type, sha, url; + private String type, sha, url; /** * Type of the object, such as "commit" + * + * @return the type */ public String getType() { return type; @@ -93,13 +111,18 @@ public String getType() { /** * SHA1 of this object. + * + * @return the sha */ public String getSha() { return sha; } /** - * API URL to this Git data, such as https://api.github.com/repos/jenkinsci/jenkins/git/commits/b72322675eb0114363a9a86e9ad5a170d1d07ac0 + * API URL to this Git data, such as + * https://api.github.com/repos/jenkinsci/jenkins/git/commits/b72322675eb0114363a9a86e9ad5a170d1d07ac0 + * + * @return the url */ public URL getUrl() { return GitHub.parseURL(url); diff --git a/src/main/java/org/kohsuke/github/GHRelease.java b/src/main/java/org/kohsuke/github/GHRelease.java index 0df6b415b0..3955693071 100644 --- a/src/main/java/org/kohsuke/github/GHRelease.java +++ b/src/main/java/org/kohsuke/github/GHRelease.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.net.URLEncoder; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -14,8 +15,8 @@ /** * Release in a github repository. * - * @see GHRepository#getReleases() - * @see GHRepository#createRelease(String) + * @see GHRepository#getReleases() GHRepository#getReleases() + * @see GHRepository#createRelease(String) GHRepository#createRelease(String) */ public class GHRelease extends GHObject { GitHub root; @@ -34,21 +35,42 @@ public class GHRelease extends GHObject { private String tarball_url; private String zipball_url; + /** + * Gets assets url. + * + * @return the assets url + */ public String getAssetsUrl() { return assets_url; } + /** + * Gets body. + * + * @return the body + */ public String getBody() { return body; } + /** + * Is draft boolean. + * + * @return the boolean + */ public boolean isDraft() { return draft; } /** - * @deprecated - * Use {@link #update()} + * Sets draft. + * + * @param draft + * the draft + * @return the draft + * @throws IOException + * the io exception + * @deprecated Use {@link #update()} */ public GHRelease setDraft(boolean draft) throws IOException { return update().draft(draft).update(); @@ -58,50 +80,112 @@ public URL getHtmlUrl() { return GitHub.parseURL(html_url); } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Sets name. + * + * @param name + * the name + */ public void setName(String name) { this.name = name; } + /** + * Gets owner. + * + * @return the owner + */ public GHRepository getOwner() { return owner; } + /** + * Sets owner. + * + * @param owner + * the owner + */ public void setOwner(GHRepository owner) { this.owner = owner; } + /** + * Is prerelease boolean. + * + * @return the boolean + */ public boolean isPrerelease() { return prerelease; } + /** + * Gets published at. + * + * @return the published at + */ public Date getPublished_at() { return new Date(published_at.getTime()); } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Gets tag name. + * + * @return the tag name + */ public String getTagName() { return tag_name; } + /** + * Gets target commitish. + * + * @return the target commitish + */ public String getTargetCommitish() { return target_commitish; } + /** + * Gets upload url. + * + * @return the upload url + */ public String getUploadUrl() { return upload_url; } + /** + * Gets zipball url. + * + * @return the zipball url + */ public String getZipballUrl() { return zipball_url; } + /** + * Gets tarball url. + * + * @return the tarball url + */ public String getTarballUrl() { return tarball_url; } @@ -121,10 +205,18 @@ static GHRelease[] wrap(GHRelease[] releases, GHRepository owner) { /** * Because github relies on SNI (http://en.wikipedia.org/wiki/Server_Name_Indication) this method will only work on - * Java 7 or greater. Options for fixing this for earlier JVMs can be found here + * Java 7 or greater. Options for fixing this for earlier JVMs can be found here * http://stackoverflow.com/questions/12361090/server-name-indication-sni-on-java but involve more complicated * handling of the HTTP requests to github's API. - */ + * + * @param file + * the file + * @param contentType + * the content type + * @return the gh asset + * @throws IOException + * the io exception + */ public GHAsset uploadAsset(File file, String contentType) throws IOException { FileInputStream s = new FileInputStream(file); try { @@ -133,41 +225,63 @@ public GHAsset uploadAsset(File file, String contentType) throws IOException { s.close(); } } - + + /** + * Upload asset gh asset. + * + * @param filename + * the filename + * @param stream + * the stream + * @param contentType + * the content type + * @return the gh asset + * @throws IOException + * the io exception + */ public GHAsset uploadAsset(String filename, InputStream stream, String contentType) throws IOException { Requester builder = new Requester(owner.root); - - String url = format("https://uploads.github.com%s/releases/%d/assets?name=%s", - owner.getApiTailUrl(""), getId(), filename); - return builder.contentType(contentType) - .with(stream) - .to(url, GHAsset.class).wrap(this); + String url = getUploadUrl(); + // strip the helpful garbage from the url + url = url.substring(0, url.indexOf('{')); + url += "?name=" + URLEncoder.encode(filename, "UTF-8"); + return builder.contentType(contentType).with(stream).to(url, GHAsset.class).wrap(this); } + /** + * Gets assets. + * + * @return the assets + * @throws IOException + * the io exception + */ public List getAssets() throws IOException { Requester builder = new Requester(owner.root); - GHAsset[] assets = builder - .method("GET") - .to(getApiTailUrl("assets"), GHAsset[].class); + GHAsset[] assets = builder.method("GET").to(getApiTailUrl("assets"), GHAsset[].class); return Arrays.asList(GHAsset.wrap(assets, this)); } /** * Deletes this release. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { - new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/"+id)); + new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/" + id)); } /** * Updates this release via a builder. + * + * @return the gh release updater */ public GHReleaseUpdater update() { return new GHReleaseUpdater(this); } private String getApiTailUrl(String end) { - return owner.getApiTailUrl(format("releases/%s/%s",id,end)); + return owner.getApiTailUrl(format("releases/%s/%s", id, end)); } } diff --git a/src/main/java/org/kohsuke/github/GHReleaseBuilder.java b/src/main/java/org/kohsuke/github/GHReleaseBuilder.java index e427bdf8a5..19dbafd6bf 100644 --- a/src/main/java/org/kohsuke/github/GHReleaseBuilder.java +++ b/src/main/java/org/kohsuke/github/GHReleaseBuilder.java @@ -5,12 +5,20 @@ /** * Builder pattern for creating a {@link GHRelease} * - * @see GHRepository#createRelease(String) + * @see GHRepository#createRelease(String) GHRepository#createRelease(String) */ public class GHReleaseBuilder { private final GHRepository repo; private final Requester builder; + /** + * Instantiates a new Gh release builder. + * + * @param ghRepository + * the gh repository + * @param tag + * the tag + */ public GHReleaseBuilder(GHRepository ghRepository, String tag) { this.repo = ghRepository; this.builder = new Requester(repo.root); @@ -18,7 +26,11 @@ public GHReleaseBuilder(GHRepository ghRepository, String tag) { } /** - * @param body The release notes body. + * Body gh release builder. + * + * @param body + * The release notes body. + * @return the gh release builder */ public GHReleaseBuilder body(String body) { builder.with("body", body); @@ -26,11 +38,11 @@ public GHReleaseBuilder body(String body) { } /** - * Specifies the commitish value that determines where the Git tag is created from. Can be any branch or - * commit SHA. + * Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. * - * @param commitish Defaults to the repository’s default branch (usually "master"). Unused if the Git tag - * already exists. + * @param commitish + * Defaults to the repository’s default branch (usually "master"). Unused if the Git tag already exists. + * @return the gh release builder */ public GHReleaseBuilder commitish(String commitish) { builder.with("target_commitish", commitish); @@ -40,8 +52,10 @@ public GHReleaseBuilder commitish(String commitish) { /** * Optional. * - * @param draft {@code true} to create a draft (unpublished) release, {@code false} to create a published one. - * Default is {@code false}. + * @param draft + * {@code true} to create a draft (unpublished) release, {@code false} to create a published one. Default + * is {@code false}. + * @return the gh release builder */ public GHReleaseBuilder draft(boolean draft) { builder.with("draft", draft); @@ -49,7 +63,11 @@ public GHReleaseBuilder draft(boolean draft) { } /** - * @param name the name of the release + * Name gh release builder. + * + * @param name + * the name of the release + * @return the gh release builder */ public GHReleaseBuilder name(String name) { builder.with("name", name); @@ -59,14 +77,23 @@ public GHReleaseBuilder name(String name) { /** * Optional * - * @param prerelease {@code true} to identify the release as a prerelease. {@code false} to identify the release - * as a full release. Default is {@code false}. + * @param prerelease + * {@code true} to identify the release as a prerelease. {@code false} to identify the release as a full + * release. Default is {@code false}. + * @return the gh release builder */ public GHReleaseBuilder prerelease(boolean prerelease) { builder.with("prerelease", prerelease); return this; } + /** + * Create gh release. + * + * @return the gh release + * @throws IOException + * the io exception + */ public GHRelease create() throws IOException { return builder.to(repo.getApiTailUrl("releases"), GHRelease.class).wrap(repo); } diff --git a/src/main/java/org/kohsuke/github/GHReleaseUpdater.java b/src/main/java/org/kohsuke/github/GHReleaseUpdater.java index a34a5b0bc2..3c52eb0864 100644 --- a/src/main/java/org/kohsuke/github/GHReleaseUpdater.java +++ b/src/main/java/org/kohsuke/github/GHReleaseUpdater.java @@ -6,7 +6,7 @@ * Modifies {@link GHRelease}. * * @author Kohsuke Kawaguchi - * @see GHRelease#update() + * @see GHRelease#update() GHRelease#update() */ public class GHReleaseUpdater { private final GHRelease base; @@ -17,13 +17,24 @@ public class GHReleaseUpdater { this.builder = new Requester(base.root); } + /** + * Tag gh release updater. + * + * @param tag + * the tag + * @return the gh release updater + */ public GHReleaseUpdater tag(String tag) { - builder.with("tag_name",tag); + builder.with("tag_name", tag); return this; } /** - * @param body The release notes body. + * Body gh release updater. + * + * @param body + * The release notes body. + * @return the gh release updater */ public GHReleaseUpdater body(String body) { builder.with("body", body); @@ -31,11 +42,11 @@ public GHReleaseUpdater body(String body) { } /** - * Specifies the commitish value that determines where the Git tag is created from. Can be any branch or - * commit SHA. + * Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. * - * @param commitish Defaults to the repository’s default branch (usually "master"). Unused if the Git tag - * already exists. + * @param commitish + * Defaults to the repository’s default branch (usually "master"). Unused if the Git tag already exists. + * @return the gh release updater */ public GHReleaseUpdater commitish(String commitish) { builder.with("target_commitish", commitish); @@ -45,8 +56,10 @@ public GHReleaseUpdater commitish(String commitish) { /** * Optional. * - * @param draft {@code true} to create a draft (unpublished) release, {@code false} to create a published one. - * Default is {@code false}. + * @param draft + * {@code true} to create a draft (unpublished) release, {@code false} to create a published one. Default + * is {@code false}. + * @return the gh release updater */ public GHReleaseUpdater draft(boolean draft) { builder.with("draft", draft); @@ -54,7 +67,11 @@ public GHReleaseUpdater draft(boolean draft) { } /** - * @param name the name of the release + * Name gh release updater. + * + * @param name + * the name of the release + * @return the gh release updater */ public GHReleaseUpdater name(String name) { builder.with("name", name); @@ -64,18 +81,27 @@ public GHReleaseUpdater name(String name) { /** * Optional * - * @param prerelease {@code true} to identify the release as a prerelease. {@code false} to identify the release - * as a full release. Default is {@code false}. + * @param prerelease + * {@code true} to identify the release as a prerelease. {@code false} to identify the release as a full + * release. Default is {@code false}. + * @return the gh release updater */ public GHReleaseUpdater prerelease(boolean prerelease) { builder.with("prerelease", prerelease); return this; } + /** + * Update gh release. + * + * @return the gh release + * @throws IOException + * the io exception + */ public GHRelease update() throws IOException { - return builder - .method("PATCH") - .to(base.owner.getApiTailUrl("releases/"+base.id), GHRelease.class).wrap(base.owner); + return builder.method("PATCH") + .to(base.owner.getApiTailUrl("releases/" + base.id), GHRelease.class) + .wrap(base.owner); } } diff --git a/src/main/java/org/kohsuke/github/GHRepoHook.java b/src/main/java/org/kohsuke/github/GHRepoHook.java index 948438eb96..d273168f42 100644 --- a/src/main/java/org/kohsuke/github/GHRepoHook.java +++ b/src/main/java/org/kohsuke/github/GHRepoHook.java @@ -4,9 +4,9 @@ class GHRepoHook extends GHHook { /** * Repository that the hook belongs to. */ - /*package*/ transient GHRepository repository; + transient GHRepository repository; - /*package*/ GHRepoHook wrap(GHRepository owner) { + GHRepoHook wrap(GHRepository owner) { this.repository = owner; return this; } diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 7a554c8558..932e769ad6 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -24,9 +24,6 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; @@ -37,9 +34,7 @@ import java.io.InputStreamReader; import java.io.InterruptedIOException; import java.io.Reader; -import java.io.UnsupportedEncodingException; import java.net.URL; -import java.net.URLEncoder; import java.util.AbstractSet; import java.util.ArrayList; import java.util.Arrays; @@ -54,9 +49,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.WeakHashMap; -import java.util.NoSuchElementException; -import java.util.logging.Level; -import java.util.logging.Logger; import static java.util.Arrays.*; import static org.kohsuke.github.Previews.*; @@ -66,14 +58,14 @@ * * @author Kohsuke Kawaguchi */ -@SuppressWarnings({"UnusedDeclaration"}) -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressWarnings({ "UnusedDeclaration" }) +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHRepository extends GHObject { - /*package almost final*/ GitHub root; + /* package almost final */ GitHub root; private String description, homepage, name, full_name; - private String html_url; // this is the UI + private String html_url; // this is the UI /* * The license information makes use of the preview API. * @@ -82,51 +74,83 @@ public class GHRepository extends GHObject { private GHLicense license; private String git_url, ssh_url, clone_url, svn_url, mirror_url; - private GHUser owner; // not fully populated. beware. + private GHUser owner; // not fully populated. beware. private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived; - + private boolean allow_squash_merge; private boolean allow_merge_commit; private boolean allow_rebase_merge; - + @JsonProperty("private") private boolean _private; private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count; private String pushed_at; - private Map milestones = new WeakHashMap(); + private Map milestones = new WeakHashMap(); - private String default_branch,language; - private Map commits = new WeakHashMap(); + private String default_branch, language; + private Map commits = new WeakHashMap(); @SkipFromToString private GHRepoPermission permissions; private GHRepository source, parent; + /** + * Create deployment gh deployment builder. + * + * @param ref + * the ref + * @return the gh deployment builder + */ public GHDeploymentBuilder createDeployment(String ref) { - return new GHDeploymentBuilder(this,ref); + return new GHDeploymentBuilder(this, ref); } /** - * @deprecated - * Use {@code getDeployment(id).listStatuses()} + * Gets deployment statuses. + * + * @param id + * the id + * @return the deployment statuses + * @throws IOException + * the io exception + * @deprecated Use {@code getDeployment(id).listStatuses()} */ public PagedIterable getDeploymentStatuses(final int id) throws IOException { return getDeployment(id).listStatuses(); } - public PagedIterable listDeployments(String sha,String ref,String task,String environment){ - List params = Arrays.asList(getParam("sha", sha), getParam("ref", ref), getParam("task", task), getParam("environment", environment)); - final String deploymentsUrl = getApiTailUrl("deployments") + "?"+ join(params,"&"); + /** + * List deployments paged iterable. + * + * @param sha + * the sha + * @param ref + * the ref + * @param task + * the task + * @param environment + * the environment + * @return the paged iterable + */ + public PagedIterable listDeployments(String sha, String ref, String task, String environment) { + List params = Arrays.asList(getParam("sha", sha), + getParam("ref", ref), + getParam("task", task), + getParam("environment", environment)); + final String deploymentsUrl = getApiTailUrl("deployments") + "?" + join(params, "&"); return root.retrieve() - .asPagedIterable( - deploymentsUrl, - GHDeployment[].class, - item -> item.wrap(GHRepository.this) ); + .asPagedIterable(deploymentsUrl, GHDeployment[].class, item -> item.wrap(GHRepository.this)); } /** * Obtains a single {@link GHDeployment} by its ID. + * + * @param id + * the id + * @return the deployment + * @throws IOException + * the io exception */ public GHDeployment getDeployment(long id) throws IOException { return root.retrieve().to(getApiTailUrl("deployments/" + id), GHDeployment.class).wrap(this); @@ -134,58 +158,80 @@ public GHDeployment getDeployment(long id) throws IOException { private String join(List params, String joinStr) { StringBuilder output = new StringBuilder(); - for(String param: params){ - if(param != null){ - output.append(param+joinStr); + for (String param : params) { + if (param != null) { + output.append(param + joinStr); } } return output.toString(); } private String getParam(String name, String value) { - return StringUtils.trimToNull(value)== null? null: name+"="+value; + return StringUtils.trimToNull(value) == null ? null : name + "=" + value; } /** - * @deprecated - * Use {@code getDeployment(deploymentId).createStatus(ghDeploymentState)} + * Gets deploy status. + * + * @param deploymentId + * the deployment id + * @param ghDeploymentState + * the gh deployment state + * @return the deploy status + * @throws IOException + * the io exception + * @deprecated Use {@code getDeployment(deploymentId).createStatus(ghDeploymentState)} */ - public GHDeploymentStatusBuilder createDeployStatus(int deploymentId, GHDeploymentState ghDeploymentState) throws IOException { + public GHDeploymentStatusBuilder createDeployStatus(int deploymentId, GHDeploymentState ghDeploymentState) + throws IOException { return getDeployment(deploymentId).createStatus(ghDeploymentState); } private static class GHRepoPermission { - boolean pull,push,admin; + boolean pull, push, admin; } - + /** + * Gets description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Gets homepage. + * + * @return the homepage + */ public String getHomepage() { return homepage; } /** - * Gets the git:// URL to this repository, such as "git://github.com/kohsuke/jenkins.git" - * This URL is read-only. + * Gets the git:// URL to this repository, such as "git://github.com/kohsuke/jenkins.git" This URL is read-only. + * + * @return the git transport url */ public String getGitTransportUrl() { return git_url; } /** - * Gets the HTTPS URL to this repository, such as "https://github.com/kohsuke/jenkins.git" - * This URL is read-only. + * Gets the HTTPS URL to this repository, such as "https://github.com/kohsuke/jenkins.git" This URL is read-only. + * + * @return the http transport url */ public String getHttpTransportUrl() { return clone_url; } /** - * @deprecated - * Typo of {@link #getHttpTransportUrl()} + * Git http transport url string. + * + * @return the string + * @deprecated Typo of {@link #getHttpTransportUrl()} */ public String gitHttpTransportUrl() { return clone_url; @@ -193,14 +239,18 @@ public String gitHttpTransportUrl() { /** * Gets the Subversion URL to access this repository: https://github.com/rails/rails + * + * @return the svn url */ public String getSvnUrl() { return svn_url; } /** - * Gets the Mirror URL to access this repository: https://github.com/apache/tomee - * mirrored from git://git.apache.org/tomee.git + * Gets the Mirror URL to access this repository: https://github.com/apache/tomee mirrored from + * git://git.apache.org/tomee.git + * + * @return the mirror url */ public String getMirrorUrl() { return mirror_url; @@ -208,6 +258,8 @@ public String getMirrorUrl() { /** * Gets the SSH URL to access this repository, such as git@github.com:rails/rails.git + * + * @return the ssh url */ public String getSshUrl() { return ssh_url; @@ -219,98 +271,190 @@ public URL getHtmlUrl() { /** * Short repository name without the owner. For example 'jenkins' in case of http://github.com/jenkinsci/jenkins + * + * @return the name */ public String getName() { return name; } /** - * Full repository name including the owner or organization. For example 'jenkinsci/jenkins' in case of http://github.com/jenkinsci/jenkins + * Full repository name including the owner or organization. For example 'jenkinsci/jenkins' in case of + * http://github.com/jenkinsci/jenkins + * + * @return the full name */ public String getFullName() { return full_name; } + /** + * Has pull access boolean. + * + * @return the boolean + */ public boolean hasPullAccess() { - return permissions!=null && permissions.pull; + return permissions != null && permissions.pull; } + /** + * Has push access boolean. + * + * @return the boolean + */ public boolean hasPushAccess() { - return permissions!=null && permissions.push; + return permissions != null && permissions.push; } + /** + * Has admin access boolean. + * + * @return the boolean + */ public boolean hasAdminAccess() { - return permissions!=null && permissions.admin; + return permissions != null && permissions.admin; } /** * Gets the primary programming language. + * + * @return the language */ public String getLanguage() { return language; } + /** + * Gets owner. + * + * @return the owner + * @throws IOException + * the io exception + */ public GHUser getOwner() throws IOException { - return root.isOffline() ? owner : root.getUser(getOwnerName()); // because 'owner' isn't fully populated + return root.isOffline() ? owner : root.getUser(getOwnerName()); // because 'owner' isn't fully populated } + /** + * Gets issue. + * + * @param id + * the id + * @return the issue + * @throws IOException + * the io exception + */ public GHIssue getIssue(int id) throws IOException { return root.retrieve().to(getApiTailUrl("issues/" + id), GHIssue.class).wrap(this); } + /** + * Create issue gh issue builder. + * + * @param title + * the title + * @return the gh issue builder + */ public GHIssueBuilder createIssue(String title) { - return new GHIssueBuilder(this,title); + return new GHIssueBuilder(this, title); } + /** + * Gets issues. + * + * @param state + * the state + * @return the issues + * @throws IOException + * the io exception + */ public List getIssues(GHIssueState state) throws IOException { return listIssues(state).asList(); } + /** + * Gets issues. + * + * @param state + * the state + * @param milestone + * the milestone + * @return the issues + * @throws IOException + * the io exception + */ public List getIssues(GHIssueState state, GHMilestone milestone) throws IOException { return Arrays.asList(GHIssue.wrap(root.retrieve() .with("state", state) .with("milestone", milestone == null ? "none" : "" + milestone.getNumber()) - .to(getApiTailUrl("issues"), - GHIssue[].class), this)); + .to(getApiTailUrl("issues"), GHIssue[].class), this)); } /** * Lists up all the issues in this repository. + * + * @param state + * the state + * @return the paged iterable */ public PagedIterable listIssues(final GHIssueState state) { - return root.retrieve().with("state",state) - .asPagedIterable( - getApiTailUrl("issues"), - GHIssue[].class, - item -> item.wrap(GHRepository.this) ); + return root.retrieve() + .with("state", state) + .asPagedIterable(getApiTailUrl("issues"), GHIssue[].class, item -> item.wrap(GHRepository.this)); } + /** + * Create release gh release builder. + * + * @param tag + * the tag + * @return the gh release builder + */ public GHReleaseBuilder createRelease(String tag) { - return new GHReleaseBuilder(this,tag); + return new GHReleaseBuilder(this, tag); } /** * Creates a named ref, such as tag, branch, etc. * * @param name - * The name of the fully qualified reference (ie: refs/heads/master). - * If it doesn't start with 'refs' and have at least two slashes, it will be rejected. + * The name of the fully qualified reference (ie: refs/heads/master). If it doesn't start with 'refs' and + * have at least two slashes, it will be rejected. * @param sha - * The SHA1 value to set this reference to + * The SHA1 value to set this reference to + * @return the gh ref + * @throws IOException + * the io exception */ public GHRef createRef(String name, String sha) throws IOException { - return new Requester(root) - .with("ref", name).with("sha", sha).method("POST").to(getApiTailUrl("git/refs"), GHRef.class).wrap(root); + return new Requester(root).with("ref", name) + .with("sha", sha) + .method("POST") + .to(getApiTailUrl("git/refs"), GHRef.class) + .wrap(root); } /** - * @deprecated - * use {@link #listReleases()} + * Gets releases. + * + * @return the releases + * @throws IOException + * the io exception + * @deprecated use {@link #listReleases()} */ public List getReleases() throws IOException { return listReleases().asList(); } + /** + * Gets release. + * + * @param id + * the id + * @return the release + * @throws IOException + * the io exception + */ public GHRelease getRelease(long id) throws IOException { try { return root.retrieve().to(getApiTailUrl("releases/" + id), GHRelease.class).wrap(this); @@ -319,6 +463,15 @@ public GHRelease getRelease(long id) throws IOException { } } + /** + * Gets release by tag name. + * + * @param tag + * the tag + * @return the release by tag name + * @throws IOException + * the io exception + */ public GHRelease getReleaseByTagName(String tag) throws IOException { try { return root.retrieve().to(getApiTailUrl("releases/tags/" + tag), GHRelease.class).wrap(this); @@ -326,7 +479,14 @@ public GHRelease getReleaseByTagName(String tag) throws IOException { return null; // no release for this tag } } - + + /** + * Gets latest release. + * + * @return the latest release + * @throws IOException + * the io exception + */ public GHRelease getLatestRelease() throws IOException { try { return root.retrieve().to(getApiTailUrl("releases/latest"), GHRelease.class).wrap(this); @@ -335,34 +495,47 @@ public GHRelease getLatestRelease() throws IOException { } } + /** + * List releases paged iterable. + * + * @return the paged iterable + * @throws IOException + * the io exception + */ public PagedIterable listReleases() throws IOException { return root.retrieve() - .asPagedIterable( - getApiTailUrl("releases"), - GHRelease[].class, - item -> item.wrap(GHRepository.this) ); + .asPagedIterable(getApiTailUrl("releases"), GHRelease[].class, item -> item.wrap(GHRepository.this)); } + /** + * List tags paged iterable. + * + * @return the paged iterable + * @throws IOException + * the io exception + */ public PagedIterable listTags() throws IOException { return root.retrieve() - .asPagedIterable( - getApiTailUrl("tags"), - GHTag[].class, - item -> item.wrap(GHRepository.this) ); + .asPagedIterable(getApiTailUrl("tags"), GHTag[].class, item -> item.wrap(GHRepository.this)); } /** - * List languages for the specified repository. - * The value on the right of a language is the number of bytes of code written in that language. - * { - "C": 78769, - "Python": 7769 - } + * List languages for the specified repository. The value on the right of a language is the number of bytes of code + * written in that language. { "C": 78769, "Python": 7769 } + * + * @return the map + * @throws IOException + * the io exception */ - public Map listLanguages() throws IOException { + public Map listLanguages() throws IOException { return root.retrieve().to(getApiTailUrl("languages"), HashMap.class); } + /** + * Gets owner name. + * + * @return the owner name + */ 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 @@ -371,83 +544,156 @@ public String getOwnerName() { return owner.login != null ? owner.login : owner.name; } + /** + * Has issues boolean. + * + * @return the boolean + */ public boolean hasIssues() { return has_issues; } + /** + * Has wiki boolean. + * + * @return the boolean + */ public boolean hasWiki() { return has_wiki; } + /** + * Is fork boolean. + * + * @return the boolean + */ public boolean isFork() { return fork; } + /** + * Is archived boolean. + * + * @return the boolean + */ public boolean isArchived() { return archived; } - + + /** + * Is allow squash merge boolean. + * + * @return the boolean + */ public boolean isAllowSquashMerge() { - return allow_squash_merge; + return allow_squash_merge; } - + + /** + * Is allow merge commit boolean. + * + * @return the boolean + */ public boolean isAllowMergeCommit() { - return allow_merge_commit; + return allow_merge_commit; } - + + /** + * Is allow rebase merge boolean. + * + * @return the boolean + */ public boolean isAllowRebaseMerge() { - return allow_rebase_merge; + return allow_rebase_merge; } /** - * Returns the number of all forks of this repository. - * This not only counts direct forks, but also forks of forks, and so on. + * Returns the number of all forks of this repository. This not only counts direct forks, but also forks of forks, + * and so on. + * + * @return the forks */ public int getForks() { return forks_count; } + /** + * Gets stargazers count. + * + * @return the stargazers count + */ public int getStargazersCount() { return stargazers_count; } + /** + * Is private boolean. + * + * @return the boolean + */ public boolean isPrivate() { return _private; } + /** + * Has downloads boolean. + * + * @return the boolean + */ public boolean hasDownloads() { return has_downloads; } + /** + * Has pages boolean. + * + * @return the boolean + */ public boolean hasPages() { return has_pages; } + /** + * Gets watchers. + * + * @return the watchers + */ public int getWatchers() { return watchers_count; } + /** + * Gets open issue count. + * + * @return the open issue count + */ public int getOpenIssueCount() { return open_issues_count; } /** - * @deprecated - * This no longer exists in the official API documentation. - * Use {@link #getForks()} + * Gets network count. + * + * @return the network count + * @deprecated This no longer exists in the official API documentation. Use {@link #getForks()} */ public int getNetworkCount() { return forks_count; } + /** + * Gets subscribers count. + * + * @return the subscribers count + */ public int getSubscribersCount() { return subscribers_count; } /** + * Gets pushed at. * - * @return - * null if the repository was never pushed at. + * @return null if the repository was never pushed at. */ public Date getPushedAt() { return GitHub.parseDate(pushed_at); @@ -456,29 +702,37 @@ public Date getPushedAt() { /** * Returns the primary branch you'll configure in the "Admin > Options" config page. * - * @return - * This field is null until the user explicitly configures the master branch. + * @return This field is null until the user explicitly configures the master branch. */ public String getDefaultBranch() { return default_branch; } /** - * @deprecated - * Renamed to {@link #getDefaultBranch()} + * Gets master branch. + * + * @return the master branch + * @deprecated Renamed to {@link #getDefaultBranch()} */ public String getMasterBranch() { return default_branch; } + /** + * Gets size. + * + * @return the size + */ public int getSize() { return size; } - /** - * Gets the collaborators on this repository. - * This set always appear to include the owner. + * Gets the collaborators on this repository. This set always appear to include the owner. + * + * @return the collaborators + * @throws IOException + * the io exception */ @WithBridgeMethods(Set.class) public GHPersonSet getCollaborators() throws IOException { @@ -488,15 +742,22 @@ public GHPersonSet getCollaborators() throws IOException { /** * Lists up the collaborators on this repository. * - * @return Users + * @return Users paged iterable + * @throws IOException + * the io exception */ public PagedIterable listCollaborators() throws IOException { return listUsers("collaborators"); } /** - * Lists all the available assignees - * to which issues may be assigned. + * Lists all + * the + * available assignees to which issues may be assigned. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listAssignees() throws IOException { return listUsers("assignees"); @@ -504,38 +765,56 @@ public PagedIterable listAssignees() throws IOException { /** * Checks if the given user is an assignee for this repository. + * + * @param u + * the u + * @return the boolean + * @throws IOException + * the io exception */ public boolean hasAssignee(GHUser u) throws IOException { - return root.retrieve().asHttpStatusCode(getApiTailUrl("assignees/" + u.getLogin()))/100==2; + return root.retrieve().asHttpStatusCode(getApiTailUrl("assignees/" + u.getLogin())) / 100 == 2; } /** - * Gets the names of the collaborators on this repository. - * This method deviates from the principle of this library but it works a lot faster than {@link #getCollaborators()}. + * Gets the names of the collaborators on this repository. This method deviates from the principle of this library + * but it works a lot faster than {@link #getCollaborators()}. + * + * @return the collaborator names + * @throws IOException + * the io exception */ public Set getCollaboratorNames() throws IOException { Set r = new HashSet(); - for (GHUser u : GHUser.wrap(root.retrieve().to(getApiTailUrl("collaborators"), GHUser[].class),root)) + for (GHUser u : GHUser.wrap(root.retrieve().to(getApiTailUrl("collaborators"), GHUser[].class), root)) r.add(u.login); return r; } /** * Obtain permission for a given user in this repository. - * @param user a {@link GHUser#getLogin} - * @throws FileNotFoundException under some conditions (e.g., private repo you can see but are not an admin of); treat as unknown - * @throws HttpException with a 403 under other conditions (e.g., public repo you have no special rights to); treat as unknown + * + * @param user + * a {@link GHUser#getLogin} + * @return the permission + * @throws IOException + * the io exception */ public GHPermissionType getPermission(String user) throws IOException { - GHPermission perm = root.retrieve().to(getApiTailUrl("collaborators/" + user + "/permission"), GHPermission.class); + GHPermission perm = root.retrieve() + .to(getApiTailUrl("collaborators/" + user + "/permission"), GHPermission.class); perm.wrapUp(root); return perm.getPermissionType(); } /** * Obtain permission for a given user in this repository. - * @throws FileNotFoundException under some conditions (e.g., private repo you can see but are not an admin of); treat as unknown - * @throws HttpException with a 403 under other conditions (e.g., public repo you have no special rights to); treat as unknown + * + * @param u + * the u + * @return the permission + * @throws IOException + * the io exception */ public GHPermissionType getPermission(GHUser u) throws IOException { return getPermission(u.getLogin()); @@ -543,23 +822,61 @@ public GHPermissionType getPermission(GHUser u) throws IOException { /** * If this repository belongs to an organization, return a set of teams. + * + * @return the teams + * @throws IOException + * the io exception */ public Set getTeams() throws IOException { - return Collections.unmodifiableSet(new HashSet(Arrays.asList(GHTeam.wrapUp(root.retrieve().to(getApiTailUrl("teams"), GHTeam[].class), root.getOrganization(getOwnerName()))))); + return Collections.unmodifiableSet(new HashSet( + Arrays.asList(GHTeam.wrapUp(root.retrieve().to(getApiTailUrl("teams"), GHTeam[].class), + root.getOrganization(getOwnerName()))))); } + /** + * Add collaborators. + * + * @param users + * the users + * @throws IOException + * the io exception + */ public void addCollaborators(GHUser... users) throws IOException { addCollaborators(asList(users)); } + /** + * Add collaborators. + * + * @param users + * the users + * @throws IOException + * the io exception + */ public void addCollaborators(Collection users) throws IOException { modifyCollaborators(users, "PUT"); } + /** + * Remove collaborators. + * + * @param users + * the users + * @throws IOException + * the io exception + */ public void removeCollaborators(GHUser... users) throws IOException { removeCollaborators(asList(users)); } + /** + * Remove collaborators. + * + * @param users + * the users + * @throws IOException + * the io exception + */ public void removeCollaborators(Collection users) throws IOException { modifyCollaborators(users, "DELETE"); } @@ -570,22 +887,38 @@ private void modifyCollaborators(Collection users, String method) throws } } + /** + * Sets email service hook. + * + * @param address + * the address + * @throws IOException + * the io exception + */ public void setEmailServiceHook(String address) throws IOException { Map config = new HashMap(); config.put("address", address); - new Requester(root).method("POST").with("name", "email").with("config", config).with("active", true) + new Requester(root).method("POST") + .with("name", "email") + .with("config", config) + .with("active", true) .to(getApiTailUrl("hooks")); } private void edit(String key, String value) throws IOException { Requester requester = new Requester(root); if (!key.equals("name")) - requester.with("name", name); // even when we don't change the name, we need to send it in + requester.with("name", name); // even when we don't change the name, we need to send it in requester.with(key, value).method("PATCH").to(getApiTailUrl("")); } /** * Enables or disables the issue tracker for this repository. + * + * @param v + * the v + * @throws IOException + * the io exception */ public void enableIssueTracker(boolean v) throws IOException { edit("has_issues", String.valueOf(v)); @@ -593,67 +926,146 @@ public void enableIssueTracker(boolean v) throws IOException { /** * Enables or disables Wiki for this repository. + * + * @param v + * the v + * @throws IOException + * the io exception */ public void enableWiki(boolean v) throws IOException { edit("has_wiki", String.valueOf(v)); } + /** + * Enable downloads. + * + * @param v + * the v + * @throws IOException + * the io exception + */ public void enableDownloads(boolean v) throws IOException { - edit("has_downloads",String.valueOf(v)); + edit("has_downloads", String.valueOf(v)); } /** * Rename this repository. + * + * @param name + * the name + * @throws IOException + * the io exception */ public void renameTo(String name) throws IOException { - edit("name",name); + edit("name", name); } + /** + * Sets description. + * + * @param value + * the value + * @throws IOException + * the io exception + */ public void setDescription(String value) throws IOException { - edit("description",value); + edit("description", value); } + /** + * Sets homepage. + * + * @param value + * the value + * @throws IOException + * the io exception + */ public void setHomepage(String value) throws IOException { - edit("homepage",value); + edit("homepage", value); } + /** + * Sets default branch. + * + * @param value + * the value + * @throws IOException + * the io exception + */ public void setDefaultBranch(String value) throws IOException { edit("default_branch", value); } + /** + * Sets private. + * + * @param value + * the value + * @throws IOException + * the io exception + */ public void setPrivate(boolean value) throws IOException { edit("private", Boolean.toString(value)); } - + + /** + * Allow squash merge. + * + * @param value + * the value + * @throws IOException + * the io exception + */ public void allowSquashMerge(boolean value) throws IOException { edit("allow_squash_merge", Boolean.toString(value)); } - + + /** + * Allow merge commit. + * + * @param value + * the value + * @throws IOException + * the io exception + */ public void allowMergeCommit(boolean value) throws IOException { edit("allow_merge_commit", Boolean.toString(value)); } - + + /** + * Allow rebase merge. + * + * @param value + * the value + * @throws IOException + * the io exception + */ public void allowRebaseMerge(boolean value) throws IOException { edit("allow_rebase_merge", Boolean.toString(value)); } - + /** * Deletes this repository. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { try { new Requester(root).method("DELETE").to(getApiTailUrl("")); } catch (FileNotFoundException x) { - throw (FileNotFoundException) new FileNotFoundException("Failed to delete " + getOwnerName() + "/" + name + "; might not exist, or you might need the delete_repo scope in your token: http://stackoverflow.com/a/19327004/12916").initCause(x); + throw (FileNotFoundException) new FileNotFoundException("Failed to delete " + getOwnerName() + "/" + name + + "; might not exist, or you might need the delete_repo scope in your token: http://stackoverflow.com/a/19327004/12916") + .initCause(x); } } /** - * Will archive and this repository as read-only. When a repository is archived, any operation - * that can change its state is forbidden. This applies symmetrically if trying to unarchive it. + * Will archive and this repository as read-only. When a repository is archived, any operation that can change its + * state is forbidden. This applies symmetrically if trying to unarchive it. * - *

When you try to do any operation that modifies a read-only repository, it returns the - * response: + *

+ * When you try to do any operation that modifies a read-only repository, it returns the response: * *

      * org.kohsuke.github.HttpException: {
@@ -662,7 +1074,8 @@ public void delete() throws IOException {
      * }
      * 
* - * @throws IOException In case of any networking error or error from the server. + * @throws IOException + * In case of any networking error or error from the server. */ public void archive() throws IOException { edit("archived", "true"); @@ -674,86 +1087,109 @@ public void archive() throws IOException { /** * Sort orders for listing forks */ - public enum ForkSort { NEWEST, OLDEST, STARGAZERS } + public enum ForkSort { + NEWEST, OLDEST, STARGAZERS + } /** - * Lists all the direct forks of this repository, sorted by - * github api default, currently {@link ForkSort#NEWEST ForkSort.NEWEST}. + * Lists all the direct forks of this repository, sorted by github api default, currently {@link ForkSort#NEWEST + * ForkSort.NEWEST}*. + * + * @return the paged iterable */ public PagedIterable listForks() { - return listForks(null); + return listForks(null); } /** * Lists all the direct forks of this repository, sorted by the given sort order. - * @param sort the sort order. If null, defaults to github api default, - * currently {@link ForkSort#NEWEST ForkSort.NEWEST}. + * + * @param sort + * the sort order. If null, defaults to github api default, currently {@link ForkSort#NEWEST + * ForkSort.NEWEST}. + * @return the paged iterable */ public PagedIterable listForks(final ForkSort sort) { - return root.retrieve().with("sort",sort) - .asPagedIterable( - getApiTailUrl("forks"), - GHRepository[].class, - item -> item.wrap(root) ); + return root.retrieve() + .with("sort", sort) + .asPagedIterable(getApiTailUrl("forks"), GHRepository[].class, item -> item.wrap(root)); } /** * Forks this repository as your repository. * - * @return - * Newly forked repository that belong to you. + * @return Newly forked repository that belong to you. + * @throws IOException + * the io exception */ public GHRepository fork() throws IOException { new Requester(root).method("POST").to(getApiTailUrl("forks"), null); // this API is asynchronous. we need to wait for a bit - for (int i=0; i<10; i++) { + for (int i = 0; i < 10; i++) { GHRepository r = root.getMyself().getRepository(name); - if (r!=null) return r; + if (r != null) + return r; try { Thread.sleep(3000); } catch (InterruptedException e) { - throw (IOException)new InterruptedIOException().initCause(e); + throw (IOException) new InterruptedIOException().initCause(e); } } - throw new IOException(this+" was forked but can't find the new repository"); + throw new IOException(this + " was forked but can't find the new repository"); } /** * Forks this repository into an organization. * - * @return - * Newly forked repository that belong to you. + * @param org + * the org + * @return Newly forked repository that belong to you. + * @throws IOException + * the io exception */ public GHRepository forkTo(GHOrganization org) throws IOException { - new Requester(root).to(getApiTailUrl("forks?org="+org.getLogin())); + new Requester(root).to(getApiTailUrl("forks?org=" + org.getLogin())); // this API is asynchronous. we need to wait for a bit - for (int i=0; i<10; i++) { + for (int i = 0; i < 10; i++) { GHRepository r = org.getRepository(name); - if (r!=null) return r; + if (r != null) + return r; try { Thread.sleep(3000); } catch (InterruptedException e) { - throw (IOException)new InterruptedIOException().initCause(e); + throw (IOException) new InterruptedIOException().initCause(e); } } - throw new IOException(this+" was forked into "+org.getLogin()+" but can't find the new repository"); + throw new IOException(this + " was forked into " + org.getLogin() + " but can't find the new repository"); } /** * Retrieves a specified pull request. + * + * @param i + * the + * @return the pull request + * @throws IOException + * the io exception */ public GHPullRequest getPullRequest(int i) throws IOException { return root.retrieve() - .withPreview(SHADOW_CAT) - .to(getApiTailUrl("pulls/" + i), GHPullRequest.class).wrapUp(this); + .withPreview(SHADOW_CAT) + .to(getApiTailUrl("pulls/" + i), GHPullRequest.class) + .wrapUp(this); } /** * Retrieves all the pull requests of a particular state. * - * @see #listPullRequests(GHIssueState) + * @param state + * the state + * @return the pull requests + * @throws IOException + * the io exception + * @see #listPullRequests(GHIssueState) #listPullRequests(GHIssueState) */ public List getPullRequests(GHIssueState state) throws IOException { return queryPullRequests().state(state).list().asList(); @@ -762,8 +1198,10 @@ public List getPullRequests(GHIssueState state) throws IOExceptio /** * Retrieves all the pull requests of a particular state. * - * @deprecated - * Use {@link #queryPullRequests()} + * @param state + * the state + * @return the paged iterable + * @deprecated Use {@link #queryPullRequests()} */ public PagedIterable listPullRequests(GHIssueState state) { return queryPullRequests().state(state).list(); @@ -771,6 +1209,8 @@ public PagedIterable listPullRequests(GHIssueState state) { /** * Retrieves pull requests. + * + * @return the gh pull request query builder */ public GHPullRequestQueryBuilder queryPullRequests() { return new GHPullRequestQueryBuilder(this); @@ -780,17 +1220,18 @@ public GHPullRequestQueryBuilder queryPullRequests() { * Creates a new pull request. * * @param title - * Required. The title of the pull request. + * Required. The title of the pull request. * @param head - * Required. The name of the branch where your changes are implemented. - * For cross-repository pull requests in the same network, - * namespace head with a user like this: username:branch. + * Required. The name of the branch where your changes are implemented. For cross-repository pull + * requests in the same network, namespace head with a user like this: username:branch. * @param base - * Required. The name of the branch you want your changes pulled into. - * This should be an existing branch on the current repository. + * Required. The name of the branch you want your changes pulled into. This should be an existing branch + * on the current repository. * @param body - * The contents of the pull request. This is the markdown description - * of a pull request. + * The contents of the pull request. This is the markdown description of a pull request. + * @return the gh pull request + * @throws IOException + * the io exception */ public GHPullRequest createPullRequest(String title, String head, String base, String body) throws IOException { return createPullRequest(title, head, base, body, true); @@ -800,21 +1241,25 @@ public GHPullRequest createPullRequest(String title, String head, String base, S * Creates a new pull request. Maintainer's permissions aware. * * @param title - * Required. The title of the pull request. + * Required. The title of the pull request. * @param head - * Required. The name of the branch where your changes are implemented. - * For cross-repository pull requests in the same network, - * namespace head with a user like this: username:branch. + * Required. The name of the branch where your changes are implemented. For cross-repository pull + * requests in the same network, namespace head with a user like this: username:branch. * @param base - * Required. The name of the branch you want your changes pulled into. - * This should be an existing branch on the current repository. + * Required. The name of the branch you want your changes pulled into. This should be an existing branch + * on the current repository. * @param body - * The contents of the pull request. This is the markdown description - * of a pull request. + * The contents of the pull request. This is the markdown description of a pull request. * @param maintainerCanModify - * Indicates whether maintainers can modify the pull request. + * Indicates whether maintainers can modify the pull request. + * @return the gh pull request + * @throws IOException + * the io exception */ - public GHPullRequest createPullRequest(String title, String head, String base, String body, + public GHPullRequest createPullRequest(String title, + String head, + String base, + String body, boolean maintainerCanModify) throws IOException { return createPullRequest(title, head, base, body, maintainerCanModify, false); } @@ -823,71 +1268,116 @@ public GHPullRequest createPullRequest(String title, String head, String base, S * Creates a new pull request. Maintainer's permissions and draft aware. * * @param title - * Required. The title of the pull request. + * Required. The title of the pull request. * @param head - * Required. The name of the branch where your changes are implemented. - * For cross-repository pull requests in the same network, - * namespace head with a user like this: username:branch. + * Required. The name of the branch where your changes are implemented. For cross-repository pull + * requests in the same network, namespace head with a user like this: username:branch. * @param base - * Required. The name of the branch you want your changes pulled into. - * This should be an existing branch on the current repository. + * Required. The name of the branch you want your changes pulled into. This should be an existing branch + * on the current repository. * @param body - * The contents of the pull request. This is the markdown description - * of a pull request. + * The contents of the pull request. This is the markdown description of a pull request. * @param maintainerCanModify - * Indicates whether maintainers can modify the pull request. + * Indicates whether maintainers can modify the pull request. * @param draft - * Indicates whether to create a draft pull request or not. - */ - public GHPullRequest createPullRequest(String title, String head, String base, String body, - boolean maintainerCanModify, boolean draft) throws IOException { - return new Requester(root) - .withPreview(SHADOW_CAT) - .with("title",title) - .with("head",head) - .with("base",base) - .with("body",body) + * Indicates whether to create a draft pull request or not. + * @return the gh pull request + * @throws IOException + * the io exception + */ + public GHPullRequest createPullRequest(String title, + String head, + String base, + String body, + boolean maintainerCanModify, + boolean draft) throws IOException { + return new Requester(root).withPreview(SHADOW_CAT) + .with("title", title) + .with("head", head) + .with("base", base) + .with("body", body) .with("maintainer_can_modify", maintainerCanModify) .with("draft", draft) - .to(getApiTailUrl("pulls"),GHPullRequest.class) + .to(getApiTailUrl("pulls"), GHPullRequest.class) .wrapUp(this); } /** * Retrieves the currently configured hooks. + * + * @return the hooks + * @throws IOException + * the io exception */ public List getHooks() throws IOException { return GHHooks.repoContext(this, owner).getHooks(); } + /** + * Gets hook. + * + * @param id + * the id + * @return the hook + * @throws IOException + * the io exception + */ public GHHook getHook(int id) throws IOException { return GHHooks.repoContext(this, owner).getHook(id); } /** - * 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 direct tag name - * @param id2 an identifier for the second point to compare to. Can be the same as the first point. + * 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 + * direct tag name + * @param id2 + * an identifier for the second point to compare to. Can be the same as the first point. * @return the comparison output - * @throws IOException on failure communicating with GitHub + * @throws IOException + * on failure communicating with GitHub */ public GHCompare getCompare(String id1, String id2) throws IOException { - GHCompare compare = root.retrieve().to(getApiTailUrl(String.format("compare/%s...%s", id1, id2)), GHCompare.class); + GHCompare compare = root.retrieve() + .to(getApiTailUrl(String.format("compare/%s...%s", id1, id2)), GHCompare.class); return compare.wrap(this); } + /** + * Gets compare. + * + * @param id1 + * the id 1 + * @param id2 + * the id 2 + * @return the compare + * @throws IOException + * the io exception + */ public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException { return getCompare(id1.getSHA1(), id2.getSHA1()); } + /** + * Gets compare. + * + * @param id1 + * the id 1 + * @param id2 + * the id 2 + * @return the compare + * @throws IOException + * the io exception + */ public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException { GHRepository owner1 = id1.getOwner(); GHRepository owner2 = id2.getOwner(); // If the owner of the branches is different, we have a cross-fork compare. - if (owner1!=null && owner2!=null) { + if (owner1 != null && owner2 != null) { String ownerName1 = owner1.getOwnerName(); String ownerName2 = owner2.getOwnerName(); if (!StringUtils.equals(ownerName1, ownerName2)) { @@ -903,53 +1393,57 @@ public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException { /** * Retrieves all refs for the github repository. + * * @return an array of GHRef elements coresponding with the refs in the remote repository. - * @throws IOException on failure communicating with GitHub + * @throws IOException + * on failure communicating with GitHub */ public GHRef[] getRefs() throws IOException { - return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs", getOwnerName(), name), GHRef[].class), root); + return GHRef.wrap( + root.retrieve().to(String.format("/repos/%s/%s/git/refs", getOwnerName(), name), GHRef[].class), + root); } - /** * Retrieves all refs for the github repository. * * @return paged iterable of all refs - * @throws IOException on failure communicating with GitHub, potentially due to an invalid ref type being requested + * @throws IOException + * on failure communicating with GitHub, potentially due to an invalid ref type being requested */ public PagedIterable listRefs() throws IOException { final String url = String.format("/repos/%s/%s/git/refs", getOwnerName(), name); - return root.retrieve() - .asPagedIterable( - url, - GHRef[].class, - item -> item.wrap(root) ); + return root.retrieve().asPagedIterable(url, GHRef[].class, item -> item.wrap(root)); } /** * Retrieves all refs of the given type for the current GitHub repository. - * @param refType the type of reg to search for e.g. tags or commits + * + * @param refType + * the type of reg to search for e.g. tags or commits * @return an array of all refs matching the request type - * @throws IOException on failure communicating with GitHub, potentially due to an invalid ref type being requested + * @throws IOException + * on failure communicating with GitHub, potentially due to an invalid ref type being requested */ public GHRef[] getRefs(String refType) throws IOException { - return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType), GHRef[].class),root); + return GHRef.wrap( + root.retrieve() + .to(String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType), GHRef[].class), + root); } /** * Retrieves all refs of the given type for the current GitHub repository. * - * @param refType the type of reg to search for e.g. tags or commits + * @param refType + * the type of reg to search for e.g. tags or commits * @return paged iterable of all refs of the specified type - * @throws IOException on failure communicating with GitHub, potentially due to an invalid ref type being requested + * @throws IOException + * on failure communicating with GitHub, potentially due to an invalid ref type being requested */ public PagedIterable listRefs(String refType) throws IOException { final String url = String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refType); - return root.retrieve() - .asPagedIterable( - url, - GHRef[].class, - item -> item.wrap(root)); + return root.retrieve().asPagedIterable(url, GHRef[].class, item -> item.wrap(root)); } /** @@ -959,23 +1453,21 @@ public PagedIterable listRefs(String refType) throws IOException { * eg: heads/branch * @return refs matching the request type * @throws IOException - * on failure communicating with GitHub, potentially due to an - * invalid ref type being requested + * on failure communicating with GitHub, potentially due to an invalid ref type being requested */ public GHRef getRef(String refName) throws IOException { - // hashes in branch names must be replaced with the url encoded equivalent or this call will fail - // FIXME: how about other URL unsafe characters, like space, @, : etc? do we need to be using URLEncoder.encode()? - // OTOH, '/' need no escaping - refName = refName.replaceAll("#", "%23"); - return root.retrieve().to(String.format("/repos/%s/%s/git/refs/%s", getOwnerName(), name, refName), GHRef.class).wrap(root); + return root.retrieve().to(getApiTailUrl(String.format("git/refs/%s", refName)), GHRef.class).wrap(root); } /** * Returns the annotated tag object. Only valid if the {@link GHRef#getObject()} has a * {@link GHRef.GHObject#getType()} of {@code tag}. * - * @param sha the sha of the tag object + * @param sha + * the sha of the tag object * @return the annotated tag object + * @throws IOException + * the io exception */ public GHTagObject getTagObject(String sha) throws IOException { return root.retrieve().to(getApiTailUrl("git/tags/" + sha), GHTagObject.class).wrap(this); @@ -984,17 +1476,22 @@ public GHTagObject getTagObject(String sha) throws IOException { /** * Retrive a tree of the given type for the current GitHub repository. * - * @param sha - sha number or branch name ex: "master" + * @param sha + * sha number or branch name ex: "master" * @return refs matching the request type * @throws IOException - * on failure communicating with GitHub, potentially due to an - * invalid tree type being requested + * on failure communicating with GitHub, potentially due to an invalid tree type being requested */ public GHTree getTree(String sha) throws IOException { String url = String.format("/repos/%s/%s/git/trees/%s", getOwnerName(), name, sha); return root.retrieve().to(url, GHTree.class).wrap(this); } + /** + * Create tree gh tree builder. + * + * @return the gh tree builder + */ public GHTreeBuilder createTree() { return new GHTreeBuilder(this); } @@ -1003,11 +1500,13 @@ public GHTreeBuilder createTree() { * Retrieves the tree for the current GitHub repository, recursively as described in here: * https://developer.github.com/v3/git/trees/#get-a-tree-recursively * - * @param sha - sha number or branch name ex: "master" - * @param recursive use 1 + * @param sha + * sha number or branch name ex: "master" + * @param recursive + * use 1 + * @return the tree recursive * @throws IOException - * on failure communicating with GitHub, potentially due to an - * invalid tree type being requested + * on failure communicating with GitHub, potentially due to an invalid tree type being requested */ public GHTree getTreeRecursive(String sha, int recursive) throws IOException { String url = String.format("/repos/%s/%s/git/trees/%s?recursive=%d", getOwnerName(), name, sha, recursive); @@ -1020,14 +1519,24 @@ public GHTree getTreeRecursive(String sha, int recursive) throws IOException { *

* This method retrieves the whole content in memory, so beware when you are dealing with large BLOB. * + * @param blobSha + * the blob sha + * @return the blob + * @throws IOException + * the io exception * @see Get a blob - * @see #readBlob(String) + * @see #readBlob(String) #readBlob(String) */ public GHBlob getBlob(String blobSha) throws IOException { String target = getApiTailUrl("git/blobs/" + blobSha); return root.retrieve().to(target, GHBlob.class); } + /** + * Create blob gh blob builder. + * + * @return the gh blob builder + */ public GHBlobBuilder createBlob() { return new GHBlobBuilder(this); } @@ -1035,43 +1544,64 @@ public GHBlobBuilder createBlob() { /** * Reads the content of a blob as a stream for better efficiency. * + * @param blobSha + * the blob sha + * @return the input stream + * @throws IOException + * the io exception * @see Get a blob - * @see #getBlob(String) + * @see #getBlob(String) #getBlob(String) */ public InputStream readBlob(String blobSha) throws IOException { String target = getApiTailUrl("git/blobs/" + blobSha); - return root.retrieve().withHeader("Accept","application/vnd.github.VERSION.raw").asStream(target); + return root.retrieve().withHeader("Accept", "application/vnd.github.VERSION.raw").asStream(target); } /** * Gets a commit object in this repository. + * + * @param sha1 + * the sha 1 + * @return the commit + * @throws IOException + * the io exception */ public GHCommit getCommit(String sha1) throws IOException { GHCommit c = commits.get(sha1); - if (c==null) { - c = root.retrieve().to(String.format("/repos/%s/%s/commits/%s", getOwnerName(), name, sha1), GHCommit.class).wrapUp(this); - commits.put(sha1,c); + if (c == null) { + c = root.retrieve() + .to(String.format("/repos/%s/%s/commits/%s", getOwnerName(), name, sha1), GHCommit.class) + .wrapUp(this); + commits.put(sha1, c); } return c; } + /** + * Create commit gh commit builder. + * + * @return the gh commit builder + */ public GHCommitBuilder createCommit() { return new GHCommitBuilder(this); } /** * Lists all the commits. + * + * @return the paged iterable */ public PagedIterable listCommits() { return root.retrieve() - .asPagedIterable( - String.format("/repos/%s/%s/commits", getOwnerName(), name), - GHCommit[].class, - item -> item.wrapUp(GHRepository.this) ); + .asPagedIterable(String.format("/repos/%s/%s/commits", getOwnerName(), name), + GHCommit[].class, + item -> item.wrapUp(GHRepository.this)); } /** * Search commits by specifying filters through a builder pattern. + * + * @return the gh commit query builder */ public GHCommitQueryBuilder queryCommits() { return new GHCommitQueryBuilder(this); @@ -1079,25 +1609,27 @@ public GHCommitQueryBuilder queryCommits() { /** * Lists up all the commit comments in this repository. + * + * @return the paged iterable */ public PagedIterable listCommitComments() { return root.retrieve() - .asPagedIterable( - String.format("/repos/%s/%s/comments", getOwnerName(), name), - GHCommitComment[].class, - item -> item.wrap(GHRepository.this) ); + .asPagedIterable(String.format("/repos/%s/%s/comments", getOwnerName(), name), + GHCommitComment[].class, + item -> item.wrap(GHRepository.this)); } /** * Gets the basic license details for the repository. *

* - * @throws IOException as usual but also if you don't use the preview connector * @return null if there's no license. + * @throws IOException + * as usual but also if you don't use the preview connector */ - public GHLicense getLicense() throws IOException{ + public GHLicense getLicense() throws IOException { GHContentWithLicense lic = getLicenseContent_(); - return lic!=null ? lic.license : null; + return lic != null ? lic.license : null; } /** @@ -1105,7 +1637,8 @@ public GHLicense getLicense() throws IOException{ *

* * @return details regarding the license contents, or null if there's no license. - * @throws IOException as usual but also if you don't use the preview connector + * @throws IOException + * as usual but also if you don't use the preview connector */ public GHContent getLicenseContent() throws IOException { return getLicenseContent_(); @@ -1113,28 +1646,36 @@ public GHContent getLicenseContent() throws IOException { private GHContentWithLicense getLicenseContent_() throws IOException { try { - return root.retrieve() - .to(getApiTailUrl("license"), GHContentWithLicense.class).wrap(this); + return root.retrieve().to(getApiTailUrl("license"), GHContentWithLicense.class).wrap(this); } catch (FileNotFoundException e) { return null; } } /** - - /** - * Lists all the commit statues attached to the given commit, newer ones first. + * /** Lists all the commit statues attached to the given commit, newer ones first. + * + * @param sha1 + * the sha 1 + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listCommitStatuses(final String sha1) throws IOException { return root.retrieve() - .asPagedIterable( - String.format("/repos/%s/%s/statuses/%s", getOwnerName(), name, sha1), - GHCommitStatus[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(String.format("/repos/%s/%s/statuses/%s", getOwnerName(), name, sha1), + GHCommitStatus[].class, + item -> item.wrapUp(root)); } /** * Gets the last status of this commit, which is what gets shown in the UI. + * + * @param sha1 + * the sha 1 + * @return the last commit status + * @throws IOException + * the io exception */ public GHCommitStatus getLastCommitStatus(String sha1) throws IOException { List v = listCommitStatuses(sha1).asList(); @@ -1144,171 +1685,252 @@ public GHCommitStatus getLastCommitStatus(String sha1) throws IOException { /** * Creates a commit status * + * @param sha1 + * the sha 1 + * @param state + * the state * @param targetUrl - * Optional parameter that points to the URL that has more details. + * Optional parameter that points to the URL that has more details. * @param description - * Optional short description. - * @param context - * Optinal commit status context. - */ - public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description, String context) throws IOException { - return new Requester(root) - .with("state", state) + * Optional short description. + * @param context + * Optinal commit status context. + * @return the gh commit status + * @throws IOException + * the io exception + */ + public GHCommitStatus createCommitStatus(String sha1, + GHCommitState state, + String targetUrl, + String description, + String context) throws IOException { + return new Requester(root).with("state", state) .with("target_url", targetUrl) .with("description", description) .with("context", context) - .to(String.format("/repos/%s/%s/statuses/%s",getOwnerName(),this.name,sha1),GHCommitStatus.class).wrapUp(root); + .to(String.format("/repos/%s/%s/statuses/%s", getOwnerName(), this.name, sha1), GHCommitStatus.class) + .wrapUp(root); } /** - * @see #createCommitStatus(String, GHCommitState,String,String,String) + * Create commit status gh commit status. + * + * @param sha1 + * the sha 1 + * @param state + * the state + * @param targetUrl + * the target url + * @param description + * the description + * @return the gh commit status + * @throws IOException + * the io exception + * @see #createCommitStatus(String, GHCommitState, String, String, String) #createCommitStatus(String, + * GHCommitState,String,String,String) */ - public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) throws IOException { + public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) + throws IOException { return createCommitStatus(sha1, state, targetUrl, description, null); } /** * Lists repository events. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listEvents() throws IOException { return root.retrieve() - .asPagedIterable( - String.format("/repos/%s/%s/events", getOwnerName(), name), - GHEventInfo[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(String.format("/repos/%s/%s/events", getOwnerName(), name), + GHEventInfo[].class, + item -> item.wrapUp(root)); } /** * Lists labels in this repository. - * + *

* https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listLabels() throws IOException { return root.retrieve() - .withPreview(SYMMETRA) - .asPagedIterable( - getApiTailUrl("labels"), - GHLabel[].class, - item -> item.wrapUp(GHRepository.this) ); + .withPreview(SYMMETRA) + .asPagedIterable(getApiTailUrl("labels"), GHLabel[].class, item -> item.wrapUp(GHRepository.this)); } + /** + * Gets label. + * + * @param name + * the name + * @return the label + * @throws IOException + * the io exception + */ public GHLabel getLabel(String name) throws IOException { - return root.retrieve() - .withPreview(SYMMETRA) - .to(getApiTailUrl("labels/"+name), GHLabel.class) - .wrapUp(this); + return root.retrieve().withPreview(SYMMETRA).to(getApiTailUrl("labels/" + name), GHLabel.class).wrapUp(this); } + /** + * Create label gh label. + * + * @param name + * the name + * @param color + * the color + * @return the gh label + * @throws IOException + * the io exception + */ public GHLabel createLabel(String name, String color) throws IOException { return createLabel(name, color, ""); } /** * Description is still in preview. + * * @param name + * the name * @param color + * the color * @param description - * @return + * the description + * @return gh label * @throws IOException + * the io exception */ - @Preview @Deprecated + @Preview + @Deprecated public GHLabel createLabel(String name, String color, String description) throws IOException { - return root.retrieve().method("POST") + return root.retrieve() + .method("POST") .withPreview(SYMMETRA) - .with("name",name) + .with("name", name) .with("color", color) .with("description", description) - .to(getApiTailUrl("labels"), GHLabel.class).wrapUp(this); + .to(getApiTailUrl("labels"), GHLabel.class) + .wrapUp(this); } /** * Lists all the invitations. + * + * @return the paged iterable */ public PagedIterable listInvitations() { return root.retrieve() - .asPagedIterable( - String.format("/repos/%s/%s/invitations", getOwnerName(), name), - GHInvitation[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(String.format("/repos/%s/%s/invitations", getOwnerName(), name), + GHInvitation[].class, + item -> item.wrapUp(root)); } /** * Lists all the subscribers (aka watchers.) - * + *

* https://developer.github.com/v3/activity/watching/ + * + * @return the paged iterable */ public PagedIterable listSubscribers() { return listUsers("subscribers"); } /** - * Lists all the users who have starred this repo based on the old version of the API. For - * additional information, like date when the repository was starred, see {@link #listStargazers2()} + * Lists all the users who have starred this repo based on the old version of the API. For additional information, + * like date when the repository was starred, see {@link #listStargazers2()} + * + * @return the paged iterable */ public PagedIterable listStargazers() { return listUsers("stargazers"); } /** - * Lists all the users who have starred this repo based on new version of the API, having extended - * information like the time when the repository was starred. For compatibility with the old API - * see {@link #listStargazers()} + * Lists all the users who have starred this repo based on new version of the API, having extended information like + * the time when the repository was starred. For compatibility with the old API see {@link #listStargazers()} + * + * @return the paged iterable */ public PagedIterable listStargazers2() { return root.retrieve() - .withPreview("application/vnd.github.v3.star+json") - .asPagedIterable( - getApiTailUrl("stargazers"), + .withPreview("application/vnd.github.v3.star+json") + .asPagedIterable(getApiTailUrl("stargazers"), GHStargazer[].class, - item -> item.wrapUp(GHRepository.this) ); + item -> item.wrapUp(GHRepository.this)); } private PagedIterable listUsers(final String suffix) { - return root.retrieve() - .asPagedIterable( - getApiTailUrl(suffix), - GHUser[].class, - item -> item.wrapUp(root) ); + return root.retrieve().asPagedIterable(getApiTailUrl(suffix), GHUser[].class, item -> item.wrapUp(root)); } /** - * - * See https://api.github.com/hooks for possible names and their configuration scheme. - * TODO: produce type-safe binding + * See https://api.github.com/hooks for possible names and their configuration scheme. TODO: produce type-safe + * binding * * @param name - * Type of the hook to be created. See https://api.github.com/hooks for possible names. + * Type of the hook to be created. See https://api.github.com/hooks for possible names. * @param config - * The configuration hash. + * The configuration hash. * @param events - * Can be null. Types of events to hook into. + * Can be null. Types of events to hook into. + * @param active + * the active + * @return the gh hook + * @throws IOException + * the io exception */ - public GHHook createHook(String name, Map config, Collection events, boolean active) throws IOException { + public GHHook createHook(String name, Map config, Collection events, boolean active) + throws IOException { return GHHooks.repoContext(this, owner).createHook(name, config, events, active); } + /** + * Create web hook gh hook. + * + * @param url + * the url + * @param events + * the events + * @return the gh hook + * @throws IOException + * the io exception + */ public GHHook createWebHook(URL url, Collection events) throws IOException { - return createHook("web",Collections.singletonMap("url",url.toExternalForm()),events,true); + return createHook("web", Collections.singletonMap("url", url.toExternalForm()), events, true); } + /** + * Create web hook gh hook. + * + * @param url + * the url + * @return the gh hook + * @throws IOException + * the io exception + */ public GHHook createWebHook(URL url) throws IOException { - return createWebHook(url,null); + return createWebHook(url, null); } -// this is no different from getPullRequests(OPEN) -// /** -// * Retrieves all the pull requests. -// */ -// public List getPullRequests() throws IOException { -// return root.retrieveWithAuth("/pulls/"+owner+'/'+name,JsonPullRequests.class).wrap(root); -// } + // this is no different from getPullRequests(OPEN) + // /** + // * Retrieves all the pull requests. + // */ + // public List getPullRequests() throws IOException { + // return root.retrieveWithAuth("/pulls/"+owner+'/'+name,JsonPullRequests.class).wrap(root); + // } /** - * Returns a set that represents the post-commit hook URLs. - * The returned set is live, and changes made to them are reflected to GitHub. + * Returns a set that represents the post-commit hook URLs. The returned set is live, and changes made to them are + * reflected to GitHub. * - * @deprecated - * Use {@link #getHooks()} and {@link #createHook(String, Map, Collection, boolean)} + * @return the post commit hooks + * @deprecated Use {@link #getHooks()} and {@link #createHook(String, Map, Collection, boolean)} */ @SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "It causes a performance degradation, but we have already exposed it to the API") @@ -1333,7 +1955,7 @@ private List getPostCommitHooks() { } return r; } catch (IOException e) { - throw new GHException("Failed to retrieve post-commit hooks",e); + throw new GHException("Failed to retrieve post-commit hooks", e); } } @@ -1353,14 +1975,14 @@ public boolean add(URL url) { createWebHook(url); return true; } catch (IOException e) { - throw new GHException("Failed to update post-commit hooks",e); + throw new GHException("Failed to update post-commit hooks", e); } } @Override public boolean remove(Object url) { try { - String _url = ((URL)url).toExternalForm(); + String _url = ((URL) url).toExternalForm(); for (GHHook h : getHooks()) { if (h.getName().equals("web") && h.getConfig().get("url").equals(_url)) { h.delete(); @@ -1369,12 +1991,12 @@ public boolean remove(Object url) { } return false; } catch (IOException e) { - throw new GHException("Failed to update post-commit hooks",e); + throw new GHException("Failed to update post-commit hooks", e); } } }; - /*package*/ GHRepository wrap(GitHub root) { + GHRepository wrap(GitHub root) { this.root = root; if (root.isOffline()) { owner.wrapUp(root); @@ -1384,43 +2006,43 @@ public boolean remove(Object url) { /** * Gets branches by {@linkplain GHBranch#getName() their names}. + * + * @return the branches + * @throws IOException + * the io exception */ - public Map getBranches() throws IOException { - Map r = new TreeMap(); + public Map getBranches() throws IOException { + Map r = new TreeMap(); for (GHBranch p : root.retrieve().to(getApiTailUrl("branches"), GHBranch[].class)) { p.wrap(this); - r.put(p.getName(),p); + r.put(p.getName(), p); } return r; } /** - * Replace special characters (e.g. #) with standard values (e.g. %23) so - * GitHub understands what is being requested. - * @param value string to be encoded. - * @return The encoded string. + * Gets branch. + * + * @param name + * the name + * @return the branch + * @throws IOException + * the io exception */ - private String UrlEncode(String value) { - try { - return URLEncoder.encode(value, org.apache.commons.codec.CharEncoding.UTF_8); - } catch (UnsupportedEncodingException ex) { - Logger.getLogger(GHRepository.class.getName()).log(Level.SEVERE, null, ex); - } - - // Something went wrong - just return original value as is. - return value; - } - public GHBranch getBranch(String name) throws IOException { - return root.retrieve().to(getApiTailUrl("branches/"+UrlEncode(name)),GHBranch.class).wrap(this); + return root.retrieve().to(getApiTailUrl("branches/" + name), GHBranch.class).wrap(this); } /** - * @deprecated - * Use {@link #listMilestones(GHIssueState)} + * Gets milestones. + * + * @return the milestones + * @throws IOException + * the io exception + * @deprecated Use {@link #listMilestones(GHIssueState)} */ public Map getMilestones() throws IOException { - Map milestones = new TreeMap(); + Map milestones = new TreeMap(); for (GHMilestone m : listMilestones(GHIssueState.OPEN)) { milestones.put(m.getNumber(), m); } @@ -1429,15 +2051,28 @@ public Map getMilestones() throws IOException { /** * Lists up all the milestones in this repository. + * + * @param state + * the state + * @return the paged iterable */ public PagedIterable listMilestones(final GHIssueState state) { - return root.retrieve().with("state",state) - .asPagedIterable( - getApiTailUrl("milestones"), - GHMilestone[].class, - item -> item.wrap(GHRepository.this) ); + return root.retrieve() + .with("state", state) + .asPagedIterable(getApiTailUrl("milestones"), + GHMilestone[].class, + item -> item.wrap(GHRepository.this)); } + /** + * Gets milestone. + * + * @param number + * the number + * @return the milestone + * @throws IOException + * the io exception + */ public GHMilestone getMilestone(int number) throws IOException { GHMilestone m = milestones.get(number); if (m == null) { @@ -1449,21 +2084,61 @@ public GHMilestone getMilestone(int number) throws IOException { return m; } + /** + * Gets file content. + * + * @param path + * the path + * @return the file content + * @throws IOException + * the io exception + */ public GHContent getFileContent(String path) throws IOException { return getFileContent(path, null); } + /** + * Gets file content. + * + * @param path + * the path + * @param ref + * the ref + * @return the file content + * @throws IOException + * the io exception + */ public GHContent getFileContent(String path, String ref) throws IOException { Requester requester = root.retrieve(); String target = getApiTailUrl("contents/" + path); - return requester.with("ref",ref).to(target, GHContent.class).wrap(this); + return requester.with("ref", ref).to(target, GHContent.class).wrap(this); } + /** + * Gets directory content. + * + * @param path + * the path + * @return the directory content + * @throws IOException + * the io exception + */ public List getDirectoryContent(String path) throws IOException { return getDirectoryContent(path, null); } + /** + * Gets directory content. + * + * @param path + * the path + * @param ref + * the ref + * @return the directory content + * @throws IOException + * the io exception + */ public List getDirectoryContent(String path, String ref) throws IOException { Requester requester = root.retrieve(); while (path.endsWith("/")) { @@ -1471,7 +2146,7 @@ public List getDirectoryContent(String path, String ref) throws IOExc } String target = getApiTailUrl("contents/" + path); - GHContent[] files = requester.with("ref",ref).to(target, GHContent[].class); + GHContent[] files = requester.with("ref", ref).to(target, GHContent[].class); GHContent.wrap(files, this); @@ -1480,6 +2155,10 @@ public List getDirectoryContent(String path, String ref) throws IOExc /** * https://developer.github.com/v3/repos/contents/#get-the-readme + * + * @return the readme + * @throws IOException + * the io exception */ public GHContent getReadme() throws IOException { Requester requester = root.retrieve(); @@ -1488,6 +2167,8 @@ public GHContent getReadme() throws IOException { /** * Creates a new content, or update an existing content. + * + * @return the gh content builder */ public GHContentBuilder createContent() { return new GHContentBuilder(this); @@ -1495,6 +2176,16 @@ public GHContentBuilder createContent() { /** * Use {@link #createContent()}. + * + * @param content + * the content + * @param commitMessage + * the commit message + * @param path + * the path + * @return the gh content update response + * @throws IOException + * the io exception */ @Deprecated public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException { @@ -1503,74 +2194,149 @@ public GHContentUpdateResponse createContent(String content, String commitMessag /** * Use {@link #createContent()}. + * + * @param content + * the content + * @param commitMessage + * the commit message + * @param path + * the path + * @param branch + * the branch + * @return the gh content update response + * @throws IOException + * the io exception */ @Deprecated - public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException { + public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) + throws IOException { return createContent().content(content).message(commitMessage).path(path).branch(branch).commit(); } /** * Use {@link #createContent()}. + * + * @param contentBytes + * the content bytes + * @param commitMessage + * the commit message + * @param path + * the path + * @return the gh content update response + * @throws IOException + * the io exception */ @Deprecated - public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path) throws IOException { + public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path) + throws IOException { return createContent().content(contentBytes).message(commitMessage).path(path).commit(); } /** * Use {@link #createContent()}. + * + * @param contentBytes + * the content bytes + * @param commitMessage + * the commit message + * @param path + * the path + * @param branch + * the branch + * @return the gh content update response + * @throws IOException + * the io exception */ @Deprecated - public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path, String branch) throws IOException { + public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path, String branch) + throws IOException { return createContent().content(contentBytes).message(commitMessage).path(path).branch(branch).commit(); } + /** + * Create milestone gh milestone. + * + * @param title + * the title + * @param description + * the description + * @return the gh milestone + * @throws IOException + * the io exception + */ public GHMilestone createMilestone(String title, String description) throws IOException { - return new Requester(root) - .with("title", title).with("description", description).method("POST").to(getApiTailUrl("milestones"), GHMilestone.class).wrap(this); + return new Requester(root).with("title", title) + .with("description", description) + .method("POST") + .to(getApiTailUrl("milestones"), GHMilestone.class) + .wrap(this); } - public GHDeployKey addDeployKey(String title,String key) throws IOException { - return new Requester(root) - .with("title", title).with("key", key).method("POST").to(getApiTailUrl("keys"), GHDeployKey.class).wrap(this); + /** + * Add deploy key gh deploy key. + * + * @param title + * the title + * @param key + * the key + * @return the gh deploy key + * @throws IOException + * the io exception + */ + public GHDeployKey addDeployKey(String title, String key) throws IOException { + return new Requester(root).with("title", title) + .with("key", key) + .method("POST") + .to(getApiTailUrl("keys"), GHDeployKey.class) + .wrap(this); } - public List getDeployKeys() throws IOException{ - List list = new ArrayList(Arrays.asList( - root.retrieve().to(getApiTailUrl("keys"), GHDeployKey[].class))); - for (GHDeployKey h : list) - h.wrap(this); - return list; + /** + * Gets deploy keys. + * + * @return the deploy keys + * @throws IOException + * the io exception + */ + public List getDeployKeys() throws IOException { + List list = new ArrayList( + Arrays.asList(root.retrieve().to(getApiTailUrl("keys"), GHDeployKey[].class))); + for (GHDeployKey h : list) + h.wrap(this); + return list; } /** * Forked repositories have a 'source' attribute that specifies the ultimate source of the forking chain. * - * @return - * {@link GHRepository} that points to the root repository where this repository is forked - * (indirectly or directly) from. Otherwise null. - * @see #getParent() + * @return {@link GHRepository} that points to the root repository where this repository is forked (indirectly or + * directly) from. Otherwise null. + * @throws IOException + * the io exception + * @see #getParent() #getParent() */ public GHRepository getSource() throws IOException { - if (source == null) return null; + if (source == null) + return null; if (source.root == null) source = root.getRepository(source.getFullName()); return source; } /** - * Forked repositories have a 'parent' attribute that specifies the repository this repository - * is directly forked from. If we keep traversing {@link #getParent()} until it returns null, that - * is {@link #getSource()}. + * Forked repositories have a 'parent' attribute that specifies the repository this repository is directly forked + * from. If we keep traversing {@link #getParent()} until it returns null, that is {@link #getSource()}. * - * @return - * {@link GHRepository} that points to the repository where this repository is forked - * directly from. Otherwise null. - * @see #getSource() + * @return {@link GHRepository} that points to the repository where this repository is forked directly from. + * Otherwise null. + * @throws IOException + * the io exception + * @see #getSource() #getSource() */ public GHRepository getParent() throws IOException { - if (parent == null) return null; + if (parent == null) + return null; if (parent.root == null) parent = root.getRepository(parent.getFullName()); return parent; @@ -1578,18 +2344,29 @@ public GHRepository getParent() throws IOException { /** * Subscribes to this repository to get notifications. + * + * @param subscribed + * the subscribed + * @param ignored + * the ignored + * @return the gh subscription + * @throws IOException + * the io exception */ public GHSubscription subscribe(boolean subscribed, boolean ignored) throws IOException { - return new Requester(root) - .with("subscribed", subscribed) - .with("ignored", ignored) - .method("PUT").to(getApiTailUrl("subscription"), GHSubscription.class).wrapUp(this); + return new Requester(root).with("subscribed", subscribed) + .with("ignored", ignored) + .method("PUT") + .to(getApiTailUrl("subscription"), GHSubscription.class) + .wrapUp(this); } /** * Returns the current subscription. * * @return null if no subscription exists. + * @throws IOException + * the io exception */ public GHSubscription getSubscription() throws IOException { try { @@ -1599,17 +2376,29 @@ public GHSubscription getSubscription() throws IOException { } } + /** + * List contributors paged iterable. + * + * @return the paged iterable + * @throws IOException + * the io exception + */ public PagedIterable listContributors() throws IOException { return root.retrieve() - .asPagedIterable( - getApiTailUrl("contributors"), - Contributor[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(getApiTailUrl("contributors"), Contributor[].class, item -> item.wrapUp(root)); } + /** + * The type Contributor. + */ public static class Contributor extends GHUser { private int contributions; + /** + * Gets contributions. + * + * @return the contributions + */ public int getContributions() { return contributions; } @@ -1629,6 +2418,8 @@ public boolean equals(Object obj) { /** * Returns the statistics for this repository. + * + * @return the statistics */ public GHRepositoryStatistics getStatistics() { // TODO: Use static object and introduce refresh() method, @@ -1638,30 +2429,47 @@ public GHRepositoryStatistics getStatistics() { /** * Create a project for this repository. + * + * @param name + * the name + * @param body + * the body + * @return the gh project + * @throws IOException + * the io exception */ public GHProject createProject(String name, String body) throws IOException { - return root.retrieve().method("POST") + return root.retrieve() + .method("POST") .withPreview(INERTIA) .with("name", name) .with("body", body) - .to(getApiTailUrl("projects"), GHProject.class).wrap(this); + .to(getApiTailUrl("projects"), GHProject.class) + .wrap(this); } /** * Returns the projects for this repository. - * @param status The status filter (all, open or closed). + * + * @param status + * The status filter (all, open or closed). + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listProjects(final GHProject.ProjectStateFilter status) throws IOException { - return root.retrieve().withPreview(INERTIA) - .with("state", status) - .asPagedIterable( - getApiTailUrl("projects"), - GHProject[].class, - item -> item.wrap(GHRepository.this) ); + return root.retrieve() + .withPreview(INERTIA) + .with("state", status) + .asPagedIterable(getApiTailUrl("projects"), GHProject[].class, item -> item.wrap(GHRepository.this)); } /** * Returns open projects for this repository. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listProjects() throws IOException { return listProjects(GHProject.ProjectStateFilter.OPEN); @@ -1669,77 +2477,99 @@ public PagedIterable listProjects() throws IOException { /** * Render a Markdown document. + *

+ * In {@linkplain MarkdownMode#GFM GFM mode}, issue numbers and user mentions are linked accordingly. * - * In {@linkplain MarkdownMode#GFM GFM mode}, issue numbers and user mentions - * are linked accordingly. - * - * @see GitHub#renderMarkdown(String) + * @param text + * the text + * @param mode + * the mode + * @return the reader + * @throws IOException + * the io exception + * @see GitHub#renderMarkdown(String) GitHub#renderMarkdown(String) */ public Reader renderMarkdown(String text, MarkdownMode mode) throws IOException { - return new InputStreamReader( - new Requester(root) - .with("text", text) - .with("mode",mode==null?null:mode.toString()) - .with("context", getFullName()) - .asStream("/markdown"), - "UTF-8"); + return new InputStreamReader(new Requester(root).with("text", text) + .with("mode", mode == null ? null : mode.toString()) + .with("context", getFullName()) + .asStream("/markdown"), "UTF-8"); } /** * List all the notifications in a repository for the current user. + * + * @return the gh notification stream */ public GHNotificationStream listNotifications() { - return new GHNotificationStream(root,getApiTailUrl("/notifications")); + return new GHNotificationStream(root, getApiTailUrl("/notifications")); } /** - * https://developer.github.com/v3/repos/traffic/#views + * https://developer.github.com/v3/repos/traffic/#views + * + * @return the view traffic + * @throws IOException + * the io exception */ - public GHRepositoryViewTraffic getViewTraffic() throws IOException{ + public GHRepositoryViewTraffic getViewTraffic() throws IOException { return root.retrieve().to(getApiTailUrl("/traffic/views"), GHRepositoryViewTraffic.class); } /** - * https://developer.github.com/v3/repos/traffic/#clones + * https://developer.github.com/v3/repos/traffic/#clones + * + * @return the clone traffic + * @throws IOException + * the io exception */ - public GHRepositoryCloneTraffic getCloneTraffic() throws IOException{ + public GHRepositoryCloneTraffic getCloneTraffic() throws IOException { return root.retrieve().to(getApiTailUrl("/traffic/clones"), GHRepositoryCloneTraffic.class); } @Override public int hashCode() { - return ("Repository:"+getOwnerName()+":"+name).hashCode(); + return ("Repository:" + getOwnerName() + ":" + name).hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof GHRepository) { GHRepository that = (GHRepository) obj; - return this.getOwnerName().equals(that.getOwnerName()) - && this.name.equals(that.name); + return this.getOwnerName().equals(that.getOwnerName()) && this.name.equals(that.name); } return false; } String getApiTailUrl(String tail) { - if (tail.length()>0 && !tail.startsWith("/")) tail='/'+tail; - return "/repos/" + getOwnerName() + "/" + name +tail; + if (tail.length() > 0 && !tail.startsWith("/")) + tail = '/' + tail; + return Requester.urlPathEncode("/repos/" + getOwnerName() + "/" + name + tail); } /** - * Get all issue events for this repository. - * See https://developer.github.com/v3/issues/events/#list-events-for-a-repository + * Get all issue events for this repository. See + * https://developer.github.com/v3/issues/events/#list-events-for-a-repository + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listIssueEvents() throws IOException { - return root.retrieve().asPagedIterable( - getApiTailUrl("issues/events"), - GHIssueEvent[].class, - item -> item.wrapUp(root) ); + return root.retrieve() + .asPagedIterable(getApiTailUrl("issues/events"), GHIssueEvent[].class, item -> item.wrapUp(root)); } /** - * Get a single issue event. - * See https://developer.github.com/v3/issues/events/#get-a-single-event + * Get a single issue event. See https://developer.github.com/v3/issues/events/#get-a-single-event + * + * @param id + * the id + * @return the issue event + * @throws IOException + * the io exception */ public GHIssueEvent getIssueEvent(long id) throws IOException { return root.retrieve().to(getApiTailUrl("issues/events/" + id), GHIssueEvent.class).wrapUp(root); @@ -1751,8 +2581,12 @@ private static class Topics { } /** - * Return the topics for this repository. - * See https://developer.github.com/v3/repos/#list-all-topics-for-a-repository + * Return the topics for this repository. See + * https://developer.github.com/v3/repos/#list-all-topics-for-a-repository + * + * @return the list + * @throws IOException + * the io exception */ public List listTopics() throws IOException { Topics topics = root.retrieve().withPreview(MERCY).to(getApiTailUrl("topics"), Topics.class); @@ -1760,13 +2594,17 @@ public List listTopics() throws IOException { } /** - * Set the topics for this repository. - * See https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository + * Set the topics for this repository. See + * https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository + * + * @param topics + * the topics + * @throws IOException + * the io exception */ - // This currently returns a "404" error (as of 30 Oct 2019). -// public void setTopics(List topics) throws IOException { -// Requester requester = new Requester(root); -// requester.with("names", topics); -// requester.method("PUT").withPreview(MERCY).to(getApiTailUrl("topics")); -// } + public void setTopics(List topics) throws IOException { + Requester requester = new Requester(root); + requester.with("names", topics); + requester.method("PUT").withPreview(MERCY).to(getApiTailUrl("topics")); + } } diff --git a/src/main/java/org/kohsuke/github/GHRepositoryCloneTraffic.java b/src/main/java/org/kohsuke/github/GHRepositoryCloneTraffic.java index c75198e4a8..4b5ce1c7df 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryCloneTraffic.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryCloneTraffic.java @@ -5,19 +5,24 @@ /** * Repository clone statistics. * - * @see GHRepository#getCloneTraffic() + * @see GHRepository#getCloneTraffic() GHRepository#getCloneTraffic() */ public class GHRepositoryCloneTraffic extends GHRepositoryTraffic { private List clones; - /*package*/ GHRepositoryCloneTraffic() { + GHRepositoryCloneTraffic() { } - /*package*/ GHRepositoryCloneTraffic(Integer count, Integer uniques, List clones) { + GHRepositoryCloneTraffic(Integer count, Integer uniques, List clones) { super(count, uniques); this.clones = clones; } + /** + * Gets clones. + * + * @return the clones + */ public List getClones() { return clones; } @@ -26,11 +31,14 @@ public List getDailyInfo() { return getClones(); } + /** + * The type DailyInfo. + */ public static class DailyInfo extends GHRepositoryTraffic.DailyInfo { - /*package*/ DailyInfo() { + DailyInfo() { } - /*package*/ DailyInfo(String timestamp, int count, int uniques) { + DailyInfo(String timestamp, int count, int uniques) { super(timestamp, count, uniques); } } diff --git a/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java b/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java index 0ecd77e600..3103bd031a 100644 --- a/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHRepositorySearchBuilder.java @@ -4,11 +4,11 @@ * Search repositories. * * @author Kohsuke Kawaguchi - * @see GitHub#searchRepositories() + * @see GitHub#searchRepositories() GitHub#searchRepositories() */ public class GHRepositorySearchBuilder extends GHSearchBuilder { - /*package*/ GHRepositorySearchBuilder(GitHub root) { - super(root,RepositorySearchResult.class); + GHRepositorySearchBuilder(GitHub root) { + super(root, RepositorySearchResult.class); } /** @@ -19,63 +19,152 @@ public GHRepositorySearchBuilder q(String term) { return this; } + /** + * In gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder in(String v) { - return q("in:"+v); + return q("in:" + v); } + /** + * Size gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder size(String v) { - return q("size:"+v); + return q("size:" + v); } + /** + * Forks gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder forks(String v) { - return q("forks:"+v); + return q("forks:" + v); } + /** + * Created gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder created(String v) { - return q("created:"+v); + return q("created:" + v); } + /** + * Pushed gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder pushed(String v) { - return q("pushed:"+v); + return q("pushed:" + v); } + /** + * User gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder user(String v) { - return q("user:"+v); + return q("user:" + v); } + /** + * Repo gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder repo(String v) { - return q("repo:"+v); + return q("repo:" + v); } + /** + * Language gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder language(String v) { - return q("language:"+v); + return q("language:" + v); } + /** + * Stars gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder stars(String v) { - return q("stars:"+v); + return q("stars:" + v); } + /** + * Topic gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder topic(String v) { - return q("topic:"+v); + return q("topic:" + v); } + /** + * Order gh repository search builder. + * + * @param v + * the v + * @return the gh repository search builder + */ public GHRepositorySearchBuilder order(GHDirection v) { - req.with("order",v); + req.with("order", v); return this; } + /** + * Sort gh repository search builder. + * + * @param sort + * the sort + * @return the gh repository search builder + */ public GHRepositorySearchBuilder sort(Sort sort) { - req.with("sort",sort); + req.with("sort", sort); return this; } - public enum Sort { STARS, FORKS, UPDATED } + /** + * The enum Sort. + */ + public enum Sort { + STARS, FORKS, UPDATED + } private static class RepositorySearchResult extends SearchResult { private GHRepository[] items; @Override - /*package*/ GHRepository[] getItems(GitHub root) { + GHRepository[] getItems(GitHub root) { for (GHRepository item : items) item.wrap(root); return items; diff --git a/src/main/java/org/kohsuke/github/GHRepositorySelection.java b/src/main/java/org/kohsuke/github/GHRepositorySelection.java index afba38aaa2..5039545213 100644 --- a/src/main/java/org/kohsuke/github/GHRepositorySelection.java +++ b/src/main/java/org/kohsuke/github/GHRepositorySelection.java @@ -6,12 +6,10 @@ * App installation repository selection. * * @author Paulo Miguel Almeida - * * @see GHAppInstallation */ public enum GHRepositorySelection { - SELECTED, - ALL; + SELECTED, ALL; /** * Returns GitHub's internal representation of this event. diff --git a/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java b/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java index 3d8187da20..043a585f15 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryStatistics.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -24,6 +25,12 @@ public class GHRepositoryStatistics { private static final int MAX_WAIT_ITERATIONS = 3; private static final int WAIT_SLEEP_INTERVAL = 5000; + /** + * Instantiates a new Gh repository statistics. + * + * @param repo + * the repo + */ public GHRepositoryStatistics(GHRepository repo) { this.repo = repo; this.root = repo.root; @@ -32,24 +39,37 @@ public GHRepositoryStatistics(GHRepository repo) { /** * Get contributors list with additions, deletions, and commit count. See * https://developer.github.com/v3/repos/statistics/#get-contributors-list-with-additions-deletions-and-commit-counts + * + * @return the contributor stats + * @throws IOException + * the io exception + * @throws InterruptedException + * the interrupted exception */ public PagedIterable getContributorStats() throws IOException, InterruptedException { return getContributorStats(true); } /** - * @param waitTillReady Whether to sleep the thread if necessary until the - * statistics are ready. This is true by default. + * Gets contributor stats. + * + * @param waitTillReady + * Whether to sleep the thread if necessary until the statistics are ready. This is true by default. + * @return the contributor stats + * @throws IOException + * the io exception + * @throws InterruptedException + * the interrupted exception */ @Preview @Deprecated @SuppressWarnings("SleepWhileInLoop") - @SuppressFBWarnings(value = {"RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"}, justification = "JSON API") - public PagedIterable getContributorStats(boolean waitTillReady) throws IOException, InterruptedException { - PagedIterable stats = - getContributorStatsImpl(); + @SuppressFBWarnings(value = { "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" }, justification = "JSON API") + public PagedIterable getContributorStats(boolean waitTillReady) + throws IOException, InterruptedException { + PagedIterable stats = getContributorStatsImpl(); - if (stats == null && waitTillReady) { + if (stats == null && waitTillReady) { for (int i = 0; i < MAX_WAIT_ITERATIONS; i += 1) { // Wait a few seconds and try again. Thread.sleep(WAIT_SLEEP_INTERVAL); @@ -64,21 +84,22 @@ public PagedIterable getContributorStats(boolean waitTillReady } /** - * This gets the actual statistics from the server. Returns null if they - * are still being cached. + * This gets the actual statistics from the server. Returns null if they are still being cached. */ private PagedIterable getContributorStatsImpl() throws IOException { return root.retrieve() - .asPagedIterable( - getApiTailUrl("contributors"), - ContributorStats[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(getApiTailUrl("contributors"), ContributorStats[].class, item -> item.wrapUp(root)); } - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD"}, justification = "JSON API") + /** + * The type ContributorStats. + */ + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "URF_UNREAD_FIELD" }, + justification = "JSON API") public static class ContributorStats extends GHObject { - /*package almost final*/ private GitHub root; + /* package almost final */ private GitHub root; private GHUser author; private int total; private List weeks; @@ -88,11 +109,18 @@ public URL getHtmlUrl() throws IOException { throw new UnsupportedOperationException("Not supported yet."); } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } /** + * Gets author. + * * @return The author described by these statistics. */ public GHUser getAuthor() { @@ -100,6 +128,8 @@ public GHUser getAuthor() { } /** + * Gets total. + * * @return The total number of commits authored by the contributor. */ public int getTotal() { @@ -109,10 +139,11 @@ public int getTotal() { /** * Convenience method to look up week with particular timestamp. * - * @param timestamp The timestamp to look for. - * @return The week starting with the given timestamp. Throws an - * exception if it is not found. + * @param timestamp + * The timestamp to look for. + * @return The week starting with the given timestamp. Throws an exception if it is not found. * @throws NoSuchElementException + * the no such element exception */ public Week getWeek(long timestamp) throws NoSuchElementException { // maybe store the weeks in a map to make this more efficient? @@ -127,6 +158,8 @@ public Week getWeek(long timestamp) throws NoSuchElementException { } /** + * Gets weeks. + * * @return The total number of commits authored by the contributor. */ public List getWeeks() { @@ -135,13 +168,17 @@ public List getWeeks() { @Override public String toString() { - return author.getLogin() + " made " + String.valueOf(total) - + " contributions over " + String.valueOf(weeks.size()) - + " weeks"; + return author.getLogin() + " made " + String.valueOf(total) + " contributions over " + + String.valueOf(weeks.size()) + " weeks"; } - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD"}, justification = "JSON API") + /** + * The type Week. + */ + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", + "URF_UNREAD_FIELD" }, + justification = "JSON API") public static class Week { private long w; @@ -150,6 +187,8 @@ public static class Week { private int c; /** + * Gets week timestamp. + * * @return Start of the week, as a UNIX timestamp. */ public long getWeekTimestamp() { @@ -157,6 +196,8 @@ public long getWeekTimestamp() { } /** + * Gets number of additions. + * * @return The number of additions for the week. */ public int getNumberOfAdditions() { @@ -164,6 +205,8 @@ public int getNumberOfAdditions() { } /** + * Gets number of deletions. + * * @return The number of deletions for the week. */ public int getNumberOfDeletions() { @@ -171,6 +214,8 @@ public int getNumberOfDeletions() { } /** + * Gets number of commits. + * * @return The number of commits for the week. */ public int getNumberOfCommits() { @@ -183,7 +228,7 @@ public String toString() { } } - /*package*/ ContributorStats wrapUp(GitHub root) { + ContributorStats wrapUp(GitHub root) { this.root = root; return this; } @@ -192,32 +237,40 @@ public String toString() { /** * Get the last year of commit activity data. See * https://developer.github.com/v3/repos/statistics/#get-the-last-year-of-commit-activity-data + * + * @return the commit activity + * @throws IOException + * the io exception */ public PagedIterable getCommitActivity() throws IOException { return root.retrieve() - .asPagedIterable( - getApiTailUrl("commit_activity"), - CommitActivity[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(getApiTailUrl("commit_activity"), CommitActivity[].class, item -> item.wrapUp(root)); } - @SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") + /** + * The type CommitActivity. + */ + @SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public static class CommitActivity extends GHObject { - /*package almost final*/ private GitHub root; + /* package almost final */ private GitHub root; private List days; private int total; private long week; /** - * @return The number of commits for each day of the week. 0 = Sunday, 1 - * = Monday, etc. + * Gets days. + * + * @return The number of commits for each day of the week. 0 = Sunday, 1 = Monday, etc. */ public List getDays() { return days; } /** + * Gets total. + * * @return The total number of commits for the week. */ public int getTotal() { @@ -225,17 +278,24 @@ public int getTotal() { } /** + * Gets week. + * * @return The start of the week as a UNIX timestamp. */ public long getWeek() { return week; } - /*package*/ CommitActivity wrapUp(GitHub root) { + CommitActivity wrapUp(GitHub root) { this.root = root; return this; } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } @@ -246,9 +306,13 @@ public URL getHtmlUrl() throws IOException { } } - /** - * Get the number of additions and deletions per week. - * See https://developer.github.com/v3/repos/statistics/#get-the-number-of-additions-and-deletions-per-week + /** + * Get the number of additions and deletions per week. See + * https://developer.github.com/v3/repos/statistics/#get-the-number-of-additions-and-deletions-per-week + * + * @return the code frequency + * @throws IOException + * the io exception */ public List getCodeFrequency() throws IOException { // Map to ArrayLists first, since there are no field names in the @@ -257,14 +321,13 @@ public List getCodeFrequency() throws IOException { InputStream stream = root.retrieve().asStream(getApiTailUrl("code_frequency")); ObjectMapper mapper = new ObjectMapper(); - TypeReference > > typeRef = - new TypeReference > >() {}; - ArrayList > list = mapper.readValue(stream, typeRef); + TypeReference>> typeRef = new TypeReference>>() { + }; + ArrayList> list = mapper.readValue(stream, typeRef); // Convert to proper objects. ArrayList returnList = new ArrayList(); - for(ArrayList item: list) - { + for (ArrayList item : list) { CodeFrequency cf = new CodeFrequency(item); returnList.add(cf); } @@ -278,6 +341,9 @@ public List getCodeFrequency() throws IOException { } } + /** + * The type CodeFrequency. + */ public static class CodeFrequency { private int week; private int additions; @@ -290,6 +356,8 @@ private CodeFrequency(ArrayList item) { } /** + * Gets week timestamp. + * * @return The start of the week as a UNIX timestamp. */ public int getWeekTimestamp() { @@ -297,6 +365,8 @@ public int getWeekTimestamp() { } /** + * Gets additions. + * * @return The number of additions for the week. */ public long getAdditions() { @@ -304,8 +374,9 @@ public long getAdditions() { } /** - * @return The number of deletions for the week. - * NOTE: This will be a NEGATIVE number. + * Gets deletions. + * + * @return The number of deletions for the week. NOTE: This will be a NEGATIVE number. */ public long getDeletions() { // TODO: Perhaps return Math.abs(deletions), @@ -315,21 +386,28 @@ public long getDeletions() { @Override public String toString() { - return "Week starting " + getWeekTimestamp() + " has " + getAdditions() + - " additions and " + Math.abs(getDeletions()) + " deletions"; + return "Week starting " + getWeekTimestamp() + " has " + getAdditions() + " additions and " + + Math.abs(getDeletions()) + " deletions"; } } /** - * Get the weekly commit count for the repository owner and everyone else. - * See https://developer.github.com/v3/repos/statistics/#get-the-weekly-commit-count-for-the-repository-owner-and-everyone-else + * Get the weekly commit count for the repository owner and everyone else. See + * https://developer.github.com/v3/repos/statistics/#get-the-weekly-commit-count-for-the-repository-owner-and-everyone-else + * + * @return the participation + * @throws IOException + * the io exception */ public Participation getParticipation() throws IOException { return root.retrieve().to(getApiTailUrl("participation"), Participation.class); } + /** + * The type Participation. + */ public static class Participation extends GHObject { - /*package almost final*/ private GitHub root; + /* package almost final */ private GitHub root; private List all; private List owner; @@ -338,35 +416,46 @@ public URL getHtmlUrl() throws IOException { throw new UnsupportedOperationException("Not supported yet."); } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } /** - * @return The list of commit counts for everyone combined, for the - * last 52 weeks. + * Gets all commits. + * + * @return The list of commit counts for everyone combined, for the last 52 weeks. */ public List getAllCommits() { return all; } /** - * @return The list of commit counts for the owner, for the - * last 52 weeks. + * Gets owner commits. + * + * @return The list of commit counts for the owner, for the last 52 weeks. */ public List getOwnerCommits() { return owner; } - /*package*/ Participation wrapUp(GitHub root) { - this.root = root; - return this; + Participation wrapUp(GitHub root) { + this.root = root; + return this; } } /** - * Get the number of commits per hour in each day. - * See https://developer.github.com/v3/repos/statistics/#get-the-number-of-commits-per-hour-in-each-day + * Get the number of commits per hour in each day. See + * https://developer.github.com/v3/repos/statistics/#get-the-number-of-commits-per-hour-in-each-day + * + * @return the punch card + * @throws IOException + * the io exception */ public List getPunchCard() throws IOException { // Map to ArrayLists first, since there are no field names in the @@ -374,13 +463,13 @@ public List getPunchCard() throws IOException { InputStream stream = root.retrieve().asStream(getApiTailUrl("punch_card")); ObjectMapper mapper = new ObjectMapper(); - TypeReference > > typeRef = - new TypeReference > >() {}; - ArrayList > list = mapper.readValue(stream, typeRef); + TypeReference>> typeRef = new TypeReference>>() { + }; + ArrayList> list = mapper.readValue(stream, typeRef); // Convert to proper objects. ArrayList returnList = new ArrayList(); - for(ArrayList item: list) { + for (ArrayList item : list) { PunchCardItem pci = new PunchCardItem(item); returnList.add(pci); } @@ -388,6 +477,9 @@ public List getPunchCard() throws IOException { return returnList; } + /** + * The type PunchCardItem. + */ public static class PunchCardItem { private int dayOfWeek; private int hourOfDay; @@ -400,14 +492,17 @@ private PunchCardItem(ArrayList item) { } /** - * @return The day of the week. - * 0 = Sunday, 1 = Monday, etc. + * Gets day of week. + * + * @return The day of the week. 0 = Sunday, 1 = Monday, etc. */ public int getDayOfWeek() { return dayOfWeek; } /** + * Gets hour of day. + * * @return The hour of the day from 0 to 23. */ public long getHourOfDay() { @@ -415,6 +510,8 @@ public long getHourOfDay() { } /** + * Gets number of commits. + * * @return The number of commits for the day and hour. */ public long getNumberOfCommits() { @@ -422,8 +519,7 @@ public long getNumberOfCommits() { } public String toString() { - return "Day " + getDayOfWeek() + " Hour " + getHourOfDay() + ": " + - getNumberOfCommits() + " commits"; + return "Day " + getDayOfWeek() + " Hour " + getHourOfDay() + ": " + getNumberOfCommits() + " commits"; } } diff --git a/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java b/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java index 42d07e848d..9b4be50a77 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java @@ -3,14 +3,17 @@ import java.util.Date; import java.util.List; +/** + * The type GHRepositoryTraffic. + */ public abstract class GHRepositoryTraffic implements TrafficInfo { private int count; private int uniques; - /*package*/ GHRepositoryTraffic() { + GHRepositoryTraffic() { } - /*package*/ GHRepositoryTraffic(int count, int uniques) { + GHRepositoryTraffic(int count, int uniques) { this.count = count; this.uniques = uniques; } @@ -23,13 +26,26 @@ public int getUniques() { return uniques; } + /** + * Gets daily info. + * + * @return the daily info + */ public abstract List getDailyInfo(); + /** + * The type DailyInfo. + */ public static abstract class DailyInfo implements TrafficInfo { private String timestamp; private int count; private int uniques; + /** + * Gets timestamp. + * + * @return the timestamp + */ public Date getTimestamp() { return GitHub.parseDate(timestamp); } @@ -42,10 +58,10 @@ public int getUniques() { return uniques; } - /*package*/ DailyInfo() { + DailyInfo() { } - /*package*/ DailyInfo(String timestamp, Integer count, Integer uniques) { + DailyInfo(String timestamp, Integer count, Integer uniques) { this.timestamp = timestamp; this.count = count; this.uniques = uniques; diff --git a/src/main/java/org/kohsuke/github/GHRepositoryViewTraffic.java b/src/main/java/org/kohsuke/github/GHRepositoryViewTraffic.java index f2f1e5b440..ee6916a5d2 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryViewTraffic.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryViewTraffic.java @@ -5,19 +5,24 @@ /** * Repository view statistics. * - * @see GHRepository#getViewTraffic() + * @see GHRepository#getViewTraffic() GHRepository#getViewTraffic() */ public class GHRepositoryViewTraffic extends GHRepositoryTraffic { private List views; - /*package*/ GHRepositoryViewTraffic() { + GHRepositoryViewTraffic() { } - /*package*/ GHRepositoryViewTraffic(int count, int uniques, List views) { + GHRepositoryViewTraffic(int count, int uniques, List views) { super(count, uniques); this.views = views; } + /** + * Gets views. + * + * @return the views + */ public List getViews() { return views; } @@ -26,11 +31,14 @@ public List getDailyInfo() { return getViews(); } + /** + * The type DailyInfo. + */ public static class DailyInfo extends GHRepositoryTraffic.DailyInfo { - /*package*/ DailyInfo() { + DailyInfo() { } - /*package*/ DailyInfo(String timestamp, int count, int uniques) { + DailyInfo(String timestamp, int count, int uniques) { super(timestamp, count, uniques); } } diff --git a/src/main/java/org/kohsuke/github/GHSearchBuilder.java b/src/main/java/org/kohsuke/github/GHSearchBuilder.java index 44521687f4..a1c9e7c89d 100644 --- a/src/main/java/org/kohsuke/github/GHSearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHSearchBuilder.java @@ -8,6 +8,8 @@ /** * Base class for various search builders. * + * @param + * the type parameter * @author Kohsuke Kawaguchi */ public abstract class GHSearchBuilder extends GHQueryBuilder { @@ -18,13 +20,17 @@ public abstract class GHSearchBuilder extends GHQueryBuilder { */ private final Class> receiverType; - /*package*/ GHSearchBuilder(GitHub root, Class> receiverType) { + GHSearchBuilder(GitHub root, Class> receiverType) { super(root); this.receiverType = receiverType; } /** * Search terms. + * + * @param term + * the term + * @return the gh query builder */ public GHQueryBuilder q(String term) { terms.add(term); @@ -48,5 +54,10 @@ protected void wrapUp(T[] page) { }; } + /** + * Gets api url. + * + * @return the api url + */ protected abstract String getApiUrl(); } diff --git a/src/main/java/org/kohsuke/github/GHStargazer.java b/src/main/java/org/kohsuke/github/GHStargazer.java index 2384d01939..d599a74f93 100644 --- a/src/main/java/org/kohsuke/github/GHStargazer.java +++ b/src/main/java/org/kohsuke/github/GHStargazer.java @@ -9,7 +9,7 @@ * * @author noctarius */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, justification = "JSON API") public class GHStargazer { private GHRepository repository; @@ -26,8 +26,8 @@ public GHRepository getRepository() { } /** - * Gets the date when the repository was starred, however old stars before - * August 2012, will all show the date the API was changed to support starred_at. + * Gets the date when the repository was starred, however old stars before August 2012, will all show the date the + * API was changed to support starred_at. * * @return the date the stargazer was added */ diff --git a/src/main/java/org/kohsuke/github/GHSubscription.java b/src/main/java/org/kohsuke/github/GHSubscription.java index 40939fa42b..a8ddc81dd9 100644 --- a/src/main/java/org/kohsuke/github/GHSubscription.java +++ b/src/main/java/org/kohsuke/github/GHSubscription.java @@ -7,8 +7,8 @@ * Represents your subscribing to a repository / conversation thread.. * * @author Kohsuke Kawaguchi - * @see GHRepository#getSubscription() - * @see GHThread#getSubscription() + * @see GHRepository#getSubscription() GHRepository#getSubscription() + * @see GHThread#getSubscription() GHThread#getSubscription() */ public class GHSubscription { private String created_at, url, repository_url, reason; @@ -17,36 +17,74 @@ public class GHSubscription { private GitHub root; private GHRepository repo; + /** + * Gets created at. + * + * @return the created at + */ public Date getCreatedAt() { return GitHub.parseDate(created_at); } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets repository url. + * + * @return the repository url + */ public String getRepositoryUrl() { return repository_url; } + /** + * Gets reason. + * + * @return the reason + */ public String getReason() { return reason; } + /** + * Is subscribed boolean. + * + * @return the boolean + */ public boolean isSubscribed() { return subscribed; } + /** + * Is ignored boolean. + * + * @return the boolean + */ public boolean isIgnored() { return ignored; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repo; } /** * Removes this subscription. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { new Requester(root).method("DELETE").to(repo.getApiTailUrl("subscription")); diff --git a/src/main/java/org/kohsuke/github/GHTag.java b/src/main/java/org/kohsuke/github/GHTag.java index 802f51f8f3..3832199253 100644 --- a/src/main/java/org/kohsuke/github/GHTag.java +++ b/src/main/java/org/kohsuke/github/GHTag.java @@ -5,10 +5,10 @@ /** * Represents a tag in {@link GHRepository} * - * @see GHRepository#listTags() + * @see GHRepository#listTags() GHRepository#listTags() */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHTag { private GHRepository owner; private GitHub root; @@ -16,26 +16,46 @@ public class GHTag { private String name; private GHCommit commit; - /*package*/ GHTag wrap(GHRepository owner) { + GHTag wrap(GHRepository owner) { this.owner = owner; this.root = owner.root; - if (commit!=null) + if (commit != null) commit.wrapUp(owner); return this; } + /** + * Gets owner. + * + * @return the owner + */ public GHRepository getOwner() { return owner; } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets commit. + * + * @return the commit + */ public GHCommit getCommit() { return commit; } diff --git a/src/main/java/org/kohsuke/github/GHTagObject.java b/src/main/java/org/kohsuke/github/GHTagObject.java index 0e3acdeaa7..4c0234e202 100644 --- a/src/main/java/org/kohsuke/github/GHTagObject.java +++ b/src/main/java/org/kohsuke/github/GHTagObject.java @@ -5,10 +5,10 @@ /** * Represents an annotated tag in a {@link GHRepository} * - * @see GHRepository#getTagObject(String) + * @see GHRepository#getTagObject(String) GHRepository#getTagObject(String) */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHTagObject { private GHRepository owner; private GitHub root; @@ -20,40 +20,80 @@ public class GHTagObject { private GitUser tagger; private GHRef.GHObject object; - /*package*/ GHTagObject wrap(GHRepository owner) { + GHTagObject wrap(GHRepository owner) { this.owner = owner; this.root = owner.root; return this; } + /** + * Gets owner. + * + * @return the owner + */ public GHRepository getOwner() { return owner; } + /** + * Gets root. + * + * @return the root + */ public GitHub getRoot() { return root; } + /** + * Gets tag. + * + * @return the tag + */ public String getTag() { return tag; } + /** + * Gets sha. + * + * @return the sha + */ public String getSha() { return sha; } + /** + * Gets url. + * + * @return the url + */ public String getUrl() { return url; } + /** + * Gets message. + * + * @return the message + */ public String getMessage() { return message; } + /** + * Gets tagger. + * + * @return the tagger + */ public GitUser getTagger() { return tagger; } + /** + * Gets object. + * + * @return the object + */ public GHRef.GHObject getObject() { return object; } diff --git a/src/main/java/org/kohsuke/github/GHTargetType.java b/src/main/java/org/kohsuke/github/GHTargetType.java index 42a23d8726..050c27e4f6 100644 --- a/src/main/java/org/kohsuke/github/GHTargetType.java +++ b/src/main/java/org/kohsuke/github/GHTargetType.java @@ -8,12 +8,10 @@ * App installation target type. * * @author Paulo Miguel Almeida - * * @see GHAppInstallation */ public enum GHTargetType { - ORGANIZATION, - USER; + ORGANIZATION, USER; /** * Returns GitHub's internal representation of this event. diff --git a/src/main/java/org/kohsuke/github/GHTeam.java b/src/main/java/org/kohsuke/github/GHTeam.java index 00f43e194b..9254817b91 100644 --- a/src/main/java/org/kohsuke/github/GHTeam.java +++ b/src/main/java/org/kohsuke/github/GHTeam.java @@ -8,127 +8,184 @@ /** * A team in GitHub organization. - * + * * @author Kohsuke Kawaguchi */ public class GHTeam implements Refreshable { - private String name,permission,slug,description; + private String name, permission, slug, description; private int id; private GHOrganization organization; // populated by GET /user/teams where Teams+Orgs are returned together - protected /*final*/ GitHub root; + protected /* final */ GitHub root; - /** Member's role in a team */ + /** + * Member's role in a team + */ public enum Role { /** * A normal member of the team */ MEMBER, /** - * Able to add/remove other team members, promote other team members to team maintainer, and edit the team's name and description. + * Able to add/remove other team members, promote other team members to team maintainer, and edit the team's + * name and description. */ MAINTAINER } - /*package*/ GHTeam wrapUp(GHOrganization owner) { + GHTeam wrapUp(GHOrganization owner) { this.organization = owner; this.root = owner.root; return this; } - /*package*/ GHTeam wrapUp(GitHub root) { // auto-wrapUp when organization is known from GET /user/teams - this.organization.wrapUp(root); - return wrapUp(organization); + GHTeam wrapUp(GitHub root) { // auto-wrapUp when organization is known from GET /user/teams + this.organization.wrapUp(root); + return wrapUp(organization); } - /*package*/ static GHTeam[] wrapUp(GHTeam[] teams, GHOrganization owner) { + static GHTeam[] wrapUp(GHTeam[] teams, GHOrganization owner) { for (GHTeam t : teams) { t.wrapUp(owner); } return teams; } - /*package*/ static GHTeam[] wrapUp(GHTeam[] teams, GHPullRequest owner) { + static GHTeam[] wrapUp(GHTeam[] teams, GHPullRequest owner) { for (GHTeam t : teams) { t.root = owner.root; } return teams; } + /** + * Gets name. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets permission. + * + * @return the permission + */ public String getPermission() { return permission; } + /** + * Gets slug. + * + * @return the slug + */ public String getSlug() { return slug; } + /** + * Gets description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Sets description. + * + * @param description + * the description + * @throws IOException + * the io exception + */ public void setDescription(String description) throws IOException { - root.retrieve().method("PATCH") - .with("description", description) - .to(api("")); + root.retrieve().method("PATCH").with("description", description).to(api("")); } + /** + * Gets id. + * + * @return the id + */ public int getId() { return id; } /** * Retrieves the current members. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listMembers() throws IOException { - return root.retrieve() - .asPagedIterable( - api("/members"), - GHUser[].class, - item -> item.wrapUp(root) ); + return root.retrieve().asPagedIterable(api("/members"), GHUser[].class, item -> item.wrapUp(root)); } + /** + * Gets members. + * + * @return the members + * @throws IOException + * the io exception + */ public Set getMembers() throws IOException { return Collections.unmodifiableSet(listMembers().asSet()); } /** * Checks if this team has the specified user as a member. + * + * @param user + * the user + * @return the boolean */ public boolean hasMember(GHUser user) { try { - root.retrieve().to("/teams/" + id + "/members/" + user.getLogin()); + root.retrieve().to("/teams/" + id + "/members/" + user.getLogin()); return true; } catch (IOException ignore) { return false; } } - public Map getRepositories() throws IOException { - Map m = new TreeMap(); + /** + * Gets repositories. + * + * @return the repositories + * @throws IOException + * the io exception + */ + public Map getRepositories() throws IOException { + Map m = new TreeMap(); for (GHRepository r : listRepositories()) { m.put(r.getName(), r); } return m; } + /** + * List repositories paged iterable. + * + * @return the paged iterable + */ public PagedIterable listRepositories() { - return root.retrieve() - .asPagedIterable( - api("/repos"), - GHRepository[].class, - item -> item.wrap(root) ); + return root.retrieve().asPagedIterable(api("/repos"), GHRepository[].class, item -> item.wrap(root)); } /** * Adds a member to the team. - * + *

* The user will be invited to the organization if required. * + * @param u + * the u + * @throws IOException + * the io exception * @since 1.59 */ public void add(GHUser u) throws IOException { @@ -137,43 +194,78 @@ public void add(GHUser u) throws IOException { /** * Adds a member to the team - * + *

* The user will be invited to the organization if required. * - * @param user github user - * @param role role for the new member - * + * @param user + * github user + * @param role + * role for the new member * @throws IOException + * the io exception */ public void add(GHUser user, Role role) throws IOException { - root.retrieve().method("PUT") - .with("role", role) - .to(api("/memberships/" + user.getLogin()), null); + root.retrieve().method("PUT").with("role", role).to(api("/memberships/" + user.getLogin()), null); } /** * Removes a member to the team. + * + * @param u + * the u + * @throws IOException + * the io exception */ public void remove(GHUser u) throws IOException { root.retrieve().method("DELETE").to(api("/members/" + u.getLogin()), null); } + /** + * Add. + * + * @param r + * the r + * @throws IOException + * the io exception + */ public void add(GHRepository r) throws IOException { - add(r,null); + add(r, null); } + /** + * Add. + * + * @param r + * the r + * @param permission + * the permission + * @throws IOException + * the io exception + */ public void add(GHRepository r, GHOrganization.Permission permission) throws IOException { - root.retrieve().method("PUT") + root.retrieve() + .method("PUT") .with("permission", permission) .to(api("/repos/" + r.getOwnerName() + '/' + r.getName()), null); } + /** + * Remove. + * + * @param r + * the r + * @throws IOException + * the io exception + */ public void remove(GHRepository r) throws IOException { root.retrieve().method("DELETE").to(api("/repos/" + r.getOwnerName() + '/' + r.getName()), null); } - + /** * Deletes this team. + * + * @throws IOException + * the io exception */ public void delete() throws IOException { root.retrieve().method("DELETE").to(api("")); @@ -183,6 +275,13 @@ private String api(String tail) { return "/teams/" + id + tail; } + /** + * Gets organization. + * + * @return the organization + * @throws IOException + * the io exception + */ public GHOrganization getOrganization() throws IOException { refresh(organization); return organization; diff --git a/src/main/java/org/kohsuke/github/GHThread.java b/src/main/java/org/kohsuke/github/GHThread.java index faf4c87b7b..52b942512b 100644 --- a/src/main/java/org/kohsuke/github/GHThread.java +++ b/src/main/java/org/kohsuke/github/GHThread.java @@ -10,12 +10,12 @@ /** * A conversation in the notification API. * + * @author Kohsuke Kawaguchi * @see documentation * @see GHNotificationStream - * @author Kohsuke Kawaguchi */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GHThread extends GHObject { private GitHub root; private GHRepository repository; @@ -23,7 +23,7 @@ public class GHThread extends GHObject { private String reason; private boolean unread; private String last_read_at; - private String url,subscription_url; + private String url, subscription_url; static class Subject { String title; @@ -37,6 +37,8 @@ private GHThread() {// no external construction allowed /** * Returns null if the entire thread has never been read. + * + * @return the last read at */ public Date getLastReadAt() { return GitHub.parseDate(last_read_at); @@ -50,60 +52,94 @@ public URL getHtmlUrl() { return null; } + /** + * Gets reason. + * + * @return the reason + */ public String getReason() { return reason; } + /** + * Gets repository. + * + * @return the repository + */ public GHRepository getRepository() { return repository; } // TODO: how to expose the subject? + /** + * Is read boolean. + * + * @return the boolean + */ public boolean isRead() { return !unread; } + /** + * Gets title. + * + * @return the title + */ public String getTitle() { return subject.title; } + /** + * Gets type. + * + * @return the type + */ public String getType() { return subject.type; } - + + /** + * Gets last comment url. + * + * @return the last comment url + */ public String getLastCommentUrl() { return subject.latest_comment_url; } /** * If this thread is about an issue, return that issue. - * + * * @return null if this thread is not about an issue. + * @throws IOException + * the io exception */ public GHIssue getBoundIssue() throws IOException { if (!"Issue".equals(subject.type) && "PullRequest".equals(subject.type)) return null; - return repository.getIssue( - Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1))); + return repository.getIssue(Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1))); } /** * If this thread is about a pull request, return that pull request. * * @return null if this thread is not about a pull request. + * @throws IOException + * the io exception */ public GHPullRequest getBoundPullRequest() throws IOException { if (!"PullRequest".equals(subject.type)) return null; - return repository.getPullRequest( - Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1))); + return repository.getPullRequest(Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1))); } /** * If this thread is about a commit, return that commit. * * @return null if this thread is not about a commit. + * @throws IOException + * the io exception */ public GHCommit getBoundCommit() throws IOException { if (!"Commit".equals(subject.type)) @@ -111,15 +147,18 @@ public GHCommit getBoundCommit() throws IOException { return repository.getCommit(subject.url.substring(subject.url.lastIndexOf('/') + 1)); } - /*package*/ GHThread wrap(GitHub root) { + GHThread wrap(GitHub root) { this.root = root; - if (this.repository!=null) + if (this.repository != null) this.repository.wrap(root); return this; } /** * Marks this thread as read. + * + * @throws IOException + * the io exception */ public void markAsRead() throws IOException { new Requester(root).method("PATCH").to(url); @@ -127,18 +166,29 @@ public void markAsRead() throws IOException { /** * Subscribes to this conversation to get notifications. + * + * @param subscribed + * the subscribed + * @param ignored + * the ignored + * @return the gh subscription + * @throws IOException + * the io exception */ public GHSubscription subscribe(boolean subscribed, boolean ignored) throws IOException { - return new Requester(root) - .with("subscribed", subscribed) - .with("ignored", ignored) - .method("PUT").to(subscription_url, GHSubscription.class).wrapUp(root); + return new Requester(root).with("subscribed", subscribed) + .with("ignored", ignored) + .method("PUT") + .to(subscription_url, GHSubscription.class) + .wrapUp(root); } /** * Returns the current subscription for this thread. * * @return null if no subscription exists. + * @throws IOException + * the io exception */ public GHSubscription getSubscription() throws IOException { try { diff --git a/src/main/java/org/kohsuke/github/GHTree.java b/src/main/java/org/kohsuke/github/GHTree.java index d52e02a793..f23ead9fe7 100644 --- a/src/main/java/org/kohsuke/github/GHTree.java +++ b/src/main/java/org/kohsuke/github/GHTree.java @@ -6,13 +6,12 @@ import java.util.List; /** - * Provides information for Git Trees - * https://developer.github.com/v3/git/trees/ + * Provides information for Git Trees https://developer.github.com/v3/git/trees/ * * @author Daniel Teixeira - https://github.com/ddtxra - * @see GHCommit#getTree() - * @see GHRepository#getTree(String) - * @see GHTreeEntry#asTree() + * @see GHCommit#getTree() GHCommit#getTree() + * @see GHRepository#getTree(String) GHRepository#getTree(String) + * @see GHTreeEntry#asTree() GHTreeEntry#asTree() */ public class GHTree { /* package almost final */GHRepository repo; @@ -23,6 +22,8 @@ public class GHTree { /** * The SHA for this trees + * + * @return the sha */ public String getSha() { return sha; @@ -30,6 +31,8 @@ public String getSha() { /** * Return an array of entries of the trees + * + * @return the tree */ public List getTree() { return Collections.unmodifiableList(Arrays.asList(tree)); @@ -37,8 +40,12 @@ public List getTree() { /** * Finds a tree entry by its name. - * + *

* IOW, find a directory entry by a file name. + * + * @param path + * the path + * @return the entry */ public GHTreeEntry getEntry(String path) { for (GHTreeEntry e : tree) { @@ -49,7 +56,8 @@ public GHTreeEntry getEntry(String path) { } /** - * Returns true if the number of items in the tree array exceeded the GitHub maximum limit. + * Returns true if the number of items in the tree array exceeded the GitHub maximum limit. + * * @return true true if the number of items in the tree array exceeded the GitHub maximum limit otherwise false. */ public boolean isTruncated() { @@ -57,14 +65,16 @@ public boolean isTruncated() { } /** - * The API URL of this tag, such as - * "url": "https://api.github.com/repos/octocat/Hello-World/trees/fc6274d15fa3ae2ab983129fb037999f264ba9a7", + * The API URL of this tag, such as "url": + * "https://api.github.com/repos/octocat/Hello-World/trees/fc6274d15fa3ae2ab983129fb037999f264ba9a7", + * + * @return the url */ public URL getUrl() { return GitHub.parseURL(url); } - /* package */GHTree wrap(GHRepository repo) { + GHTree wrap(GHRepository repo) { this.repo = repo; for (GHTreeEntry e : tree) { e.tree = this; diff --git a/src/main/java/org/kohsuke/github/GHTreeBuilder.java b/src/main/java/org/kohsuke/github/GHTreeBuilder.java index 122c5775b5..ed27854b13 100644 --- a/src/main/java/org/kohsuke/github/GHTreeBuilder.java +++ b/src/main/java/org/kohsuke/github/GHTreeBuilder.java @@ -3,12 +3,12 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; /** - * Builder pattern for creating a new tree. - * Based on https://developer.github.com/v3/git/trees/#create-a-tree + * Builder pattern for creating a new tree. Based on https://developer.github.com/v3/git/trees/#create-a-tree */ public class GHTreeBuilder { private final GHRepository repo; @@ -37,7 +37,11 @@ private TreeEntry(String path, String mode, String type) { } /** - * @param baseTree the SHA of tree you want to update with new data + * Base tree gh tree builder. + * + * @param baseTree + * the SHA of tree you want to update with new data + * @return the gh tree builder */ public GHTreeBuilder baseTree(String baseTree) { req.with("base_tree", baseTree); @@ -45,9 +49,22 @@ public GHTreeBuilder baseTree(String baseTree) { } /** - * Adds a new entry to the tree. - * Exactly one of the parameters {@code sha} and {@code content} must be non-null. + * Adds a new entry to the tree. Exactly one of the parameters {@code sha} and {@code content} must be non-null. + * + * @param path + * the path + * @param mode + * the mode + * @param type + * the type + * @param sha + * the sha + * @param content + * the content + * @return the gh tree builder + * @deprecated use {@link #add(String, String, boolean)} or {@link #add(String, byte[], boolean)} instead. */ + @Deprecated public GHTreeBuilder entry(String path, String mode, String type, String sha, String content) { TreeEntry entry = new TreeEntry(path, mode, type); entry.sha = sha; @@ -57,8 +74,19 @@ public GHTreeBuilder entry(String path, String mode, String type, String sha, St } /** - * Specialized version of {@link #entry(String, String, String, String, String)} for adding an existing blob referred by its SHA. + * Specialized version of {@link #entry(String, String, String, String, String)} for adding an existing blob + * referred by its SHA. + * + * @param path + * the path + * @param sha + * the sha + * @param executable + * the executable + * @return the gh tree builder + * @deprecated use {@link #add(String, String, boolean)} or {@link #add(String, byte[], boolean)} instead. */ + @Deprecated public GHTreeBuilder shaEntry(String path, String sha, boolean executable) { TreeEntry entry = new TreeEntry(path, executable ? "100755" : "100644", "blob"); entry.sha = sha; @@ -67,8 +95,19 @@ public GHTreeBuilder shaEntry(String path, String sha, boolean executable) { } /** - * Specialized version of {@link #entry(String, String, String, String, String)} for adding a text file with the specified {@code content}. + * Specialized version of {@link #entry(String, String, String, String, String)} for adding a text file with the + * specified {@code content}. + * + * @param path + * the path + * @param content + * the content + * @param executable + * the executable + * @return the gh tree builder + * @deprecated use {@link #add(String, String, boolean)} or {@link #add(String, byte[], boolean)} instead. */ + @Deprecated public GHTreeBuilder textEntry(String path, String content, boolean executable) { TreeEntry entry = new TreeEntry(path, executable ? "100755" : "100644", "blob"); entry.content = content; @@ -76,15 +115,54 @@ public GHTreeBuilder textEntry(String path, String content, boolean executable) return this; } + /** + * Adds a new entry with the given binary content to the tree. + * + * @param path + * the file path in the tree + * @param content + * the file content as byte array + * @param executable + * true, if the file should be executable + * @return this GHTreeBuilder + */ + public GHTreeBuilder add(String path, byte[] content, boolean executable) { + try { + String dataSha = repo.createBlob().binaryContent(content).create().getSha(); + return shaEntry(path, dataSha, executable); + } catch (IOException e) { + throw new GHException("Cannot create binary content of '" + path + "'", e); + } + } + + /** + * Adds a new entry with the given text content to the tree. + * + * @param path + * the file path in the tree + * @param content + * the file content as UTF-8 encoded string + * @param executable + * true, if the file should be executable + * @return this GHTreeBuilder + */ + public GHTreeBuilder add(String path, String content, boolean executable) { + return add(path, content.getBytes(StandardCharsets.UTF_8), executable); + } + private String getApiTail() { return String.format("/repos/%s/%s/git/trees", repo.getOwnerName(), repo.getName()); } /** * Creates a tree based on the parameters specified thus far. + * + * @return the gh tree + * @throws IOException + * the io exception */ public GHTree create() throws IOException { - req._with("tree", treeEntries); + req.with("tree", treeEntries); return req.method("POST").to(getApiTail(), GHTree.class).wrap(repo); } } diff --git a/src/main/java/org/kohsuke/github/GHTreeEntry.java b/src/main/java/org/kohsuke/github/GHTreeEntry.java index ba6d45e15e..58cfe366c0 100644 --- a/src/main/java/org/kohsuke/github/GHTreeEntry.java +++ b/src/main/java/org/kohsuke/github/GHTreeEntry.java @@ -5,8 +5,7 @@ import java.net.URL; /** - * Provides information for Git Trees - * https://developer.github.com/v3/git/trees/ + * Provides information for Git Trees https://developer.github.com/v3/git/trees/ * * @author Daniel Teixeira - https://github.com/ddtxra * @see GHTree @@ -18,8 +17,7 @@ public class GHTreeEntry { private long size; /** - * Get the path such as - * "subdir/file.txt" + * Get the path such as "subdir/file.txt" * * @return the path */ @@ -28,8 +26,7 @@ public String getPath() { } /** - * Get mode such as - * 100644 + * Get mode such as 100644 * * @return the mode */ @@ -38,8 +35,8 @@ public String getMode() { } /** - * Gets the size of the file, such as - * 132 + * Gets the size of the file, such as 132 + * * @return The size of the path or 0 if it is a directory */ public long getSize() { @@ -47,8 +44,7 @@ public long getSize() { } /** - * Gets the type such as: - * "blob", "tree", etc. + * Gets the type such as: "blob", "tree", etc. * * @return The type */ @@ -56,26 +52,31 @@ public String getType() { return type; } - /** * SHA1 of this object. + * + * @return the sha */ public String getSha() { return sha; } /** - * API URL to this Git data, such as - * https://api.github.com/repos/jenkinsci + * API URL to this Git data, such as https://api.github.com/repos/jenkinsci * /jenkins/git/commits/b72322675eb0114363a9a86e9ad5a170d1d07ac0 + * + * @return the url */ public URL getUrl() { return GitHub.parseURL(url); } /** - * If this tree entry represents a file, then return its information. - * Otherwise null. + * If this tree entry represents a file, then return its information. Otherwise null. + * + * @return the gh blob + * @throws IOException + * the io exception */ public GHBlob asBlob() throws IOException { if (type.equals("blob")) @@ -85,8 +86,11 @@ public GHBlob asBlob() throws IOException { } /** - * If this tree entry represents a file, then return its content. - * Otherwise null. + * If this tree entry represents a file, then return its content. Otherwise null. + * + * @return the input stream + * @throws IOException + * the io exception */ public InputStream readAsBlob() throws IOException { if (type.equals("blob")) @@ -96,8 +100,11 @@ public InputStream readAsBlob() throws IOException { } /** - * If this tree entry represents a directory, then return it. - * Otherwise null. + * If this tree entry represents a directory, then return it. Otherwise null. + * + * @return the gh tree + * @throws IOException + * the io exception */ public GHTree asTree() throws IOException { if (type.equals("tree")) diff --git a/src/main/java/org/kohsuke/github/GHUser.java b/src/main/java/org/kohsuke/github/GHUser.java index d794a8c74f..73cdfea9bd 100644 --- a/src/main/java/org/kohsuke/github/GHUser.java +++ b/src/main/java/org/kohsuke/github/GHUser.java @@ -35,12 +35,22 @@ */ public class GHUser extends GHPerson { + /** + * Gets keys. + * + * @return the keys + * @throws IOException + * the io exception + */ public List getKeys() throws IOException { return Collections.unmodifiableList(Arrays.asList(root.retrieve().to(getApiTailUrl("keys"), GHKey[].class))); } /** * Follow this user. + * + * @throws IOException + * the io exception */ public void follow() throws IOException { new Requester(root).method("PUT").to("/user/following/" + login); @@ -48,6 +58,9 @@ public void follow() throws IOException { /** * Unfollow this user. + * + * @throws IOException + * the io exception */ public void unfollow() throws IOException { new Requester(root).method("DELETE").to("/user/following/" + login); @@ -55,6 +68,10 @@ public void unfollow() throws IOException { /** * Lists the users that this user is following + * + * @return the follows + * @throws IOException + * the io exception */ @WithBridgeMethods(Set.class) public GHPersonSet getFollows() throws IOException { @@ -63,6 +80,8 @@ public GHPersonSet getFollows() throws IOException { /** * Lists the users that this user is following + * + * @return the paged iterable */ public PagedIterable listFollows() { return listUser("following"); @@ -70,6 +89,10 @@ public PagedIterable listFollows() { /** * Lists the users who are following this user. + * + * @return the followers + * @throws IOException + * the io exception */ @WithBridgeMethods(Set.class) public GHPersonSet getFollowers() throws IOException { @@ -78,23 +101,23 @@ public GHPersonSet getFollowers() throws IOException { /** * Lists the users who are following this user. + * + * @return the paged iterable */ public PagedIterable listFollowers() { return listUser("followers"); } private PagedIterable listUser(final String suffix) { - return root.retrieve() - .asPagedIterable( - getApiTailUrl(suffix), - GHUser[].class, - item -> item.wrapUp(root) ); + return root.retrieve().asPagedIterable(getApiTailUrl(suffix), GHUser[].class, item -> item.wrapUp(root)); } /** * Lists all the subscribed (aka watched) repositories. - * + *

* https://developer.github.com/v3/activity/watching/ + * + * @return the paged iterable */ public PagedIterable listSubscriptions() { return listRepositories("subscriptions"); @@ -102,21 +125,23 @@ public PagedIterable listSubscriptions() { /** * Lists all the repositories that this user has starred. + * + * @return the paged iterable */ public PagedIterable listStarredRepositories() { return listRepositories("starred"); } private PagedIterable listRepositories(final String suffix) { - return root.retrieve() - .asPagedIterable( - getApiTailUrl(suffix), - GHRepository[].class, - item -> item.wrap(root) ); + return root.retrieve().asPagedIterable(getApiTailUrl(suffix), GHRepository[].class, item -> item.wrap(root)); } /** * Returns true if this user belongs to the specified organization. + * + * @param org + * the org + * @return the boolean */ public boolean isMemberOf(GHOrganization org) { return org.hasMember(this); @@ -124,6 +149,10 @@ public boolean isMemberOf(GHOrganization org) { /** * Returns true if this user belongs to the specified team. + * + * @param team + * the team + * @return the boolean */ public boolean isMemberOf(GHTeam team) { return team.hasMember(this); @@ -131,12 +160,16 @@ public boolean isMemberOf(GHTeam team) { /** * Returns true if this user belongs to the specified organization as a public member. + * + * @param org + * the org + * @return the boolean */ public boolean isPublicMemberOf(GHOrganization org) { return org.hasPublicMember(this); } - /*package*/ static GHUser[] wrap(GHUser[] users, GitHub root) { + static GHUser[] wrap(GHUser[] users, GitHub root) { for (GHUser f : users) f.root = root; return users; @@ -144,13 +177,17 @@ public boolean isPublicMemberOf(GHOrganization org) { /** * Gets the organization that this user belongs to publicly. + * + * @return the organizations + * @throws IOException + * the io exception */ @WithBridgeMethods(Set.class) public GHPersonSet getOrganizations() throws IOException { GHPersonSet orgs = new GHPersonSet(); Set names = new HashSet(); for (GHOrganization o : root.retrieve().to("/users/" + login + "/orgs", GHOrganization[].class)) { - if (names.add(o.getLogin())) // I've seen some duplicates in the data + if (names.add(o.getLogin())) // I've seen some duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; @@ -161,21 +198,23 @@ public GHPersonSet getOrganizations() throws IOException { */ public PagedIterable listEvents() throws IOException { return root.retrieve() - .asPagedIterable( - String.format("/users/%s/events", login), - GHEventInfo[].class, - item -> item.wrapUp(root) ); + .asPagedIterable(String.format("/users/%s/events", login), + GHEventInfo[].class, + item -> item.wrapUp(root)); } /** * Lists Gists created by this user. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listGists() throws IOException { return root.retrieve() - .asPagedIterable( - String.format("/users/%s/gists", login), - GHGist[].class, - item -> item.wrapUp(GHUser.this) ); + .asPagedIterable(String.format("/users/%s/gists", login), + GHGist[].class, + item -> item.wrapUp(GHUser.this)); } @Override @@ -193,11 +232,12 @@ public boolean equals(Object obj) { } String getApiTailUrl(String tail) { - if (tail.length()>0 && !tail.startsWith("/")) tail='/'+tail; + if (tail.length() > 0 && !tail.startsWith("/")) + tail = '/' + tail; return "/users/" + login + tail; } - /*package*/ GHUser wrapUp(GitHub root) { + GHUser wrapUp(GitHub root) { super.wrapUp(root); return this; } diff --git a/src/main/java/org/kohsuke/github/GHUserSearchBuilder.java b/src/main/java/org/kohsuke/github/GHUserSearchBuilder.java index 3edcd15065..616a3b7852 100644 --- a/src/main/java/org/kohsuke/github/GHUserSearchBuilder.java +++ b/src/main/java/org/kohsuke/github/GHUserSearchBuilder.java @@ -4,11 +4,11 @@ * Search users. * * @author Kohsuke Kawaguchi - * @see GitHub#searchUsers() + * @see GitHub#searchUsers() GitHub#searchUsers() */ public class GHUserSearchBuilder extends GHSearchBuilder { - /*package*/ GHUserSearchBuilder(GitHub root) { - super(root,UserSearchResult.class); + GHUserSearchBuilder(GitHub root) { + super(root, UserSearchResult.class); } /** @@ -19,52 +19,120 @@ public GHUserSearchBuilder q(String term) { return this; } + /** + * Type gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder type(String v) { - return q("type:"+v); + return q("type:" + v); } + /** + * In gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder in(String v) { - return q("in:"+v); + return q("in:" + v); } + /** + * Repos gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder repos(String v) { - return q("repos:"+v); + return q("repos:" + v); } + /** + * Location gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder location(String v) { - return q("location:"+v); + return q("location:" + v); } + /** + * Language gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder language(String v) { - return q("language:"+v); + return q("language:" + v); } + /** + * Created gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder created(String v) { - return q("created:"+v); + return q("created:" + v); } + /** + * Followers gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder followers(String v) { - return q("followers:"+v); + return q("followers:" + v); } + /** + * Order gh user search builder. + * + * @param v + * the v + * @return the gh user search builder + */ public GHUserSearchBuilder order(GHDirection v) { - req.with("order",v); + req.with("order", v); return this; } + /** + * Sort gh user search builder. + * + * @param sort + * the sort + * @return the gh user search builder + */ public GHUserSearchBuilder sort(Sort sort) { - req.with("sort",sort); + req.with("sort", sort); return this; } - public enum Sort { FOLLOWERS, REPOSITORIES, JOINED } + /** + * The enum Sort. + */ + public enum Sort { + FOLLOWERS, REPOSITORIES, JOINED + } private static class UserSearchResult extends SearchResult { private GHUser[] items; @Override - /*package*/ GHUser[] getItems(GitHub root) { - return GHUser.wrap(items,root); + GHUser[] getItems(GitHub root) { + return GHUser.wrap(items, root); } } diff --git a/src/main/java/org/kohsuke/github/GHVerifiedKey.java b/src/main/java/org/kohsuke/github/GHVerifiedKey.java index d81597d748..24dfbdbfa0 100644 --- a/src/main/java/org/kohsuke/github/GHVerifiedKey.java +++ b/src/main/java/org/kohsuke/github/GHVerifiedKey.java @@ -1,13 +1,19 @@ package org.kohsuke.github; +/** + * The type GHVerifiedKey. + */ public class GHVerifiedKey extends GHKey { - public GHVerifiedKey() { - this.verified = true; - } + /** + * Instantiates a new Gh verified key. + */ + public GHVerifiedKey() { + this.verified = true; + } - @Override - public String getTitle() { - return (title == null ? "key-" + id : title); - } + @Override + public String getTitle() { + return (title == null ? "key-" + id : title); + } } diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 2d90ec0435..27b29540e4 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -26,14 +26,13 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import org.apache.commons.codec.Charsets; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; @@ -43,8 +42,12 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.function.Supplier; import java.util.logging.Logger; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; @@ -57,28 +60,28 @@ * *

Thread safety

*

- * This library aims to be safe for use by multiple threads concurrently, although - * the library itself makes no attempt to control/serialize potentially conflicting - * operations to GitHub, such as updating & deleting a repository at the same time. + * This library aims to be safe for use by multiple threads concurrently, although the library itself makes no attempt + * to control/serialize potentially conflicting operations to GitHub, such as updating & deleting a repository at + * the same time. * * @author Kohsuke Kawaguchi */ public class GitHub { - /*package*/ final String login; + final String login; /** * Value of the authorization header to be sent with the request. */ - /*package*/ final String encodedAuthorization; + final String encodedAuthorization; - private final ConcurrentMap users; - private final ConcurrentMap orgs; + private final ConcurrentMap users; + private final ConcurrentMap orgs; // Cache of myself object. private GHMyself myself; private final String apiUrl; - /*package*/ final RateLimitHandler rateLimitHandler; - /*package*/ final AbuseLimitHandler abuseLimitHandler; + final RateLimitHandler rateLimitHandler; + final AbuseLimitHandler abuseLimitHandler; private HttpConnector connector = HttpConnector.DEFAULT; @@ -90,58 +93,67 @@ public class GitHub { * Creates a client API root object. * *

- * Several different combinations of the login/oauthAccessToken/password parameters are allowed - * to represent different ways of authentication. + * Several different combinations of the login/oauthAccessToken/password parameters are allowed to represent + * different ways of authentication. * *

- *
Log in anonymously - *
Leave all three parameters null and you will be making HTTP requests without any authentication. - * - *
Log in with password - *
Specify the login and password, then leave oauthAccessToken null. - * This will use the HTTP BASIC auth with the GitHub API. - * - *
Log in with OAuth token - *
Specify oauthAccessToken, and optionally specify the login. Leave password null. - * This will send OAuth token to the GitHub API. If the login parameter is null, - * The constructor makes an API call to figure out the user name that owns the token. - * - *
Log in with JWT token - *
Specify jwtToken. Leave password null. - * This will send JWT token to the GitHub API via the Authorization HTTP header. - * Please note that only operations in which permissions have been previously configured and accepted during - * the GitHub App will be executed successfully. + *
Log in anonymously + *
Leave all three parameters null and you will be making HTTP requests without any authentication. + * + *
Log in with password + *
Specify the login and password, then leave oauthAccessToken null. This will use the HTTP BASIC auth with the + * GitHub API. + * + *
Log in with OAuth token + *
Specify oauthAccessToken, and optionally specify the login. Leave password null. This will send OAuth token + * to the GitHub API. If the login parameter is null, The constructor makes an API call to figure out the user name + * that owns the token. + * + *
Log in with JWT token + *
Specify jwtToken. Leave password null. This will send JWT token to the GitHub API via the Authorization HTTP + * header. Please note that only operations in which permissions have been previously configured and accepted during + * the GitHub App will be executed successfully. *
* * @param apiUrl - * The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or - * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has /api/v3 in the URL. - * For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated. - * Password is also considered deprecated as it is no longer required for api usage. + * The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or + * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has /api/v3 in the URL. For + * historical reasons, this parameter still accepts the bare domain name, but that's considered + * deprecated. Password is also considered deprecated as it is no longer required for api usage. * @param login - * The user ID on GitHub that you are logging in as. Can be omitted if the OAuth token is - * provided or if logging in anonymously. Specifying this would save one API call. + * The user ID on GitHub that you are logging in as. Can be omitted if the OAuth token is provided or if + * logging in anonymously. Specifying this would save one API call. * @param oauthAccessToken - * Secret OAuth token. + * Secret OAuth token. * @param password - * User's password. Always used in conjunction with the {@code login} parameter + * User's password. Always used in conjunction with the {@code login} parameter * @param connector - * HttpConnector to use. Pass null to use default connector. + * HttpConnector to use. Pass null to use default connector. */ - /* package */ GitHub(String apiUrl, String login, String oauthAccessToken, String jwtToken, String password, HttpConnector connector, RateLimitHandler rateLimitHandler, AbuseLimitHandler abuseLimitHandler) throws IOException { - if (apiUrl.endsWith("/")) apiUrl = apiUrl.substring(0, apiUrl.length()-1); // normalize + GitHub(String apiUrl, + String login, + String oauthAccessToken, + String jwtToken, + String password, + HttpConnector connector, + RateLimitHandler rateLimitHandler, + AbuseLimitHandler abuseLimitHandler) throws IOException { + if (apiUrl.endsWith("/")) + apiUrl = apiUrl.substring(0, apiUrl.length() - 1); // normalize this.apiUrl = apiUrl; - if (null != connector) this.connector = connector; + if (null != connector) + this.connector = connector; - if (oauthAccessToken!=null) { - encodedAuthorization = "token "+oauthAccessToken; + if (oauthAccessToken != null) { + encodedAuthorization = "token " + oauthAccessToken; } else { - if(jwtToken!=null){ - encodedAuthorization = "Bearer "+jwtToken; - }else if (password!=null) { + if (jwtToken != null) { + encodedAuthorization = "Bearer " + jwtToken; + } else if (password != null) { String authorization = (login + ':' + password); String charsetName = Charsets.UTF_8.name(); - encodedAuthorization = "Basic "+new String(Base64.encodeBase64(authorization.getBytes(charsetName)), charsetName); + encodedAuthorization = "Basic " + + new String(Base64.encodeBase64(authorization.getBytes(charsetName)), charsetName); } else {// anonymous access encodedAuthorization = null; } @@ -152,13 +164,17 @@ public class GitHub { this.rateLimitHandler = rateLimitHandler; this.abuseLimitHandler = abuseLimitHandler; - if (login==null && encodedAuthorization!=null && jwtToken == null) + if (login == null && encodedAuthorization != null && jwtToken == null) login = getMyself().getLogin(); this.login = login; } /** * Obtains the credential from "~/.github" or from the System Environment Properties. + * + * @return the git hub + * @throws IOException + * the io exception */ public static GitHub connect() throws IOException { return GitHubBuilder.fromCredentials().build(); @@ -167,66 +183,146 @@ public static GitHub connect() throws IOException { /** * Version that connects to GitHub Enterprise. * - * @deprecated - * Use {@link #connectToEnterpriseWithOAuth(String, String, String)} + * @param apiUrl + * the api url + * @param oauthAccessToken + * the oauth access token + * @return the git hub + * @throws IOException + * the io exception + * @deprecated Use {@link #connectToEnterpriseWithOAuth(String, String, String)} */ @Deprecated public static GitHub connectToEnterprise(String apiUrl, String oauthAccessToken) throws IOException { - return connectToEnterpriseWithOAuth(apiUrl,null,oauthAccessToken); + return connectToEnterpriseWithOAuth(apiUrl, null, oauthAccessToken); } /** * Version that connects to GitHub Enterprise. * * @param apiUrl - * The URL of GitHub (or GitHub Enterprise) API endpoint, such as "https://api.github.com" or - * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has /api/v3 in the URL. - * For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated. + * The URL of GitHub (or GitHub Enterprise) API endpoint, such as "https://api.github.com" or + * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has /api/v3 in the URL. For + * historical reasons, this parameter still accepts the bare domain name, but that's considered + * deprecated. + * @param login + * the login + * @param oauthAccessToken + * the oauth access token + * @return the git hub + * @throws IOException + * the io exception */ - public static GitHub connectToEnterpriseWithOAuth(String apiUrl, String login, String oauthAccessToken) throws IOException { + public static GitHub connectToEnterpriseWithOAuth(String apiUrl, String login, String oauthAccessToken) + throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken, login).build(); } /** * Version that connects to GitHub Enterprise. * - * @deprecated - * Use with caution. Login with password is not a preferred method. + * @param apiUrl + * the api url + * @param login + * the login + * @param password + * the password + * @return the git hub + * @throws IOException + * the io exception + * @deprecated Use with caution. Login with password is not a preferred method. */ @Deprecated public static GitHub connectToEnterprise(String apiUrl, String login, String password) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).withPassword(login, password).build(); } + /** + * Connect git hub. + * + * @param login + * the login + * @param oauthAccessToken + * the oauth access token + * @return the git hub + * @throws IOException + * the io exception + */ public static GitHub connect(String login, String oauthAccessToken) throws IOException { return new GitHubBuilder().withOAuthToken(oauthAccessToken, login).build(); } /** - * @deprecated - * Either OAuth token or password is sufficient, so there's no point in passing both. - * Use {@link #connectUsingPassword(String, String)} or {@link #connectUsingOAuth(String)}. + * Connect git hub. + * + * @param login + * the login + * @param oauthAccessToken + * the oauth access token + * @param password + * the password + * @return the git hub + * @throws IOException + * the io exception + * @deprecated Either OAuth token or password is sufficient, so there's no point in passing both. Use + * {@link #connectUsingPassword(String, String)} or {@link #connectUsingOAuth(String)}. */ @Deprecated public static GitHub connect(String login, String oauthAccessToken, String password) throws IOException { return new GitHubBuilder().withOAuthToken(oauthAccessToken, login).withPassword(login, password).build(); } + /** + * Connect using password git hub. + * + * @param login + * the login + * @param password + * the password + * @return the git hub + * @throws IOException + * the io exception + */ public static GitHub connectUsingPassword(String login, String password) throws IOException { return new GitHubBuilder().withPassword(login, password).build(); } + /** + * Connect using o auth git hub. + * + * @param oauthAccessToken + * the oauth access token + * @return the git hub + * @throws IOException + * the io exception + */ public static GitHub connectUsingOAuth(String oauthAccessToken) throws IOException { return new GitHubBuilder().withOAuthToken(oauthAccessToken).build(); } + /** + * Connect using o auth git hub. + * + * @param githubServer + * the github server + * @param oauthAccessToken + * the oauth access token + * @return the git hub + * @throws IOException + * the io exception + */ public static GitHub connectUsingOAuth(String githubServer, String oauthAccessToken) throws IOException { return new GitHubBuilder().withEndpoint(githubServer).withOAuthToken(oauthAccessToken).build(); } + /** * Connects to GitHub anonymously. - * + *

* All operations that require authentication will fail. + * + * @return the git hub + * @throws IOException + * the io exception */ public static GitHub connectAnonymously() throws IOException { return new GitHubBuilder().build(); @@ -234,8 +330,14 @@ public static GitHub connectAnonymously() throws IOException { /** * Connects to GitHub Enterprise anonymously. - * + *

* All operations that require authentication will fail. + * + * @param apiUrl + * the api url + * @return the git hub + * @throws IOException + * the io exception */ public static GitHub connectToEnterpriseAnonymously(String apiUrl) throws IOException { return new GitHubBuilder().withEndpoint(apiUrl).build(); @@ -243,15 +345,14 @@ public static GitHub connectToEnterpriseAnonymously(String apiUrl) throws IOExce /** * An offline-only {@link GitHub} useful for parsing event notification from an unknown source. - * + *

* All operations that require a connection will fail. * * @return An offline-only {@link GitHub}. */ public static GitHub offline() { try { - return new GitHubBuilder() - .withEndpoint("https://api.github.invalid") + return new GitHubBuilder().withEndpoint("https://api.github.invalid") .withConnector(HttpConnector.OFFLINE) .build(); } catch (IOException e) { @@ -261,41 +362,57 @@ public static GitHub offline() { /** * Is this an anonymous connection + * * @return {@code true} if operations that require authentication will fail. */ public boolean isAnonymous() { - return login==null && encodedAuthorization==null; + return login == null && encodedAuthorization == null; } /** * Is this an always offline "connection". + * * @return {@code true} if this is an always offline "connection". */ public boolean isOffline() { return connector == HttpConnector.OFFLINE; } + /** + * Gets connector. + * + * @return the connector + */ public HttpConnector getConnector() { return connector; } + /** + * Gets api url. + * + * @return the api url + */ public String getApiUrl() { return apiUrl; } /** * Sets the custom connector used to make requests to GitHub. + * + * @param connector + * the connector */ public void setConnector(HttpConnector connector) { this.connector = connector; } - /*package*/ void requireCredential() { + void requireCredential() { if (isAnonymous()) - throw new IllegalStateException("This operation requires a credential but none is given to the GitHub constructor"); + throw new IllegalStateException( + "This operation requires a credential but none is given to the GitHub constructor"); } - /*package*/ URL getApiURL(String tailApiUrl) throws IOException { + URL getApiURL(String tailApiUrl) throws IOException { if (tailApiUrl.startsWith("/")) { if ("github.com".equals(apiUrl)) {// backward compatibility return new URL(GITHUB_URL + tailApiUrl); @@ -307,42 +424,81 @@ public void setConnector(HttpConnector connector) { } } - /*package*/ Requester retrieve() { + Requester retrieve() { return new Requester(this).method("GET"); } /** * Gets the current rate limit. + * + * @return the rate limit + * @throws IOException + * the io exception */ public GHRateLimit getRateLimit() throws IOException { + GHRateLimit rateLimit; try { - return rateLimit = retrieve().to("/rate_limit", JsonRateLimit.class).rate; + rateLimit = retrieve().to("/rate_limit", JsonRateLimit.class).resources; } catch (FileNotFoundException e) { - // GitHub Enterprise doesn't have the rate limit, so in that case - // return some big number that's not too big. - // see issue #78 - GHRateLimit r = new GHRateLimit(); - r.limit = r.remaining = 1000000; - long hour = 60L * 60L; // this is madness, storing the date as seconds in a Date object - r.reset = new Date(System.currentTimeMillis() / 1000L + hour); - return rateLimit = r; + // GitHub Enterprise doesn't have the rate limit + // return a default rate limit that + rateLimit = GHRateLimit.Unknown(); } + + return this.rateLimit = rateLimit; } - /*package*/ void updateRateLimit(@Nonnull GHRateLimit observed) { + /** + * Update the Rate Limit with the latest info from response header. Due to multi-threading requests might complete + * out of order, we want to pick the one with the most recent info from the server. + * + * @param observed + * {@link GHRateLimit.Record} constructed from the response header information + */ + void updateCoreRateLimit(@Nonnull GHRateLimit.Record observed) { synchronized (headerRateLimitLock) { - if (headerRateLimit == null - || headerRateLimit.getResetDate().getTime() < observed.getResetDate().getTime() - || headerRateLimit.remaining > observed.remaining) { - headerRateLimit = observed; + if (headerRateLimit == null || shouldReplace(observed, headerRateLimit.getCore())) { + headerRateLimit = GHRateLimit.fromHeaderRecord(observed); LOGGER.log(FINE, "Rate limit now: {0}", headerRateLimit); } } } /** - * Returns the most recently observed rate limit data or {@code null} if either there is no rate limit - * (for example GitHub Enterprise) or if no requests have been made. + * Update the Rate Limit with the latest info from response header. Due to multi-threading requests might complete + * out of order, we want to pick the one with the most recent info from the server. Header date is only accurate to + * the second, so we look at the information in the record itself. + * + * {@link GHRateLimit.UnknownLimitRecord}s are always replaced by regular {@link GHRateLimit.Record}s. Regular + * {@link GHRateLimit.Record}s are never replaced by {@link GHRateLimit.UnknownLimitRecord}s. Candidates with + * resetEpochSeconds later than current record are more recent. Candidates with the same reset and a lower remaining + * count are more recent. Candidates with an earlier reset are older. + * + * @param candidate + * {@link GHRateLimit.Record} constructed from the response header information + * @param current + * the current {@link GHRateLimit.Record} record + */ + static boolean shouldReplace(@Nonnull GHRateLimit.Record candidate, @Nonnull GHRateLimit.Record current) { + if (candidate instanceof GHRateLimit.UnknownLimitRecord + && !(current instanceof GHRateLimit.UnknownLimitRecord)) { + // Unknown candidate never replaces a regular record + return false; + } else if (current instanceof GHRateLimit.UnknownLimitRecord + && !(candidate instanceof GHRateLimit.UnknownLimitRecord)) { + // Any real record should replace an unknown Record. + return true; + } else { + // records of the same type compare to each other as normal. + return current.getResetEpochSeconds() < candidate.getResetEpochSeconds() + || (current.getResetEpochSeconds() == candidate.getResetEpochSeconds() + && current.getRemaining() > candidate.getRemaining()); + } + } + + /** + * Returns the most recently observed rate limit data or {@code null} if either there is no rate limit (for example + * GitHub Enterprise) or if no requests have been made. * * @return the most recently observed rate limit data or {@code null}. */ @@ -357,17 +513,18 @@ public GHRateLimit lastRateLimit() { * Gets the current rate limit while trying not to actually make any remote requests unless absolutely necessary. * * @return the current rate limit data. - * @throws IOException if we couldn't get the current rate limit data. + * @throws IOException + * if we couldn't get the current rate limit data. */ @Nonnull public GHRateLimit rateLimit() throws IOException { synchronized (headerRateLimitLock) { - if (headerRateLimit != null) { + if (headerRateLimit != null && !headerRateLimit.isExpired()) { return headerRateLimit; } } GHRateLimit rateLimit = this.rateLimit; - if (rateLimit == null || rateLimit.getResetDate().getTime() < System.currentTimeMillis()) { + if (rateLimit == null || rateLimit.isExpired()) { rateLimit = getRateLimit(); } return rateLimit; @@ -375,12 +532,17 @@ public GHRateLimit rateLimit() throws IOException { /** * Gets the {@link GHUser} that represents yourself. + * + * @return the myself + * @throws IOException + * the io exception */ @WithBridgeMethods(GHUser.class) public GHMyself getMyself() throws IOException { requireCredential(); synchronized (this) { - if (this.myself != null) return myself; + if (this.myself != null) + return myself; GHMyself u = retrieve().to("/user", GHMyself.class); @@ -392,6 +554,12 @@ public GHMyself getMyself() throws IOException { /** * Obtains the object that represents the named user. + * + * @param login + * the login + * @return the user + * @throws IOException + * the io exception */ public GHUser getUser(String login) throws IOException { GHUser u = users.get(login); @@ -403,7 +571,6 @@ public GHUser getUser(String login) throws IOException { return u; } - /** * clears all cached data in order for external changes (modifications and del) to be reflected */ @@ -414,12 +581,16 @@ public void refreshCache() { /** * Interns the given {@link GHUser}. + * + * @param orig + * the orig + * @return the user */ protected GHUser getUser(GHUser orig) { GHUser u = users.get(orig.getLogin()); - if (u==null) { + if (u == null) { orig.root = this; - users.put(orig.getLogin(),orig); + users.put(orig.getLogin(), orig); return orig; } return u; @@ -427,18 +598,26 @@ protected GHUser getUser(GHUser orig) { /** * Gets {@link GHOrganization} specified by name. + * + * @param name + * the name + * @return the organization + * @throws IOException + * the io exception */ public GHOrganization getOrganization(String name) throws IOException { GHOrganization o = orgs.get(name); - if (o==null) { + if (o == null) { o = retrieve().to("/orgs/" + name, GHOrganization.class).wrapUp(this); - orgs.put(name,o); + orgs.put(name, o); } return o; } /** * Gets a list of all organizations. + * + * @return the paged iterable */ public PagedIterable listOrganizations() { return listOrganizations(null); @@ -447,21 +626,25 @@ public PagedIterable listOrganizations() { /** * Gets a list of all organizations starting after the organization identifier specified by 'since'. * + * @param since + * the since + * @return the paged iterable * @see List All Orgs - Parameters */ public PagedIterable listOrganizations(final String since) { - return retrieve() - .with("since",since) - .asPagedIterable( - "/organizations", - GHOrganization[].class, - item -> item.wrapUp(GitHub.this) ); + return retrieve().with("since", since) + .asPagedIterable("/organizations", GHOrganization[].class, item -> item.wrapUp(GitHub.this)); } /** * Gets the repository object from 'user/reponame' string that GitHub calls as "repository name" * - * @see GHRepository#getName() + * @param name + * the name + * @return the repository + * @throws IOException + * the io exception + * @see GHRepository#getName() GHRepository#getName() */ public GHRepository getRepository(String name) throws IOException { String[] tokens = name.split("/"); @@ -470,6 +653,12 @@ public GHRepository getRepository(String name) throws IOException { /** * Gets the repository object from its ID + * + * @param id + * the id + * @return the repository by id + * @throws IOException + * the io exception */ public GHRepository getRepositoryById(String id) throws IOException { return retrieve().to("/repositories/" + id, GHRepository.class).wrap(this); @@ -478,35 +667,35 @@ public GHRepository getRepositoryById(String id) throws IOException { /** * Returns a list of popular open source licenses * - * @see GitHub API - Licenses - * * @return a list of popular open source licenses + * @throws IOException + * the io exception + * @see GitHub API - Licenses */ public PagedIterable listLicenses() throws IOException { - return retrieve() - .asPagedIterable( - "/licenses", - GHLicense[].class, - item -> item.wrap(GitHub.this) ); + return retrieve().asPagedIterable("/licenses", GHLicense[].class, item -> item.wrap(GitHub.this)); } /** * Returns a list of all users. + * + * @return the paged iterable + * @throws IOException + * the io exception */ public PagedIterable listUsers() throws IOException { - return retrieve() - .asPagedIterable( - "/users", - GHUser[].class, - item -> item.wrapUp(GitHub.this) ); + return retrieve().asPagedIterable("/users", GHUser[].class, item -> item.wrapUp(GitHub.this)); } /** * Returns the full details for a license * - * @param key The license key provided from the API + * @param key + * The license key provided from the API * @return The license details - * @see GHLicense#getKey() + * @throws IOException + * the io exception + * @see GHLicense#getKey() GHLicense#getKey() */ public GHLicense getLicense(String key) throws IOException { return retrieve().to("/licenses/" + key, GHLicense.class); @@ -514,6 +703,10 @@ public GHLicense getLicense(String key) throws IOException { /** * Gets complete list of open invitations for current user. + * + * @return the my invitations + * @throws IOException + * the io exception */ public List getMyInvitations() throws IOException { GHInvitation[] invitations = retrieve().to("/user/repository_invitations", GHInvitation[].class); @@ -525,52 +718,67 @@ public List getMyInvitations() throws IOException { /** * This method returns shallowly populated organizations. + *

+ * To retrieve full organization details, you need to call {@link #getOrganization(String)} TODO: make this + * automatic. * - * To retrieve full organization details, you need to call {@link #getOrganization(String)} - * TODO: make this automatic. + * @return the my organizations + * @throws IOException + * the io exception */ public Map getMyOrganizations() throws IOException { GHOrganization[] orgs = retrieve().to("/user/orgs", GHOrganization[].class); Map r = new HashMap(); for (GHOrganization o : orgs) { // don't put 'o' into orgs because they are shallow - r.put(o.getLogin(),o.wrapUp(this)); + r.put(o.getLogin(), o.wrapUp(this)); } return r; } - + /** * Alias for {@link #getUserPublicOrganizations(String)}. + * + * @param user + * the user + * @return the user public organizations + * @throws IOException + * the io exception */ public Map getUserPublicOrganizations(GHUser user) throws IOException { - return getUserPublicOrganizations( user.getLogin() ); + return getUserPublicOrganizations(user.getLogin()); } /** * This method returns a shallowly populated organizations. - * + *

* To retrieve full organization details, you need to call {@link #getOrganization(String)} * - * @param login the user to retrieve public Organization membership information for - * + * @param login + * the user to retrieve public Organization membership information for * @return the public Organization memberships for the user + * @throws IOException + * the io exception */ public Map getUserPublicOrganizations(String login) throws IOException { GHOrganization[] orgs = retrieve().to("/users/" + login + "/orgs", GHOrganization[].class); Map r = new HashMap(); for (GHOrganization o : orgs) { // don't put 'o' into orgs because they are shallow - r.put(o.getLogin(),o.wrapUp(this)); + r.put(o.getLogin(), o.wrapUp(this)); } return r; } /** * Gets complete map of organizations/teams that current user belongs to. + *

+ * Leverages the new GitHub API /user/teams made available recently to get in a single call the complete set of + * organizations, teams and permissions in a single call. * - * Leverages the new GitHub API /user/teams made available recently to - * get in a single call the complete set of organizations, teams and permissions - * in a single call. + * @return the my teams + * @throws IOException + * the io exception */ public Map> getMyTeams() throws IOException { Map> allMyTeams = new HashMap>(); @@ -589,13 +797,23 @@ public Map> getMyTeams() throws IOException { /** * Gets a sigle team by ID. + * + * @param id + * the id + * @return the team + * @throws IOException + * the io exception */ public GHTeam getTeam(int id) throws IOException { return retrieve().to("/teams/" + id, GHTeam.class).wrapUp(this); } - + /** * Public events visible to you. Equivalent of what's displayed on https://github.com/ + * + * @return the events + * @throws IOException + * the io exception */ public List getEvents() throws IOException { GHEventInfo[] events = retrieve().to("/events", GHEventInfo[].class); @@ -606,21 +824,41 @@ public List getEvents() throws IOException { /** * Gets a single gist by ID. + * + * @param id + * the id + * @return the gist + * @throws IOException + * the io exception */ public GHGist getGist(String id) throws IOException { - return retrieve().to("/gists/"+id,GHGist.class).wrapUp(this); + return retrieve().to("/gists/" + id, GHGist.class).wrapUp(this); } + /** + * Create gist gh gist builder. + * + * @return the gh gist builder + */ public GHGistBuilder createGist() { return new GHGistBuilder(this); } /** * Parses the GitHub event object. + *

+ * This is primarily intended for receiving a POST HTTP call from a hook. Unfortunately, hook script payloads aren't + * self-descriptive, so you need to know the type of the payload you are expecting. * - * This is primarily intended for receiving a POST HTTP call from a hook. - * Unfortunately, hook script payloads aren't self-descriptive, so you need - * to know the type of the payload you are expecting. + * @param + * the type parameter + * @param r + * the r + * @param type + * the type + * @return the t + * @throws IOException + * the io exception */ public T parseEventPayload(Reader r, Class type) throws IOException { T t = MAPPER.readValue(r, type); @@ -631,13 +869,22 @@ public T parseEventPayload(Reader r, Class type) t /** * Creates a new repository. * - * @return - * Newly created repository. - * @deprecated - * Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect. + * @param name + * the name + * @param description + * the description + * @param homepage + * the homepage + * @param isPublic + * the is public + * @return Newly created repository. + * @throws IOException + * the io exception + * @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect. */ @Deprecated - public GHRepository createRepository(String name, String description, String homepage, boolean isPublic) throws IOException { + public GHRepository createRepository(String name, String description, String homepage, boolean isPublic) + throws IOException { return createRepository(name).description(description).homepage(homepage).private_(!isPublic).create(); } @@ -645,41 +892,105 @@ public GHRepository createRepository(String name, String description, String hom * Starts a builder that creates a new repository. * *

- * You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} - * to finally create a repository. + * You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to + * finally create a repository. * *

* To create a repository in an organization, see * {@link GHOrganization#createRepository(String, String, String, GHTeam, boolean)} + * + * @param name + * the name + * @return the gh create repository builder */ public GHCreateRepositoryBuilder createRepository(String name) { - return new GHCreateRepositoryBuilder(this,"/user/repos",name); + return new GHCreateRepositoryBuilder(this, "/user/repos", name); } /** * Creates a new authorization. - * + *

* The token created can be then used for {@link GitHub#connectUsingOAuth(String)} in the future. * + * @param scope + * the scope + * @param note + * the note + * @param noteUrl + * the note url + * @return the gh authorization + * @throws IOException + * the io exception * @see Documentation */ - public GHAuthorization createToken(Collection scope, String note, String noteUrl) throws IOException{ - Requester requester = new Requester(this) - .with("scopes", scope) - .with("note", note) - .with("note_url", noteUrl); + public GHAuthorization createToken(Collection scope, String note, String noteUrl) throws IOException { + Requester requester = new Requester(this).with("scopes", scope).with("note", note).with("note_url", noteUrl); return requester.method("POST").to("/authorizations", GHAuthorization.class).wrap(this); } /** - * @see docs + * Creates a new authorization using an OTP. + *

+ * Start by running createToken, if exception is thrown, prompt for OTP from user + *

+ * Once OTP is received, call this token request + *

+ * The token created can be then used for {@link GitHub#connectUsingOAuth(String)} in the future. + * + * @param scope + * the scope + * @param note + * the note + * @param noteUrl + * the note url + * @param OTP + * the otp + * @return the gh authorization + * @throws IOException + * the io exception + * @see Documentation */ - public GHAuthorization createOrGetAuth(String clientId, String clientSecret, List scopes, String note, - String note_url) + public GHAuthorization createToken(Collection scope, String note, String noteUrl, Supplier OTP) throws IOException { - Requester requester = new Requester(this) - .with("client_secret", clientSecret) + try { + return createToken(scope, note, noteUrl); + } catch (GHOTPRequiredException ex) { + String OTPstring = OTP.get(); + Requester requester = new Requester(this).with("scopes", scope) + .with("note", note) + .with("note_url", noteUrl); + // Add the OTP from the user + requester.setHeader("x-github-otp", OTPstring); + return requester.method("POST").to("/authorizations", GHAuthorization.class).wrap(this); + } + } + + /** + * Create or get auth gh authorization. + * + * @param clientId + * the client id + * @param clientSecret + * the client secret + * @param scopes + * the scopes + * @param note + * the note + * @param note_url + * the note url + * @return the gh authorization + * @throws IOException + * the io exception + * @see docs + */ + public GHAuthorization createOrGetAuth(String clientId, + String clientSecret, + List scopes, + String note, + String note_url) throws IOException { + Requester requester = new Requester(this).with("client_secret", clientSecret) .with("scopes", scopes) .with("note", note) .with("note_url", note_url); @@ -688,52 +999,88 @@ public GHAuthorization createOrGetAuth(String clientId, String clientSecret, Lis } /** - * @see Delete an authorization + * Delete auth. + * + * @param id + * the id + * @throws IOException + * the io exception + * @see Delete an + * authorization */ public void deleteAuth(long id) throws IOException { retrieve().method("DELETE").to("/authorizations/" + id); } /** - * @see Check an authorization + * Check auth gh authorization. + * + * @param clientId + * the client id + * @param accessToken + * the access token + * @return the gh authorization + * @throws IOException + * the io exception + * @see Check an + * authorization */ public GHAuthorization checkAuth(@Nonnull String clientId, @Nonnull String accessToken) throws IOException { return retrieve().to("/applications/" + clientId + "/tokens/" + accessToken, GHAuthorization.class); } /** - * @see Reset an authorization + * Reset auth gh authorization. + * + * @param clientId + * the client id + * @param accessToken + * the access token + * @return the gh authorization + * @throws IOException + * the io exception + * @see Reset an + * authorization */ public GHAuthorization resetAuth(@Nonnull String clientId, @Nonnull String accessToken) throws IOException { - return retrieve().method("POST").to("/applications/" + clientId + "/tokens/" + accessToken, GHAuthorization.class); + return retrieve().method("POST") + .to("/applications/" + clientId + "/tokens/" + accessToken, GHAuthorization.class); } /** * Returns a list of all authorizations. - * @see List your authorizations + * + * @return the paged iterable + * @throws IOException + * the io exception + * @see List your + * authorizations */ public PagedIterable listMyAuthorizations() throws IOException { - return retrieve() - .asPagedIterable( - "/authorizations", - GHAuthorization[].class, - item -> item.wrap(GitHub.this) ); + return retrieve().asPagedIterable("/authorizations", GHAuthorization[].class, item -> item.wrap(GitHub.this)); } /** * Returns the GitHub App associated with the authentication credentials used. - * + *

* You must use a JWT to access this endpoint. * - * @see Get the authenticated GitHub App + * @return the app + * @throws IOException + * the io exception + * @see Get the authenticated + * GitHub App */ - @Preview @Deprecated + @Preview + @Deprecated public GHApp getApp() throws IOException { return retrieve().withPreview(MACHINE_MAN).to("/app", GHApp.class).wrapUp(this); } /** * Ensures that the credential is valid. + * + * @return the boolean */ public boolean isCredentialValid() { try { @@ -741,41 +1088,85 @@ public boolean isCredentialValid() { return true; } catch (IOException e) { if (LOGGER.isLoggable(FINE)) - LOGGER.log(FINE, "Exception validating credentials on " + this.apiUrl + " with login '" + this.login + "' " + e, e); + LOGGER.log(FINE, + "Exception validating credentials on " + this.apiUrl + " with login '" + this.login + "' " + e, + e); return false; } } - /*package*/ GHUser intern(GHUser user) throws IOException { - if (user==null) return user; + /** + * Provides a list of GitHub's IP addresses. + * + * @return an instance of {@link GHMeta} + * @throws IOException + * if the credentials supplied are invalid or if you're trying to access it as a GitHub App via the JWT + * authentication + * @see Get Meta + */ + public GHMeta getMeta() throws IOException { + return retrieve().to("/meta", GHMeta.class); + } + + GHUser intern(GHUser user) throws IOException { + if (user == null) + return user; // if we already have this user in our map, use it GHUser u = users.get(user.getLogin()); - if (u!=null) return u; + if (u != null) + return u; // if not, remember this new user - users.putIfAbsent(user.getLogin(),user); + users.putIfAbsent(user.getLogin(), user); return user; } + /** + * Gets project. + * + * @param id + * the id + * @return the project + * @throws IOException + * the io exception + */ public GHProject getProject(long id) throws IOException { - return retrieve().withPreview(INERTIA).to("/projects/"+id, GHProject.class).wrap(this); + return retrieve().withPreview(INERTIA).to("/projects/" + id, GHProject.class).wrap(this); } + /** + * Gets project column. + * + * @param id + * the id + * @return the project column + * @throws IOException + * the io exception + */ public GHProjectColumn getProjectColumn(long id) throws IOException { - return retrieve().withPreview(INERTIA).to("/projects/columns/"+id, GHProjectColumn.class).wrap(this); + return retrieve().withPreview(INERTIA).to("/projects/columns/" + id, GHProjectColumn.class).wrap(this); } + /** + * Gets project card. + * + * @param id + * the id + * @return the project card + * @throws IOException + * the io exception + */ public GHProjectCard getProjectCard(long id) throws IOException { - return retrieve().withPreview(INERTIA).to("/projects/columns/cards/"+id, GHProjectCard.class).wrap(this); + return retrieve().withPreview(INERTIA).to("/projects/columns/cards/" + id, GHProjectCard.class).wrap(this); } private static class GHApiInfo { private String rate_limit_url; void check(String apiUrl) throws IOException { - if (rate_limit_url==null) - throw new IOException(apiUrl+" doesn't look like GitHub API URL"); + if (rate_limit_url == null) + throw new IOException(apiUrl + " doesn't look like GitHub API URL"); // make sure that the URL is legitimate new URL(rate_limit_url); @@ -789,22 +1180,48 @@ void check(String apiUrl) throws IOException { * Verify that the API URL and credentials are valid to access this GitHub. * *

- * This method returns normally if the endpoint is reachable and verified to be GitHub API URL. - * Otherwise this method throws {@link IOException} to indicate the problem. + * This method returns normally if the endpoint is reachable and verified to be GitHub API URL. Otherwise this + * method throws {@link IOException} to indicate the problem. + * + * @throws IOException + * the io exception */ public void checkApiUrlValidity() throws IOException { try { retrieve().to("/", GHApiInfo.class).check(apiUrl); } catch (IOException e) { if (isPrivateModeEnabled()) { - throw (IOException)new IOException("GitHub Enterprise server (" + apiUrl + ") with private mode enabled").initCause(e); + throw (IOException) new IOException( + "GitHub Enterprise server (" + apiUrl + ") with private mode enabled").initCause(e); } throw e; } } /** - * Ensures if a GitHub Enterprise server is configured in private mode. + * Checks if a GitHub Enterprise server is configured in private mode. + * + * In private mode response looks like: + * + *

+     *  $ curl -i https://github.mycompany.com/api/v3/
+     *     HTTP/1.1 401 Unauthorized
+     *     Server: GitHub.com
+     *     Date: Sat, 05 Mar 2016 19:45:01 GMT
+     *     Content-Type: application/json; charset=utf-8
+     *     Content-Length: 130
+     *     Status: 401 Unauthorized
+     *     X-GitHub-Media-Type: github.v3
+     *     X-XSS-Protection: 1; mode=block
+     *     X-Frame-Options: deny
+     *     Content-Security-Policy: default-src 'none'
+     *     Access-Control-Allow-Credentials: true
+     *     Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
+     *     Access-Control-Allow-Origin: *
+     *     X-GitHub-Request-Id: dbc70361-b11d-4131-9a7f-674b8edd0411
+     *     Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
+     *     X-Content-Type-Options: nosniff
+     * 
* * @return {@code true} if private mode is enabled. If it tries to use this method with GitHub, returns {@code * false}. @@ -812,28 +1229,8 @@ public void checkApiUrlValidity() throws IOException { private boolean isPrivateModeEnabled() { try { HttpURLConnection uc = getConnector().connect(getApiURL("/")); - /* - $ curl -i https://github.mycompany.com/api/v3/ - HTTP/1.1 401 Unauthorized - Server: GitHub.com - Date: Sat, 05 Mar 2016 19:45:01 GMT - Content-Type: application/json; charset=utf-8 - Content-Length: 130 - Status: 401 Unauthorized - X-GitHub-Media-Type: github.v3 - X-XSS-Protection: 1; mode=block - X-Frame-Options: deny - Content-Security-Policy: default-src 'none' - Access-Control-Allow-Credentials: true - Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval - Access-Control-Allow-Origin: * - X-GitHub-Request-Id: dbc70361-b11d-4131-9a7f-674b8edd0411 - Strict-Transport-Security: max-age=31536000; includeSubdomains; preload - X-Content-Type-Options: nosniff - */ try { - return uc.getResponseCode() == HTTP_UNAUTHORIZED - && uc.getHeaderField("X-GitHub-Media-Type") != null; + return uc.getResponseCode() == HTTP_UNAUTHORIZED && uc.getHeaderField("X-GitHub-Media-Type") != null; } finally { // ensure that the connection opened by getResponseCode gets closed try { @@ -850,14 +1247,19 @@ private boolean isPrivateModeEnabled() { /** * Search commits. + * + * @return the gh commit search builder */ - @Preview @Deprecated + @Preview + @Deprecated public GHCommitSearchBuilder searchCommits() { return new GHCommitSearchBuilder(this); } /** * Search issues. + * + * @return the gh issue search builder */ public GHIssueSearchBuilder searchIssues() { return new GHIssueSearchBuilder(this); @@ -865,6 +1267,8 @@ public GHIssueSearchBuilder searchIssues() { /** * Search users. + * + * @return the gh user search builder */ public GHUserSearchBuilder searchUsers() { return new GHUserSearchBuilder(this); @@ -872,6 +1276,8 @@ public GHUserSearchBuilder searchUsers() { /** * Search repositories. + * + * @return the gh repository search builder */ public GHRepositorySearchBuilder searchRepositories() { return new GHRepositorySearchBuilder(this); @@ -879,6 +1285,8 @@ public GHRepositorySearchBuilder searchRepositories() { /** * Search content. + * + * @return the gh content search builder */ public GHContentSearchBuilder searchContent() { return new GHContentSearchBuilder(this); @@ -886,13 +1294,17 @@ public GHContentSearchBuilder searchContent() { /** * List all the notifications. + * + * @return the gh notification stream */ public GHNotificationStream listNotifications() { - return new GHNotificationStream(this,"/notifications"); + return new GHNotificationStream(this, "/notifications"); } /** * This provides a dump of every public repository, in the order that they were created. + * + * @return the paged iterable * @see documentation */ public PagedIterable listAllPublicRepositories() { @@ -903,46 +1315,46 @@ public PagedIterable listAllPublicRepositories() { * This provides a dump of every public repository, in the order that they were created. * * @param since - * The numeric ID of the last Repository that you’ve seen. See {@link GHRepository#getId()} + * The numeric ID of the last Repository that you’ve seen. See {@link GHRepository#getId()} + * @return the paged iterable * @see documentation */ public PagedIterable listAllPublicRepositories(final String since) { - return retrieve().with("since",since) - .asPagedIterable( - "/repositories", - GHRepository[].class, - item -> item.wrap(GitHub.this) ); + return retrieve().with("since", since) + .asPagedIterable("/repositories", GHRepository[].class, item -> item.wrap(GitHub.this)); } /** * Render a Markdown document in raw mode. * *

- * It takes a Markdown document as plaintext and renders it as plain Markdown - * without a repository context (just like a README.md file is rendered – this - * is the simplest way to preview a readme online). + * It takes a Markdown document as plaintext and renders it as plain Markdown without a repository context (just + * like a README.md file is rendered – this is the simplest way to preview a readme online). * - * @see GHRepository#renderMarkdown(String, MarkdownMode) + * @param text + * the text + * @return the reader + * @throws IOException + * the io exception + * @see GHRepository#renderMarkdown(String, MarkdownMode) GHRepository#renderMarkdown(String, MarkdownMode) */ public Reader renderMarkdown(String text) throws IOException { - return new InputStreamReader( - new Requester(this) - .with(new ByteArrayInputStream(text.getBytes("UTF-8"))) - .contentType("text/plain;charset=UTF-8") - .asStream("/markdown/raw"), - "UTF-8"); + return new InputStreamReader(new Requester(this).with(new ByteArrayInputStream(text.getBytes("UTF-8"))) + .contentType("text/plain;charset=UTF-8") + .asStream("/markdown/raw"), "UTF-8"); } - /*package*/ static URL parseURL(String s) { + static URL parseURL(String s) { try { - return s==null ? null : new URL(s); + return s == null ? null : new URL(s); } catch (MalformedURLException e) { - throw new IllegalStateException("Invalid URL: "+s); + throw new IllegalStateException("Invalid URL: " + s); } } - /*package*/ static Date parseDate(String timestamp) { - if (timestamp==null) return null; + static Date parseDate(String timestamp) { + if (timestamp == null) + return null; for (String f : TIME_FORMATS) { try { SimpleDateFormat df = new SimpleDateFormat(f); @@ -952,30 +1364,29 @@ public Reader renderMarkdown(String text) throws IOException { // try next } } - throw new IllegalStateException("Unable to parse the timestamp: "+timestamp); + throw new IllegalStateException("Unable to parse the timestamp: " + timestamp); } - /*package*/ static String printDate(Date dt) { + static String printDate(Date dt) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getTimeZone("GMT")); return df.format(dt); } - /*package*/ static final ObjectMapper MAPPER = new ObjectMapper(); + static final ObjectMapper MAPPER = new ObjectMapper(); - private static final String[] TIME_FORMATS = { - "yyyy/MM/dd HH:mm:ss ZZZZ", - "yyyy-MM-dd'T'HH:mm:ss'Z'", + private static final String[] TIME_FORMATS = { "yyyy/MM/dd HH:mm:ss ZZZZ", "yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd'T'HH:mm:ss.S'Z'" // GitHub App endpoints return a different date format }; static { - MAPPER.setVisibilityChecker(new Std(NONE, NONE, NONE, NONE, ANY)); + MAPPER.setVisibility(new Std(NONE, NONE, NONE, NONE, ANY)); MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true); + MAPPER.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); } - /* package */ static final String GITHUB_URL = "https://api.github.com"; + static final String GITHUB_URL = "https://api.github.com"; private static final Logger LOGGER = Logger.getLogger(GitHub.class.getName()); } diff --git a/src/main/java/org/kohsuke/github/GitHubBuilder.java b/src/main/java/org/kohsuke/github/GitHubBuilder.java index f0db8e609b..63f0877d9e 100644 --- a/src/main/java/org/kohsuke/github/GitHubBuilder.java +++ b/src/main/java/org/kohsuke/github/GitHubBuilder.java @@ -33,20 +33,25 @@ public class GitHubBuilder implements Cloneable { private RateLimitHandler rateLimitHandler = RateLimitHandler.WAIT; private AbuseLimitHandler abuseLimitHandler = AbuseLimitHandler.WAIT; + /** + * Instantiates a new Git hub builder. + */ public GitHubBuilder() { } /** - * First check if the credentials are configured in the environment. - * We use environment first because users are not likely to give required (full) permissions to their default key. + * First check if the credentials are configured in the environment. We use environment first because users are not + * likely to give required (full) permissions to their default key. * * If no user is specified it means there is no configuration present, so try using the ~/.github properties file. ** * If there is still no user it means there are no credentials defined and throw an IOException. * - * @return the configured Builder from credentials defined on the system or in the environment. Otherwise returns null. + * @return the configured Builder from credentials defined on the system or in the environment. Otherwise returns + * null. * - * @throws IOException If there are no credentials defined in the ~/.github properties file or the process environment. + * @throws IOException + * If there are no credentials defined in the ~/.github properties file or the process environment. */ static GitHubBuilder fromCredentials() throws IOException { Exception cause = null; @@ -54,7 +59,7 @@ static GitHubBuilder fromCredentials() throws IOException { builder = fromEnvironment(); - if (builder.oauthToken != null || builder.user != null || builder.jwtToken != null) + if (builder.oauthToken != null || builder.user != null || builder.jwtToken != null) return builder; try { @@ -66,35 +71,63 @@ static GitHubBuilder fromCredentials() throws IOException { // fall through cause = e; } - throw (IOException)new IOException("Failed to resolve credentials from ~/.github or the environment.").initCause(cause); + throw (IOException) new IOException("Failed to resolve credentials from ~/.github or the environment.") + .initCause(cause); } /** - * @deprecated - * Use {@link #fromEnvironment()} to pick up standard set of environment variables, so that - * different clients of this library will all recognize one consistent set of coordinates. + * From environment git hub builder. + * + * @param loginVariableName + * the login variable name + * @param passwordVariableName + * the password variable name + * @param oauthVariableName + * the oauth variable name + * @return the git hub builder + * @throws IOException + * the io exception + * @deprecated Use {@link #fromEnvironment()} to pick up standard set of environment variables, so that different + * clients of this library will all recognize one consistent set of coordinates. */ - public static GitHubBuilder fromEnvironment(String loginVariableName, String passwordVariableName, String oauthVariableName) throws IOException { + public static GitHubBuilder fromEnvironment(String loginVariableName, + String passwordVariableName, + String oauthVariableName) throws IOException { return fromEnvironment(loginVariableName, passwordVariableName, oauthVariableName, ""); } private static void loadIfSet(String envName, Properties p, String propName) { String v = System.getenv(envName); - if (v != null) - p.put(propName, v); + if (v != null) + p.put(propName, v); } /** - * @deprecated - * Use {@link #fromEnvironment()} to pick up standard set of environment variables, so that - * different clients of this library will all recognize one consistent set of coordinates. + * From environment git hub builder. + * + * @param loginVariableName + * the login variable name + * @param passwordVariableName + * the password variable name + * @param oauthVariableName + * the oauth variable name + * @param endpointVariableName + * the endpoint variable name + * @return the git hub builder + * @throws IOException + * the io exception + * @deprecated Use {@link #fromEnvironment()} to pick up standard set of environment variables, so that different + * clients of this library will all recognize one consistent set of coordinates. */ - public static GitHubBuilder fromEnvironment(String loginVariableName, String passwordVariableName, String oauthVariableName, String endpointVariableName) throws IOException { + public static GitHubBuilder fromEnvironment(String loginVariableName, + String passwordVariableName, + String oauthVariableName, + String endpointVariableName) throws IOException { Properties env = new Properties(); - loadIfSet(loginVariableName,env,"login"); - loadIfSet(passwordVariableName,env,"password"); - loadIfSet(oauthVariableName,env,"oauth"); - loadIfSet(endpointVariableName,env,"endpoint"); + loadIfSet(loginVariableName, env, "login"); + loadIfSet(passwordVariableName, env, "password"); + loadIfSet(oauthVariableName, env, "oauth"); + loadIfSet(endpointVariableName, env, "endpoint"); return fromProperties(env); } @@ -105,36 +138,57 @@ public static GitHubBuilder fromEnvironment(String loginVariableName, String pas * The following environment variables are recognized: * *

    - *
  • GITHUB_LOGIN: username like 'kohsuke' - *
  • GITHUB_PASSWORD: raw password - *
  • GITHUB_OAUTH: OAuth token to login - *
  • GITHUB_ENDPOINT: URL of the API endpoint - *
  • GITHUB_JWT: JWT token to login + *
  • GITHUB_LOGIN: username like 'kohsuke' + *
  • GITHUB_PASSWORD: raw password + *
  • GITHUB_OAUTH: OAuth token to login + *
  • GITHUB_ENDPOINT: URL of the API endpoint + *
  • GITHUB_JWT: JWT token to login *
* *

* See class javadoc for the relationship between these coordinates. * *

- * For backward compatibility, the following environment variables are recognized but discouraged: - * login, password, oauth + * For backward compatibility, the following environment variables are recognized but discouraged: login, password, + * oauth + * + * @return the git hub builder + * @throws IOException + * the io exception */ public static GitHubBuilder fromEnvironment() throws IOException { Properties props = new Properties(); for (Entry e : System.getenv().entrySet()) { String name = e.getKey().toLowerCase(Locale.ENGLISH); - if (name.startsWith("github_")) name=name.substring(7); - props.put(name,e.getValue()); + if (name.startsWith("github_")) + name = name.substring(7); + props.put(name, e.getValue()); } return fromProperties(props); } + /** + * From property file git hub builder. + * + * @return the git hub builder + * @throws IOException + * the io exception + */ public static GitHubBuilder fromPropertyFile() throws IOException { File homeDir = new File(System.getProperty("user.home")); File propertyFile = new File(homeDir, ".github"); return fromPropertyFile(propertyFile.getPath()); } + /** + * From property file git hub builder. + * + * @param propertyFileName + * the property file name + * @return the git hub builder + * @throws IOException + * the io exception + */ public static GitHubBuilder fromPropertyFile(String propertyFileName) throws IOException { Properties props = new Properties(); FileInputStream in = null; @@ -144,10 +198,17 @@ public static GitHubBuilder fromPropertyFile(String propertyFileName) throws IOE } finally { IOUtils.closeQuietly(in); } - + return fromProperties(props); } - + + /** + * From properties git hub builder. + * + * @param props + * the props + * @return the git hub builder + */ public static GitHubBuilder fromProperties(Properties props) { GitHubBuilder self = new GitHubBuilder(); self.withOAuthToken(props.getProperty("oauth"), props.getProperty("login")); @@ -158,23 +219,55 @@ public static GitHubBuilder fromProperties(Properties props) { } /** + * With endpoint git hub builder. + * * @param endpoint - * The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or - * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has /api/v3 in the URL. - * For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated. + * The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or + * "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has /api/v3 in the URL. For + * historical reasons, this parameter still accepts the bare domain name, but that's considered + * deprecated. + * @return the git hub builder */ public GitHubBuilder withEndpoint(String endpoint) { this.endpoint = endpoint; return this; } + + /** + * With password git hub builder. + * + * @param user + * the user + * @param password + * the password + * @return the git hub builder + */ public GitHubBuilder withPassword(String user, String password) { this.user = user; this.password = password; return this; } + + /** + * With o auth token git hub builder. + * + * @param oauthToken + * the oauth token + * @return the git hub builder + */ public GitHubBuilder withOAuthToken(String oauthToken) { return withOAuthToken(oauthToken, null); } + + /** + * With o auth token git hub builder. + * + * @param oauthToken + * the oauth token + * @param user + * the user + * @return the git hub builder + */ public GitHubBuilder withOAuthToken(String oauthToken, String user) { this.oauthToken = oauthToken; this.user = user; @@ -184,35 +277,70 @@ public GitHubBuilder withOAuthToken(String oauthToken, String user) { /** * Configures {@link GitHubBuilder} with Installation Token generated by the GitHub Application * - * @param appInstallationToken A string containing the GitHub App installation token + * @param appInstallationToken + * A string containing the GitHub App installation token * @return the configured Builder from given GitHub App installation token. - * @see GHAppInstallation#createToken(java.util.Map) + * @see GHAppInstallation#createToken(java.util.Map) GHAppInstallation#createToken(java.util.Map) */ - public GitHubBuilder withAppInstallationToken(String appInstallationToken){ + public GitHubBuilder withAppInstallationToken(String appInstallationToken) { return withOAuthToken(appInstallationToken, ""); } - public GitHubBuilder withJwtToken(String jwtToken){ + /** + * With jwt token git hub builder. + * + * @param jwtToken + * the jwt token + * @return the git hub builder + */ + public GitHubBuilder withJwtToken(String jwtToken) { this.jwtToken = jwtToken; return this; } + + /** + * With connector git hub builder. + * + * @param connector + * the connector + * @return the git hub builder + */ public GitHubBuilder withConnector(HttpConnector connector) { this.connector = connector; return this; } + + /** + * With rate limit handler git hub builder. + * + * @param handler + * the handler + * @return the git hub builder + */ public GitHubBuilder withRateLimitHandler(RateLimitHandler handler) { this.rateLimitHandler = handler; return this; } + + /** + * With abuse limit handler git hub builder. + * + * @param handler + * the handler + * @return the git hub builder + */ public GitHubBuilder withAbuseLimitHandler(AbuseLimitHandler handler) { this.abuseLimitHandler = handler; return this; } /** - * Configures {@linkplain #withConnector(HttpConnector) connector} - * that uses HTTP library in JRE but use a specific proxy, instead of - * the system default one. + * Configures {@linkplain #withConnector(HttpConnector) connector} that uses HTTP library in JRE but use a specific + * proxy, instead of the system default one. + * + * @param p + * the p + * @return the git hub builder */ public GitHubBuilder withProxy(final Proxy p) { return withConnector(new ImpatientHttpConnector(new HttpConnector() { @@ -222,8 +350,22 @@ public HttpURLConnection connect(URL url) throws IOException { })); } + /** + * Build git hub. + * + * @return the git hub + * @throws IOException + * the io exception + */ public GitHub build() throws IOException { - return new GitHub(endpoint, user, oauthToken, jwtToken, password, connector, rateLimitHandler, abuseLimitHandler); + return new GitHub(endpoint, + user, + oauthToken, + jwtToken, + password, + connector, + rateLimitHandler, + abuseLimitHandler); } @Override diff --git a/src/main/java/org/kohsuke/github/GitUser.java b/src/main/java/org/kohsuke/github/GitUser.java index 9cd50bb22a..6a887b5802 100644 --- a/src/main/java/org/kohsuke/github/GitUser.java +++ b/src/main/java/org/kohsuke/github/GitUser.java @@ -6,35 +6,39 @@ /** * Represents a user in Git who authors/commits a commit. - * - * In contrast, {@link GHUser} is an user of GitHub. Because Git allows a person to - * use multiple e-mail addresses and names when creating a commit, there's generally - * no meaningful mapping between {@link GHUser} and {@link GitUser}. + *

+ * In contrast, {@link GHUser} is an user of GitHub. Because Git allows a person to use multiple e-mail addresses and + * names when creating a commit, there's generally no meaningful mapping between {@link GHUser} and {@link GitUser}. * * @author Kohsuke Kawaguchi */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "NP_UNWRITTEN_FIELD"}, justification = "JSON API") +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, + justification = "JSON API") public class GitUser { private String name, email, date; /** - * Human readable name of the user, such as "Kohsuke Kawaguchi" + * Gets name. + * + * @return Human readable name of the user, such as "Kohsuke Kawaguchi" */ public String getName() { return name; } /** - * E-mail address, such as "foo@example.com" + * Gets email. + * + * @return E -mail address, such as "foo@example.com" */ public String getEmail() { return email; } /** - * This field doesn't appear to be consistently available in all the situations where this class - * is used. + * Gets date. + * + * @return This field doesn't appear to be consistently available in all the situations where this class is used. */ public Date getDate() { return GitHub.parseDate(date); diff --git a/src/main/java/org/kohsuke/github/HttpConnector.java b/src/main/java/org/kohsuke/github/HttpConnector.java index 2d87c148c9..c883400668 100644 --- a/src/main/java/org/kohsuke/github/HttpConnector.java +++ b/src/main/java/org/kohsuke/github/HttpConnector.java @@ -17,6 +17,12 @@ public interface HttpConnector { /** * Opens a connection to the given URL. + * + * @param url + * the url + * @return the http url connection + * @throws IOException + * the io exception */ HttpURLConnection connect(URL url) throws IOException; diff --git a/src/main/java/org/kohsuke/github/HttpException.java b/src/main/java/org/kohsuke/github/HttpException.java index 79def83c2a..df29f269dd 100644 --- a/src/main/java/org/kohsuke/github/HttpException.java +++ b/src/main/java/org/kohsuke/github/HttpException.java @@ -1,14 +1,14 @@ package org.kohsuke.github; -import javax.annotation.CheckForNull; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import javax.annotation.CheckForNull; + /** - * {@link IOException} for http exceptions because {@link HttpURLConnection} throws un-discerned - * {@link IOException} and it can help to know the http response code to decide how to handle an - * http exceptions. + * {@link IOException} for http exceptions because {@link HttpURLConnection} throws un-discerned {@link IOException} and + * it can help to know the http response code to decide how to handle an http exceptions. * * @author Cyrille Le Clerc */ @@ -20,13 +20,18 @@ public class HttpException extends IOException { private final String url; /** - * @param message The detail message (which is saved for later retrieval - * by the {@link #getMessage()} method) - * @param responseCode Http response code. {@code -1} if no code can be discerned. - * @param responseMessage Http response message - * @param url The url that was invoked - * @see HttpURLConnection#getResponseCode() - * @see HttpURLConnection#getResponseMessage() + * Instantiates a new Http exception. + * + * @param message + * The detail message (which is saved for later retrieval by the {@link #getMessage()} method) + * @param responseCode + * Http response code. {@code -1} if no code can be discerned. + * @param responseMessage + * Http response message + * @param url + * The url that was invoked + * @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode() + * @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage() */ public HttpException(String message, int responseCode, String responseMessage, String url) { super(message); @@ -36,16 +41,21 @@ public HttpException(String message, int responseCode, String responseMessage, S } /** - * @param message The detail message (which is saved for later retrieval - * by the {@link #getMessage()} method) - * @param responseCode Http response code. {@code -1} if no code can be discerned. - * @param responseMessage Http response message - * @param url The url that was invoked - * @param cause The cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A null value is permitted, - * and indicates that the cause is nonexistent or unknown.) - * @see HttpURLConnection#getResponseCode() - * @see HttpURLConnection#getResponseMessage() + * Instantiates a new Http exception. + * + * @param message + * The detail message (which is saved for later retrieval by the {@link #getMessage()} method) + * @param responseCode + * Http response code. {@code -1} if no code can be discerned. + * @param responseMessage + * Http response message + * @param url + * The url that was invoked + * @param cause + * The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or unknown.) + * @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode() + * @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage() */ public HttpException(String message, int responseCode, String responseMessage, String url, Throwable cause) { super(message); @@ -56,18 +66,23 @@ public HttpException(String message, int responseCode, String responseMessage, S } /** - * @param responseCode Http response code. {@code -1} if no code can be discerned. - * @param responseMessage Http response message - * @param url The url that was invoked - * @param cause The cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A null value is permitted, - * and indicates that the cause is nonexistent or unknown.) - * @see HttpURLConnection#getResponseCode() - * @see HttpURLConnection#getResponseMessage() + * Instantiates a new Http exception. + * + * @param responseCode + * Http response code. {@code -1} if no code can be discerned. + * @param responseMessage + * Http response message + * @param url + * The url that was invoked + * @param cause + * The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or unknown.) + * @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode() + * @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage() */ public HttpException(int responseCode, String responseMessage, String url, Throwable cause) { - super("Server returned HTTP response code: " + responseCode + ", message: '" + responseMessage + "'" + - " for URL: " + url); + super("Server returned HTTP response code: " + responseCode + ", message: '" + responseMessage + "'" + + " for URL: " + url); initCause(cause); this.responseCode = responseCode; this.responseMessage = responseMessage; @@ -75,14 +90,19 @@ public HttpException(int responseCode, String responseMessage, String url, Throw } /** - * @param responseCode Http response code. {@code -1} if no code can be discerned. - * @param responseMessage Http response message - * @param url The url that was invoked - * @param cause The cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A null value is permitted, - * and indicates that the cause is nonexistent or unknown.) - * @see HttpURLConnection#getResponseCode() - * @see HttpURLConnection#getResponseMessage() + * Instantiates a new Http exception. + * + * @param responseCode + * Http response code. {@code -1} if no code can be discerned. + * @param responseMessage + * Http response message + * @param url + * The url that was invoked + * @param cause + * The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or unknown.) + * @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode() + * @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage() */ public HttpException(int responseCode, String responseMessage, @CheckForNull URL url, Throwable cause) { this(responseCode, responseMessage, url == null ? null : url.toString(), cause); @@ -109,7 +129,7 @@ public String getResponseMessage() { /** * The http URL that caused the exception * - * @return url + * @return url url */ public String getUrl() { return url; diff --git a/src/main/java/org/kohsuke/github/JsonRateLimit.java b/src/main/java/org/kohsuke/github/JsonRateLimit.java index 6276ae9b87..6dbfcdb5e4 100644 --- a/src/main/java/org/kohsuke/github/JsonRateLimit.java +++ b/src/main/java/org/kohsuke/github/JsonRateLimit.java @@ -4,5 +4,7 @@ * @author Kohsuke Kawaguchi */ class JsonRateLimit { - GHRateLimit rate; + + GHRateLimit resources; + } diff --git a/src/main/java/org/kohsuke/github/MarkdownMode.java b/src/main/java/org/kohsuke/github/MarkdownMode.java index 1d63760555..a4cb87f602 100644 --- a/src/main/java/org/kohsuke/github/MarkdownMode.java +++ b/src/main/java/org/kohsuke/github/MarkdownMode.java @@ -6,8 +6,8 @@ * Rendering mode of markdown. * * @author Kohsuke Kawaguchi - * @see GitHub#renderMarkdown(String) - * @see GHRepository#renderMarkdown(String, MarkdownMode) + * @see GitHub#renderMarkdown(String) GitHub#renderMarkdown(String) + * @see GHRepository#renderMarkdown(String, MarkdownMode) GHRepository#renderMarkdown(String, MarkdownMode) */ public enum MarkdownMode { /** @@ -15,9 +15,8 @@ public enum MarkdownMode { */ MARKDOWN, /** - * Render a document as user-content, e.g. like user comments or issues are rendered. - * In GFM mode, hard line breaks are always taken into account, and issue and user - * mentions are linked accordingly. + * Render a document as user-content, e.g. like user comments or issues are rendered. In GFM mode, hard line breaks + * are always taken into account, and issue and user mentions are linked accordingly. * * @see GHRepository#renderMarkdown(String, MarkdownMode) */ diff --git a/src/main/java/org/kohsuke/github/PagedIterable.java b/src/main/java/org/kohsuke/github/PagedIterable.java index 1c6eccea36..536922e039 100644 --- a/src/main/java/org/kohsuke/github/PagedIterable.java +++ b/src/main/java/org/kohsuke/github/PagedIterable.java @@ -8,6 +8,8 @@ /** * {@link Iterable} that returns {@link PagedIterator} * + * @param + * the type parameter * @author Kohsuke Kawaguchi */ public abstract class PagedIterable implements Iterable { @@ -21,6 +23,10 @@ public abstract class PagedIterable implements Iterable { * *

* When set to non-zero, each API call will retrieve this many entries. + * + * @param size + * the size + * @return the paged iterable */ public PagedIterable withPageSize(int size) { this.size = size; @@ -31,14 +37,23 @@ public final PagedIterator iterator() { return _iterator(size); } + /** + * Iterator paged iterator. + * + * @param pageSize + * the page size + * @return the paged iterator + */ public abstract PagedIterator _iterator(int pageSize); /** * Eagerly walk {@link Iterable} and return the result in a list. + * + * @return the list */ public List asList() { List r = new ArrayList(); - for(PagedIterator i = iterator(); i.hasNext();) { + for (PagedIterator i = iterator(); i.hasNext();) { r.addAll(i.nextPage()); } return r; @@ -46,10 +61,12 @@ public List asList() { /** * Eagerly walk {@link Iterable} and return the result in a set. + * + * @return the set */ public Set asSet() { LinkedHashSet r = new LinkedHashSet(); - for(PagedIterator i = iterator(); i.hasNext();) { + for (PagedIterator i = iterator(); i.hasNext();) { r.addAll(i.nextPage()); } return r; diff --git a/src/main/java/org/kohsuke/github/PagedIterator.java b/src/main/java/org/kohsuke/github/PagedIterator.java index aaa8182076..e63273a3a3 100644 --- a/src/main/java/org/kohsuke/github/PagedIterator.java +++ b/src/main/java/org/kohsuke/github/PagedIterator.java @@ -7,10 +7,12 @@ /** * Iterator over a paginated data source. + *

+ * Aside from the normal iterator operation, this method exposes {@link #nextPage()} that allows the caller to retrieve + * items per page. * - * Aside from the normal iterator operation, this method exposes {@link #nextPage()} - * that allows the caller to retrieve items per page. - * + * @param + * the type parameter * @author Kohsuke Kawaguchi */ public abstract class PagedIterator implements Iterator { @@ -22,25 +24,32 @@ public abstract class PagedIterator implements Iterator { private T[] current; private int pos; - /*package*/ PagedIterator(Iterator base) { + PagedIterator(Iterator base) { this.base = base; } + /** + * Wrap up. + * + * @param page + * the page + */ protected abstract void wrapUp(T[] page); public boolean hasNext() { fetch(); - return current!=null; + return current != null; } public T next() { fetch(); - if (current==null) throw new NoSuchElementException(); + if (current == null) + throw new NoSuchElementException(); return current[pos++]; } private void fetch() { - while (current==null || current.length<=pos) { + while (current == null || current.length <= pos) { if (!base.hasNext()) {// no more to retrieve current = null; pos = 0; @@ -60,11 +69,13 @@ public void remove() { /** * Gets the next page worth of data. + * + * @return the list */ public List nextPage() { fetch(); List r = Arrays.asList(current); - r = r.subList(pos,r.size()); + r = r.subList(pos, r.size()); current = null; pos = 0; return r; diff --git a/src/main/java/org/kohsuke/github/PagedSearchIterable.java b/src/main/java/org/kohsuke/github/PagedSearchIterable.java index f23bd6b58c..4e3b846508 100644 --- a/src/main/java/org/kohsuke/github/PagedSearchIterable.java +++ b/src/main/java/org/kohsuke/github/PagedSearchIterable.java @@ -7,10 +7,14 @@ /** * {@link PagedIterable} enhanced to report search result specific information. * + * @param + * the type parameter * @author Kohsuke Kawaguchi */ -@SuppressFBWarnings(value = {"UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", - "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"}, justification = "Constructed by JSON API") +@SuppressFBWarnings( + value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", + "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, + justification = "Constructed by JSON API") public abstract class PagedSearchIterable extends PagedIterable { private final GitHub root; @@ -19,35 +23,46 @@ public abstract class PagedSearchIterable extends PagedIterable { */ private SearchResult result; - /*package*/ PagedSearchIterable(GitHub root) { + PagedSearchIterable(GitHub root) { this.root = root; } @Override public PagedSearchIterable withPageSize(int size) { - return (PagedSearchIterable)super.withPageSize(size); + return (PagedSearchIterable) super.withPageSize(size); } /** * Returns the total number of hit, including the results that's not yet fetched. + * + * @return the total count */ public int getTotalCount() { populate(); return result.total_count; } + /** + * Is incomplete boolean. + * + * @return the boolean + */ public boolean isIncomplete() { populate(); return result.incomplete_results; } private void populate() { - if (result==null) + if (result == null) iterator().hasNext(); } /** * Adapts {@link Iterator}. + * + * @param base + * the base + * @return the iterator */ protected Iterator adapt(final Iterator> base) { return new Iterator() { @@ -57,7 +72,8 @@ public boolean hasNext() { public T[] next() { SearchResult v = base.next(); - if (result==null) result = v; + if (result == null) + result = v; return v.getItems(root); } diff --git a/src/main/java/org/kohsuke/github/Preview.java b/src/main/java/org/kohsuke/github/Preview.java index 2eeed60456..69b029044e 100644 --- a/src/main/java/org/kohsuke/github/Preview.java +++ b/src/main/java/org/kohsuke/github/Preview.java @@ -6,9 +6,9 @@ /** * Indicates that the method/class/etc marked maps to GitHub API in the preview period. - * - * These APIs are subject to change and not a part of the backward compatibility commitment. - * Always used in conjunction with 'deprecated' to raise awareness to clients. + *

+ * These APIs are subject to change and not a part of the backward compatibility commitment. Always used in conjunction + * with 'deprecated' to raise awareness to clients. * * @author Kohsuke Kawaguchi */ diff --git a/src/main/java/org/kohsuke/github/Previews.java b/src/main/java/org/kohsuke/github/Previews.java index cbdd3cf068..2468ac94cb 100644 --- a/src/main/java/org/kohsuke/github/Previews.java +++ b/src/main/java/org/kohsuke/github/Previews.java @@ -7,7 +7,7 @@ * * @author Kohsuke Kawaguchi */ -/*package*/ class Previews { +class Previews { /** * Commit Search @@ -33,7 +33,8 @@ /** * Require multiple approving reviews * - * @see GitHub API Previews + * @see GitHub API + * Previews */ static final String LUKE_CAGE = "application/vnd.github.luke-cage-preview+json"; @@ -68,7 +69,8 @@ /** * Label emoji, search, and descriptions * - * @see GitHub API Previews + * @see GitHub API + * Previews */ static final String SYMMETRA = "application/vnd.github.symmetra-preview+json"; diff --git a/src/main/java/org/kohsuke/github/RateLimitHandler.java b/src/main/java/org/kohsuke/github/RateLimitHandler.java index e5351da541..20c3390b04 100644 --- a/src/main/java/org/kohsuke/github/RateLimitHandler.java +++ b/src/main/java/org/kohsuke/github/RateLimitHandler.java @@ -8,7 +8,7 @@ * Pluggable strategy to determine what to do when the API rate limit is reached. * * @author Kohsuke Kawaguchi - * @see GitHubBuilder#withRateLimitHandler(RateLimitHandler) + * @see GitHubBuilder#withRateLimitHandler(RateLimitHandler) GitHubBuilder#withRateLimitHandler(RateLimitHandler) * @see AbuseLimitHandler */ public abstract class RateLimitHandler { @@ -16,16 +16,18 @@ public abstract class RateLimitHandler { * Called when the library encounters HTTP error indicating that the API rate limit is reached. * *

- * Any exception thrown from this method will cause the request to fail, and the caller of github-api - * will receive an exception. If this method returns normally, another request will be attempted. - * For that to make sense, the implementation needs to wait for some time. + * Any exception thrown from this method will cause the request to fail, and the caller of github-api will receive + * an exception. If this method returns normally, another request will be attempted. For that to make sense, the + * implementation needs to wait for some time. * - * @see API documentation from GitHub * @param e - * Exception from Java I/O layer. If you decide to fail the processing, you can throw - * this exception (or wrap this exception into another exception and throw it.) + * Exception from Java I/O layer. If you decide to fail the processing, you can throw this exception (or + * wrap this exception into another exception and throw it.) * @param uc - * Connection that resulted in an error. Useful for accessing other response headers. + * Connection that resulted in an error. Useful for accessing other response headers. + * @throws IOException + * the io exception + * @see API documentation from GitHub */ public abstract void onError(IOException e, HttpURLConnection uc) throws IOException; @@ -38,15 +40,16 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException { try { Thread.sleep(parseWaitTime(uc)); } catch (InterruptedException x) { - throw (InterruptedIOException)new InterruptedIOException().initCause(e); + throw (InterruptedIOException) new InterruptedIOException().initCause(e); } } private long parseWaitTime(HttpURLConnection uc) { String v = uc.getHeaderField("X-RateLimit-Reset"); - if (v==null) return 10000; // can't tell + if (v == null) + return 10000; // can't tell - return Math.max(10000, Long.parseLong(v)*1000 - System.currentTimeMillis()); + return Math.max(10000, Long.parseLong(v) * 1000 - System.currentTimeMillis()); } }; @@ -56,7 +59,7 @@ private long parseWaitTime(HttpURLConnection uc) { public static final RateLimitHandler FAIL = new RateLimitHandler() { @Override public void onError(IOException e, HttpURLConnection uc) throws IOException { - throw (IOException)new IOException("API rate limit reached").initCause(e); + throw (IOException) new IOException("API rate limit reached").initCause(e); } }; } diff --git a/src/main/java/org/kohsuke/github/Reactable.java b/src/main/java/org/kohsuke/github/Reactable.java index d8821362cf..82908f28d6 100644 --- a/src/main/java/org/kohsuke/github/Reactable.java +++ b/src/main/java/org/kohsuke/github/Reactable.java @@ -7,17 +7,28 @@ * * @author Kohsuke Kawaguchi */ -@Preview @Deprecated +@Preview +@Deprecated public interface Reactable { /** * List all the reactions left to this object. + * + * @return the paged iterable */ - @Preview @Deprecated + @Preview + @Deprecated PagedIterable listReactions(); /** * Leaves a reaction to this object. + * + * @param content + * the content + * @return the gh reaction + * @throws IOException + * the io exception */ - @Preview @Deprecated + @Preview + @Deprecated GHReaction createReaction(ReactionContent content) throws IOException; } diff --git a/src/main/java/org/kohsuke/github/ReactionContent.java b/src/main/java/org/kohsuke/github/ReactionContent.java index 57a204b56d..d1f1a01ed5 100644 --- a/src/main/java/org/kohsuke/github/ReactionContent.java +++ b/src/main/java/org/kohsuke/github/ReactionContent.java @@ -11,12 +11,7 @@ * @see GHReaction */ public enum ReactionContent { - PLUS_ONE("+1"), - MINUS_ONE("-1"), - LAUGH("laugh"), - CONFUSED("confused"), - HEART("heart"), - HOORAY("hooray"); + PLUS_ONE("+1"), MINUS_ONE("-1"), LAUGH("laugh"), CONFUSED("confused"), HEART("heart"), HOORAY("hooray"); private final String content; @@ -24,11 +19,23 @@ public enum ReactionContent { this.content = content; } + /** + * Gets content. + * + * @return the content + */ @JsonValue public String getContent() { return content; } + /** + * For content reaction content. + * + * @param content + * the content + * @return the reaction content + */ @JsonCreator public static ReactionContent forContent(String content) { for (ReactionContent c : ReactionContent.values()) { diff --git a/src/main/java/org/kohsuke/github/Refreshable.java b/src/main/java/org/kohsuke/github/Refreshable.java index 6c75ad63c6..1793a3c430 100644 --- a/src/main/java/org/kohsuke/github/Refreshable.java +++ b/src/main/java/org/kohsuke/github/Refreshable.java @@ -1,26 +1,29 @@ package org.kohsuke.github; -import org.kohsuke.github.extras.ImpatientHttpConnector; - import java.io.IOException; -import java.net.HttpURLConnection; import java.net.URL; /** - * - * + * The interface Refreshable. * * @author Liam Newman */ public interface Refreshable { /** * Opens a connection to the given URL. + * + * @throws IOException + * the io exception */ void refresh() throws IOException; - /** * Calls refresh if the provided value is null + * + * @param value + * the value + * @throws IOException + * the io exception */ default void refresh(Object value) throws IOException { if (value == null) { diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index b2a2a2f9b8..1fe3bab8bb 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -28,8 +28,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import javax.annotation.CheckForNull; -import javax.annotation.WillClose; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -42,11 +40,12 @@ import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.SocketTimeoutException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -60,10 +59,11 @@ import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; +import javax.annotation.CheckForNull; +import javax.annotation.WillClose; + import static java.util.Arrays.asList; -import static java.util.logging.Level.FINE; -import static java.util.logging.Level.FINEST; -import static java.util.logging.Level.INFO; +import static java.util.logging.Level.*; import static org.apache.commons.lang3.StringUtils.defaultString; import static org.kohsuke.github.GitHub.MAPPER; @@ -75,7 +75,7 @@ class Requester { private final GitHub root; private final List args = new ArrayList(); - private final Map headers = new LinkedHashMap(); + private final Map headers = new LinkedHashMap(); /** * Request method. @@ -106,105 +106,179 @@ private Entry(String key, Object value) { /** * Sets the request HTTP header. - * + *

* If a header of the same name is already set, this method overrides it. + * + * @param name + * the name + * @param value + * the value */ public void setHeader(String name, String value) { - headers.put(name,value); + headers.put(name, value); } + /** + * With header requester. + * + * @param name + * the name + * @param value + * the value + * @return the requester + */ public Requester withHeader(String name, String value) { - setHeader(name,value); + setHeader(name, value); return this; } - /*package*/ Requester withPreview(String name) { - return withHeader("Accept",name); + public Requester withPreview(String name) { + return withHeader("Accept", name); } /** - * Makes a request with authentication credential. + * With requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester */ - @Deprecated - public Requester withCredential() { - // keeping it inline with retrieveWithAuth not to enforce the check - // root.requireCredential(); - return this; - } - public Requester with(String key, int value) { - return _with(key, value); + return with(key, (Object) value); } + /** + * With requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester + */ public Requester with(String key, long value) { - return _with(key, value); - } - - public Requester with(String key, Integer value) { - if (value!=null) - _with(key, value); - return this; + return with(key, (Object) value); } + /** + * With requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester + */ public Requester with(String key, boolean value) { - return _with(key, value); - } - public Requester with(String key, Boolean value) { - return _with(key, value); + return with(key, (Object) value); } + /** + * With requester. + * + * @param key + * the key + * @param e + * the e + * @return the requester + */ public Requester with(String key, Enum e) { - if (e==null) return _with(key, null); + if (e == null) + return with(key, (Object) null); return with(key, transformEnum(e)); } + /** + * With requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester + */ public Requester with(String key, String value) { - return _with(key, value); + return with(key, (Object) value); } + /** + * With requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester + */ public Requester with(String key, Collection value) { - return _with(key, value); - } - - public Requester withLogins(String key, Collection users) { - List names = new ArrayList(users.size()); - for (GHUser a : users) { - names.add(a.getLogin()); - } - return with(key,names); + return with(key, (Object) value); } + /** + * With requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester + */ public Requester with(String key, Map value) { - return _with(key, value); - } - - public Requester withPermissions(String key, Map value) { - Map retMap = new HashMap(); - for (Map.Entry entry : value.entrySet()) { - retMap.put(entry.getKey(), transformEnum(entry.getValue())); - } - return _with(key, retMap); + return with(key, (Object) value); } - public Requester with(@WillClose/*later*/ InputStream body) { + /** + * With requester. + * + * @param body + * the body + * @return the requester + */ + public Requester with(@WillClose /* later */ InputStream body) { this.body = body; return this; } - public Requester withNullable(String key, Object value) { - args.add(new Entry(key, value)); - return this; - } + /** + * With nullable requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester + */ + public Requester withNullable(String key, Object value) { + args.add(new Entry(key, value)); + return this; + } - public Requester _with(String key, Object value) { - if (value!=null) { - args.add(new Entry(key,value)); + /** + * With requester. + * + * @param key + * the key + * @param value + * the value + * @return the requester + */ + public Requester with(String key, Object value) { + if (value != null) { + args.add(new Entry(key, value)); } return this; } /** * Unlike {@link #with(String, String)}, overrides the existing value + * + * @param key + * the key + * @param value + * the value + * @return the requester */ public Requester set(String key, Object value) { for (Entry e : args) { @@ -213,14 +287,28 @@ public Requester set(String key, Object value) { return this; } } - return _with(key,value); + return with(key, value); } + /** + * Method requester. + * + * @param method + * the method + * @return the requester + */ public Requester method(String method) { this.method = method; return this; } + /** + * Content type requester. + * + * @param contentType + * the content type + * @return the requester + */ public Requester contentType(String contentType) { this.contentType = contentType; return this; @@ -228,25 +316,38 @@ public Requester contentType(String contentType) { /** * Small number of GitHub APIs use HTTP methods somewhat inconsistently, and use a body where it's not expected. - * Normally whether parameters go as query parameters or a body depends on the HTTP verb in use, - * but this method forces the parameters to be sent as a body. + * Normally whether parameters go as query parameters or a body depends on the HTTP verb in use, but this method + * forces the parameters to be sent as a body. */ - /*package*/ Requester inBody() { + public Requester inBody() { forceBody = true; return this; } + /** + * To. + * + * @param tailApiUrl + * the tail api url + * @throws IOException + * the io exception + */ public void to(String tailApiUrl) throws IOException { - to(tailApiUrl,null); + _to(tailApiUrl, null, null); } /** * Sends a request to the specified URL, and parses the response into the given type via databinding. * + * @param + * the type parameter + * @param tailApiUrl + * the tail api url + * @param type + * the type + * @return {@link Reader} that reads the response. * @throws IOException - * if the server returns 4xx/5xx responses. - * @return - * {@link Reader} that reads the response. + * if the server returns 4xx/5xx responses. */ public T to(String tailApiUrl, Class type) throws IOException { return _to(tailApiUrl, type, null); @@ -254,19 +355,21 @@ public T to(String tailApiUrl, Class type) throws IOException { /** * Like {@link #to(String, Class)} but updates an existing object instead of creating a new instance. + * + * @param + * the type parameter + * @param tailApiUrl + * the tail api url + * @param existingInstance + * the existing instance + * @return the t + * @throws IOException + * the io exception */ public T to(String tailApiUrl, T existingInstance) throws IOException { return _to(tailApiUrl, null, existingInstance); } - /** - * Short for {@code method(method).to(tailApiUrl,type)} - */ - @Deprecated - public T to(String tailApiUrl, Class type, String method) throws IOException { - return method(method).to(tailApiUrl, type); - } - @SuppressFBWarnings("SBSC_USE_STRINGBUFFER_CONCATENATION") private T _to(String tailApiUrl, Class type, T instance) throws IOException { if (!isMethodWithBody() && !args.isEmpty()) { @@ -274,7 +377,7 @@ private T _to(String tailApiUrl, Class type, T instance) throws IOExcepti tailApiUrl += questionMarkFound ? '&' : '?'; for (Iterator it = args.listIterator(); it.hasNext();) { Entry arg = it.next(); - tailApiUrl += arg.key + '=' + URLEncoder.encode(arg.value.toString(),"UTF-8"); + tailApiUrl += arg.key + '=' + URLEncoder.encode(arg.value.toString(), "UTF-8"); if (it.hasNext()) { tailApiUrl += '&'; } @@ -299,7 +402,8 @@ private T _to(String tailApiUrl, Class type, T instance) throws IOExcepti setResponseHeaders(nextResult); final int resultLength = Array.getLength(result); final int nextResultLength = Array.getLength(nextResult); - T concatResult = (T) Array.newInstance(type.getComponentType(), resultLength + nextResultLength); + T concatResult = (T) Array.newInstance(type.getComponentType(), + resultLength + nextResultLength); System.arraycopy(result, 0, concatResult, 0, resultLength); System.arraycopy(nextResult, 0, concatResult, resultLength, nextResultLength); result = concatResult; @@ -317,6 +421,12 @@ private T _to(String tailApiUrl, Class type, T instance) throws IOExcepti /** * Makes a request and just obtains the HTTP status code. + * + * @param tailApiUrl + * the tail api url + * @return the int + * @throws IOException + * the io exception */ public int asHttpStatusCode(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit @@ -335,6 +445,15 @@ public int asHttpStatusCode(String tailApiUrl) throws IOException { } } + /** + * As stream input stream. + * + * @param tailApiUrl + * the tail api url + * @return the input stream + * @throws IOException + * the io exception + */ public InputStream asStream(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit setupConnection(root.getApiURL(tailApiUrl)); @@ -352,61 +471,70 @@ public InputStream asStream(String tailApiUrl) throws IOException { } private void noteRateLimit(String tailApiUrl) { - if ("/rate_limit".equals(tailApiUrl)) { - // the rate_limit API is "free" - return; - } if (tailApiUrl.startsWith("/search")) { // the search API uses a different rate limit return; } - String limit = uc.getHeaderField("X-RateLimit-Limit"); - if (StringUtils.isBlank(limit)) { + String limitString = uc.getHeaderField("X-RateLimit-Limit"); + if (StringUtils.isBlank(limitString)) { // if we are missing a header, return fast return; } - String remaining = uc.getHeaderField("X-RateLimit-Remaining"); - if (StringUtils.isBlank(remaining)) { + String remainingString = uc.getHeaderField("X-RateLimit-Remaining"); + if (StringUtils.isBlank(remainingString)) { // if we are missing a header, return fast return; } - String reset = uc.getHeaderField("X-RateLimit-Reset"); - if (StringUtils.isBlank(reset)) { + String resetString = uc.getHeaderField("X-RateLimit-Reset"); + if (StringUtils.isBlank(resetString)) { // if we are missing a header, return fast return; } - GHRateLimit observed = new GHRateLimit(); + + int limit, remaining; + long reset; try { - observed.limit = Integer.parseInt(limit); + limit = Integer.parseInt(limitString); } catch (NumberFormatException e) { if (LOGGER.isLoggable(FINEST)) { - LOGGER.log(FINEST, "Malformed X-RateLimit-Limit header value " + limit, e); + LOGGER.log(FINEST, "Malformed X-RateLimit-Limit header value " + limitString, e); } return; } try { - observed.remaining = Integer.parseInt(remaining); + + remaining = Integer.parseInt(remainingString); } catch (NumberFormatException e) { if (LOGGER.isLoggable(FINEST)) { - LOGGER.log(FINEST, "Malformed X-RateLimit-Remaining header value " + remaining, e); + LOGGER.log(FINEST, "Malformed X-RateLimit-Remaining header value " + remainingString, e); } return; } try { - observed.reset = new Date(Long.parseLong(reset)); // this is madness, storing the date as seconds - root.updateRateLimit(observed); + reset = Long.parseLong(resetString); } catch (NumberFormatException e) { if (LOGGER.isLoggable(FINEST)) { - LOGGER.log(FINEST, "Malformed X-RateLimit-Reset header value " + reset, e); + LOGGER.log(FINEST, "Malformed X-RateLimit-Reset header value " + resetString, e); } + return; } + + GHRateLimit.Record observed = new GHRateLimit.Record(limit, remaining, reset, uc.getHeaderField("Date")); + + root.updateCoreRateLimit(observed); } + /** + * Gets response header. + * + * @param header + * the header + * @return the response header + */ public String getResponseHeader(String header) { return uc.getHeaderField(header); } - /** * Set up the request parameters or POST payload. */ @@ -415,14 +543,14 @@ private void buildRequest() throws IOException { uc.setDoOutput(true); if (body == null) { - uc.setRequestProperty("Content-type", defaultString(contentType,"application/json")); + uc.setRequestProperty("Content-type", defaultString(contentType, "application/json")); Map json = new HashMap(); for (Entry e : args) { json.put(e.key, e.value); } MAPPER.writeValue(uc.getOutputStream(), json); } else { - uc.setRequestProperty("Content-type", defaultString(contentType,"application/x-www-form-urlencoded")); + uc.setRequestProperty("Content-type", defaultString(contentType, "application/x-www-form-urlencoded")); try { byte[] bytes = new byte[32768]; int read; @@ -440,18 +568,18 @@ private boolean isMethodWithBody() { return forceBody || !METHODS_WITHOUT_BODY.contains(method); } - /*package*/ PagedIterable asPagedIterable(String tailApiUrl, Class type, Consumer consumer) { - return new PagedIterableWithConsumer(type, this, tailApiUrl, consumer); + PagedIterable asPagedIterable(String tailApiUrl, Class type, Consumer consumer) { + return new PagedIterableWithConsumer<>(type, this, tailApiUrl, consumer); } - private static class PagedIterableWithConsumer extends PagedIterable { + static class PagedIterableWithConsumer extends PagedIterable { private final Class clazz; private final Requester requester; private final String tailApiUrl; private final Consumer consumer; - public PagedIterableWithConsumer(Class clazz, Requester requester, String tailApiUrl, Consumer consumer) { + PagedIterableWithConsumer(Class clazz, Requester requester, String tailApiUrl, Consumer consumer) { this.clazz = clazz; this.tailApiUrl = tailApiUrl; this.requester = requester; @@ -479,11 +607,11 @@ protected void wrapUp(S[] page) { * * Every iterator call reports a new batch. */ - /*package*/ Iterator asIterator(String tailApiUrl, Class type, int pageSize) { + Iterator asIterator(String tailApiUrl, Class type, int pageSize) { method("GET"); - if (pageSize!=0) - args.add(new Entry("per_page",pageSize)); + if (pageSize != 0) + args.add(new Entry("per_page", pageSize)); StringBuilder s = new StringBuilder(tailApiUrl); if (!args.isEmpty()) { @@ -497,14 +625,14 @@ protected void wrapUp(S[] page) { s.append(URLEncoder.encode(a.value.toString(), "UTF-8")); } } catch (UnsupportedEncodingException e) { - throw new AssertionError(e); // UTF-8 is mandatory + throw new AssertionError(e); // UTF-8 is mandatory } } try { return new PagingIterator(type, tailApiUrl, root.getApiURL(s.toString())); } catch (IOException e) { - throw new GHException("Unable to build github Api URL",e); + throw new GHException("Unable to build github Api URL", e); } } @@ -531,13 +659,14 @@ class PagingIterator implements Iterator { public boolean hasNext() { fetch(); - return next!=null; + return next != null; } public T next() { fetch(); T r = next; - if (r==null) throw new NoSuchElementException(); + if (r == null) + throw new NoSuchElementException(); next = null; return r; } @@ -547,15 +676,17 @@ public void remove() { } private void fetch() { - if (next!=null) return; // already fetched - if (url==null) return; // no more data to fetch + if (next != null) + return; // already fetched + if (url == null) + return; // no more data to fetch try { while (true) {// loop while API rate limit is hit setupConnection(url); try { - next = parse(type,null); - assert next!=null; + next = parse(type, null); + assert next != null; findNextURL(); return; } catch (IOException e) { @@ -575,14 +706,15 @@ private void fetch() { private void findNextURL() throws MalformedURLException { url = null; // start defensively String link = uc.getHeaderField("Link"); - if (link==null) return; + if (link == null) + return; for (String token : link.split(", ")) { if (token.endsWith("rel=\"next\"")) { // found the next page. This should look something like // ; rel="next" int idx = token.indexOf('>'); - url = new URL(token.substring(1,idx)); + url = new URL(token.substring(1, idx)); return; } } @@ -591,21 +723,22 @@ private void findNextURL() throws MalformedURLException { } } - private void setupConnection(URL url) throws IOException { if (LOGGER.isLoggable(FINE)) { - LOGGER.log(FINE, "GitHub API request [" + (root.login == null ? "anonymous" : root.login) + "]: " + method + " " + url.toString()); + LOGGER.log(FINE, + "GitHub API request [" + (root.login == null ? "anonymous" : root.login) + "]: " + method + " " + + url.toString()); } uc = root.getConnector().connect(url); // if the authentication is needed but no credential is given, try it anyway (so that some calls // that do work with anonymous access in the reduced form should still work.) - if (root.encodedAuthorization!=null) + if (root.encodedAuthorization != null) uc.setRequestProperty("Authorization", root.encodedAuthorization); for (Map.Entry e : headers.entrySet()) { String v = e.getValue(); - if (v!=null) + if (v != null) uc.setRequestProperty(e.getKey(), v); } @@ -621,9 +754,9 @@ private void setRequestMethod(HttpURLConnection uc) throws IOException { try { Field $method = HttpURLConnection.class.getDeclaredField("method"); $method.setAccessible(true); - $method.set(uc,method); + $method.set(uc, method); } catch (Exception x) { - throw (IOException)new IOException("Failed to set the custom verb").initCause(x); + throw (IOException) new IOException("Failed to set the custom verb").initCause(x); } // sun.net.www.protocol.https.DelegatingHttpsURLConnection delegates to another HttpURLConnection try { @@ -637,11 +770,11 @@ private void setRequestMethod(HttpURLConnection uc) throws IOException { } catch (NoSuchFieldException x) { // no problem } catch (IllegalAccessException x) { - throw (IOException)new IOException("Failed to set the custom verb").initCause(x); + throw (IOException) new IOException("Failed to set the custom verb").initCause(x); } } if (!uc.getRequestMethod().equals(method)) - throw new IllegalStateException("Failed to set the request method to "+method); + throw new IllegalStateException("Failed to set the request method to " + method); } @CheckForNull @@ -657,35 +790,46 @@ private T parse(Class type, T instance, int timeouts) throws IOException responseCode = uc.getResponseCode(); responseMessage = uc.getResponseMessage(); if (responseCode == 304) { - return null; // special case handling for 304 unmodified, as the content will be "" + return null; // special case handling for 304 unmodified, as the content will be "" } - if (responseCode == 204 && type!=null && type.isArray()) { + if (responseCode == 204 && type != null && type.isArray()) { // no content - return type.cast(Array.newInstance(type.getComponentType(),0)); + return type.cast(Array.newInstance(type.getComponentType(), 0)); } - // Response code 202 means the statistics are still being cached. + // Response code 202 means data is being generated still being cached. + // This happens in for statistics: // See https://developer.github.com/v3/repos/statistics/#a-word-about-caching + // And for fork creation: + // See https://developer.github.com/v3/repos/forks/#create-a-fork if (responseCode == 202) { - LOGGER.log(INFO, "The statistics are still being generated. Please try again in 5 seconds."); + if (uc.getURL().toString().endsWith("/forks")) { + LOGGER.log(INFO, "The fork is being created. Please try again in 5 seconds."); + } else if (uc.getURL().toString().endsWith("/statistics")) { + LOGGER.log(INFO, "The statistics are being generated. Please try again in 5 seconds."); + } else { + LOGGER.log(INFO, + "Received 202 from " + uc.getURL().toString() + " . Please try again in 5 seconds."); + } // Maybe throw an exception instead? return null; } r = new InputStreamReader(wrapStream(uc.getInputStream()), "UTF-8"); String data = IOUtils.toString(r); - if (type!=null) + if (type != null) try { return setResponseHeaders(MAPPER.readValue(data, type)); } catch (JsonMappingException e) { - throw (IOException)new IOException("Failed to deserialize " +data).initCause(e); + throw (IOException) new IOException("Failed to deserialize " + data).initCause(e); } - if (instance!=null) { + if (instance != null) { return setResponseHeaders(MAPPER.readerForUpdating(instance).readValue(data)); } return null; } catch (FileNotFoundException e) { - // java.net.URLConnection handles 404 exception has FileNotFoundException, don't wrap exception in HttpException + // java.net.URLConnection handles 404 exception has FileNotFoundException, don't wrap exception in + // HttpException // to preserve backward compatibility throw e; } catch (IOException e) { @@ -706,6 +850,9 @@ private T setResponseHeaders(T readValue) { } } else if (readValue instanceof GHObject) { setResponseHeaders((GHObject) readValue); + } else if (readValue instanceof JsonRateLimit) { + // if we're getting a GHRateLimit it needs the server date + ((JsonRateLimit) readValue).resources.getCore().recalculateResetDate(uc.getHeaderField("Date")); } return readValue; } @@ -719,16 +866,18 @@ private void setResponseHeaders(GHObject readValue) { */ private InputStream wrapStream(InputStream in) throws IOException { String encoding = uc.getContentEncoding(); - if (encoding==null || in==null) return in; - if (encoding.equals("gzip")) return new GZIPInputStream(in); + if (encoding == null || in == null) + return in; + if (encoding.equals("gzip")) + return new GZIPInputStream(in); - throw new UnsupportedOperationException("Unexpected Content-Encoding: "+encoding); + throw new UnsupportedOperationException("Unexpected Content-Encoding: " + encoding); } /** * Handle API error by either throwing it or by returning normally to retry. */ - /*package*/ void handleApiError(IOException e) throws IOException { + void handleApiError(IOException e) throws IOException { int responseCode; try { responseCode = uc.getResponseCode(); @@ -736,8 +885,10 @@ private InputStream wrapStream(InputStream in) throws IOException { // likely to be a network exception (e.g. SSLHandshakeException), // uc.getResponseCode() and any other getter on the response will cause an exception if (LOGGER.isLoggable(FINE)) - LOGGER.log(FINE, "Silently ignore exception retrieving response code for '" + uc.getURL() + "'" + - " handling exception " + e, e); + LOGGER.log(FINE, + "Silently ignore exception retrieving response code for '" + uc.getURL() + "'" + + " handling exception " + e, + e); throw e; } InputStream es = wrapStream(uc.getErrorStream()); @@ -749,8 +900,7 @@ private InputStream wrapStream(InputStream in) throws IOException { e = (IOException) new GHFileNotFoundException(error).withResponseHeaderFields(uc).initCause(e); } else if (e instanceof HttpException) { HttpException http = (HttpException) e; - e = new HttpException(error, http.getResponseCode(), http.getResponseMessage(), - http.getUrl(), e); + e = new HttpException(error, http.getResponseCode(), http.getResponseMessage(), http.getUrl(), e); } else { e = (IOException) new GHIOException(error).withResponseHeaderFields(uc).initCause(e); } @@ -758,18 +908,22 @@ private InputStream wrapStream(InputStream in) throws IOException { IOUtils.closeQuietly(es); } } - if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 / Unauthorized == bad creds - throw e; + if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 Unauthorized == bad creds or OTP request + // In the case of a user with 2fa enabled, a header with X-GitHub-OTP + // will be returned indicating the user needs to respond with an otp + if (uc.getHeaderField("X-GitHub-OTP") != null) + throw (IOException) new GHOTPRequiredException().withResponseHeaderFields(uc).initCause(e); + else + throw e; // usually org.kohsuke.github.HttpException (which extends IOException) if ("0".equals(uc.getHeaderField("X-RateLimit-Remaining"))) { - root.rateLimitHandler.onError(e,uc); + root.rateLimitHandler.onError(e, uc); return; } // Retry-After is not documented but apparently that field exists - if (responseCode == HttpURLConnection.HTTP_FORBIDDEN && - uc.getHeaderField("Retry-After") != null) { - this.root.abuseLimitHandler.onError(e,uc); + if (responseCode == HttpURLConnection.HTTP_FORBIDDEN && uc.getHeaderField("Retry-After") != null) { + this.root.abuseLimitHandler.onError(e, uc); return; } @@ -778,16 +932,33 @@ private InputStream wrapStream(InputStream in) throws IOException { /** * Transform Java Enum into Github constants given its conventions - * @param en - Enum to be transformed + * + * @param en + * Enum to be transformed * @return a String containing the value of a Github constant */ - private String transformEnum(Enum en){ + static String transformEnum(Enum en) { // by convention Java constant names are upper cases, but github uses // lower-case constants. GitHub also uses '-', which in Java we always // replace by '_' return en.toString().toLowerCase(Locale.ENGLISH).replace('_', '-'); } + /** + * Encode the path to url safe string. + * + * @param value + * string to be path encoded. + * @return The encoded string. + */ + public static String urlPathEncode(String value) { + try { + return new URI(null, null, value, null, null).toString(); + } catch (URISyntaxException ex) { + throw new AssertionError(ex); + } + } + private static final List METHODS_WITHOUT_BODY = asList("GET", "DELETE"); private static final Logger LOGGER = Logger.getLogger(Requester.class.getName()); } diff --git a/src/main/java/org/kohsuke/github/SearchResult.java b/src/main/java/org/kohsuke/github/SearchResult.java index 2fb2dca06e..e3b86a9e97 100644 --- a/src/main/java/org/kohsuke/github/SearchResult.java +++ b/src/main/java/org/kohsuke/github/SearchResult.java @@ -10,12 +10,12 @@ abstract class SearchResult { @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization") int total_count; - + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization") boolean incomplete_results; /** * Wraps up the retrieved object and return them. Only called once. */ - /*package*/ abstract T[] getItems(GitHub root); + abstract T[] getItems(GitHub root); } diff --git a/src/main/java/org/kohsuke/github/TrafficInfo.java b/src/main/java/org/kohsuke/github/TrafficInfo.java index 9b232e9f1a..a23e6c033f 100644 --- a/src/main/java/org/kohsuke/github/TrafficInfo.java +++ b/src/main/java/org/kohsuke/github/TrafficInfo.java @@ -1,16 +1,22 @@ package org.kohsuke.github; /** + * The interface TrafficInfo. + * * @author Kohsuke Kawaguchi */ public interface TrafficInfo { /** * Total count of hits. + * + * @return the count */ int getCount(); /** * Unique visitors. + * + * @return the uniques */ int getUniques(); } diff --git a/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java b/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java new file mode 100644 index 0000000000..c9e96613bd --- /dev/null +++ b/src/main/java/org/kohsuke/github/example/dataobject/ReadOnlyObjects.java @@ -0,0 +1,551 @@ +package org.kohsuke.github.example.dataobject; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +/** + * {@link org.kohsuke.github.GHMeta} wraps the list of GitHub's IP addresses. + *

+ * This class is used to show examples of different ways to create simple read-only data objects. For data objects that + * can be modified, perform actions, or get other objects we'll need other examples. + *

+ * IMPORTANT: There is no one right way to do this, but there are better and worse. + *

    + *
  • Better: {@link GHMetaGettersUnmodifiable} is a good balance of clarity and brevity
  • + *
  • Worse: {@link GHMetaPublic} exposes setters that are not needed, making it unclear that fields are actually + * read-only
  • + *
+ * + * @author Liam Newman + * @see org.kohsuke.github.GHMeta + * @see Get Meta + */ +public final class ReadOnlyObjects { + + /** + * All GHMeta data objects should expose these values. + * + * @author Liam Newman + */ + public interface GHMetaExample { + /** + * Is verifiable password authentication boolean. + * + * @return the boolean + */ + boolean isVerifiablePasswordAuthentication(); + + /** + * Gets hooks. + * + * @return the hooks + */ + List getHooks(); + + /** + * Gets git. + * + * @return the git + */ + List getGit(); + + /** + * Gets web. + * + * @return the web + */ + List getWeb(); + + /** + * Gets api. + * + * @return the api + */ + List getApi(); + + /** + * Gets pages. + * + * @return the pages + */ + List getPages(); + + /** + * Gets importer. + * + * @return the importer + */ + List getImporter(); + } + + /** + * This version uses public getters and setters and leaves it up to Jackson how it wants to fill them. + *

+ * Pro: + *

    + *
  • Easy to create
  • + *
  • Not much code
  • + *
  • Mininal annotations
  • + *
+ * Con: + *
    + *
  • Exposes public setters for fields that should not be changed
  • + *
  • Lists modifiable when they should not be changed
  • + *
  • Jackson generally doesn't call the setters, it just sets the fields directly
  • + *
+ * + * @author Paulo Miguel Almeida + * @see org.kohsuke.github.GHMeta + */ + public static class GHMetaPublic implements GHMetaExample { + + @JsonProperty("verifiable_password_authentication") + private boolean verifiablePasswordAuthentication; + private List hooks; + private List git; + private List web; + private List api; + private List pages; + private List importer; + + public boolean isVerifiablePasswordAuthentication() { + return verifiablePasswordAuthentication; + } + + /** + * Sets verifiable password authentication. + * + * @param verifiablePasswordAuthentication + * the verifiable password authentication + */ + public void setVerifiablePasswordAuthentication(boolean verifiablePasswordAuthentication) { + this.verifiablePasswordAuthentication = verifiablePasswordAuthentication; + } + + public List getHooks() { + return hooks; + } + + /** + * Sets hooks. + * + * @param hooks + * the hooks + */ + public void setHooks(List hooks) { + this.hooks = hooks; + } + + public List getGit() { + return git; + } + + /** + * Sets git. + * + * @param git + * the git + */ + public void setGit(List git) { + this.git = git; + } + + public List getWeb() { + return web; + } + + /** + * Sets web. + * + * @param web + * the web + */ + public void setWeb(List web) { + this.web = web; + } + + public List getApi() { + return api; + } + + /** + * Sets api. + * + * @param api + * the api + */ + public void setApi(List api) { + this.api = api; + } + + public List getPages() { + return pages; + } + + /** + * Sets pages. + * + * @param pages + * the pages + */ + public void setPages(List pages) { + this.pages = pages; + } + + public List getImporter() { + return importer; + } + + /** + * Sets importer. + * + * @param importer + * the importer + */ + public void setImporter(List importer) { + this.importer = importer; + } + + } + + /** + * This version uses public getters and shows that package or private setters both can be used by jackson. You can + * check this by running in debug and setting break points in the setters. + * + *

+ * Pro: + *

    + *
  • Easy to create
  • + *
  • Not much code
  • + *
  • Some annotations
  • + *
+ * Con: + *
    + *
  • Exposes some package setters for fields that should not be changed, better than public
  • + *
  • Lists modifiable when they should not be changed
  • + *
+ * + * @author Liam Newman + * @see org.kohsuke.github.GHMeta + */ + public static class GHMetaPackage implements GHMetaExample { + + private boolean verifiablePasswordAuthentication; + private List hooks; + private List git; + private List web; + private List api; + private List pages; + + /** + * Missing {@link JsonProperty} or having it on the field will cause Jackson to ignore getters and setters. + */ + @JsonProperty + private List importer; + + @JsonProperty("verifiable_password_authentication") + public boolean isVerifiablePasswordAuthentication() { + return verifiablePasswordAuthentication; + } + + private void setVerifiablePasswordAuthentication(boolean verifiablePasswordAuthentication) { + this.verifiablePasswordAuthentication = verifiablePasswordAuthentication; + } + + @JsonProperty + public List getHooks() { + return hooks; + } + + /** + * Setters can be private (or package local) and will still be called by Jackson. The {@link JsonProperty} can + * got on the getter or setter and still work. + * + * @param hooks + * list of hooks + */ + private void setHooks(List hooks) { + this.hooks = hooks; + } + + public List getGit() { + return git; + } + + /** + * Since we mostly use Jackson for deserialization, {@link JsonSetter} is also okay, but {@link JsonProperty} is + * preferred. + * + * @param git + * list of git addresses + */ + @JsonSetter + void setGit(List git) { + this.git = git; + } + + public List getWeb() { + return web; + } + + /** + * The {@link JsonProperty} can got on the getter or setter and still work. + * + * @param web + * list of web addresses + */ + void setWeb(List web) { + this.web = web; + } + + @JsonProperty + public List getApi() { + return api; + } + + void setApi(List api) { + this.api = api; + } + + @JsonProperty + public List getPages() { + return pages; + } + + void setPages(List pages) { + this.pages = pages; + } + + /** + * Missing {@link JsonProperty} or having it on the field will cause Jackson to ignore getters and setters. + * + * @return list of importer addresses + */ + public List getImporter() { + return importer; + } + + /** + * Missing {@link JsonProperty} or having it on the field will cause Jackson to ignore getters and setters. + * + * @param importer + * list of importer addresses + */ + void setImporter(List importer) { + this.importer = importer; + } + + } + + /** + * This version uses only public getters and returns unmodifiable lists. + * + * + *

+ * Pro: + *

    + *
  • Very Easy to create
  • + *
  • Minimal code
  • + *
  • Mininal annotations
  • + *
  • Fields effectively final and lists unmodifiable
  • + *
+ * Con: + *
    + *
  • Effectively final is not quite really final
  • + *
  • If one of the lists were missing (an option member, for example), it will throw NPE but we could mitigate by + * checking for null or assigning a default.
  • + *
+ * + * @author Liam Newman + * @see org.kohsuke.github.GHMeta + */ + public static class GHMetaGettersUnmodifiable implements GHMetaExample { + + @JsonProperty("verifiable_password_authentication") + private boolean verifiablePasswordAuthentication; + private List hooks; + private List git; + private List web; + private List api; + private List pages; + /** + * If this were an optional member, we could fill it with an empty list by default. + */ + private List importer = new ArrayList<>(); + + public boolean isVerifiablePasswordAuthentication() { + return verifiablePasswordAuthentication; + } + + public List getHooks() { + return Collections.unmodifiableList(hooks); + } + + public List getGit() { + return Collections.unmodifiableList(git); + } + + public List getWeb() { + return Collections.unmodifiableList(web); + } + + public List getApi() { + return Collections.unmodifiableList(api); + } + + public List getPages() { + return Collections.unmodifiableList(pages); + } + + public List getImporter() { + return Collections.unmodifiableList(importer); + } + } + + /** + * This version uses only public getters and returns unmodifiable lists and has final fields + *

+ * Pro: + *

    + *
  • Moderate amount of code
  • + *
  • More annotations
  • + *
  • Fields final and lists unmodifiable
  • + *
+ * Con: + *
    + *
  • Extra allocations - default array lists will be replaced by Jackson (yes, even though they are final)
  • + *
  • Added constructor is annoying
  • + *
  • If this object could be refreshed or populated, then the final is misleading (and possibly buggy)
  • + *
+ * + * @author Liam Newman + * @see org.kohsuke.github.GHMeta + */ + public static class GHMetaGettersFinal implements GHMetaExample { + + private final boolean verifiablePasswordAuthentication; + private final List hooks = new ArrayList<>(); + private final List git = new ArrayList<>(); + private final List web = new ArrayList<>(); + private final List api = new ArrayList<>(); + private final List pages = new ArrayList<>(); + private final List importer = new ArrayList<>(); + + @JsonCreator + private GHMetaGettersFinal( + @JsonProperty("verifiable_password_authentication") boolean verifiablePasswordAuthentication) { + // boolean fields when final seem to be really final, so we have to switch to constructor + this.verifiablePasswordAuthentication = verifiablePasswordAuthentication; + } + + public boolean isVerifiablePasswordAuthentication() { + return verifiablePasswordAuthentication; + } + + public List getHooks() { + return Collections.unmodifiableList(hooks); + } + + public List getGit() { + return Collections.unmodifiableList(git); + } + + public List getWeb() { + return Collections.unmodifiableList(web); + } + + public List getApi() { + return Collections.unmodifiableList(api); + } + + public List getPages() { + return Collections.unmodifiableList(pages); + } + + public List getImporter() { + return Collections.unmodifiableList(importer); + } + } + + /** + * This version uses only public getters and returns unmodifiable lists + *

+ * Pro: + *

    + *
  • Fields final and lists unmodifiable
  • + *
  • Construction behavior can be controlled - if values depended on each other or needed to be set in a specific + * order, this could do that.
  • + *
+ * Con: + *
    + *
  • There is no way you'd know about this without some research
  • + *
  • Specific annotations needed
  • + *
  • Brittle and verbose - not friendly to optional fields or large number of fields
  • + *
+ * + * @author Liam Newman + * @see org.kohsuke.github.GHMeta + */ + public static class GHMetaGettersFinalCreator implements GHMetaExample { + + private final boolean verifiablePasswordAuthentication; + private final List hooks; + private final List git; + private final List web; + private final List api; + private final List pages; + private final List importer; + + @JsonCreator + private GHMetaGettersFinalCreator(@Nonnull @JsonProperty("hooks") List hooks, + @Nonnull @JsonProperty("git") List git, + @Nonnull @JsonProperty("web") List web, + @Nonnull @JsonProperty("api") List api, + @Nonnull @JsonProperty("pages") List pages, + @Nonnull @JsonProperty("importer") List importer, + @JsonProperty("verifiable_password_authentication") boolean verifiablePasswordAuthentication) { + this.verifiablePasswordAuthentication = verifiablePasswordAuthentication; + this.hooks = Collections.unmodifiableList(hooks); + this.git = Collections.unmodifiableList(git); + this.web = Collections.unmodifiableList(web); + this.api = Collections.unmodifiableList(api); + this.pages = Collections.unmodifiableList(pages); + this.importer = Collections.unmodifiableList(importer); + } + + public boolean isVerifiablePasswordAuthentication() { + return verifiablePasswordAuthentication; + } + + public List getHooks() { + return hooks; + } + + public List getGit() { + return git; + } + + public List getWeb() { + return web; + } + + public List getApi() { + return api; + } + + public List getPages() { + return pages; + } + + public List getImporter() { + return importer; + } + } +} diff --git a/src/main/java/org/kohsuke/github/extras/ImpatientHttpConnector.java b/src/main/java/org/kohsuke/github/extras/ImpatientHttpConnector.java index 740b9a037d..c02d75bdf1 100644 --- a/src/main/java/org/kohsuke/github/extras/ImpatientHttpConnector.java +++ b/src/main/java/org/kohsuke/github/extras/ImpatientHttpConnector.java @@ -18,10 +18,14 @@ public class ImpatientHttpConnector implements HttpConnector { private final int readTimeout, connectTimeout; /** + * Instantiates a new Impatient http connector. + * + * @param base + * the base * @param connectTimeout - * HTTP connection timeout in milliseconds + * HTTP connection timeout in milliseconds * @param readTimeout - * HTTP read timeout in milliseconds + * HTTP read timeout in milliseconds */ public ImpatientHttpConnector(HttpConnector base, int connectTimeout, int readTimeout) { this.base = base; @@ -29,12 +33,26 @@ public ImpatientHttpConnector(HttpConnector base, int connectTimeout, int readTi this.readTimeout = readTimeout; } + /** + * Instantiates a new Impatient http connector. + * + * @param base + * the base + * @param timeout + * the timeout + */ public ImpatientHttpConnector(HttpConnector base, int timeout) { - this(base,timeout,timeout); + this(base, timeout, timeout); } + /** + * Instantiates a new Impatient http connector. + * + * @param base + * the base + */ public ImpatientHttpConnector(HttpConnector base) { - this(base,CONNECT_TIMEOUT,READ_TIMEOUT); + this(base, CONNECT_TIMEOUT, READ_TIMEOUT); } public HttpURLConnection connect(URL url) throws IOException { diff --git a/src/main/java/org/kohsuke/github/extras/OkHttp3Connector.java b/src/main/java/org/kohsuke/github/extras/OkHttp3Connector.java index 17b93b3318..7e9dabe35c 100644 --- a/src/main/java/org/kohsuke/github/extras/OkHttp3Connector.java +++ b/src/main/java/org/kohsuke/github/extras/OkHttp3Connector.java @@ -10,20 +10,24 @@ /** * {@link HttpConnector} for {@link OkHttpClient}. + *

+ * Unlike {@link #DEFAULT}, OkHttp does response caching. Making a conditional request against GitHubAPI and receiving a + * 304 response does not count against the rate limit. See http://developer.github.com/v3/#conditional-requests * - * Unlike {@link #DEFAULT}, OkHttp does response caching. - * Making a conditional request against GitHubAPI and receiving a 304 - * response does not count against the rate limit. - * See http://developer.github.com/v3/#conditional-requests - * - * @see org.kohsuke.github.extras.okhttp3.OkHttpConnector * @author Roberto Tyley * @author Kohsuke Kawaguchi + * @see org.kohsuke.github.extras.okhttp3.OkHttpConnector */ @Deprecated public class OkHttp3Connector implements HttpConnector { private final OkUrlFactory urlFactory; + /** + * Instantiates a new Ok http 3 connector. + * + * @param urlFactory + * the url factory + */ /* * @see org.kohsuke.github.extras.okhttp3.OkHttpConnector */ diff --git a/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java b/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java index 60b41e18ea..9c54c71cb7 100644 --- a/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java +++ b/src/main/java/org/kohsuke/github/extras/OkHttpConnector.java @@ -4,17 +4,13 @@ import com.squareup.okhttp.ConnectionSpec; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkUrlFactory; - import org.kohsuke.github.HttpConnector; import java.io.IOException; - import java.net.HttpURLConnection; import java.net.URL; - import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; - import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; @@ -24,11 +20,9 @@ /** * {@link HttpConnector} for {@link OkHttpClient}. - * - * Unlike {@link #DEFAULT}, OkHttp does response caching. - * Making a conditional request against GitHubAPI and receiving a 304 - * response does not count against the rate limit. - * See http://developer.github.com/v3/#conditional-requests + *

+ * Unlike {@link #DEFAULT}, OkHttp does response caching. Making a conditional request against GitHubAPI and receiving a + * 304 response does not count against the rate limit. See http://developer.github.com/v3/#conditional-requests * * @author Roberto Tyley * @author Kohsuke Kawaguchi @@ -39,12 +33,19 @@ public class OkHttpConnector implements HttpConnector { private final String maxAgeHeaderValue; + /** + * Instantiates a new Ok http connector. + * + * @param urlFactory + * the url factory + */ public OkHttpConnector(OkUrlFactory urlFactory) { this(urlFactory, 0); } /** * package private for tests to be able to change max-age for cache. + * * @param urlFactory * @param cacheMaxAge */ @@ -54,16 +55,12 @@ public OkHttpConnector(OkUrlFactory urlFactory) { this.urlFactory = urlFactory; if (cacheMaxAge >= 0 && urlFactory.client() != null && urlFactory.client().getCache() != null) { - maxAgeHeaderValue = new CacheControl.Builder() - .maxAge(cacheMaxAge, TimeUnit.SECONDS) - .build() - .toString(); + maxAgeHeaderValue = new CacheControl.Builder().maxAge(cacheMaxAge, TimeUnit.SECONDS).build().toString(); } else { maxAgeHeaderValue = null; } } - public HttpURLConnection connect(URL url) throws IOException { HttpURLConnection urlConnection = urlFactory.open(url); if (maxAgeHeaderValue != null) { diff --git a/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java b/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java index 7a4b53f11a..ba38334d0c 100644 --- a/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java +++ b/src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java @@ -1,5 +1,25 @@ package org.kohsuke.github.extras.okhttp3; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Dispatcher; +import okhttp3.Handshake; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Protocol; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; +import okio.Pipe; +import okio.Timeout; + /* * Copyright (C) 2014 Square, Inc. * @@ -15,7 +35,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -40,1154 +59,1311 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; + import javax.annotation.Nullable; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.Dispatcher; -import okhttp3.Handshake; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.Interceptor; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Protocol; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okio.Buffer; -import okio.BufferedSink; -import okio.Okio; -import okio.Pipe; -import okio.Timeout; - import static java.net.HttpURLConnection.HTTP_NOT_MODIFIED; import static java.net.HttpURLConnection.HTTP_NO_CONTENT; /** - * OkHttp 3.14 dropped support for the long-deprecated OkUrlFactory class, which allows you to use - * the HttpURLConnection API with OkHttp's implementation. This class does the same thing using only - * public APIs in OkHttp. It requires OkHttp 3.14 or newer. + * OkHttp 3.14 dropped support for the long-deprecated OkUrlFactory class, which allows you to use the HttpURLConnection + * API with OkHttp's implementation. This class does the same thing using only public APIs in OkHttp. It requires OkHttp + * 3.14 or newer. * - *

Rather than pasting this 1100 line gist into your source code, please upgrade to OkHttp's - * request/response API. Your code will be shorter, easier to read, and you'll be able to use - * interceptors. + *

+ * Rather than pasting this 1100 line gist into your source code, please upgrade to OkHttp's request/response API. Your + * code will be shorter, easier to read, and you'll be able to use interceptors. */ public final class ObsoleteUrlFactory implements URLStreamHandlerFactory, Cloneable { - static final String SELECTED_PROTOCOL = "ObsoleteUrlFactory-Selected-Protocol"; - - static final String RESPONSE_SOURCE = "ObsoleteUrlFactory-Response-Source"; - - static final Set METHODS = new LinkedHashSet<>( - Arrays.asList("OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "PATCH")); - - static final TimeZone UTC = TimeZone.getTimeZone("GMT"); - - static final int HTTP_CONTINUE = 100; - - static final ThreadLocal STANDARD_DATE_FORMAT = ThreadLocal.withInitial(() -> { - // Date format specified by RFC 7231 section 7.1.1.1. - DateFormat rfc1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); - rfc1123.setLenient(false); - rfc1123.setTimeZone(UTC); - return rfc1123; - }); - - static final Comparator FIELD_NAME_COMPARATOR = (a, b) -> { - if (Objects.equals(a, b)) { - return 0; - } else if (Objects.isNull(a)) { - return -1; - } else if (Objects.isNull(b)) { - return 1; - } else { - return String.CASE_INSENSITIVE_ORDER.compare(a, b); - } - }; - - private OkHttpClient client; - - public ObsoleteUrlFactory(OkHttpClient client) { - this.client = client; - } - - public OkHttpClient client() { - return client; - } - - public ObsoleteUrlFactory setClient(OkHttpClient client) { - this.client = client; - return this; - } - - /** - * Returns a copy of this stream handler factory that includes a shallow copy of the internal - * {@linkplain OkHttpClient HTTP client}. - */ - @Override public ObsoleteUrlFactory clone() { - return new ObsoleteUrlFactory(client); - } - - public HttpURLConnection open(URL url) { - return open(url, client.proxy()); - } - - HttpURLConnection open(URL url, @Nullable Proxy proxy) { - String protocol = url.getProtocol(); - OkHttpClient copy = client.newBuilder() - .proxy(proxy) - .build(); - - if (protocol.equals("http")) return new OkHttpURLConnection(url, copy); - if (protocol.equals("https")) return new OkHttpsURLConnection(url, copy); - throw new IllegalArgumentException("Unexpected protocol: " + protocol); - } - - /** - * Creates a URLStreamHandler as a {@link java.net.URL#setURLStreamHandlerFactory}. - * - *

This code configures OkHttp to handle all HTTP and HTTPS connections - * created with {@link java.net.URL#openConnection()}:

   {@code
-   *
-   *   OkHttpClient okHttpClient = new OkHttpClient();
-   *   URL.setURLStreamHandlerFactory(new ObsoleteUrlFactory(okHttpClient));
-   * }
- */ - @Override public URLStreamHandler createURLStreamHandler(final String protocol) { - if (!protocol.equals("http") && !protocol.equals("https")) return null; - - return new URLStreamHandler() { - @Override protected URLConnection openConnection(URL url) { - return open(url); - } - - @Override protected URLConnection openConnection(URL url, Proxy proxy) { - return open(url, proxy); - } - - @Override protected int getDefaultPort() { - if (protocol.equals("http")) return 80; - if (protocol.equals("https")) return 443; - throw new AssertionError(); - } + static final String SELECTED_PROTOCOL = "ObsoleteUrlFactory-Selected-Protocol"; + + static final String RESPONSE_SOURCE = "ObsoleteUrlFactory-Response-Source"; + + static final Set METHODS = new LinkedHashSet<>( + Arrays.asList("OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "PATCH")); + + static final TimeZone UTC = TimeZone.getTimeZone("GMT"); + + static final int HTTP_CONTINUE = 100; + + static final ThreadLocal STANDARD_DATE_FORMAT = ThreadLocal.withInitial(() -> { + // Date format specified by RFC 7231 section 7.1.1.1. + DateFormat rfc1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); + rfc1123.setLenient(false); + rfc1123.setTimeZone(UTC); + return rfc1123; + }); + + static final Comparator FIELD_NAME_COMPARATOR = (a, b) -> { + if (Objects.equals(a, b)) { + return 0; + } else if (Objects.isNull(a)) { + return -1; + } else if (Objects.isNull(b)) { + return 1; + } else { + return String.CASE_INSENSITIVE_ORDER.compare(a, b); + } }; - } - static String format(Date value) { - return STANDARD_DATE_FORMAT.get().format(value); - } - - static boolean permitsRequestBody(String method) { - return !(method.equals("GET") || method.equals("HEAD")); - } + private OkHttpClient client; + + /** + * Instantiates a new Obsolete url factory. + * + * @param client + * the client + */ + public ObsoleteUrlFactory(OkHttpClient client) { + this.client = client; + } + + /** + * Client ok http client. + * + * @return the ok http client + */ + public OkHttpClient client() { + return client; + } + + /** + * Sets client. + * + * @param client + * the client + * @return the client + */ + public ObsoleteUrlFactory setClient(OkHttpClient client) { + this.client = client; + return this; + } + + /** + * Returns a copy of this stream handler factory that includes a shallow copy of the internal + * {@linkplain OkHttpClient HTTP client}. + */ + @Override + public ObsoleteUrlFactory clone() { + return new ObsoleteUrlFactory(client); + } + + /** + * Open http url connection. + * + * @param url + * the url + * @return the http url connection + */ + public HttpURLConnection open(URL url) { + return open(url, client.proxy()); + } + + HttpURLConnection open(URL url, @Nullable Proxy proxy) { + String protocol = url.getProtocol(); + OkHttpClient copy = client.newBuilder().proxy(proxy).build(); + + if (protocol.equals("http")) + return new OkHttpURLConnection(url, copy); + if (protocol.equals("https")) + return new OkHttpsURLConnection(url, copy); + throw new IllegalArgumentException("Unexpected protocol: " + protocol); + } + + /** + * Creates a URLStreamHandler as a {@link java.net.URL#setURLStreamHandlerFactory}. + * + *

+ * This code configures OkHttp to handle all HTTP and HTTPS connections created with + * {@link java.net.URL#openConnection()}: + * + *

+     * {
+     *     @code
+     *
+     *     OkHttpClient okHttpClient = new OkHttpClient();
+     *     URL.setURLStreamHandlerFactory(new ObsoleteUrlFactory(okHttpClient));
+     * }
+     * 
+ */ + @Override + public URLStreamHandler createURLStreamHandler(final String protocol) { + if (!protocol.equals("http") && !protocol.equals("https")) + return null; + + return new URLStreamHandler() { + @Override + protected URLConnection openConnection(URL url) { + return open(url); + } - /** Returns true if the response must have a (possibly 0-length) body. See RFC 7231. */ - static boolean hasBody(Response response) { - // HEAD requests never yield a body regardless of the response headers. - if (response.request().method().equals("HEAD")) { - return false; - } + @Override + protected URLConnection openConnection(URL url, Proxy proxy) { + return open(url, proxy); + } - int responseCode = response.code(); - if ((responseCode < HTTP_CONTINUE || responseCode >= 200) - && responseCode != HTTP_NO_CONTENT - && responseCode != HTTP_NOT_MODIFIED) { - return true; + @Override + protected int getDefaultPort() { + if (protocol.equals("http")) + return 80; + if (protocol.equals("https")) + return 443; + throw new AssertionError(); + } + }; } - // If the Content-Length or Transfer-Encoding headers disagree with the response code, the - // response is malformed. For best compatibility, we honor the headers. - if (contentLength(response.headers()) != -1 - || "chunked".equalsIgnoreCase(response.header("Transfer-Encoding"))) { - return true; + static String format(Date value) { + return STANDARD_DATE_FORMAT.get().format(value); } - return false; - } - - static long contentLength(Headers headers) { - String s = headers.get("Content-Length"); - if (s == null) return -1; - try { - return Long.parseLong(s); - } catch (NumberFormatException e) { - return -1; + static boolean permitsRequestBody(String method) { + return !(method.equals("GET") || method.equals("HEAD")); } - } - static String responseSourceHeader(Response response) { - if (response.networkResponse() == null) { - return response.cacheResponse() == null - ? "NONE" - : "CACHE " + response.code(); - } - return response.cacheResponse() == null - ? "NETWORK " + response.code() - : "CONDITIONAL_CACHE " + response.networkResponse().code(); - } - - static String statusLineToString(Response response) { - return (response.protocol() == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1") - + ' ' + response.code() - + ' ' + response.message(); - } - - static String toHumanReadableAscii(String s) { - for (int i = 0, length = s.length(), c; i < length; i += Character.charCount(c)) { - c = s.codePointAt(i); - if (c > '\u001f' && c < '\u007f') continue; - - Buffer buffer = new Buffer(); - buffer.writeUtf8(s, 0, i); - buffer.writeUtf8CodePoint('?'); - for (int j = i + Character.charCount(c); j < length; j += Character.charCount(c)) { - c = s.codePointAt(j); - buffer.writeUtf8CodePoint(c > '\u001f' && c < '\u007f' ? c : '?'); - } - return buffer.readUtf8(); - } - return s; - } - - static Map> toMultimap(Headers headers, @Nullable String valueForNullKey) { - Map> result = new TreeMap<>(FIELD_NAME_COMPARATOR); - for (int i = 0, size = headers.size(); i < size; i++) { - String fieldName = headers.name(i); - String value = headers.value(i); - - List allValues = new ArrayList<>(); - List otherValues = result.get(fieldName); - if (otherValues != null) { - allValues.addAll(otherValues); - } - allValues.add(value); - result.put(fieldName, Collections.unmodifiableList(allValues)); - } - if (valueForNullKey != null) { - result.put(null, Collections.unmodifiableList(Collections.singletonList(valueForNullKey))); - } - return Collections.unmodifiableMap(result); - } - - static String getSystemProperty(String key, @Nullable String defaultValue) { - String value; - try { - value = System.getProperty(key); - } catch (AccessControlException ex) { - return defaultValue; - } - return value != null ? value : defaultValue; - } - - static String defaultUserAgent() { - String agent = getSystemProperty("http.agent", null); - return agent != null ? toHumanReadableAscii(agent) : "ObsoleteUrlFactory"; - } - - static IOException propagate(Throwable throwable) throws IOException { - if (throwable instanceof IOException) throw (IOException) throwable; - if (throwable instanceof Error) throw (Error) throwable; - if (throwable instanceof RuntimeException) throw (RuntimeException) throwable; - throw new AssertionError(); - } - - static final class OkHttpURLConnection extends HttpURLConnection implements Callback { - // These fields are confined to the application thread that uses HttpURLConnection. - OkHttpClient client; - final NetworkInterceptor networkInterceptor = new NetworkInterceptor(); - Headers.Builder requestHeaders = new Headers.Builder(); - Headers responseHeaders; - boolean executed; - Call call; - - /** Like the superclass field of the same name, but a long and available on all platforms. */ - long fixedContentLength = -1L; - - // These fields are guarded by lock. - private final Object lock = new Object(); - private Response response; - private Throwable callFailure; - Response networkResponse; - boolean connectPending = true; - Proxy proxy; - Handshake handshake; - - OkHttpURLConnection(URL url, OkHttpClient client) { - super(url); - this.client = client; - } + /** Returns true if the response must have a (possibly 0-length) body. See RFC 7231. */ + static boolean hasBody(Response response) { + // HEAD requests never yield a body regardless of the response headers. + if (response.request().method().equals("HEAD")) { + return false; + } - @Override public void connect() throws IOException { - if (executed) return; + int responseCode = response.code(); + if ((responseCode < HTTP_CONTINUE || responseCode >= 200) && responseCode != HTTP_NO_CONTENT + && responseCode != HTTP_NOT_MODIFIED) { + return true; + } - Call call = buildCall(); - executed = true; - call.enqueue(this); + // If the Content-Length or Transfer-Encoding headers disagree with the response code, the + // response is malformed. For best compatibility, we honor the headers. + if (contentLength(response.headers()) != -1 + || "chunked".equalsIgnoreCase(response.header("Transfer-Encoding"))) { + return true; + } - synchronized (lock) { - try { - while (connectPending && response == null && callFailure == null) { - lock.wait(); // Wait 'til the network interceptor is reached or the call fails. - } - if (callFailure != null) { - throw propagate(callFailure); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // Retain interrupted status. - throw new InterruptedIOException(); - } - } + return false; } - @Override public void disconnect() { - // Calling disconnect() before a connection exists should have no effect. - if (call == null) return; - - networkInterceptor.proceed(); // Unblock any waiting async thread. - call.cancel(); + static long contentLength(Headers headers) { + String s = headers.get("Content-Length"); + if (s == null) + return -1; + try { + return Long.parseLong(s); + } catch (NumberFormatException e) { + return -1; + } } - @Override public InputStream getErrorStream() { - try { - Response response = getResponse(true); - if (hasBody(response) && response.code() >= HTTP_BAD_REQUEST) { - return response.body().byteStream(); + static String responseSourceHeader(Response response) { + Response networkResponse = response.networkResponse(); + if (networkResponse == null) { + return response.cacheResponse() == null ? "NONE" : "CACHE " + response.code(); + } else { + return response.cacheResponse() == null + ? "NETWORK " + response.code() + : "CONDITIONAL_CACHE " + networkResponse.code(); } - return null; - } catch (IOException e) { - return null; - } } - Headers getHeaders() throws IOException { - if (responseHeaders == null) { - Response response = getResponse(true); - Headers headers = response.headers(); - responseHeaders = headers.newBuilder() - .add(SELECTED_PROTOCOL, response.protocol().toString()) - .add(RESPONSE_SOURCE, responseSourceHeader(response)) - .build(); - } - return responseHeaders; + static String statusLineToString(Response response) { + return (response.protocol() == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1") + ' ' + response.code() + ' ' + + response.message(); } - @Override public String getHeaderField(int position) { - try { - Headers headers = getHeaders(); - if (position < 0 || position >= headers.size()) return null; - return headers.value(position); - } catch (IOException e) { - return null; - } - } + static String toHumanReadableAscii(String s) { + for (int i = 0, length = s.length(), c; i < length; i += Character.charCount(c)) { + c = s.codePointAt(i); + if (c > '\u001f' && c < '\u007f') + continue; - @Override public String getHeaderField(String fieldName) { - try { - return fieldName == null - ? statusLineToString(getResponse(true)) - : getHeaders().get(fieldName); - } catch (IOException e) { - return null; - } + Buffer buffer = new Buffer(); + buffer.writeUtf8(s, 0, i); + buffer.writeUtf8CodePoint('?'); + for (int j = i + Character.charCount(c); j < length; j += Character.charCount(c)) { + c = s.codePointAt(j); + buffer.writeUtf8CodePoint(c > '\u001f' && c < '\u007f' ? c : '?'); + } + return buffer.readUtf8(); + } + return s; } - @Override public String getHeaderFieldKey(int position) { - try { - Headers headers = getHeaders(); - if (position < 0 || position >= headers.size()) return null; - return headers.name(position); - } catch (IOException e) { - return null; - } - } + static Map> toMultimap(Headers headers, @Nullable String valueForNullKey) { + Map> result = new TreeMap<>(FIELD_NAME_COMPARATOR); + for (int i = 0, size = headers.size(); i < size; i++) { + String fieldName = headers.name(i); + String value = headers.value(i); - @Override public Map> getHeaderFields() { - try { - return toMultimap(getHeaders(), statusLineToString(getResponse(true))); - } catch (IOException e) { - return Collections.emptyMap(); - } + List allValues = new ArrayList<>(); + List otherValues = result.get(fieldName); + if (otherValues != null) { + allValues.addAll(otherValues); + } + allValues.add(value); + result.put(fieldName, Collections.unmodifiableList(allValues)); + } + if (valueForNullKey != null) { + result.put(null, Collections.unmodifiableList(Collections.singletonList(valueForNullKey))); + } + return Collections.unmodifiableMap(result); } - @Override public Map> getRequestProperties() { - if (connected) { - throw new IllegalStateException( - "Cannot access request header fields after connection is set"); - } - - return toMultimap(requestHeaders.build(), null); + static String getSystemProperty(String key, @Nullable String defaultValue) { + String value; + try { + value = System.getProperty(key); + } catch (AccessControlException ex) { + return defaultValue; + } + return value != null ? value : defaultValue; } - @Override public InputStream getInputStream() throws IOException { - if (!doInput) { - throw new ProtocolException("This protocol does not support input"); - } - - Response response = getResponse(false); - if (response.code() >= HTTP_BAD_REQUEST) throw new FileNotFoundException(url.toString()); - return response.body().byteStream(); + static String defaultUserAgent() { + String agent = getSystemProperty("http.agent", null); + return agent != null ? toHumanReadableAscii(agent) : "ObsoleteUrlFactory"; } - @Override public OutputStream getOutputStream() throws IOException { - OutputStreamRequestBody requestBody = (OutputStreamRequestBody) buildCall().request().body(); - if (requestBody == null) { - throw new ProtocolException("method does not support a request body: " + method); - } - - if (requestBody instanceof StreamedRequestBody) { - connect(); - networkInterceptor.proceed(); - } - - if (requestBody.closed) { - throw new ProtocolException("cannot write request body after response has been read"); - } - - return requestBody.outputStream; + static IOException propagate(Throwable throwable) throws IOException { + if (throwable instanceof IOException) + throw (IOException) throwable; + if (throwable instanceof Error) + throw (Error) throwable; + if (throwable instanceof RuntimeException) + throw (RuntimeException) throwable; + throw new AssertionError(); } - @Override public Permission getPermission() { - URL url = getURL(); - String hostname = url.getHost(); - int hostPort = url.getPort() != -1 - ? url.getPort() - : HttpUrl.defaultPort(url.getProtocol()); - if (usingProxy()) { - InetSocketAddress proxyAddress = (InetSocketAddress) client.proxy().address(); - hostname = proxyAddress.getHostName(); - hostPort = proxyAddress.getPort(); - } - return new SocketPermission(hostname + ":" + hostPort, "connect, resolve"); - } + static final class OkHttpURLConnection extends HttpURLConnection implements Callback { + // These fields are confined to the application thread that uses HttpURLConnection. + OkHttpClient client; + final NetworkInterceptor networkInterceptor = new NetworkInterceptor(); + Headers.Builder requestHeaders = new Headers.Builder(); + Headers responseHeaders; + boolean executed; + Call call; + + /** Like the superclass field of the same name, but a long and available on all platforms. */ + long fixedContentLength = -1L; + + // These fields are guarded by lock. + private final Object lock = new Object(); + private Response response; + private Throwable callFailure; + Response networkResponse; + boolean connectPending = true; + Proxy proxy; + Handshake handshake; + + OkHttpURLConnection(URL url, OkHttpClient client) { + super(url); + this.client = client; + } - @Override public String getRequestProperty(String field) { - if (field == null) return null; - return requestHeaders.get(field); - } + @Override + public void connect() throws IOException { + if (executed) + return; + + Call call = buildCall(); + executed = true; + call.enqueue(this); + + synchronized (lock) { + try { + while (connectPending && response == null && callFailure == null) { + lock.wait(); // Wait 'til the network interceptor is reached or the call fails. + } + if (callFailure != null) { + throw propagate(callFailure); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); // Retain interrupted status. + throw new InterruptedIOException(); + } + } + } - @Override public void setConnectTimeout(int timeoutMillis) { - client = client.newBuilder() - .connectTimeout(timeoutMillis, TimeUnit.MILLISECONDS) - .build(); - } + @Override + public void disconnect() { + // Calling disconnect() before a connection exists should have no effect. + if (call == null) + return; - @Override public void setInstanceFollowRedirects(boolean followRedirects) { - client = client.newBuilder() - .followRedirects(followRedirects) - .build(); - } + networkInterceptor.proceed(); // Unblock any waiting async thread. + call.cancel(); + } - @Override public boolean getInstanceFollowRedirects() { - return client.followRedirects(); - } + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "hasBody checks for this") + @Override + public InputStream getErrorStream() { + try { + Response response = getResponse(true); + if (hasBody(response) && response.code() >= HTTP_BAD_REQUEST) { + return response.body().byteStream(); + } + return null; + } catch (IOException e) { + return null; + } + } - @Override public int getConnectTimeout() { - return client.connectTimeoutMillis(); - } + Headers getHeaders() throws IOException { + if (responseHeaders == null) { + Response response = getResponse(true); + Headers headers = response.headers(); + responseHeaders = headers.newBuilder() + .add(SELECTED_PROTOCOL, response.protocol().toString()) + .add(RESPONSE_SOURCE, responseSourceHeader(response)) + .build(); + } + return responseHeaders; + } - @Override public void setReadTimeout(int timeoutMillis) { - client = client.newBuilder() - .readTimeout(timeoutMillis, TimeUnit.MILLISECONDS) - .build(); - } + @Override + public String getHeaderField(int position) { + try { + Headers headers = getHeaders(); + if (position < 0 || position >= headers.size()) + return null; + return headers.value(position); + } catch (IOException e) { + return null; + } + } - @Override public int getReadTimeout() { - return client.readTimeoutMillis(); - } + @Override + public String getHeaderField(String fieldName) { + try { + return fieldName == null ? statusLineToString(getResponse(true)) : getHeaders().get(fieldName); + } catch (IOException e) { + return null; + } + } - @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") - private Call buildCall() throws IOException { - if (call != null) { - return call; - } + @Override + public String getHeaderFieldKey(int position) { + try { + Headers headers = getHeaders(); + if (position < 0 || position >= headers.size()) + return null; + return headers.name(position); + } catch (IOException e) { + return null; + } + } - connected = true; - if (doOutput) { - if (method.equals("GET")) { - method = "POST"; - } else if (!permitsRequestBody(method)) { - throw new ProtocolException(method + " does not support writing"); + @Override + public Map> getHeaderFields() { + try { + return toMultimap(getHeaders(), statusLineToString(getResponse(true))); + } catch (IOException e) { + return Collections.emptyMap(); + } } - } - if (requestHeaders.get("User-Agent") == null) { - requestHeaders.add("User-Agent", defaultUserAgent()); - } + @Override + public Map> getRequestProperties() { + if (connected) { + throw new IllegalStateException("Cannot access request header fields after connection is set"); + } - OutputStreamRequestBody requestBody = null; - if (permitsRequestBody(method)) { - String contentType = requestHeaders.get("Content-Type"); - if (contentType == null) { - contentType = "application/x-www-form-urlencoded"; - requestHeaders.add("Content-Type", contentType); + return toMultimap(requestHeaders.build(), null); } - boolean stream = fixedContentLength != -1L || chunkLength > 0; - - long contentLength = -1L; - String contentLengthString = requestHeaders.get("Content-Length"); - if (fixedContentLength != -1L) { - contentLength = fixedContentLength; - } else if (contentLengthString != null) { - contentLength = Long.parseLong(contentLengthString); - } - - requestBody = stream - ? new StreamedRequestBody(contentLength) - : new BufferedRequestBody(contentLength); - requestBody.timeout.timeout(client.writeTimeoutMillis(), TimeUnit.MILLISECONDS); - } - - HttpUrl url; - try { - url = HttpUrl.get(getURL().toString()); - } catch (IllegalArgumentException e) { - MalformedURLException malformedUrl = new MalformedURLException(); - malformedUrl.initCause(e); - throw malformedUrl; - } - - Request request = new Request.Builder() - .url(url) - .headers(requestHeaders.build()) - .method(method, requestBody) - .build(); - - OkHttpClient.Builder clientBuilder = client.newBuilder(); - clientBuilder.interceptors().clear(); - clientBuilder.interceptors().add(UnexpectedException.INTERCEPTOR); - clientBuilder.networkInterceptors().clear(); - clientBuilder.networkInterceptors().add(networkInterceptor); - - // Use a separate dispatcher so that limits aren't impacted. But use the same executor service! - clientBuilder.dispatcher(new Dispatcher(client.dispatcher().executorService())); - - // If we're currently not using caches, make sure the engine's client doesn't have one. - if (!getUseCaches()) { - clientBuilder.cache(null); - } - - return call = clientBuilder.build().newCall(request); - } + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", + justification = "Good request will have body") + @Override + public InputStream getInputStream() throws IOException { + if (!doInput) { + throw new ProtocolException("This protocol does not support input"); + } - private Response getResponse(boolean networkResponseOnError) throws IOException { - synchronized (lock) { - if (response != null) return response; - if (callFailure != null) { - if (networkResponseOnError && networkResponse != null) return networkResponse; - throw propagate(callFailure); + Response response = getResponse(false); + if (response.code() >= HTTP_BAD_REQUEST) + throw new FileNotFoundException(url.toString()); + return response.body().byteStream(); } - } - Call call = buildCall(); - networkInterceptor.proceed(); + @Override + public OutputStream getOutputStream() throws IOException { + OutputStreamRequestBody requestBody = (OutputStreamRequestBody) buildCall().request().body(); + if (requestBody == null) { + throw new ProtocolException("method does not support a request body: " + method); + } - OutputStreamRequestBody requestBody = (OutputStreamRequestBody) call.request().body(); - if (requestBody != null) requestBody.outputStream.close(); + if (requestBody instanceof StreamedRequestBody) { + connect(); + networkInterceptor.proceed(); + } - if (executed) { - synchronized (lock) { - try { - while (response == null && callFailure == null) { - lock.wait(); // Wait until the response is returned or the call fails. + if (requestBody.closed) { + throw new ProtocolException("cannot write request body after response has been read"); } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // Retain interrupted status. - throw new InterruptedIOException(); - } + + return requestBody.outputStream; } - } else { - executed = true; - try { - onResponse(call, call.execute()); - } catch (IOException e) { - onFailure(call, e); + + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", + justification = "usingProxy() handles this") + @Override + public Permission getPermission() { + URL url = getURL(); + String hostname = url.getHost(); + int hostPort = url.getPort() != -1 ? url.getPort() : HttpUrl.defaultPort(url.getProtocol()); + if (usingProxy()) { + InetSocketAddress proxyAddress = (InetSocketAddress) client.proxy().address(); + hostname = proxyAddress.getHostName(); + hostPort = proxyAddress.getPort(); + } + return new SocketPermission(hostname + ":" + hostPort, "connect, resolve"); } - } - synchronized (lock) { - if (callFailure != null) throw propagate(callFailure); - if (response != null) return response; - } + @Override + public String getRequestProperty(String field) { + if (field == null) + return null; + return requestHeaders.get(field); + } - throw new AssertionError(); - } + @Override + public void setConnectTimeout(int timeoutMillis) { + client = client.newBuilder().connectTimeout(timeoutMillis, TimeUnit.MILLISECONDS).build(); + } - @Override public boolean usingProxy() { - if (proxy != null) return true; - Proxy clientProxy = client.proxy(); - return clientProxy != null && clientProxy.type() != Proxy.Type.DIRECT; - } + @Override + public void setInstanceFollowRedirects(boolean followRedirects) { + client = client.newBuilder().followRedirects(followRedirects).build(); + } - @Override public String getResponseMessage() throws IOException { - return getResponse(true).message(); - } + @Override + public boolean getInstanceFollowRedirects() { + return client.followRedirects(); + } - @Override public int getResponseCode() throws IOException { - return getResponse(true).code(); - } + @Override + public int getConnectTimeout() { + return client.connectTimeoutMillis(); + } - @Override public void setRequestProperty(String field, String newValue) { - if (connected) { - throw new IllegalStateException("Cannot set request property after connection is made"); - } - if (field == null) { - throw new NullPointerException("field == null"); - } - if (newValue == null) { - return; - } - - requestHeaders.set(field, newValue); - } + @Override + public void setReadTimeout(int timeoutMillis) { + client = client.newBuilder().readTimeout(timeoutMillis, TimeUnit.MILLISECONDS).build(); + } - @Override public void setIfModifiedSince(long newValue) { - super.setIfModifiedSince(newValue); - if (ifModifiedSince != 0) { - requestHeaders.set("If-Modified-Since", format(new Date(ifModifiedSince))); - } else { - requestHeaders.removeAll("If-Modified-Since"); - } - } + @Override + public int getReadTimeout() { + return client.readTimeoutMillis(); + } - @Override public void addRequestProperty(String field, String value) { - if (connected) { - throw new IllegalStateException("Cannot add request property after connection is made"); - } - if (field == null) { - throw new NullPointerException("field == null"); - } - if (value == null) { - return; - } - - requestHeaders.add(field, value); - } + @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") + private Call buildCall() throws IOException { + if (call != null) { + return call; + } - @Override public void setRequestMethod(String method) throws ProtocolException { - if (!METHODS.contains(method)) { - throw new ProtocolException("Expected one of " + METHODS + " but was " + method); - } - this.method = method; - } + connected = true; + if (doOutput) { + if (method.equals("GET")) { + method = "POST"; + } else if (!permitsRequestBody(method)) { + throw new ProtocolException(method + " does not support writing"); + } + } - @Override public void setFixedLengthStreamingMode(int contentLength) { - setFixedLengthStreamingMode((long) contentLength); - } + if (requestHeaders.get("User-Agent") == null) { + requestHeaders.add("User-Agent", defaultUserAgent()); + } - @Override public void setFixedLengthStreamingMode(long contentLength) { - if (super.connected) throw new IllegalStateException("Already connected"); - if (chunkLength > 0) throw new IllegalStateException("Already in chunked mode"); - if (contentLength < 0) throw new IllegalArgumentException("contentLength < 0"); - this.fixedContentLength = contentLength; - super.fixedContentLength = (int) Math.min(contentLength, Integer.MAX_VALUE); - } + OutputStreamRequestBody requestBody = null; + if (permitsRequestBody(method)) { + String contentType = requestHeaders.get("Content-Type"); + if (contentType == null) { + contentType = "application/x-www-form-urlencoded"; + requestHeaders.add("Content-Type", contentType); + } + + boolean stream = fixedContentLength != -1L || chunkLength > 0; + + long contentLength = -1L; + String contentLengthString = requestHeaders.get("Content-Length"); + if (fixedContentLength != -1L) { + contentLength = fixedContentLength; + } else if (contentLengthString != null) { + contentLength = Long.parseLong(contentLengthString); + } + + requestBody = stream ? new StreamedRequestBody(contentLength) : new BufferedRequestBody(contentLength); + requestBody.timeout.timeout(client.writeTimeoutMillis(), TimeUnit.MILLISECONDS); + } - @Override public void onFailure(Call call, IOException e) { - synchronized (lock) { - this.callFailure = (e instanceof UnexpectedException) ? e.getCause() : e; - lock.notifyAll(); - } - } + HttpUrl url; + try { + url = HttpUrl.get(getURL().toString()); + } catch (IllegalArgumentException e) { + MalformedURLException malformedUrl = new MalformedURLException(); + malformedUrl.initCause(e); + throw malformedUrl; + } - @Override public void onResponse(Call call, Response response) { - synchronized (lock) { - this.response = response; - this.handshake = response.handshake(); - this.url = response.request().url().url(); - lock.notifyAll(); - } - } + Request request = new Request.Builder().url(url) + .headers(requestHeaders.build()) + .method(method, requestBody) + .build(); + + OkHttpClient.Builder clientBuilder = client.newBuilder(); + clientBuilder.interceptors().clear(); + clientBuilder.interceptors().add(UnexpectedException.INTERCEPTOR); + clientBuilder.networkInterceptors().clear(); + clientBuilder.networkInterceptors().add(networkInterceptor); - final class NetworkInterceptor implements Interceptor { - // Guarded by HttpUrlConnection.this. - private boolean proceed; + // Use a separate dispatcher so that limits aren't impacted. But use the same executor service! + clientBuilder.dispatcher(new Dispatcher(client.dispatcher().executorService())); + + // If we're currently not using caches, make sure the engine's client doesn't have one. + if (!getUseCaches()) { + clientBuilder.cache(null); + } - public void proceed() { - synchronized (lock) { - this.proceed = true; - lock.notifyAll(); + return call = clientBuilder.build().newCall(request); } - } - @Override public Response intercept(Chain chain) throws IOException { - Request request = chain.request(); + private Response getResponse(boolean networkResponseOnError) throws IOException { + synchronized (lock) { + if (response != null) + return response; + if (callFailure != null) { + if (networkResponseOnError && networkResponse != null) + return networkResponse; + throw propagate(callFailure); + } + } - synchronized (lock) { - connectPending = false; - proxy = chain.connection().route().proxy(); - handshake = chain.connection().handshake(); - lock.notifyAll(); + Call call = buildCall(); + networkInterceptor.proceed(); + + OutputStreamRequestBody requestBody = (OutputStreamRequestBody) call.request().body(); + if (requestBody != null) + requestBody.outputStream.close(); + + if (executed) { + synchronized (lock) { + try { + while (response == null && callFailure == null) { + lock.wait(); // Wait until the response is returned or the call fails. + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); // Retain interrupted status. + throw new InterruptedIOException(); + } + } + } else { + executed = true; + try { + onResponse(call, call.execute()); + } catch (IOException e) { + onFailure(call, e); + } + } - try { - while (!proceed) { - lock.wait(); // Wait until proceed() is called. + synchronized (lock) { + if (callFailure != null) + throw propagate(callFailure); + if (response != null) + return response; } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // Retain interrupted status. - throw new InterruptedIOException(); - } + + throw new AssertionError(); } - // Try to lock in the Content-Length before transmitting the request body. - if (request.body() instanceof OutputStreamRequestBody) { - OutputStreamRequestBody requestBody = (OutputStreamRequestBody) request.body(); - request = requestBody.prepareToSendRequest(request); + @Override + public boolean usingProxy() { + if (proxy != null) + return true; + Proxy clientProxy = client.proxy(); + return clientProxy != null && clientProxy.type() != Proxy.Type.DIRECT; } - Response response = chain.proceed(request); + @Override + public String getResponseMessage() throws IOException { + return getResponse(true).message(); + } - synchronized (lock) { - networkResponse = response; - url = response.request().url().url(); + @Override + public int getResponseCode() throws IOException { + return getResponse(true).code(); } - return response; - } - } - } + @Override + public void setRequestProperty(String field, String newValue) { + if (connected) { + throw new IllegalStateException("Cannot set request property after connection is made"); + } + if (field == null) { + throw new NullPointerException("field == null"); + } + if (newValue == null) { + return; + } - abstract static class OutputStreamRequestBody extends RequestBody { - Timeout timeout; - long expectedContentLength; - OutputStream outputStream; - boolean closed; + requestHeaders.set(field, newValue); + } - void initOutputStream(BufferedSink sink, long expectedContentLength) { - this.timeout = sink.timeout(); - this.expectedContentLength = expectedContentLength; + @Override + public void setIfModifiedSince(long newValue) { + super.setIfModifiedSince(newValue); + if (ifModifiedSince != 0) { + requestHeaders.set("If-Modified-Since", format(new Date(ifModifiedSince))); + } else { + requestHeaders.removeAll("If-Modified-Since"); + } + } - // An output stream that writes to sink. If expectedContentLength is not -1, then this expects - // exactly that many bytes to be written. - this.outputStream = new OutputStream() { - private long bytesReceived; + @Override + public void addRequestProperty(String field, String value) { + if (connected) { + throw new IllegalStateException("Cannot add request property after connection is made"); + } + if (field == null) { + throw new NullPointerException("field == null"); + } + if (value == null) { + return; + } - @Override public void write(int b) throws IOException { - write(new byte[] {(byte) b}, 0, 1); + requestHeaders.add(field, value); } - @Override public void write(byte[] source, int offset, int byteCount) throws IOException { - if (closed) throw new IOException("closed"); // Not IllegalStateException! + @Override + public void setRequestMethod(String method) throws ProtocolException { + if (!METHODS.contains(method)) { + throw new ProtocolException("Expected one of " + METHODS + " but was " + method); + } + this.method = method; + } - if (expectedContentLength != -1L && bytesReceived + byteCount > expectedContentLength) { - throw new ProtocolException("expected " + expectedContentLength - + " bytes but received " + bytesReceived + byteCount); - } + @Override + public void setFixedLengthStreamingMode(int contentLength) { + setFixedLengthStreamingMode((long) contentLength); + } - bytesReceived += byteCount; - try { - sink.write(source, offset, byteCount); - } catch (InterruptedIOException e) { - throw new SocketTimeoutException(e.getMessage()); - } + @Override + public void setFixedLengthStreamingMode(long contentLength) { + if (super.connected) + throw new IllegalStateException("Already connected"); + if (chunkLength > 0) + throw new IllegalStateException("Already in chunked mode"); + if (contentLength < 0) + throw new IllegalArgumentException("contentLength < 0"); + this.fixedContentLength = contentLength; + super.fixedContentLength = (int) Math.min(contentLength, Integer.MAX_VALUE); } - @Override public void flush() throws IOException { - if (closed) return; // Weird, but consistent with historical behavior. - sink.flush(); + @Override + public void onFailure(Call call, IOException e) { + synchronized (lock) { + this.callFailure = (e instanceof UnexpectedException) ? e.getCause() : e; + lock.notifyAll(); + } } - @Override public void close() throws IOException { - closed = true; + @Override + public void onResponse(Call call, Response response) { + synchronized (lock) { + this.response = response; + this.handshake = response.handshake(); + this.url = response.request().url().url(); + lock.notifyAll(); + } + } - if (expectedContentLength != -1L && bytesReceived < expectedContentLength) { - throw new ProtocolException("expected " + expectedContentLength - + " bytes but received " + bytesReceived); - } + final class NetworkInterceptor implements Interceptor { + // Guarded by HttpUrlConnection.this. + private boolean proceed; + + /** + * Proceed. + */ + public void proceed() { + synchronized (lock) { + this.proceed = true; + lock.notifyAll(); + } + } - sink.close(); + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", + justification = "If we get here there is a connection and request.body() is checked") + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + + synchronized (lock) { + connectPending = false; + proxy = chain.connection().route().proxy(); + handshake = chain.connection().handshake(); + lock.notifyAll(); + + try { + while (!proceed) { + lock.wait(); // Wait until proceed() is called. + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); // Retain interrupted status. + throw new InterruptedIOException(); + } + } + + // Try to lock in the Content-Length before transmitting the request body. + if (request.body() instanceof OutputStreamRequestBody) { + OutputStreamRequestBody requestBody = (OutputStreamRequestBody) request.body(); + request = requestBody.prepareToSendRequest(request); + } + + Response response = chain.proceed(request); + + synchronized (lock) { + networkResponse = response; + url = response.request().url().url(); + } + + return response; + } } - }; } - @Override public long contentLength() { - return expectedContentLength; - } + abstract static class OutputStreamRequestBody extends RequestBody { + Timeout timeout; + long expectedContentLength; + OutputStream outputStream; + boolean closed; + + void initOutputStream(BufferedSink sink, long expectedContentLength) { + this.timeout = sink.timeout(); + this.expectedContentLength = expectedContentLength; + + // An output stream that writes to sink. If expectedContentLength is not -1, then this expects + // exactly that many bytes to be written. + this.outputStream = new OutputStream() { + private long bytesReceived; + + @Override + public void write(int b) throws IOException { + write(new byte[]{ (byte) b }, 0, 1); + } + + @Override + public void write(byte[] source, int offset, int byteCount) throws IOException { + if (closed) + throw new IOException("closed"); // Not IllegalStateException! + + if (expectedContentLength != -1L && bytesReceived + byteCount > expectedContentLength) { + throw new ProtocolException("expected " + expectedContentLength + " bytes but received " + + bytesReceived + byteCount); + } + + bytesReceived += byteCount; + try { + sink.write(source, offset, byteCount); + } catch (InterruptedIOException e) { + throw new SocketTimeoutException(e.getMessage()); + } + } + + @Override + public void flush() throws IOException { + if (closed) + return; // Weird, but consistent with historical behavior. + sink.flush(); + } + + @Override + public void close() throws IOException { + closed = true; + + if (expectedContentLength != -1L && bytesReceived < expectedContentLength) { + throw new ProtocolException( + "expected " + expectedContentLength + " bytes but received " + bytesReceived); + } + + sink.close(); + } + }; + } - @Override public final @Nullable MediaType contentType() { - return null; // Let the caller provide this in a regular header. - } + @Override + public long contentLength() { + return expectedContentLength; + } + + @Override + public final @Nullable MediaType contentType() { + return null; // Let the caller provide this in a regular header. + } - public Request prepareToSendRequest(Request request) throws IOException { - return request; + /** + * Prepare to send request request. + * + * @param request + * the request + * @return the request + * @throws IOException + * the io exception + */ + public Request prepareToSendRequest(Request request) throws IOException { + return request; + } } - } - static final class BufferedRequestBody extends OutputStreamRequestBody { - final Buffer buffer = new Buffer(); - long contentLength = -1L; + static final class BufferedRequestBody extends OutputStreamRequestBody { + final Buffer buffer = new Buffer(); + long contentLength = -1L; - BufferedRequestBody(long expectedContentLength) { - initOutputStream(buffer, expectedContentLength); - } + BufferedRequestBody(long expectedContentLength) { + initOutputStream(buffer, expectedContentLength); + } - @Override public long contentLength() { - return contentLength; - } + @Override + public long contentLength() { + return contentLength; + } - @Override public Request prepareToSendRequest(Request request) throws IOException { - if (request.header("Content-Length") != null) return request; + @Override + public Request prepareToSendRequest(Request request) throws IOException { + if (request.header("Content-Length") != null) + return request; + + outputStream.close(); + contentLength = buffer.size(); + return request.newBuilder() + .removeHeader("Transfer-Encoding") + .header("Content-Length", Long.toString(buffer.size())) + .build(); + } - outputStream.close(); - contentLength = buffer.size(); - return request.newBuilder() - .removeHeader("Transfer-Encoding") - .header("Content-Length", Long.toString(buffer.size())) - .build(); + @Override + public void writeTo(BufferedSink sink) { + buffer.copyTo(sink.buffer(), 0, buffer.size()); + } } - @Override public void writeTo(BufferedSink sink) { - buffer.copyTo(sink.buffer(), 0, buffer.size()); - } - } + static final class StreamedRequestBody extends OutputStreamRequestBody { + private final Pipe pipe = new Pipe(8192); - static final class StreamedRequestBody extends OutputStreamRequestBody { - private final Pipe pipe = new Pipe(8192); + StreamedRequestBody(long expectedContentLength) { + initOutputStream(Okio.buffer(pipe.sink()), expectedContentLength); + } - StreamedRequestBody(long expectedContentLength) { - initOutputStream(Okio.buffer(pipe.sink()), expectedContentLength); - } + public boolean isOneShot() { + return true; + } - public boolean isOneShot() { - return true; + @Override + public void writeTo(BufferedSink sink) throws IOException { + Buffer buffer = new Buffer(); + while (pipe.source().read(buffer, 8192) != -1L) { + sink.write(buffer, buffer.size()); + } + } } - @Override public void writeTo(BufferedSink sink) throws IOException { - Buffer buffer = new Buffer(); - while (pipe.source().read(buffer, 8192) != -1L) { - sink.write(buffer, buffer.size()); - } - } - } + abstract static class DelegatingHttpsURLConnection extends HttpsURLConnection { + private final HttpURLConnection delegate; - abstract static class DelegatingHttpsURLConnection extends HttpsURLConnection { - private final HttpURLConnection delegate; + DelegatingHttpsURLConnection(HttpURLConnection delegate) { + super(delegate.getURL()); + this.delegate = delegate; + } - DelegatingHttpsURLConnection(HttpURLConnection delegate) { - super(delegate.getURL()); - this.delegate = delegate; - } + /** + * Handshake handshake. + * + * @return the handshake + */ + protected abstract Handshake handshake(); - protected abstract Handshake handshake(); + @Override + public abstract void setHostnameVerifier(HostnameVerifier hostnameVerifier); - @Override public abstract void setHostnameVerifier(HostnameVerifier hostnameVerifier); + @Override + public abstract HostnameVerifier getHostnameVerifier(); - @Override public abstract HostnameVerifier getHostnameVerifier(); + @Override + public abstract void setSSLSocketFactory(SSLSocketFactory sslSocketFactory); - @Override public abstract void setSSLSocketFactory(SSLSocketFactory sslSocketFactory); + @Override + public abstract SSLSocketFactory getSSLSocketFactory(); - @Override public abstract SSLSocketFactory getSSLSocketFactory(); + @Override + public String getCipherSuite() { + Handshake handshake = handshake(); + return handshake != null ? handshake.cipherSuite().javaName() : null; + } - @Override public String getCipherSuite() { - Handshake handshake = handshake(); - return handshake != null ? handshake.cipherSuite().javaName() : null; - } + @Override + public Certificate[] getLocalCertificates() { + Handshake handshake = handshake(); + if (handshake == null) + return null; + List result = handshake.localCertificates(); + return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null; + } - @Override public Certificate[] getLocalCertificates() { - Handshake handshake = handshake(); - if (handshake == null) return null; - List result = handshake.localCertificates(); - return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null; - } + @Override + public Certificate[] getServerCertificates() { + Handshake handshake = handshake(); + if (handshake == null) + return null; + List result = handshake.peerCertificates(); + return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null; + } - @Override public Certificate[] getServerCertificates() { - Handshake handshake = handshake(); - if (handshake == null) return null; - List result = handshake.peerCertificates(); - return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null; - } + @Override + public Principal getPeerPrincipal() { + Handshake handshake = handshake(); + return handshake != null ? handshake.peerPrincipal() : null; + } - @Override public Principal getPeerPrincipal() { - Handshake handshake = handshake(); - return handshake != null ? handshake.peerPrincipal() : null; - } + @Override + public Principal getLocalPrincipal() { + Handshake handshake = handshake(); + return handshake != null ? handshake.localPrincipal() : null; + } - @Override public Principal getLocalPrincipal() { - Handshake handshake = handshake(); - return handshake != null ? handshake.localPrincipal() : null; - } + @Override + public void connect() throws IOException { + connected = true; + delegate.connect(); + } - @Override public void connect() throws IOException { - connected = true; - delegate.connect(); - } + @Override + public void disconnect() { + delegate.disconnect(); + } - @Override public void disconnect() { - delegate.disconnect(); - } + @Override + public InputStream getErrorStream() { + return delegate.getErrorStream(); + } - @Override public InputStream getErrorStream() { - return delegate.getErrorStream(); - } + @Override + public String getRequestMethod() { + return delegate.getRequestMethod(); + } - @Override public String getRequestMethod() { - return delegate.getRequestMethod(); - } + @Override + public int getResponseCode() throws IOException { + return delegate.getResponseCode(); + } - @Override public int getResponseCode() throws IOException { - return delegate.getResponseCode(); - } + @Override + public String getResponseMessage() throws IOException { + return delegate.getResponseMessage(); + } - @Override public String getResponseMessage() throws IOException { - return delegate.getResponseMessage(); - } + @Override + public void setRequestMethod(String method) throws ProtocolException { + delegate.setRequestMethod(method); + } - @Override public void setRequestMethod(String method) throws ProtocolException { - delegate.setRequestMethod(method); - } + @Override + public boolean usingProxy() { + return delegate.usingProxy(); + } - @Override public boolean usingProxy() { - return delegate.usingProxy(); - } + @Override + public boolean getInstanceFollowRedirects() { + return delegate.getInstanceFollowRedirects(); + } - @Override public boolean getInstanceFollowRedirects() { - return delegate.getInstanceFollowRedirects(); - } + @Override + public void setInstanceFollowRedirects(boolean followRedirects) { + delegate.setInstanceFollowRedirects(followRedirects); + } - @Override public void setInstanceFollowRedirects(boolean followRedirects) { - delegate.setInstanceFollowRedirects(followRedirects); - } + @Override + public boolean getAllowUserInteraction() { + return delegate.getAllowUserInteraction(); + } - @Override public boolean getAllowUserInteraction() { - return delegate.getAllowUserInteraction(); - } + @Override + public Object getContent() throws IOException { + return delegate.getContent(); + } - @Override public Object getContent() throws IOException { - return delegate.getContent(); - } + @Override + public Object getContent(Class[] types) throws IOException { + return delegate.getContent(types); + } - @Override public Object getContent(Class[] types) throws IOException { - return delegate.getContent(types); - } + @Override + public String getContentEncoding() { + return delegate.getContentEncoding(); + } - @Override public String getContentEncoding() { - return delegate.getContentEncoding(); - } + @Override + public int getContentLength() { + return delegate.getContentLength(); + } - @Override public int getContentLength() { - return delegate.getContentLength(); - } + // Should only be invoked on Java 8+ or Android API 24+. + @Override + public long getContentLengthLong() { + return delegate.getContentLengthLong(); + } - // Should only be invoked on Java 8+ or Android API 24+. - @Override public long getContentLengthLong() { - return delegate.getContentLengthLong(); - } + @Override + public String getContentType() { + return delegate.getContentType(); + } - @Override public String getContentType() { - return delegate.getContentType(); - } + @Override + public long getDate() { + return delegate.getDate(); + } - @Override public long getDate() { - return delegate.getDate(); - } + @Override + public boolean getDefaultUseCaches() { + return delegate.getDefaultUseCaches(); + } - @Override public boolean getDefaultUseCaches() { - return delegate.getDefaultUseCaches(); - } + @Override + public boolean getDoInput() { + return delegate.getDoInput(); + } - @Override public boolean getDoInput() { - return delegate.getDoInput(); - } + @Override + public boolean getDoOutput() { + return delegate.getDoOutput(); + } - @Override public boolean getDoOutput() { - return delegate.getDoOutput(); - } + @Override + public long getExpiration() { + return delegate.getExpiration(); + } - @Override public long getExpiration() { - return delegate.getExpiration(); - } + @Override + public String getHeaderField(int pos) { + return delegate.getHeaderField(pos); + } - @Override public String getHeaderField(int pos) { - return delegate.getHeaderField(pos); - } + @Override + public Map> getHeaderFields() { + return delegate.getHeaderFields(); + } - @Override public Map> getHeaderFields() { - return delegate.getHeaderFields(); - } + @Override + public Map> getRequestProperties() { + return delegate.getRequestProperties(); + } - @Override public Map> getRequestProperties() { - return delegate.getRequestProperties(); - } + @Override + public void addRequestProperty(String field, String newValue) { + delegate.addRequestProperty(field, newValue); + } - @Override public void addRequestProperty(String field, String newValue) { - delegate.addRequestProperty(field, newValue); - } + @Override + public String getHeaderField(String key) { + return delegate.getHeaderField(key); + } - @Override public String getHeaderField(String key) { - return delegate.getHeaderField(key); - } + // Should only be invoked on Java 8+ or Android API 24+. + @Override + public long getHeaderFieldLong(String field, long defaultValue) { + return delegate.getHeaderFieldLong(field, defaultValue); + } - // Should only be invoked on Java 8+ or Android API 24+. - @Override public long getHeaderFieldLong(String field, long defaultValue) { - return delegate.getHeaderFieldLong(field, defaultValue); - } + @Override + public long getHeaderFieldDate(String field, long defaultValue) { + return delegate.getHeaderFieldDate(field, defaultValue); + } - @Override public long getHeaderFieldDate(String field, long defaultValue) { - return delegate.getHeaderFieldDate(field, defaultValue); - } + @Override + public int getHeaderFieldInt(String field, int defaultValue) { + return delegate.getHeaderFieldInt(field, defaultValue); + } - @Override public int getHeaderFieldInt(String field, int defaultValue) { - return delegate.getHeaderFieldInt(field, defaultValue); - } + @Override + public String getHeaderFieldKey(int position) { + return delegate.getHeaderFieldKey(position); + } - @Override public String getHeaderFieldKey(int position) { - return delegate.getHeaderFieldKey(position); - } + @Override + public long getIfModifiedSince() { + return delegate.getIfModifiedSince(); + } - @Override public long getIfModifiedSince() { - return delegate.getIfModifiedSince(); - } + @Override + public InputStream getInputStream() throws IOException { + return delegate.getInputStream(); + } - @Override public InputStream getInputStream() throws IOException { - return delegate.getInputStream(); - } + @Override + public long getLastModified() { + return delegate.getLastModified(); + } - @Override public long getLastModified() { - return delegate.getLastModified(); - } + @Override + public OutputStream getOutputStream() throws IOException { + return delegate.getOutputStream(); + } - @Override public OutputStream getOutputStream() throws IOException { - return delegate.getOutputStream(); - } + @Override + public Permission getPermission() throws IOException { + return delegate.getPermission(); + } - @Override public Permission getPermission() throws IOException { - return delegate.getPermission(); - } + @Override + public String getRequestProperty(String field) { + return delegate.getRequestProperty(field); + } - @Override public String getRequestProperty(String field) { - return delegate.getRequestProperty(field); - } + @Override + public URL getURL() { + return delegate.getURL(); + } - @Override public URL getURL() { - return delegate.getURL(); - } + @Override + public boolean getUseCaches() { + return delegate.getUseCaches(); + } - @Override public boolean getUseCaches() { - return delegate.getUseCaches(); - } + @Override + public void setAllowUserInteraction(boolean newValue) { + delegate.setAllowUserInteraction(newValue); + } - @Override public void setAllowUserInteraction(boolean newValue) { - delegate.setAllowUserInteraction(newValue); - } + @Override + public void setDefaultUseCaches(boolean newValue) { + delegate.setDefaultUseCaches(newValue); + } - @Override public void setDefaultUseCaches(boolean newValue) { - delegate.setDefaultUseCaches(newValue); - } + @Override + public void setDoInput(boolean newValue) { + delegate.setDoInput(newValue); + } - @Override public void setDoInput(boolean newValue) { - delegate.setDoInput(newValue); - } + @Override + public void setDoOutput(boolean newValue) { + delegate.setDoOutput(newValue); + } - @Override public void setDoOutput(boolean newValue) { - delegate.setDoOutput(newValue); - } + // Should only be invoked on Java 8+ or Android API 24+. + @Override + public void setFixedLengthStreamingMode(long contentLength) { + delegate.setFixedLengthStreamingMode(contentLength); + } - // Should only be invoked on Java 8+ or Android API 24+. - @Override public void setFixedLengthStreamingMode(long contentLength) { - delegate.setFixedLengthStreamingMode(contentLength); - } + @Override + public void setIfModifiedSince(long newValue) { + delegate.setIfModifiedSince(newValue); + } - @Override public void setIfModifiedSince(long newValue) { - delegate.setIfModifiedSince(newValue); - } + @Override + public void setRequestProperty(String field, String newValue) { + delegate.setRequestProperty(field, newValue); + } - @Override public void setRequestProperty(String field, String newValue) { - delegate.setRequestProperty(field, newValue); - } + @Override + public void setUseCaches(boolean newValue) { + delegate.setUseCaches(newValue); + } - @Override public void setUseCaches(boolean newValue) { - delegate.setUseCaches(newValue); - } + @Override + public void setConnectTimeout(int timeoutMillis) { + delegate.setConnectTimeout(timeoutMillis); + } - @Override public void setConnectTimeout(int timeoutMillis) { - delegate.setConnectTimeout(timeoutMillis); - } + @Override + public int getConnectTimeout() { + return delegate.getConnectTimeout(); + } - @Override public int getConnectTimeout() { - return delegate.getConnectTimeout(); - } + @Override + public void setReadTimeout(int timeoutMillis) { + delegate.setReadTimeout(timeoutMillis); + } - @Override public void setReadTimeout(int timeoutMillis) { - delegate.setReadTimeout(timeoutMillis); - } + @Override + public int getReadTimeout() { + return delegate.getReadTimeout(); + } - @Override public int getReadTimeout() { - return delegate.getReadTimeout(); - } + @Override + public String toString() { + return delegate.toString(); + } - @Override public String toString() { - return delegate.toString(); - } + @Override + public void setFixedLengthStreamingMode(int contentLength) { + delegate.setFixedLengthStreamingMode(contentLength); + } - @Override public void setFixedLengthStreamingMode(int contentLength) { - delegate.setFixedLengthStreamingMode(contentLength); + @Override + public void setChunkedStreamingMode(int chunkLength) { + delegate.setChunkedStreamingMode(chunkLength); + } } - @Override public void setChunkedStreamingMode(int chunkLength) { - delegate.setChunkedStreamingMode(chunkLength); - } - } + static final class OkHttpsURLConnection extends DelegatingHttpsURLConnection { + private final OkHttpURLConnection delegate; - static final class OkHttpsURLConnection extends DelegatingHttpsURLConnection { - private final OkHttpURLConnection delegate; + OkHttpsURLConnection(URL url, OkHttpClient client) { + this(new OkHttpURLConnection(url, client)); + } - OkHttpsURLConnection(URL url, OkHttpClient client) { - this(new OkHttpURLConnection(url, client)); - } + OkHttpsURLConnection(OkHttpURLConnection delegate) { + super(delegate); + this.delegate = delegate; + } - OkHttpsURLConnection(OkHttpURLConnection delegate) { - super(delegate); - this.delegate = delegate; - } + @Override + protected Handshake handshake() { + if (delegate.call == null) { + throw new IllegalStateException("Connection has not yet been established"); + } - @Override protected Handshake handshake() { - if (delegate.call == null) { - throw new IllegalStateException("Connection has not yet been established"); - } + return delegate.handshake; + } - return delegate.handshake; - } + @Override + public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { + delegate.client = delegate.client.newBuilder().hostnameVerifier(hostnameVerifier).build(); + } - @Override public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { - delegate.client = delegate.client.newBuilder() - .hostnameVerifier(hostnameVerifier) - .build(); - } + @Override + public HostnameVerifier getHostnameVerifier() { + return delegate.client.hostnameVerifier(); + } - @Override public HostnameVerifier getHostnameVerifier() { - return delegate.client.hostnameVerifier(); - } + @Override + public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) { + if (sslSocketFactory == null) { + throw new IllegalArgumentException("sslSocketFactory == null"); + } + // This fails in JDK 9 because OkHttp is unable to extract the trust manager. + delegate.client = delegate.client.newBuilder().sslSocketFactory(sslSocketFactory).build(); + } - @Override public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) { - if (sslSocketFactory == null) { - throw new IllegalArgumentException("sslSocketFactory == null"); - } - // This fails in JDK 9 because OkHttp is unable to extract the trust manager. - delegate.client = delegate.client.newBuilder() - .sslSocketFactory(sslSocketFactory) - .build(); + @Override + public SSLSocketFactory getSSLSocketFactory() { + return delegate.client.sslSocketFactory(); + } } - @Override public SSLSocketFactory getSSLSocketFactory() { - return delegate.client.sslSocketFactory(); - } - } - - static final class UnexpectedException extends IOException { - static final Interceptor INTERCEPTOR = chain -> { - try { - return chain.proceed(chain.request()); - } catch (Error | RuntimeException e) { - throw new UnexpectedException(e); - } - }; + static final class UnexpectedException extends IOException { + static final Interceptor INTERCEPTOR = chain -> { + try { + return chain.proceed(chain.request()); + } catch (Error | RuntimeException e) { + throw new UnexpectedException(e); + } + }; - UnexpectedException(Throwable cause) { - super(cause); + UnexpectedException(Throwable cause) { + super(cause); + } } - } -} \ No newline at end of file +} diff --git a/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java b/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java index 315ac0c352..ebfc09ad6e 100644 --- a/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java +++ b/src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java @@ -3,25 +3,20 @@ import com.squareup.okhttp.CacheControl; import okhttp3.ConnectionSpec; import okhttp3.OkHttpClient; - import org.kohsuke.github.HttpConnector; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; - import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; - /** * {@link HttpConnector} for {@link OkHttpClient}. - * - * Unlike {@link #DEFAULT}, OkHttp does response caching. - * Making a conditional request against GitHubAPI and receiving a 304 - * response does not count against the rate limit. - * See http://developer.github.com/v3/#conditional-requests + *

+ * Unlike {@link #DEFAULT}, OkHttp does response caching. Making a conditional request against GitHubAPI and receiving a + * 304 response does not count against the rate limit. See http://developer.github.com/v3/#conditional-requests * * @author Liam Newman * @author Kohsuke Kawaguchi @@ -33,11 +28,24 @@ public class OkHttpConnector implements HttpConnector { private final OkHttpClient client; private final ObsoleteUrlFactory urlFactory; - + /** + * Instantiates a new Ok http connector. + * + * @param client + * the client + */ public OkHttpConnector(OkHttpClient client) { this(client, 0); } + /** + * Instantiates a new Ok http connector. + * + * @param client + * the client + * @param cacheMaxAge + * the cache max age + */ public OkHttpConnector(OkHttpClient client, int cacheMaxAge) { OkHttpClient.Builder builder = client.newBuilder(); @@ -45,10 +53,7 @@ public OkHttpConnector(OkHttpClient client, int cacheMaxAge) { builder.connectionSpecs(TlsConnectionSpecs()); this.client = builder.build(); if (cacheMaxAge >= 0 && this.client != null && this.client.cache() != null) { - maxAgeHeaderValue = new CacheControl.Builder() - .maxAge(cacheMaxAge, TimeUnit.SECONDS) - .build() - .toString(); + maxAgeHeaderValue = new CacheControl.Builder().maxAge(cacheMaxAge, TimeUnit.SECONDS).build().toString(); } else { maxAgeHeaderValue = null; } @@ -74,4 +79,4 @@ public HttpURLConnection connect(URL url) throws IOException { private List TlsConnectionSpecs() { return Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.CLEARTEXT); } -} \ No newline at end of file +} diff --git a/src/main/resources/eclipse/formatter.xml b/src/main/resources/eclipse/formatter.xml new file mode 100644 index 0000000000..2e5dcc607f --- /dev/null +++ b/src/main/resources/eclipse/formatter.xml @@ -0,0 +1,383 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/kohsuke/HookApp.java b/src/test/java/org/kohsuke/HookApp.java index 4f8ced9685..9ee51407a0 100644 --- a/src/test/java/org/kohsuke/HookApp.java +++ b/src/test/java/org/kohsuke/HookApp.java @@ -9,15 +9,15 @@ import java.io.StringReader; /** - * App to test the hook script. You need some internet-facing server that can forward the request to you - * (typically via SSH reverse port forwarding.) + * App to test the hook script. You need some internet-facing server that can forward the request to you (typically via + * SSH reverse port forwarding.) * * @author Kohsuke Kawaguchi */ public class HookApp { public static void main(String[] args) throws Exception { -// GitHub.connect().getMyself().getRepository("sandbox").createWebHook( -// new URL("http://173.203.118.45:18080/"), EnumSet.of(GHEvent.PULL_REQUEST)); + // GitHub.connect().getMyself().getRepository("sandbox").createWebHook( + // new URL("http://173.203.118.45:18080/"), EnumSet.of(GHEvent.PULL_REQUEST)); JettyRunner jr = new JettyRunner(new HookApp()); jr.addHttpListener(8080); jr.start(); @@ -26,7 +26,8 @@ public static void main(String[] args) throws Exception { public void doIndex(StaplerRequest req) throws IOException { String str = req.getParameter("payload"); // System.out.println(str); - GHEventPayload.PullRequest o = GitHub.connect().parseEventPayload(new StringReader(str), GHEventPayload.PullRequest.class); + GHEventPayload.PullRequest o = GitHub.connect() + .parseEventPayload(new StringReader(str), GHEventPayload.PullRequest.class); // System.out.println(o); } } diff --git a/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java b/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java index 0c5010c32c..ff5d5955ae 100644 --- a/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java +++ b/src/test/java/org/kohsuke/github/AbstractGitHubApiTestBase.java @@ -1,17 +1,8 @@ package org.kohsuke.github; -import java.io.FileInputStream; -import java.util.Properties; - -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Assume; import org.junit.Before; import org.kohsuke.randname.RandomNameGenerator; -import java.io.File; -import java.io.IOException; - import static org.junit.Assume.assumeTrue; /** @@ -21,7 +12,8 @@ public abstract class AbstractGitHubApiTestBase extends AbstractGitHubWireMockTe @Before public void setUp() throws Exception { - assumeTrue("All tests inheriting from this class are not guaranteed to work without proxy", mockGitHub.isUseProxy()); + assumeTrue("All tests inheriting from this class are not guaranteed to work without proxy", + mockGitHub.isUseProxy()); } protected void kohsuke() { diff --git a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java index 7c5892eea9..9bafb4d9d1 100644 --- a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java +++ b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java @@ -33,15 +33,13 @@ public abstract class AbstractGitHubWireMockTest extends Assert { protected final Set tempGitHubRepositories = new HashSet<>(); /** - * {@link GitHub} instance for use during test. - * Traffic will be part of snapshot when taken. + * {@link GitHub} instance for use during test. Traffic will be part of snapshot when taken. */ protected GitHub gitHub; /** - * {@link GitHub} instance for use before/after test. - * Traffic will not be part of snapshot when taken. - * Should only be used when isUseProxy() or isTakeSnapShot(). + * {@link GitHub} instance for use before/after test. Traffic will not be part of snapshot when taken. Should only + * be used when isUseProxy() or isTakeSnapShot(). */ protected GitHub gitHubBeforeAfter; @@ -52,15 +50,11 @@ public abstract class AbstractGitHubWireMockTest extends Assert { public final GitHubWireMockRule mockGitHub; public AbstractGitHubWireMockTest() { - mockGitHub = new GitHubWireMockRule( - this.getWireMockOptions() - ); + mockGitHub = new GitHubWireMockRule(this.getWireMockOptions()); } protected WireMockConfiguration getWireMockOptions() { - return WireMockConfiguration.options() - .dynamicPort() - .usingFilesUnderDirectory(baseRecordPath); + return WireMockConfiguration.options().dynamicPort().usingFilesUnderDirectory(baseRecordPath); } private static GitHubBuilder createGitHubBuilder() { @@ -109,29 +103,27 @@ protected GitHubBuilder getGitHubBuilder() { @Before public void wireMockSetup() throws Exception { - GitHubBuilder builder = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()); + GitHubBuilder builder = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()); if (useDefaultGitHub) { - gitHub = builder - .build(); + gitHub = builder.build(); } if (mockGitHub.isUseProxy()) { - gitHubBeforeAfter = getGitHubBuilder() - .withEndpoint("https://api.github.com/") - .build(); + gitHubBeforeAfter = getGitHubBuilder().withEndpoint("https://api.github.com/").build(); } else { gitHubBeforeAfter = null; } } protected void snapshotNotAllowed() { - assumeFalse("Test contains hand written mappings. Only valid when not taking a snapshot.", mockGitHub.isTakeSnapshot()); + assumeFalse("Test contains hand written mappings. Only valid when not taking a snapshot.", + mockGitHub.isTakeSnapshot()); } protected void requireProxy(String reason) { - assumeTrue("Test only valid when proxying (-Dtest.github.useProxy to enable): " + reason, mockGitHub.isUseProxy()); + assumeTrue("Test only valid when proxying (-Dtest.github.useProxy to enable): " + reason, + mockGitHub.isUseProxy()); } protected GHUser getUser() { @@ -147,49 +139,57 @@ protected static GHUser getUser(GitHub gitHub) { } /** + * Creates a temporary repository that will be deleted at the end of the test. Repository name is based on the + * current test method. * + * @return a temporary repository + * @throws IOException + * if repository could not be created or retrieved. */ - protected GHRepository getTempRepository() throws IOException{ + protected GHRepository getTempRepository() throws IOException { return getTempRepository("temp-" + this.mockGitHub.getMethodName()); } /** - * Creates + * Creates a temporary repository that will be deleted at the end of the test. + * + * @param name + * string name of the the repository + * + * @return a temporary repository + * @throws IOException + * if repository could not be created or retrieved. */ protected GHRepository getTempRepository(String name) throws IOException { - String fullName = GITHUB_API_TEST_ORG +'/' + name; + String fullName = GITHUB_API_TEST_ORG + '/' + name; if (mockGitHub.isUseProxy()) { cleanupRepository(fullName); GHRepository repository = gitHubBeforeAfter.getOrganization(GITHUB_API_TEST_ORG) - .createRepository(name) - .description("A test repository for testing the github-api project: " + name) - .homepage("http://github-api.kohsuke.org/") - .autoInit(true) - .create(); + .createRepository(name) + .description("A test repository for testing the github-api project: " + name) + .homepage("http://github-api.kohsuke.org/") + .autoInit(true) + .wiki(true) + .downloads(true) + .issues(true) + .private_(false) + .create(); try { Thread.sleep(3000); } catch (InterruptedException e) { throw new RuntimeException(e.getMessage(), e); } - - configureTempRepository(repository); } return gitHub.getRepository(fullName); } - protected void configureTempRepository(GHRepository repository) throws IOException { - repository.enableIssueTracker(true); - repository.enableDownloads(true); - repository.enableWiki(true); - } - @Before @After public void cleanupTempRepositories() throws IOException { if (mockGitHub.isUseProxy()) { - for(String fullName : tempGitHubRepositories) { + for (String fullName : tempGitHubRepositories) { cleanupRepository(fullName); } } @@ -215,8 +215,8 @@ protected void kohsuke() { // Generally this means the test is doing something that requires additional access rights // Not always clear which ones. // TODO: Add helpers that assert the expected rights using gitHubBeforeAfter and only when proxy is enabled -// String login = getUserTest().getLogin(); -// assumeTrue(login.equals("kohsuke") || login.equals("kohsuke2")); + // String login = getUserTest().getLogin(); + // assumeTrue(login.equals("kohsuke") || login.equals("kohsuke2")); } } diff --git a/src/test/java/org/kohsuke/github/AppTest.java b/src/test/java/org/kohsuke/github/AppTest.java index 9f4d253ef5..fd223bb287 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -2,8 +2,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - import org.apache.commons.io.IOUtils; import org.junit.Ignore; import org.junit.Test; @@ -34,7 +32,10 @@ public void testRepoCRUD() throws Exception { cleanupUserRepository("github-api-test-rename"); cleanupUserRepository(targetName); - GHRepository r = gitHub.createRepository("github-api-test-rename", "a test repository", "http://github-api.kohsuke.org/", true); + GHRepository r = gitHub.createRepository("github-api-test-rename", + "a test repository", + "http://github-api.kohsuke.org/", + true); assertThat(r.hasIssues(), is(true)); r.enableIssueTracker(false); @@ -49,9 +50,10 @@ public void testRepositoryWithAutoInitializationCRUD() throws Exception { String name = "github-api-test-autoinit"; cleanupUserRepository(name); GHRepository r = gitHub.createRepository(name) - .description("a test repository for auto init") - .homepage("http://github-api.kohsuke.org/") - .autoInit(true).create(); + .description("a test repository for auto init") + .homepage("http://github-api.kohsuke.org/") + .autoInit(true) + .create(); r.enableIssueTracker(false); r.enableDownloads(false); r.enableWiki(false); @@ -79,11 +81,11 @@ public void testCredentialValid() throws IOException { public void testIssueWithNoComment() throws IOException { GHRepository repository = gitHub.getRepository("kohsuke/test"); List v = repository.getIssue(4).getComments(); - //System.out.println(v); + // System.out.println(v); assertTrue(v.isEmpty()); v = repository.getIssue(3).getComments(); - //System.out.println(v); + // System.out.println(v); assertTrue(v.size() == 3); } @@ -93,12 +95,12 @@ public void testCreateIssue() throws IOException { GHRepository repository = getTestRepository(); GHMilestone milestone = repository.createMilestone("Test Milestone Title3", "Test Milestone"); GHIssue o = repository.createIssue("testing") - .body("this is body") - .assignee(u) - .label("bug") - .label("question") - .milestone(milestone) - .create(); + .body("this is body") + .assignee(u) + .label("bug") + .label("question") + .milestone(milestone) + .create(); assertNotNull(o); o.close(); } @@ -107,10 +109,10 @@ public void testCreateIssue() throws IOException { public void testCreateAndListDeployments() throws IOException { GHRepository repository = getTestRepository(); GHDeployment deployment = repository.createDeployment("master") - .payload("{\"user\":\"atmos\",\"room_id\":123456}") - .description("question") - .environment("unittest") - .create(); + .payload("{\"user\":\"atmos\",\"room_id\":123456}") + .description("question") + .environment("unittest") + .create(); assertNotNull(deployment.getCreator()); assertNotNull(deployment.getId()); List deployments = repository.listDeployments(null, "master", null, "unittest").asList(); @@ -126,12 +128,13 @@ public void testCreateAndListDeployments() throws IOException { public void testGetDeploymentStatuses() throws IOException { GHRepository repository = getTestRepository(); GHDeployment deployment = repository.createDeployment("master") - .description("question") - .payload("{\"user\":\"atmos\",\"room_id\":123456}") - .create(); + .description("question") + .payload("{\"user\":\"atmos\",\"room_id\":123456}") + .create(); GHDeploymentStatus ghDeploymentStatus = deployment.createStatus(GHDeploymentState.SUCCESS) - .description("success") - .targetUrl("http://www.github.com").create(); + .description("success") + .targetUrl("http://www.github.com") + .create(); Iterable deploymentStatuses = deployment.listStatuses(); assertNotNull(deploymentStatuses); assertEquals(1, Iterables.size(deploymentStatuses)); @@ -140,7 +143,9 @@ public void testGetDeploymentStatuses() throws IOException { @Test public void testGetIssues() throws Exception { - List closedIssues = gitHub.getOrganization("github-api").getRepository("github-api").getIssues(GHIssueState.CLOSED); + List closedIssues = gitHub.getOrganization("github-api") + .getRepository("github-api") + .getIssues(GHIssueState.CLOSED); // prior to using PagedIterable GHRepository.getIssues(GHIssueState) would only retrieve 30 issues assertTrue(closedIssues.size() > 150); } @@ -160,18 +165,20 @@ public void testListIssues() throws IOException { GHIssue unhomed = null; GHIssue homed = null; try { - unhomed = repository.createIssue("testing").body("this is body") - .assignee(u) - .label("bug") - .label("question") - .create(); + unhomed = repository.createIssue("testing") + .body("this is body") + .assignee(u) + .label("bug") + .label("question") + .create(); assertEquals(unhomed.getNumber(), repository.getIssues(GHIssueState.OPEN, null).get(0).getNumber()); - homed = repository.createIssue("testing").body("this is body") - .assignee(u) - .label("bug") - .label("question") - .milestone(milestone) - .create(); + homed = repository.createIssue("testing") + .body("this is body") + .assignee(u) + .label("bug") + .label("question") + .milestone(milestone) + .create(); assertEquals(homed.getNumber(), repository.getIssues(GHIssueState.OPEN, milestone).get(0).getNumber()); } finally { if (unhomed != null) { @@ -192,15 +199,15 @@ public void testRateLimit() throws IOException { public void testMyOrganizations() throws IOException { Map org = gitHub.getMyOrganizations(); assertFalse(org.keySet().contains(null)); - //System.out.println(org); + // System.out.println(org); } @Test public void testMyOrganizationsContainMyTeams() throws IOException { Map> teams = gitHub.getMyTeams(); Map myOrganizations = gitHub.getMyOrganizations(); - //GitHub no longer has default 'owners' team, so there may be organization memberships without a team - //https://help.github.com/articles/about-improved-organization-permissions/ + // GitHub no longer has default 'owners' team, so there may be organization memberships without a team + // https://help.github.com/articles/about-improved-organization-permissions/ assertTrue(myOrganizations.keySet().containsAll(teams.keySet())); } @@ -211,30 +218,29 @@ public void testMyTeamsShouldIncludeMyself() throws IOException { String organizationName = teamsPerOrg.getKey(); for (GHTeam team : teamsPerOrg.getValue()) { String teamName = team.getName(); - assertTrue("Team " + teamName + " in organization " + organizationName - + " does not contain myself", - shouldBelongToTeam(organizationName, teamName)); + assertTrue("Team " + teamName + " in organization " + organizationName + " does not contain myself", + shouldBelongToTeam(organizationName, teamName)); } } } - + @Test public void testUserPublicOrganizationsWhenThereAreSome() throws IOException { - // kohsuke had some public org memberships at the time Wiremock recorded the GitHub API responses - GHUser user = new GHUser(); - user.login = "kohsuke"; - - Map orgs = gitHub.getUserPublicOrganizations( user ); + // kohsuke had some public org memberships at the time Wiremock recorded the GitHub API responses + GHUser user = new GHUser(); + user.login = "kohsuke"; + + Map orgs = gitHub.getUserPublicOrganizations(user); assertFalse(orgs.isEmpty()); } - + @Test public void testUserPublicOrganizationsWhenThereAreNone() throws IOException { - // bitwiseman had no public org memberships at the time Wiremock recorded the GitHub API responses - GHUser user = new GHUser(); - user.login = "bitwiseman"; - - Map orgs = gitHub.getUserPublicOrganizations( user ); + // bitwiseman had no public org memberships at the time Wiremock recorded the GitHub API responses + GHUser user = new GHUser(); + user.login = "bitwiseman"; + + Map orgs = gitHub.getUserPublicOrganizations(user); assertTrue(orgs.isEmpty()); } @@ -318,12 +324,15 @@ public void testOrgFork() throws Exception { public void testGetTeamsForRepo() throws Exception { kohsuke(); // 'Core Developers' and 'Owners' - assertEquals(2, gitHub.getOrganization(GITHUB_API_TEST_ORG).getRepository("testGetTeamsForRepo").getTeams().size()); + assertEquals(2, + gitHub.getOrganization(GITHUB_API_TEST_ORG).getRepository("testGetTeamsForRepo").getTeams().size()); } @Test public void testMembership() throws Exception { - Set members = gitHub.getOrganization(GITHUB_API_TEST_ORG).getRepository("jenkins").getCollaboratorNames(); + Set members = gitHub.getOrganization(GITHUB_API_TEST_ORG) + .getRepository("jenkins") + .getCollaboratorNames(); // System.out.println(members.contains("kohsuke")); } @@ -360,11 +369,13 @@ public void testOrgTeamBySlug() throws Exception { @Test public void testCommit() throws Exception { - GHCommit commit = gitHub.getUser("jenkinsci").getRepository("jenkins").getCommit("08c1c9970af4d609ae754fbe803e06186e3206f7"); + GHCommit commit = gitHub.getUser("jenkinsci") + .getRepository("jenkins") + .getCommit("08c1c9970af4d609ae754fbe803e06186e3206f7"); assertEquals(1, commit.getParents().size()); assertEquals(1, commit.getFiles().size()); assertEquals("https://github.com/jenkinsci/jenkins/commit/08c1c9970af4d609ae754fbe803e06186e3206f7", - commit.getHtmlUrl().toString()); + commit.getHtmlUrl().toString()); File f = commit.getFiles().get(0); assertEquals(48, f.getLinesChanged()); @@ -389,8 +400,13 @@ public void testListCommits() throws Exception { public void testQueryCommits() throws Exception { List sha1 = new ArrayList(); - for (GHCommit c : gitHub.getUser("jenkinsci").getRepository("jenkins").queryCommits() - .since(new Date(1199174400000L)).until(1201852800000L).path("pom.xml").list()) { + for (GHCommit c : gitHub.getUser("jenkinsci") + .getRepository("jenkins") + .queryCommits() + .since(new Date(1199174400000L)) + .until(1201852800000L) + .path("pom.xml") + .list()) { // System.out.println(c.getSHA1()); sha1.add(c.getSHA1()); } @@ -401,8 +417,7 @@ public void testQueryCommits() throws Exception { @Ignore("Needs mocking check") @Test public void testBranches() throws Exception { - Map b = - gitHub.getUser("jenkinsci").getRepository("jenkins").getBranches(); + Map b = gitHub.getUser("jenkinsci").getRepository("jenkins").getBranches(); // System.out.println(b); } @@ -419,7 +434,9 @@ public void testCommitComment() throws Exception { @Test public void testCreateCommitComment() throws Exception { - GHCommit commit = gitHub.getUser("kohsuke").getRepository("sandbox-ant").getCommit("8ae38db0ea5837313ab5f39d43a6f73de3bd9000"); + GHCommit commit = gitHub.getUser("kohsuke") + .getRepository("sandbox-ant") + .getCommit("8ae38db0ea5837313ab5f39d43a6f73de3bd9000"); GHCommitComment c = commit.createComment("[testing](http://kohsuse.org/)"); // System.out.println(c); c.update("updated text"); @@ -457,48 +474,50 @@ public void testEventApi() throws Exception { public void testApp() throws IOException { // System.out.println(gitHub.getMyself().getEmails()); -// GHRepository r = gitHub.getOrganization("jenkinsci").createRepository("kktest4", "Kohsuke's test", "http://kohsuke.org/", "Everyone", true); -// r.fork(); + // GHRepository r = gitHub.getOrganization("jenkinsci").createRepository("kktest4", "Kohsuke's test", + // "http://kohsuke.org/", "Everyone", true); + // r.fork(); -// tryDisablingIssueTrackers(gitHub); + // tryDisablingIssueTrackers(gitHub); -// tryDisablingWiki(gitHub); + // tryDisablingWiki(gitHub); -// GHPullRequest i = gitHub.getOrganization("jenkinsci").getRepository("sandbox").getPullRequest(1); -// for (GHIssueComment c : i.getComments()) -// // System.out.println(c); -// // System.out.println(i); + // GHPullRequest i = gitHub.getOrganization("jenkinsci").getRepository("sandbox").getPullRequest(1); + // for (GHIssueComment c : i.getComments()) + // // System.out.println(c); + // // System.out.println(i); -// gitHub.getMyself().getRepository("perforce-plugin").setEmailServiceHook("kk@kohsuke.org"); + // gitHub.getMyself().getRepository("perforce-plugin").setEmailServiceHook("kk@kohsuke.org"); -// tryRenaming(gitHub); -// tryOrgFork(gitHub); + // tryRenaming(gitHub); + // tryOrgFork(gitHub); -// testOrganization(gitHub); -// testPostCommitHook(gitHub); + // testOrganization(gitHub); + // testPostCommitHook(gitHub); -// tryTeamCreation(gitHub); + // tryTeamCreation(gitHub); -// t.add(gitHub.getMyself()); -// // System.out.println(t.getMembers()); -// t.remove(gitHub.getMyself()); -// // System.out.println(t.getMembers()); + // t.add(gitHub.getMyself()); + // // System.out.println(t.getMembers()); + // t.remove(gitHub.getMyself()); + // // System.out.println(t.getMembers()); -// GHRepository r = gitHub.getOrganization("HudsonLabs").createRepository("auto-test", "some description", "http://kohsuke.org/", "Plugin Developers", true); + // GHRepository r = gitHub.getOrganization("HudsonLabs").createRepository("auto-test", "some description", + // "http://kohsuke.org/", "Plugin Developers", true); -// r. -// GitHub hub = GitHub.connectAnonymously(); -//// hub.createRepository("test","test repository",null,true); -//// hub.getUserTest("kohsuke").getRepository("test").delete(); -// -// // System.out.println(hub.getUserTest("kohsuke").getRepository("hudson").getCollaborators()); + // r. + // GitHub hub = GitHub.connectAnonymously(); + //// hub.createRepository("test","test repository",null,true); + //// hub.getUserTest("kohsuke").getRepository("test").delete(); + // + // // System.out.println(hub.getUserTest("kohsuke").getRepository("hudson").getCollaborators()); } private void tryDisablingIssueTrackers(GitHub gitHub) throws IOException { for (GHRepository r : gitHub.getOrganization("jenkinsci").getRepositories().values()) { if (r.hasIssues()) { if (r.getOpenIssueCount() == 0) { - // System.out.println("DISABLED " + r.getName()); + // System.out.println("DISABLED " + r.getName()); r.enableIssueTracker(false); } else { // System.out.println("UNTOUCHED " + r.getName()); @@ -510,7 +529,7 @@ private void tryDisablingIssueTrackers(GitHub gitHub) throws IOException { private void tryDisablingWiki(GitHub gitHub) throws IOException { for (GHRepository r : gitHub.getOrganization("jenkinsci").getRepositories().values()) { if (r.hasWiki()) { - // System.out.println("DISABLED " + r.getName()); + // System.out.println("DISABLED " + r.getName()); r.enableWiki(false); } } @@ -560,7 +579,7 @@ public void testOrganization() throws IOException { assertNotNull(j.getRepository("jenkins")); -// t.add(labs.getRepository("xyz")); + // t.add(labs.getRepository("xyz")); } @Test @@ -569,7 +588,8 @@ public void testCommitStatus() throws Exception { GHCommitStatus state; -// state = r.createCommitStatus("ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", GHCommitState.FAILURE, "http://kohsuke.org/", "testing!"); + // state = r.createCommitStatus("ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396", GHCommitState.FAILURE, + // "http://kohsuke.org/", "testing!"); List lst = r.listCommitStatuses("ecbfdd7315ef2cf04b2be7f11a072ce0bd00c396").asList(); state = lst.get(0); @@ -619,10 +639,7 @@ public void testCreateRelease() throws Exception { String tagName = UUID.randomUUID().toString(); String releaseName = "release-" + tagName; - GHRelease rel = r.createRelease(tagName) - .name(releaseName) - .prerelease(false) - .create(); + GHRelease rel = r.createRelease(tagName).name(releaseName).prerelease(false).create(); Thread.sleep(3000); @@ -652,7 +669,8 @@ public void testCreateRelease() throws Exception { @Test public void testRef() throws IOException { GHRef masterRef = gitHub.getRepository("jenkinsci/jenkins").getRef("heads/master"); - assertEquals(mockGitHub.apiServer().baseUrl() + "/repos/jenkinsci/jenkins/git/refs/heads/master", masterRef.getUrl().toString()); + assertEquals(mockGitHub.apiServer().baseUrl() + "/repos/jenkinsci/jenkins/git/refs/heads/master", + masterRef.getUrl().toString()); } @Test @@ -662,7 +680,7 @@ public void directoryListing() throws IOException { // System.out.println(c.getName()); if (c.isDirectory()) { for (GHContent d : c.listDirectoryContent()) { - // System.out.println(" " + d.getName()); + // System.out.println(" " + d.getName()); } } } @@ -672,7 +690,8 @@ public void directoryListing() throws IOException { @Test public void testAddDeployKey() throws IOException { GHRepository myRepository = getTestRepository(); - final GHDeployKey newDeployKey = myRepository.addDeployKey("test", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUt0RAycC5cS42JKh6SecfFZBR1RrF+2hYMctz4mk74/arBE+wFb7fnSHGzdGKX2h5CFOWODifRCJVhB7hlVxodxe+QkQQYAEL/x1WVCJnGgTGQGOrhOMj95V3UE5pQKhsKD608C+u5tSofcWXLToP1/wZ7U4/AHjqYi08OLsWToHCax55TZkvdt2jo0hbIoYU+XI9Q8Uv4ONDN1oabiOdgeKi8+crvHAuvNleiBhWVBzFh8KdfzaH5uNdw7ihhFjEd1vzqACsjCINCjdMfzl6jD9ExuWuE92nZJnucls2cEoNC6k2aPmrZDg9hA32FXVpyseY+bDUWFU6LO2LG6PB kohsuke@atlas"); + final GHDeployKey newDeployKey = myRepository.addDeployKey("test", + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUt0RAycC5cS42JKh6SecfFZBR1RrF+2hYMctz4mk74/arBE+wFb7fnSHGzdGKX2h5CFOWODifRCJVhB7hlVxodxe+QkQQYAEL/x1WVCJnGgTGQGOrhOMj95V3UE5pQKhsKD608C+u5tSofcWXLToP1/wZ7U4/AHjqYi08OLsWToHCax55TZkvdt2jo0hbIoYU+XI9Q8Uv4ONDN1oabiOdgeKi8+crvHAuvNleiBhWVBzFh8KdfzaH5uNdw7ihhFjEd1vzqACsjCINCjdMfzl6jD9ExuWuE92nZJnucls2cEoNC6k2aPmrZDg9hA32FXVpyseY+bDUWFU6LO2LG6PB kohsuke@atlas"); try { assertNotNull(newDeployKey.getId()); @@ -692,7 +711,8 @@ public boolean apply(GHDeployKey deployKey) { public void testCommitStatusContext() throws IOException { GHRepository myRepository = getTestRepository(); GHRef masterRef = myRepository.getRef("heads/master"); - GHCommitStatus commitStatus = myRepository.createCommitStatus(masterRef.getObject().getSha(), GHCommitState.SUCCESS, "http://www.example.com", "test", "test/context"); + GHCommitStatus commitStatus = myRepository.createCommitStatus(masterRef.getObject() + .getSha(), GHCommitState.SUCCESS, "http://www.example.com", "test", "test/context"); assertEquals("test/context", commitStatus.getContext()); } @@ -728,14 +748,13 @@ public void testIssueSearch() throws IOException { } @Ignore("Needs mocking check") - @Test // issue #99 + @Test // issue #99 public void testReadme() throws IOException { GHContent readme = gitHub.getRepository("github-api-test-org/test-readme").getReadme(); assertEquals(readme.getName(), "README.md"); assertEquals(readme.getContent(), "This is a markdown readme.\n"); } - @Ignore("Needs mocking check") @Test public void testTrees() throws IOException { @@ -861,12 +880,10 @@ public void notifications() throws Exception { gitHub.listNotifications().markAsRead(); } - /** - * Just basic code coverage to make sure toString() doesn't blow up - */ @Ignore("Needs mocking check") @Test public void checkToString() throws Exception { + // Just basic code coverage to make sure toString() doesn't blow up GHUser u = gitHub.getUser("rails"); // System.out.println(u); GHRepository r = u.getRepository("rails"); diff --git a/src/test/java/org/kohsuke/github/BridgeMethodTest.java b/src/test/java/org/kohsuke/github/BridgeMethodTest.java index 9e840f5fbf..0256b72515 100644 --- a/src/test/java/org/kohsuke/github/BridgeMethodTest.java +++ b/src/test/java/org/kohsuke/github/BridgeMethodTest.java @@ -24,7 +24,7 @@ public void lastStatus() throws IOException { List createdAtMethods = new ArrayList<>(); for (Method method : obj.getClass().getMethods()) { if (method.getName().equalsIgnoreCase("getCreatedAt")) { - if(method.getReturnType() == Date.class) { + if (method.getReturnType() == Date.class) { createdAtMethods.add(0, method); } else { createdAtMethods.add(method); diff --git a/src/test/java/org/kohsuke/github/GHAppTest.java b/src/test/java/org/kohsuke/github/GHAppTest.java index 3c9bd0ff0f..980f3c8f6f 100644 --- a/src/test/java/org/kohsuke/github/GHAppTest.java +++ b/src/test/java/org/kohsuke/github/GHAppTest.java @@ -41,7 +41,6 @@ public void getGitHubApp() throws IOException { assertThat(app.getInstallationsCount(), is((long) 1)); } - @Test public void listInstallations() throws IOException { GHApp app = gitHub.getApp(); @@ -103,12 +102,12 @@ public void createToken() throws IOException { permissions.put("metadata", GHPermissionType.READ); GHAppInstallationToken installationToken = installation.createToken(permissions) - .repositoryIds(Arrays.asList((long)111111111)) + .repositoryIds(Arrays.asList((long) 111111111)) .create(); assertThat(installationToken.getToken(), is("bogus")); assertThat(installation.getPermissions(), is(permissions)); - assertThat(installationToken.getRepositorySelection(),is(GHRepositorySelection.SELECTED)); + assertThat(installationToken.getRepositorySelection(), is(GHRepositorySelection.SELECTED)); assertThat(installationToken.getExpiresAt(), is(GitHub.parseDate("2019-08-10T05:54:58Z"))); GHRepository repository = installationToken.getRepositories().get(0); diff --git a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java index 63f142a3fd..7f15ea61c9 100644 --- a/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java +++ b/src/test/java/org/kohsuke/github/GHBranchProtectionTest.java @@ -6,10 +6,8 @@ import org.kohsuke.github.GHBranchProtection.RequiredReviews; import org.kohsuke.github.GHBranchProtection.RequiredStatusChecks; -import java.io.FileNotFoundException; - -public class GHBranchProtectionTest extends AbstractGitHubApiTestBase { - private static final String BRANCH = "bp-test"; +public class GHBranchProtectionTest extends AbstractGitHubWireMockTest { + private static final String BRANCH = "master"; private static final String BRANCH_REF = "heads/" + BRANCH; private GHBranch branch; @@ -17,45 +15,22 @@ public class GHBranchProtectionTest extends AbstractGitHubApiTestBase { private GHRepository repo; @Before - @Override public void setUp() throws Exception { - super.setUp(); - - repo = gitHub.getRepository("github-api-test-org/GHContentIntegrationTest").fork(); - - try { - repo.getRef(BRANCH_REF); - } catch (FileNotFoundException e) { - repo.createRef("refs/" + BRANCH_REF, repo.getBranch("master").getSHA1()); - } - + repo = getTempRepository(); branch = repo.getBranch(BRANCH); - - if (branch.isProtected()) { - GHBranchProtection protection = branch.getProtection(); - if (protection.getRequiredSignatures()) { - protection.disableSignedCommits(); - } - - assertFalse(protection.getRequiredSignatures()); - branch.disableProtection(); - } - - branch = repo.getBranch(BRANCH); - assertFalse(branch.isProtected()); } @Test public void testEnableBranchProtections() throws Exception { // team/user restrictions require an organization repo to test against GHBranchProtection protection = branch.enableProtection() - .addRequiredChecks("test-status-check") - .requireBranchIsUpToDate() - .requireCodeOwnReviews() - .dismissStaleReviews() - .requiredReviewers(2) - .includeAdmins() - .enable(); + .addRequiredChecks("test-status-check") + .requireBranchIsUpToDate() + .requireCodeOwnReviews() + .dismissStaleReviews() + .requiredReviewers(2) + .includeAdmins() + .enable(); RequiredStatusChecks statusChecks = protection.getRequiredStatusChecks(); assertNotNull(statusChecks); @@ -81,9 +56,7 @@ public void testEnableProtectionOnly() throws Exception { @Test public void testEnableRequireReviewsOnly() throws Exception { - GHBranchProtection protection = branch.enableProtection() - .requireReviews() - .enable(); + GHBranchProtection protection = branch.enableProtection().requireReviews().enable(); assertNotNull(protection.getRequiredReviews()); } diff --git a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java index e3a37f80d0..0df362c7a5 100644 --- a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java +++ b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -10,25 +9,31 @@ import java.io.InputStreamReader; import java.util.List; +import static org.hamcrest.CoreMatchers.*; + /** * Integration test for {@link GHContent}. */ public class GHContentIntegrationTest extends AbstractGitHubWireMockTest { private GHRepository repo; - private String createdFilename = "test-file-to-create.txt"; + + // file name with spaces and other chars + private final String createdDirectory = "test+directory #50"; + private final String createdFilename = createdDirectory + "/test file-to+create-#1.txt"; @Before @After public void cleanup() throws Exception { - if(mockGitHub.isUseProxy()) { + if (mockGitHub.isUseProxy()) { repo = gitHubBeforeAfter.getRepository("github-api-test-org/GHContentIntegrationTest"); try { GHContent content = repo.getFileContent(createdFilename); if (content != null) { content.delete("Cleanup"); } - } catch (IOException e) {} + } catch (IOException e) { + } } } @@ -37,7 +42,6 @@ public void setUp() throws Exception { repo = gitHub.getRepository("github-api-test-org/GHContentIntegrationTest"); } - @Test public void testGetFileContent() throws Exception { repo = gitHub.getRepository("github-api-test-org/GHContentIntegrationTest"); @@ -64,7 +68,7 @@ public void testGetDirectoryContent() throws Exception { @Test public void testGetDirectoryContentTrailingSlash() throws Exception { - //Used to truncate the ?ref=master, see gh-224 https://github.com/kohsuke/github-api/pull/224 + // Used to truncate the ?ref=master, see gh-224 https://github.com/kohsuke/github-api/pull/224 List entries = repo.getDirectoryContent("ghcontent-ro/a-dir-with-3-entries/", "master"); assertTrue(entries.get(0).getUrl().endsWith("?ref=master")); @@ -72,27 +76,53 @@ public void testGetDirectoryContentTrailingSlash() throws Exception { @Test public void testCRUDContent() throws Exception { - GHContentUpdateResponse created = - repo.createContent("this is an awesome file I created\n", "Creating a file for integration tests.", createdFilename); + GHContentUpdateResponse created = repo.createContent("this is an awesome file I created\n", + "Creating a file for integration tests.", + createdFilename); GHContent createdContent = created.getContent(); assertNotNull(created.getCommit()); assertNotNull(created.getContent()); assertNotNull(createdContent.getContent()); + assertThat(createdContent.getPath(), equalTo(createdFilename)); assertEquals("this is an awesome file I created\n", createdContent.getContent()); - GHContentUpdateResponse updatedContentResponse = createdContent.update("this is some new content\n", "Updated file for integration tests."); + GHContent content = repo.getFileContent(createdFilename); + assertThat(content, is(notNullValue())); + assertThat(content.getSha(), equalTo(createdContent.getSha())); + assertThat(content.getContent(), equalTo(createdContent.getContent())); + assertThat(content.getPath(), equalTo(createdContent.getPath())); + + List directoryContents = repo.getDirectoryContent(createdDirectory); + assertThat(directoryContents, is(notNullValue())); + assertThat(directoryContents.size(), equalTo(1)); + content = directoryContents.get(0); + assertThat(content.getSha(), is(created.getContent().getSha())); + assertThat(content.getContent(), is(created.getContent().getContent())); + assertThat(content.getPath(), equalTo(createdFilename)); + + GHContentUpdateResponse updatedContentResponse = createdContent.update("this is some new content\n", + "Updated file for integration tests."); GHContent updatedContent = updatedContentResponse.getContent(); assertNotNull(updatedContentResponse.getCommit()); assertNotNull(updatedContentResponse.getContent()); // due to what appears to be a cache propagation delay, this test is too flaky - assertEquals("this is some new content", new BufferedReader(new InputStreamReader(updatedContent.read())).readLine()); + assertEquals("this is some new content", + new BufferedReader(new InputStreamReader(updatedContent.read())).readLine()); assertEquals("this is some new content\n", updatedContent.getContent()); GHContentUpdateResponse deleteResponse = updatedContent.delete("Enough of this foolishness!"); assertNotNull(deleteResponse.getCommit()); assertNull(deleteResponse.getContent()); + + try { + repo.getFileContent(createdFilename); + fail("Delete didn't work!"); + } catch (GHFileNotFoundException e) { + assertThat(e.getMessage(), + equalTo("{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/contents/#get-contents\"}")); + } } } diff --git a/src/test/java/org/kohsuke/github/GHDeploymentTest.java b/src/test/java/org/kohsuke/github/GHDeploymentTest.java index 1c228c7aad..b2dc602b15 100644 --- a/src/test/java/org/kohsuke/github/GHDeploymentTest.java +++ b/src/test/java/org/kohsuke/github/GHDeploymentTest.java @@ -3,6 +3,7 @@ import org.junit.Test; import java.io.IOException; + import static org.junit.Assert.assertNotNull; /** diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 5287f4dab1..481396a48c 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -14,8 +14,8 @@ public class GHEventPayloadTest { @Test public void commit_comment() throws Exception { - GHEventPayload.CommitComment event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.CommitComment.class); + GHEventPayload.CommitComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.CommitComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getComment().getSHA1(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); assertThat(event.getComment().getUser().getLogin(), is("baxterthehacker")); @@ -26,8 +26,8 @@ public void commit_comment() throws Exception { @Test public void create() throws Exception { - GHEventPayload.Create event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Create.class); + GHEventPayload.Create event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Create.class); assertThat(event.getRef(), is("0.0.1")); assertThat(event.getRefType(), is("tag")); assertThat(event.getMasterBranch(), is("master")); @@ -39,8 +39,8 @@ public void create() throws Exception { @Test public void delete() throws Exception { - GHEventPayload.Delete event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Delete.class); + GHEventPayload.Delete event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Delete.class); assertThat(event.getRef(), is("simple-tag")); assertThat(event.getRefType(), is("tag")); assertThat(event.getRepository().getName(), is("public-repo")); @@ -50,8 +50,8 @@ public void delete() throws Exception { @Test public void deployment() throws Exception { - GHEventPayload.Deployment event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Deployment.class); + GHEventPayload.Deployment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Deployment.class); assertThat(event.getDeployment().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); assertThat(event.getDeployment().getEnvironment(), is("production")); assertThat(event.getDeployment().getCreator().getLogin(), is("baxterthehacker")); @@ -62,8 +62,8 @@ public void deployment() throws Exception { @Test public void deployment_status() throws Exception { - GHEventPayload.DeploymentStatus event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.DeploymentStatus.class); + GHEventPayload.DeploymentStatus event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.DeploymentStatus.class); assertThat(event.getDeploymentStatus().getState(), is(GHDeploymentState.SUCCESS)); assertThat(event.getDeploymentStatus().getTargetUrl(), nullValue()); assertThat(event.getDeployment().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); @@ -76,8 +76,7 @@ public void deployment_status() throws Exception { @Test public void fork() throws Exception { - GHEventPayload.Fork event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Fork.class); + GHEventPayload.Fork event = GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Fork.class); assertThat(event.getForkee().getName(), is("public-repo")); assertThat(event.getForkee().getOwner().getLogin(), is("baxterandthehackers")); assertThat(event.getRepository().getName(), is("public-repo")); @@ -85,28 +84,28 @@ public void fork() throws Exception { assertThat(event.getSender().getLogin(), is("baxterandthehackers")); } -// TODO uncomment when we have GHPage implemented -// @Test -// public void gollum() throws Exception { -// GHEventPayload.Gollum event = -// GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Gollum.class); -// assertThat(event.getPages().size(), is(1)); -// GHPage page = event.getPages().get(0); -// assertThat(page.getName(), is("Home")); -// assertThat(page.getTitle(), is("Home")); -// assertThat(page.getSummary(), nullValue()); -// assertThat(page.getAction(), is("created")); -// assertThat(page.getSha(), is("91ea1bd42aa2ba166b86e8aefe049e9837214e67")); -// assertThat(page.getHtmlUrl(), is("https://github.com/baxterthehacker/public-repo/wiki/Home")); -// assertThat(event.getRepository().getName(), is("public-repo")); -// assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker")); -// assertThat(event.getSender().getLogin(), is("baxterthehacker")); -// } + // TODO uncomment when we have GHPage implemented + // @Test + // public void gollum() throws Exception { + // GHEventPayload.Gollum event = + // GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Gollum.class); + // assertThat(event.getPages().size(), is(1)); + // GHPage page = event.getPages().get(0); + // assertThat(page.getName(), is("Home")); + // assertThat(page.getTitle(), is("Home")); + // assertThat(page.getSummary(), nullValue()); + // assertThat(page.getAction(), is("created")); + // assertThat(page.getSha(), is("91ea1bd42aa2ba166b86e8aefe049e9837214e67")); + // assertThat(page.getHtmlUrl(), is("https://github.com/baxterthehacker/public-repo/wiki/Home")); + // assertThat(event.getRepository().getName(), is("public-repo")); + // assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker")); + // assertThat(event.getSender().getLogin(), is("baxterthehacker")); + // } @Test public void issue_comment() throws Exception { - GHEventPayload.IssueComment event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.IssueComment.class); + GHEventPayload.IssueComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.IssueComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getIssue().getNumber(), is(2)); assertThat(event.getIssue().getTitle(), is("Spelling error in the README file")); @@ -134,31 +133,31 @@ public void issues() throws Exception { assertThat(event.getSender().getLogin(), is("baxterthehacker")); } -// TODO implement support classes and write test -// @Test -// public void label() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void label() throws Exception {} -// TODO implement support classes and write test -// @Test -// public void member() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void member() throws Exception {} -// TODO implement support classes and write test -// @Test -// public void membership() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void membership() throws Exception {} -// TODO implement support classes and write test -// @Test -// public void milestone() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void milestone() throws Exception {} -// TODO implement support classes and write test -// @Test -// public void page_build() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void page_build() throws Exception {} @Test @Payload("public") public void public_() throws Exception { - GHEventPayload.Public event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Public.class); + GHEventPayload.Public event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Public.class); assertThat(event.getRepository().getName(), is("public-repo")); assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker")); assertThat(event.getSender().getLogin(), is("baxterthehacker")); @@ -166,14 +165,14 @@ public void public_() throws Exception { @Test public void pull_request() throws Exception { - GHEventPayload.PullRequest event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class); + GHEventPayload.PullRequest event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequest.class); assertThat(event.getAction(), is("opened")); assertThat(event.getNumber(), is(1)); assertThat(event.getPullRequest().getNumber(), is(1)); assertThat(event.getPullRequest().getTitle(), is("Update the README with new information")); - assertThat(event.getPullRequest().getBody(), is("This is a pretty simple change that we need to pull into " - + "master.")); + assertThat(event.getPullRequest().getBody(), + is("This is a pretty simple change that we need to pull into " + "master.")); assertThat(event.getPullRequest().getUser().getLogin(), is("baxterthehacker")); assertThat(event.getPullRequest().getHead().getUser().getLogin(), is("baxterthehacker")); assertThat(event.getPullRequest().getHead().getRef(), is("changes")); @@ -199,8 +198,8 @@ public void pull_request() throws Exception { @Test public void pull_request_review() throws Exception { - GHEventPayload.PullRequestReview event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReview.class); + GHEventPayload.PullRequestReview event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReview.class); assertThat(event.getAction(), is("submitted")); assertThat(event.getReview().getId(), is(2626884L)); @@ -228,15 +227,16 @@ public void pull_request_review() throws Exception { @Test public void pull_request_review_comment() throws Exception { - GHEventPayload.PullRequestReviewComment event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReviewComment.class); + GHEventPayload.PullRequestReviewComment event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReviewComment.class); assertThat(event.getAction(), is("created")); assertThat(event.getComment().getBody(), is("Maybe you should use more emojji on this line.")); assertThat(event.getPullRequest().getNumber(), is(1)); assertThat(event.getPullRequest().getTitle(), is("Update the README with new information")); - assertThat(event.getPullRequest().getBody(), is("This is a pretty simple change that we need to pull into master.")); + assertThat(event.getPullRequest().getBody(), + is("This is a pretty simple change that we need to pull into master.")); assertThat(event.getPullRequest().getUser().getLogin(), is("baxterthehacker")); assertThat(event.getPullRequest().getHead().getUser().getLogin(), is("baxterthehacker")); assertThat(event.getPullRequest().getHead().getRef(), is("changes")); @@ -255,8 +255,7 @@ public void pull_request_review_comment() throws Exception { @Test public void push() throws Exception { - GHEventPayload.Push event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Push.class); + GHEventPayload.Push event = GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Push.class); assertThat(event.getRef(), is("refs/heads/changes")); assertThat(event.getBefore(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b")); assertThat(event.getHead(), is("0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c")); @@ -273,20 +272,21 @@ public void push() throws Exception { assertThat(event.getCommits().get(0).getModified().get(0), is("README.md")); assertThat(event.getRepository().getName(), is("public-repo")); assertThat(event.getRepository().getOwnerName(), is("baxterthehacker")); - assertThat(event.getRepository().getUrl().toExternalForm(), is("https://github.com/baxterthehacker/public-repo")); + assertThat(event.getRepository().getUrl().toExternalForm(), + is("https://github.com/baxterthehacker/public-repo")); assertThat(event.getPusher().getName(), is("baxterthehacker")); assertThat(event.getPusher().getEmail(), is("baxterthehacker@users.noreply.github.com")); assertThat(event.getSender().getLogin(), is("baxterthehacker")); } -// TODO implement support classes and write test -// @Test -// public void release() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void release() throws Exception {} @Test public void repository() throws Exception { - GHEventPayload.Repository event = - GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.Repository.class); + GHEventPayload.Repository event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Repository.class); assertThat(event.getAction(), is("created")); assertThat(event.getRepository().getName(), is("new-repository")); assertThat(event.getRepository().getOwner().getLogin(), is("baxterandthehackers")); @@ -294,16 +294,16 @@ public void repository() throws Exception { assertThat(event.getSender().getLogin(), is("baxterthehacker")); } -// TODO implement support classes and write test -// @Test -// public void status() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void status() throws Exception {} -// TODO implement support classes and write test -// @Test -// public void team_add() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void team_add() throws Exception {} -// TODO implement support classes and write test -// @Test -// public void watch() throws Exception {} + // TODO implement support classes and write test + // @Test + // public void watch() throws Exception {} } diff --git a/src/test/java/org/kohsuke/github/GistTest.java b/src/test/java/org/kohsuke/github/GHGistTest.java similarity index 85% rename from src/test/java/org/kohsuke/github/GistTest.java rename to src/test/java/org/kohsuke/github/GHGistTest.java index 5fbb75a400..beae248f27 100644 --- a/src/test/java/org/kohsuke/github/GistTest.java +++ b/src/test/java/org/kohsuke/github/GHGistTest.java @@ -1,28 +1,24 @@ package org.kohsuke.github; -import com.github.tomakehurst.wiremock.stubbing.Scenario; import org.junit.Test; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static org.hamcrest.Matchers.notNullValue; - import static org.hamcrest.core.Is.is; /** * @author Kohsuke Kawaguchi */ -public class GistTest extends AbstractGitHubWireMockTest { - /** - * CRUD operation. - */ +public class GHGistTest extends AbstractGitHubWireMockTest { @Test public void lifecycleTest() throws Exception { + // CRUD operation GHGist gist = gitHub.createGist() - .public_(false) - .description("Test Gist") - .file("abc.txt", "abc") - .file("def.txt", "def") - .create(); + .public_(false) + .description("Test Gist") + .file("abc.txt", "abc") + .file("def.txt", "def") + .create(); assertThat(gist.getCreatedAt(), is(notNullValue())); @@ -41,7 +37,6 @@ public void starTest() throws Exception { GHGist gist = gitHub.getGist("9903708"); assertEquals("rtyler", gist.getOwner().getLogin()); - gist.star(); assertTrue(gist.isStarred()); diff --git a/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java index 23bd4622f3..83156723f4 100644 --- a/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java +++ b/src/test/java/org/kohsuke/github/GHGistUpdaterTest.java @@ -23,7 +23,7 @@ public void setUp() throws IOException { GHGistBuilder builder = new GHGistBuilder(gitHub); gist = builder.description("Test for the API") .file("unmodified.txt", "Should be unmodified") - //.file("delete-me.txt", "To be deleted") + // .file("delete-me.txt", "To be deleted") .file("rename-me.py", "print 'hello'") .file("update-me.txt", "To be updated") .public_(true) @@ -45,21 +45,21 @@ public void testGitUpdater() throws Exception { GHGistUpdater updater = gist.update(); GHGist updatedGist = updater.description("Description updated by API") .addFile("new-file.txt", "Added by updater") - //.deleteFile("delete-me.txt") + // .deleteFile("delete-me.txt") .renameFile("rename-me.py", "renamed.py") .updateFile("update-me.txt", "Content updated by API") .update(); assertEquals("Description updated by API", updatedGist.getDescription()); - Map files = updatedGist.getFiles(); + Map files = updatedGist.getFiles(); // Check that the unmodified file stays intact. assertTrue(files.containsKey("unmodified.txt")); assertEquals("Should be unmodified", files.get("unmodified.txt").getContent()); // Check that the files are updated as expected. - //assertFalse("File was not deleted.", files.containsKey("delete-me.txt")); + // assertFalse("File was not deleted.", files.containsKey("delete-me.txt")); assertTrue(files.containsKey("new-file.txt")); assertEquals("Added by updater", files.get("new-file.txt").getContent()); diff --git a/src/test/java/org/kohsuke/github/GHHookTest.java b/src/test/java/org/kohsuke/github/GHHookTest.java index b27484b5e5..d527097821 100644 --- a/src/test/java/org/kohsuke/github/GHHookTest.java +++ b/src/test/java/org/kohsuke/github/GHHookTest.java @@ -13,11 +13,9 @@ import static java.util.Collections.singletonMap; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasKey; -import static org.hamcrest.Matchers.hasValue; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertThat; - /** * @author Kanstantsin Shautsou */ @@ -59,20 +57,15 @@ public void exposeResponceHeaders() throws Exception { try { // fails because application isn't approved in organisation and you can find it only after doing real call - final GHHook hook = repository.createHook( - "my-hook", - singletonMap("url", "http://localhost"), - singletonList(GHEvent.PUSH), - true - ); + final GHHook hook = repository + .createHook("my-hook", singletonMap("url", "http://localhost"), singletonList(GHEvent.PUSH), true); } catch (IOException ex) { assertThat(ex, instanceOf(GHFileNotFoundException.class)); final GHFileNotFoundException ghFileNotFoundException = (GHFileNotFoundException) ex; final Map> responseHeaderFields = ghFileNotFoundException.getResponseHeaderFields(); assertThat(responseHeaderFields, hasKey("X-Accepted-OAuth-Scopes")); assertThat(responseHeaderFields.get("X-Accepted-OAuth-Scopes"), - hasItem("admin:repo_hook, public_repo, repo, write:repo_hook") - ); + hasItem("admin:repo_hook, public_repo, repo, write:repo_hook")); } } } diff --git a/src/test/java/org/kohsuke/github/GHIssueEventTest.java b/src/test/java/org/kohsuke/github/GHIssueEventTest.java index bee82f0928..e65f7d59c5 100644 --- a/src/test/java/org/kohsuke/github/GHIssueEventTest.java +++ b/src/test/java/org/kohsuke/github/GHIssueEventTest.java @@ -1,8 +1,9 @@ package org.kohsuke.github; +import org.junit.Test; + import java.io.IOException; import java.util.List; -import org.junit.Test; /** * @author Martin van Zijl @@ -45,7 +46,8 @@ public void testRepositoryEvents() throws Exception { int i = 0; for (GHIssueEvent event : list) { assertNotNull(event.getIssue()); - if (i++ > 10) break; + if (i++ > 10) + break; } } diff --git a/src/test/java/org/kohsuke/github/GHLicenseTest.java b/src/test/java/org/kohsuke/github/GHLicenseTest.java index 9a77972c34..301ba58d77 100644 --- a/src/test/java/org/kohsuke/github/GHLicenseTest.java +++ b/src/test/java/org/kohsuke/github/GHLicenseTest.java @@ -39,6 +39,7 @@ public class GHLicenseTest extends AbstractGitHubWireMockTest { * Basic test to ensure that the list of licenses from {@link GitHub#listLicenses()} is returned * * @throws IOException + * if test fails */ @Test public void listLicenses() throws IOException { @@ -47,10 +48,10 @@ public void listLicenses() throws IOException { } /** - * Tests that {@link GitHub#listLicenses()} returns the MIT license - * in the expected manner. + * Tests that {@link GitHub#listLicenses()} returns the MIT license in the expected manner. * * @throws IOException + * if test fails */ @Test public void listLicensesCheckIndividualLicense() throws IOException { @@ -65,10 +66,11 @@ public void listLicensesCheckIndividualLicense() throws IOException { } /** - * Checks that the request for an individual license using {@link GitHub#getLicense(String)} - * returns expected values (not all properties are checked) + * Checks that the request for an individual license using {@link GitHub#getLicense(String)} returns expected values + * (not all properties are checked) * * @throws IOException + * if test fails */ @Test public void getLicense() throws IOException { @@ -76,14 +78,16 @@ public void getLicense() throws IOException { GHLicense license = gitHub.getLicense(key); assertNotNull(license); assertTrue("The name is correct", license.getName().equals("MIT License")); - assertTrue("The HTML URL is correct", license.getHtmlUrl().equals(new URL("http://choosealicense.com/licenses/mit/"))); + assertTrue("The HTML URL is correct", + license.getHtmlUrl().equals(new URL("http://choosealicense.com/licenses/mit/"))); } /** - * Accesses the 'kohsuke/github-api' repo using {@link GitHub#getRepository(String)} - * and checks that the license is correct + * Accesses the 'kohsuke/github-api' repo using {@link GitHub#getRepository(String)} and checks that the license is + * correct * * @throws IOException + * if test failss */ @Test public void checkRepositoryLicense() throws IOException { @@ -92,14 +96,15 @@ public void checkRepositoryLicense() throws IOException { assertNotNull("The license is populated", license); assertTrue("The key is correct", license.getKey().equals("mit")); assertTrue("The name is correct", license.getName().equals("MIT License")); - assertTrue("The URL is correct", license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/mit"))); + assertTrue("The URL is correct", + license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/mit"))); } /** - * Accesses the 'atom/atom' repo using {@link GitHub#getRepository(String)} - * and checks that the license is correct + * Accesses the 'atom/atom' repo using {@link GitHub#getRepository(String)} and checks that the license is correct * * @throws IOException + * if test fails */ @Test public void checkRepositoryLicenseAtom() throws IOException { @@ -108,14 +113,15 @@ public void checkRepositoryLicenseAtom() throws IOException { assertNotNull("The license is populated", license); assertTrue("The key is correct", license.getKey().equals("mit")); assertTrue("The name is correct", license.getName().equals("MIT License")); - assertTrue("The URL is correct", license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/mit"))); + assertTrue("The URL is correct", + license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/mit"))); } /** - * Accesses the 'pomes/pomes' repo using {@link GitHub#getRepository(String)} - * and checks that the license is correct + * Accesses the 'pomes/pomes' repo using {@link GitHub#getRepository(String)} and checks that the license is correct * * @throws IOException + * if test fails */ @Test public void checkRepositoryLicensePomes() throws IOException { @@ -124,14 +130,16 @@ public void checkRepositoryLicensePomes() throws IOException { assertNotNull("The license is populated", license); assertTrue("The key is correct", license.getKey().equals("apache-2.0")); assertTrue("The name is correct", license.getName().equals("Apache License 2.0")); - assertTrue("The URL is correct", license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/apache-2.0"))); + assertTrue("The URL is correct", + license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/apache-2.0"))); } /** - * Accesses the 'dedickinson/test-repo' repo using {@link GitHub#getRepository(String)} - * and checks that *no* license is returned as the repo doesn't have one + * Accesses the 'dedickinson/test-repo' repo using {@link GitHub#getRepository(String)} and checks that *no* license + * is returned as the repo doesn't have one * * @throws IOException + * if test fails */ @Test public void checkRepositoryWithoutLicense() throws IOException { @@ -141,11 +149,11 @@ public void checkRepositoryWithoutLicense() throws IOException { } /** - * Accesses the 'kohsuke/github-api' repo using {@link GitHub#getRepository(String)} - * and then calls {@link GHRepository#getLicense()} and checks that certain - * properties are correct + * Accesses the 'kohsuke/github-api' repo using {@link GitHub#getRepository(String)} and then calls + * {@link GHRepository#getLicense()} and checks that certain properties are correct * * @throws IOException + * if test fails */ @Test public void checkRepositoryFullLicense() throws IOException { @@ -154,16 +162,18 @@ public void checkRepositoryFullLicense() throws IOException { assertNotNull("The license is populated", license); assertTrue("The key is correct", license.getKey().equals("mit")); assertTrue("The name is correct", license.getName().equals("MIT License")); - assertTrue("The URL is correct", license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/mit"))); - assertTrue("The HTML URL is correct", license.getHtmlUrl().equals(new URL("http://choosealicense.com/licenses/mit/"))); + assertTrue("The URL is correct", + license.getUrl().equals(new URL(mockGitHub.apiServer().baseUrl() + "/licenses/mit"))); + assertTrue("The HTML URL is correct", + license.getHtmlUrl().equals(new URL("http://choosealicense.com/licenses/mit/"))); } /** - * Accesses the 'pomes/pomes' repo using {@link GitHub#getRepository(String)} - * and then calls {@link GHRepository#getLicenseContent()} and checks that certain - * properties are correct + * Accesses the 'pomes/pomes' repo using {@link GitHub#getRepository(String)} and then calls + * {@link GHRepository#getLicenseContent()} and checks that certain properties are correct * * @throws IOException + * if test fails */ @Test public void checkRepositoryLicenseContent() throws IOException { diff --git a/src/test/java/org/kohsuke/github/GHMilestoneTest.java b/src/test/java/org/kohsuke/github/GHMilestoneTest.java index c0ab886743..10ccc9a1a2 100644 --- a/src/test/java/org/kohsuke/github/GHMilestoneTest.java +++ b/src/test/java/org/kohsuke/github/GHMilestoneTest.java @@ -21,8 +21,7 @@ public void cleanUp() throws Exception { } for (GHMilestone milestone : getRepository(gitHubBeforeAfter).listMilestones(GHIssueState.ALL)) { - if ("Original Title".equals(milestone.getTitle()) || - "Updated Title".equals(milestone.getTitle())) { + if ("Original Title".equals(milestone.getTitle()) || "Updated Title".equals(milestone.getTitle())) { milestone.delete(); } } @@ -31,8 +30,7 @@ public void cleanUp() throws Exception { @Test public void testUpdateMilestone() throws Exception { GHRepository repo = getRepository(); - GHMilestone milestone = repo.createMilestone("Original Title", - "To test the update methods"); + GHMilestone milestone = repo.createMilestone("Original Title", "To test the update methods"); String NEW_TITLE = "Updated Title"; String NEW_DESCRIPTION = "Updated Description"; diff --git a/src/test/java/org/kohsuke/github/GHOrganizationTest.java b/src/test/java/org/kohsuke/github/GHOrganizationTest.java index dd9d3335ee..4782ae9941 100644 --- a/src/test/java/org/kohsuke/github/GHOrganizationTest.java +++ b/src/test/java/org/kohsuke/github/GHOrganizationTest.java @@ -1,10 +1,10 @@ package org.kohsuke.github; -import com.jcraft.jsch.IO; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.kohsuke.github.GHOrganization.Permission; import java.io.IOException; @@ -13,7 +13,6 @@ public class GHOrganizationTest extends AbstractGitHubWireMockTest { public static final String GITHUB_API_TEST = "github-api-test"; public static final String TEAM_NAME_CREATE = "create-team-test"; - @Before @After public void cleanUpTeam() throws IOException { @@ -22,8 +21,7 @@ public void cleanUpTeam() throws IOException { return; } - GHTeam team = gitHubBeforeAfter.getOrganization(GITHUB_API_TEST_ORG). - getTeamByName(TEAM_NAME_CREATE); + GHTeam team = gitHubBeforeAfter.getOrganization(GITHUB_API_TEST_ORG).getTeamByName(TEAM_NAME_CREATE); if (team != null) { team.delete(); } @@ -35,7 +33,10 @@ public void testCreateRepository() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); GHRepository repository = org.createRepository(GITHUB_API_TEST, - "a test repository used to test kohsuke's github-api", "http://github-api.kohsuke.org/", "Core Developers", true); + "a test repository used to test kohsuke's github-api", + "http://github-api.kohsuke.org/", + "Core Developers", + true); Assert.assertNotNull(repository); } @@ -45,10 +46,11 @@ public void testCreateRepositoryWithAutoInitialization() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); GHRepository repository = org.createRepository(GITHUB_API_TEST) - .description("a test repository used to test kohsuke's github-api") - .homepage("http://github-api.kohsuke.org/") - .team(org.getTeamByName("Core Developers")) - .autoInit(true).create(); + .description("a test repository used to test kohsuke's github-api") + .homepage("http://github-api.kohsuke.org/") + .team(org.getTeamByName("Core Developers")) + .autoInit(true) + .create(); Assert.assertNotNull(repository); Assert.assertNotNull(repository.getReadme()); } @@ -74,7 +76,6 @@ public void testInviteUser() throws IOException { // assertTrue(org.hasMember(user)); } - @Test public void testCreateTeamWithRepoAccess() throws IOException { String REPO_NAME = "github-api"; @@ -85,5 +86,20 @@ public void testCreateTeamWithRepoAccess() throws IOException { // Create team with access to repository. Check access was granted. GHTeam team = org.createTeam(TEAM_NAME_CREATE, GHOrganization.Permission.PUSH, repo); Assert.assertTrue(team.getRepositories().containsKey(REPO_NAME)); + Assert.assertEquals(Permission.PUSH.toString().toLowerCase(), team.getPermission()); + } + + @Test + public void testCreateTeam() throws IOException { + String REPO_NAME = "github-api"; + String DEFAULT_PERMISSION = Permission.PULL.toString().toLowerCase(); + + GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); + GHRepository repo = org.getRepository(REPO_NAME); + + // Create team with no permission field. Verify that default permission is pull + GHTeam team = org.createTeam(TEAM_NAME_CREATE, repo); + Assert.assertTrue(team.getRepositories().containsKey(REPO_NAME)); + Assert.assertEquals(DEFAULT_PERMISSION, team.getPermission()); } } diff --git a/src/test/java/org/kohsuke/github/GHProjectCardTest.java b/src/test/java/org/kohsuke/github/GHProjectCardTest.java index e155f86024..e6bf0b06b3 100644 --- a/src/test/java/org/kohsuke/github/GHProjectCardTest.java +++ b/src/test/java/org/kohsuke/github/GHProjectCardTest.java @@ -12,96 +12,94 @@ * @author Gunnar Skjold */ public class GHProjectCardTest extends AbstractGitHubWireMockTest { - private GHOrganization org; - private GHProject project; - private GHProjectColumn column; - private GHProjectCard card; + private GHOrganization org; + private GHProject project; + private GHProjectColumn column; + private GHProjectCard card; - @Before - public void setUp() throws Exception { - org = gitHub.getOrganization(GITHUB_API_TEST_ORG); - project = org.createProject("test-project", "This is a test project"); - column = project.createColumn("column-one"); - card = column.createCard("This is a card"); - } + @Before + public void setUp() throws Exception { + org = gitHub.getOrganization(GITHUB_API_TEST_ORG); + project = org.createProject("test-project", "This is a test project"); + column = project.createColumn("column-one"); + card = column.createCard("This is a card"); + } - @Test - public void testCreatedCard() { - Assert.assertEquals("This is a card", card.getNote()); - Assert.assertFalse(card.isArchived()); - } + @Test + public void testCreatedCard() { + Assert.assertEquals("This is a card", card.getNote()); + Assert.assertFalse(card.isArchived()); + } - @Test - public void testEditCardNote() throws IOException { - card.setNote("New note"); - card = gitHub.getProjectCard(card.getId()); - Assert.assertEquals("New note", card.getNote()); - Assert.assertFalse(card.isArchived()); - } + @Test + public void testEditCardNote() throws IOException { + card.setNote("New note"); + card = gitHub.getProjectCard(card.getId()); + Assert.assertEquals("New note", card.getNote()); + Assert.assertFalse(card.isArchived()); + } - @Test - public void testArchiveCard() throws IOException { - card.setArchived(true); - card = gitHub.getProjectCard(card.getId()); - Assert.assertEquals("This is a card", card.getNote()); - Assert.assertTrue(card.isArchived()); - } + @Test + public void testArchiveCard() throws IOException { + card.setArchived(true); + card = gitHub.getProjectCard(card.getId()); + Assert.assertEquals("This is a card", card.getNote()); + Assert.assertTrue(card.isArchived()); + } - @Test - public void testCreateCardFromIssue() throws IOException { - GHRepository repo = org.createRepository("repo-for-project-card").create(); - try { - GHIssue issue = repo.createIssue("new-issue").body("With body").create(); - GHProjectCard card = column.createCard(issue); - Assert.assertEquals(issue.getUrl(), card.getContentUrl()); - } finally { - repo.delete(); - } - } + @Test + public void testCreateCardFromIssue() throws IOException { + GHRepository repo = org.createRepository("repo-for-project-card").create(); + try { + GHIssue issue = repo.createIssue("new-issue").body("With body").create(); + GHProjectCard card = column.createCard(issue); + Assert.assertEquals(issue.getUrl(), card.getContentUrl()); + } finally { + repo.delete(); + } + } - @Test - public void testDeleteCard() throws IOException { - card.delete(); - try { - card = gitHub.getProjectCard(card.getId()); - Assert.assertNull(card); - } catch (FileNotFoundException e) { - card = null; - } - } + @Test + public void testDeleteCard() throws IOException { + card.delete(); + try { + card = gitHub.getProjectCard(card.getId()); + Assert.assertNull(card); + } catch (FileNotFoundException e) { + card = null; + } + } - @After - public void after() throws IOException { - if(mockGitHub.isUseProxy()) { - if (card != null) { - card = gitHubBeforeAfter.getProjectCard(card.getId()); - try { - card.delete(); - card = null; - } catch (FileNotFoundException e) { - card = null; - } - } - if (column != null) { - column = gitHubBeforeAfter - .getProjectColumn(column.getId()); - try { - column.delete(); - column = null; - } catch (FileNotFoundException e) { - column = null; - } - } - if (project != null) { - project = gitHubBeforeAfter - .getProject(project.getId()); - try { - project.delete(); - project = null; - } catch (FileNotFoundException e) { - project = null; - } - } - } - } + @After + public void after() throws IOException { + if (mockGitHub.isUseProxy()) { + if (card != null) { + card = gitHubBeforeAfter.getProjectCard(card.getId()); + try { + card.delete(); + card = null; + } catch (FileNotFoundException e) { + card = null; + } + } + if (column != null) { + column = gitHubBeforeAfter.getProjectColumn(column.getId()); + try { + column.delete(); + column = null; + } catch (FileNotFoundException e) { + column = null; + } + } + if (project != null) { + project = gitHubBeforeAfter.getProject(project.getId()); + try { + project.delete(); + project = null; + } catch (FileNotFoundException e) { + project = null; + } + } + } + } } diff --git a/src/test/java/org/kohsuke/github/GHProjectColumnTest.java b/src/test/java/org/kohsuke/github/GHProjectColumnTest.java index db3003da61..29c7e0fd8e 100644 --- a/src/test/java/org/kohsuke/github/GHProjectColumnTest.java +++ b/src/test/java/org/kohsuke/github/GHProjectColumnTest.java @@ -12,63 +12,59 @@ * @author Gunnar Skjold */ public class GHProjectColumnTest extends AbstractGitHubWireMockTest { - private GHProject project; - private GHProjectColumn column; + private GHProject project; + private GHProjectColumn column; - @Before - public void setUp() throws Exception { - project = gitHub - .getOrganization(GITHUB_API_TEST_ORG) - .createProject("test-project", "This is a test project"); - column = project.createColumn("column-one"); - } + @Before + public void setUp() throws Exception { + project = gitHub.getOrganization(GITHUB_API_TEST_ORG).createProject("test-project", "This is a test project"); + column = project.createColumn("column-one"); + } - @Test - public void testCreatedColumn() { - Assert.assertEquals("column-one", column.getName()); - } + @Test + public void testCreatedColumn() { + Assert.assertEquals("column-one", column.getName()); + } - @Test - public void testEditColumnName() throws IOException { - column.setName("new-name"); - column = gitHub.getProjectColumn(column.getId()); - Assert.assertEquals("new-name", column.getName()); - } + @Test + public void testEditColumnName() throws IOException { + column.setName("new-name"); + column = gitHub.getProjectColumn(column.getId()); + Assert.assertEquals("new-name", column.getName()); + } - @Test - public void testDeleteColumn() throws IOException { - column.delete(); - try { - column = gitHub.getProjectColumn(column.getId()); - Assert.assertNull(column); - } catch (FileNotFoundException e) { - column = null; - } - } + @Test + public void testDeleteColumn() throws IOException { + column.delete(); + try { + column = gitHub.getProjectColumn(column.getId()); + Assert.assertNull(column); + } catch (FileNotFoundException e) { + column = null; + } + } - @After - public void after() throws IOException { - if(mockGitHub.isUseProxy()) { - if (column != null) { - column = gitHubBeforeAfter - .getProjectColumn(column.getId()); - try { - column.delete(); - column = null; - } catch (FileNotFoundException e) { - column = null; - } - } - if (project != null) { - project = gitHubBeforeAfter - .getProject(project.getId()); - try { - project.delete(); - project = null; - } catch (FileNotFoundException e) { - project = null; - } - } - } - } + @After + public void after() throws IOException { + if (mockGitHub.isUseProxy()) { + if (column != null) { + column = gitHubBeforeAfter.getProjectColumn(column.getId()); + try { + column.delete(); + column = null; + } catch (FileNotFoundException e) { + column = null; + } + } + if (project != null) { + project = gitHubBeforeAfter.getProject(project.getId()); + try { + project.delete(); + project = null; + } catch (FileNotFoundException e) { + project = null; + } + } + } + } } diff --git a/src/test/java/org/kohsuke/github/GHProjectTest.java b/src/test/java/org/kohsuke/github/GHProjectTest.java index fe1722576d..178a1d2b54 100644 --- a/src/test/java/org/kohsuke/github/GHProjectTest.java +++ b/src/test/java/org/kohsuke/github/GHProjectTest.java @@ -12,74 +12,71 @@ * @author Gunnar Skjold */ public class GHProjectTest extends AbstractGitHubWireMockTest { - private GHProject project; + private GHProject project; - @Before - public void setUp() throws Exception { - project = gitHub - .getOrganization(GITHUB_API_TEST_ORG) - .createProject("test-project", "This is a test project"); - } + @Before + public void setUp() throws Exception { + project = gitHub.getOrganization(GITHUB_API_TEST_ORG).createProject("test-project", "This is a test project"); + } - @Test - public void testCreatedProject() { - Assert.assertNotNull(project); - Assert.assertEquals("test-project", project.getName()); - Assert.assertEquals("This is a test project", project.getBody()); - Assert.assertEquals(GHProject.ProjectState.OPEN, project.getState()); - } + @Test + public void testCreatedProject() { + Assert.assertNotNull(project); + Assert.assertEquals("test-project", project.getName()); + Assert.assertEquals("This is a test project", project.getBody()); + Assert.assertEquals(GHProject.ProjectState.OPEN, project.getState()); + } - @Test - public void testEditProjectName() throws IOException { - project.setName("new-name"); - project = gitHub.getProject(project.getId()); - Assert.assertEquals("new-name", project.getName()); - Assert.assertEquals("This is a test project", project.getBody()); - Assert.assertEquals(GHProject.ProjectState.OPEN, project.getState()); - } + @Test + public void testEditProjectName() throws IOException { + project.setName("new-name"); + project = gitHub.getProject(project.getId()); + Assert.assertEquals("new-name", project.getName()); + Assert.assertEquals("This is a test project", project.getBody()); + Assert.assertEquals(GHProject.ProjectState.OPEN, project.getState()); + } - @Test - public void testEditProjectBody() throws IOException { - project.setBody("New body"); - project = gitHub.getProject(project.getId()); - Assert.assertEquals("test-project", project.getName()); - Assert.assertEquals("New body", project.getBody()); - Assert.assertEquals(GHProject.ProjectState.OPEN, project.getState()); - } + @Test + public void testEditProjectBody() throws IOException { + project.setBody("New body"); + project = gitHub.getProject(project.getId()); + Assert.assertEquals("test-project", project.getName()); + Assert.assertEquals("New body", project.getBody()); + Assert.assertEquals(GHProject.ProjectState.OPEN, project.getState()); + } - @Test - public void testEditProjectState() throws IOException { - project.setState(GHProject.ProjectState.CLOSED); - project = gitHub.getProject(project.getId()); - Assert.assertEquals("test-project", project.getName()); - Assert.assertEquals("This is a test project", project.getBody()); - Assert.assertEquals(GHProject.ProjectState.CLOSED, project.getState()); - } + @Test + public void testEditProjectState() throws IOException { + project.setState(GHProject.ProjectState.CLOSED); + project = gitHub.getProject(project.getId()); + Assert.assertEquals("test-project", project.getName()); + Assert.assertEquals("This is a test project", project.getBody()); + Assert.assertEquals(GHProject.ProjectState.CLOSED, project.getState()); + } - @Test - public void testDeleteProject() throws IOException { - project.delete(); - try { - project = gitHub.getProject(project.getId()); - Assert.assertNull(project); - } catch (FileNotFoundException e) { - project = null; - } - } + @Test + public void testDeleteProject() throws IOException { + project.delete(); + try { + project = gitHub.getProject(project.getId()); + Assert.assertNull(project); + } catch (FileNotFoundException e) { + project = null; + } + } - @After - public void after() throws IOException { - if (mockGitHub.isUseProxy()) { - if (project != null) { - project = gitHubBeforeAfter - .getProject(project.getId()); - try { - project.delete(); - project = null; - } catch (FileNotFoundException e) { - project = null; - } - } - } - } + @After + public void after() throws IOException { + if (mockGitHub.isUseProxy()) { + if (project != null) { + project = gitHubBeforeAfter.getProject(project.getId()); + try { + project.delete(); + project = null; + } catch (FileNotFoundException e) { + project = null; + } + } + } + } } diff --git a/src/test/java/org/kohsuke/github/GHPullRequestTest.java b/src/test/java/org/kohsuke/github/GHPullRequestTest.java index 4c9ebe4130..4ee1750908 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -57,17 +57,10 @@ public void createDraftPullRequest() throws Exception { assertThat(p2.getNumber(), is(p.getNumber())); assertThat(p2.isDraft(), is(true)); - p = repo.queryPullRequests() - .state(GHIssueState.OPEN) - .head("test/stable") - .list().asList().get(0); + p = repo.queryPullRequests().state(GHIssueState.OPEN).head("test/stable").list().asList().get(0); assertThat(p2.getNumber(), is(p.getNumber())); assertThat(p.isDraft(), is(true)); - - - - } @Test @@ -88,15 +81,14 @@ public void closePullRequest() throws Exception { assertEquals(GHIssueState.CLOSED, getRepository().getPullRequest(p.getNumber()).getState()); } - @Test public void pullRequestReviews() throws Exception { String name = "testPullRequestReviews"; GHPullRequest p = getRepository().createPullRequest(name, "test/stable", "master", "## test"); GHPullRequestReview draftReview = p.createReview() - .body("Some draft review") - .comment("Some niggle", "README.md", 1) - .create(); + .body("Some draft review") + .comment("Some niggle", "README.md", 1) + .create(); assertThat(draftReview.getState(), is(GHPullRequestReviewState.PENDING)); assertThat(draftReview.getBody(), is("Some draft review")); assertThat(draftReview.getCommitId(), notNullValue()); @@ -111,10 +103,7 @@ public void pullRequestReviews() throws Exception { assertEquals(1, comments.size()); GHPullRequestReviewComment comment = comments.get(0); assertEquals("Some niggle", comment.getBody()); - draftReview = p.createReview() - .body("Some new review") - .comment("Some niggle", "README.md", 1) - .create(); + draftReview = p.createReview().body("Some new review").comment("Some niggle", "README.md", 1).create(); draftReview.delete(); } @@ -169,14 +158,18 @@ public void testPullRequestTeamReviewRequests() throws Exception { int baseRequestCount = mockGitHub.getRequestCount(); p.refresh(); assertThat("We should not eagerly load organizations for teams", - mockGitHub.getRequestCount() - baseRequestCount , equalTo(1)); + mockGitHub.getRequestCount() - baseRequestCount, + equalTo(1)); assertThat(p.getRequestedTeams().size(), equalTo(1)); assertThat("We should not eagerly load organizations for teams", - mockGitHub.getRequestCount() - baseRequestCount , equalTo(1)); + mockGitHub.getRequestCount() - baseRequestCount, + equalTo(1)); assertThat("Org should be queried for automatically if asked for", - p.getRequestedTeams().get(0).getOrganization(), notNullValue()); + p.getRequestedTeams().get(0).getOrganization(), + notNullValue()); assertThat("Request count should show lazy load occurred", - mockGitHub.getRequestCount() - baseRequestCount , equalTo(2)); + mockGitHub.getRequestCount() - baseRequestCount, + equalTo(2)); } @Test @@ -186,25 +179,21 @@ public void mergeCommitSHA() throws Exception { GHPullRequest p = repo.createPullRequest(name, "test/mergeable_branch", "master", "## test"); int baseRequestCount = mockGitHub.getRequestCount(); assertThat(p.getMergeableNoRefresh(), nullValue()); - assertThat("Used existing value", - mockGitHub.getRequestCount() - baseRequestCount , equalTo(0)); + assertThat("Used existing value", mockGitHub.getRequestCount() - baseRequestCount, equalTo(0)); // mergeability computation takes time, this should still be null immediately after creation assertThat(p.getMergeable(), nullValue()); - assertThat("Asked for PR information", - mockGitHub.getRequestCount() - baseRequestCount , equalTo(1)); + assertThat("Asked for PR information", mockGitHub.getRequestCount() - baseRequestCount, equalTo(1)); for (int i = 2; i <= 10; i++) { if (Boolean.TRUE.equals(p.getMergeable()) && p.getMergeCommitSha() != null) { - assertThat("Asked for PR information", - mockGitHub.getRequestCount() - baseRequestCount , equalTo(i)); + assertThat("Asked for PR information", mockGitHub.getRequestCount() - baseRequestCount, equalTo(i)); // make sure commit exists GHCommit commit = repo.getCommit(p.getMergeCommitSha()); assertNotNull(commit); - assertThat("Asked for PR information", - mockGitHub.getRequestCount() - baseRequestCount , equalTo(i + 1)); + assertThat("Asked for PR information", mockGitHub.getRequestCount() - baseRequestCount, equalTo(i + 1)); return; } @@ -242,12 +231,12 @@ public void updateContentSquashMerge() throws Exception { Thread.sleep(1000); getRepository().createContent() - .content(name + name) - .path(name) - .branch(branchName) - .message(name) - .sha(response.getContent().getSha()) - .commit(); + .content(name + name) + .path(name) + .branch(branchName) + .message(name) + .sha(response.getContent().getSha()) + .commit(); GHPullRequest p = getRepository().createPullRequest(name, branchName, "master", "## test squash"); Thread.sleep(1000); p.merge("squash merge", null, GHPullRequest.MergeMethod.SQUASH); @@ -261,7 +250,12 @@ public void queryPullRequestsQualifiedHead() throws Exception { repo.createPullRequest("queryPullRequestsQualifiedHead_rc", "test/rc", "master", null); // Query by one of the heads and make sure we only get that branch's PR back. - List prs = repo.queryPullRequests().state(GHIssueState.OPEN).head("github-api-test-org:test/stable").base("master").list().asList(); + List prs = repo.queryPullRequests() + .state(GHIssueState.OPEN) + .head("github-api-test-org:test/stable") + .base("master") + .list() + .asList(); assertNotNull(prs); assertEquals(1, prs.size()); assertEquals("test/stable", prs.get(0).getHead().getRef()); @@ -275,7 +269,12 @@ public void queryPullRequestsUnqualifiedHead() throws Exception { repo.createPullRequest("queryPullRequestsUnqualifiedHead_rc", "test/rc", "master", null); // Query by one of the heads and make sure we only get that branch's PR back. - List prs = repo.queryPullRequests().state(GHIssueState.OPEN).head("test/stable").base("master").list().asList(); + List prs = repo.queryPullRequests() + .state(GHIssueState.OPEN) + .head("test/stable") + .base("master") + .list() + .asList(); assertNotNull(prs); assertEquals(1, prs.size()); assertEquals("test/stable", prs.get(0).getHead().getRef()); diff --git a/src/test/java/org/kohsuke/github/GHRateLimitTest.java b/src/test/java/org/kohsuke/github/GHRateLimitTest.java new file mode 100644 index 0000000000..2aa9e78bf5 --- /dev/null +++ b/src/test/java/org/kohsuke/github/GHRateLimitTest.java @@ -0,0 +1,413 @@ +package org.kohsuke.github; + +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; +import org.hamcrest.CoreMatchers; +import org.junit.Test; +import org.kohsuke.github.extras.okhttp3.OkHttpConnector; + +import java.io.IOException; +import java.util.Date; + +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; + +/** + * Test showing the behavior of OkHttpConnector with and without cache. + *

+ * Key take aways: + * + *

    + *
  • These tests are artificial and intended to highlight the differences in behavior between scenarios. However, the + * differences they indicate are stark.
  • + *
  • Caching reduces rate limit consumption by at least a factor of two in even the simplest case.
  • + *
  • The OkHttp cache is pretty smart and will often connect read and write requests made on the same client and + * invalidate caches.
  • + *
  • Changes made outside the current client cause the OkHttp cache to return stale data. This is expected and correct + * behavior.
  • + *
  • "max-age=0" addresses the problem of external changes by revalidating caches for each request. This produces the + * same number of requests as OkHttp without caching, but those requests only count towards the GitHub rate limit if + * data has changes.
  • + *
+ * + * @author Liam Newman + */ +public class GHRateLimitTest extends AbstractGitHubWireMockTest { + + public GHRateLimitTest() { + useDefaultGitHub = false; + } + + @Override + protected WireMockConfiguration getWireMockOptions() { + return super.getWireMockOptions() + .extensions(ResponseTemplateTransformer.builder().global(true).maxCacheEntries(0L).build()); + } + + @Test + public void testGitHubRateLimit() throws Exception { + // Customized response that templates the date to keep things working + snapshotNotAllowed(); + + assertThat(mockGitHub.getRequestCount(), equalTo(0)); + GHRateLimit rateLimit = null; + + Date lastReset = new Date(System.currentTimeMillis() / 1000L); + int lastRemaining = 5000; + + // Give this a moment + Thread.sleep(1000); + + // ------------------------------------------------------------- + // /user gets response with rate limit information + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build(); + gitHub.getMyself(); + + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + + // Since we already had rate limit info these don't request again + rateLimit = gitHub.lastRateLimit(); + assertThat(rateLimit, notNullValue()); + assertThat(rateLimit.limit, equalTo(5000)); + assertThat(rateLimit.getLimit(), equalTo(5000)); + lastRemaining = rateLimit.getRemaining(); + assertThat(rateLimit.getResetDate().compareTo(lastReset), greaterThanOrEqualTo(0)); + lastReset = rateLimit.getResetDate(); + + GHRateLimit headerRateLimit = rateLimit; + + // Give this a moment + Thread.sleep(1000); + + // ratelimit() uses headerRateLimit if available and headerRateLimit is not expired + assertThat(gitHub.rateLimit(), equalTo(headerRateLimit)); + + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + + // Give this a moment + Thread.sleep(1000); + + // Always requests new info + rateLimit = gitHub.getRateLimit(); + assertThat(mockGitHub.getRequestCount(), equalTo(2)); + + assertThat(rateLimit, notNullValue()); + assertThat(rateLimit.limit, equalTo(5000)); + assertThat(rateLimit.getLimit(), equalTo(5000)); + // rate limit request is free + assertThat(rateLimit.remaining, equalTo(lastRemaining)); + assertThat(rateLimit.getRemaining(), equalTo(lastRemaining)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), greaterThanOrEqualTo(0)); + + // Give this a moment + Thread.sleep(1000); + + // Always requests new info + rateLimit = gitHub.getRateLimit(); + assertThat(mockGitHub.getRequestCount(), equalTo(3)); + + assertThat(rateLimit, notNullValue()); + assertThat(rateLimit.limit, equalTo(5000)); + assertThat(rateLimit.getLimit(), equalTo(5000)); + // rate limit request is free + assertThat(rateLimit.remaining, equalTo(lastRemaining)); + assertThat(rateLimit.getRemaining(), equalTo(lastRemaining)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), greaterThanOrEqualTo(0)); + + gitHub.getOrganization(GITHUB_API_TEST_ORG); + assertThat(mockGitHub.getRequestCount(), equalTo(4)); + + assertThat(gitHub.lastRateLimit(), not(equalTo(headerRateLimit))); + rateLimit = gitHub.lastRateLimit(); + assertThat(rateLimit, notNullValue()); + assertThat(rateLimit.limit, equalTo(5000)); + assertThat(rateLimit.getLimit(), equalTo(5000)); + // Org costs limit to query + assertThat(rateLimit.remaining, equalTo(lastRemaining - 1)); + assertThat(rateLimit.getRemaining(), equalTo(lastRemaining - 1)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), greaterThanOrEqualTo(0)); + lastReset = rateLimit.getResetDate(); + headerRateLimit = rateLimit; + + // ratelimit() should prefer headerRateLimit when it is most recent and not expired + assertThat(gitHub.rateLimit(), equalTo(headerRateLimit)); + + assertThat(mockGitHub.getRequestCount(), equalTo(4)); + + // Give this a moment + Thread.sleep(2000); + + // Always requests new info + rateLimit = gitHub.getRateLimit(); + assertThat(mockGitHub.getRequestCount(), equalTo(5)); + + assertThat(rateLimit, notNullValue()); + assertThat(rateLimit.limit, equalTo(5000)); + assertThat(rateLimit.getLimit(), equalTo(5000)); + // Org costs limit to query + assertThat(rateLimit.remaining, equalTo(lastRemaining - 1)); + assertThat(rateLimit.getRemaining(), equalTo(lastRemaining - 1)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), greaterThanOrEqualTo(0)); + + // When getRateLimit() succeeds, headerRateLimit updates as usual as well (if needed) + // These are separate instances, but should be equal + assertThat(gitHub.rateLimit(), not(sameInstance(rateLimit))); + + // Verify different record instances can be compared + assertThat(gitHub.rateLimit().getCore(), equalTo(rateLimit.getCore())); + + // Verify different instances can be compared + // TODO: This is not work currently because the header rate limit has unknowns for records other than core. + // assertThat(gitHub.rateLimit().getCore(), equalTo(rateLimit.getCore())); + + assertThat(gitHub.rateLimit(), not(sameInstance(headerRateLimit))); + assertThat(gitHub.rateLimit(), sameInstance(gitHub.lastRateLimit())); + + assertThat(mockGitHub.getRequestCount(), equalTo(5)); + } + + @Test + public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { + // Customized response that results in file not found the same as GitHub Enterprise + snapshotNotAllowed(); + assertThat(mockGitHub.getRequestCount(), equalTo(0)); + GHRateLimit rateLimit = null; + + Date lastReset = new Date(System.currentTimeMillis() / 1000L); + + // Give this a moment + Thread.sleep(1000); + + // ------------------------------------------------------------- + // Before any queries, rate limit starts as null but may be requested + gitHub = GitHub.connectToEnterprise(mockGitHub.apiServer().baseUrl(), "bogus", "bogus"); + assertThat(mockGitHub.getRequestCount(), equalTo(0)); + + assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue()); + + rateLimit = gitHub.rateLimit(); + assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class)); + assertThat(rateLimit.limit, equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.remaining, equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); + lastReset = rateLimit.getResetDate(); + + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + + // last is still null, because it actually means lastHeaderRateLimit + assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue()); + + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + + // Give this a moment + Thread.sleep(1000); + + // ------------------------------------------------------------- + // First call to /user gets response without rate limit information + gitHub = GitHub.connectToEnterprise(mockGitHub.apiServer().baseUrl(), "bogus", "bogus"); + gitHub.getMyself(); + assertThat(mockGitHub.getRequestCount(), equalTo(2)); + + assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue()); + + rateLimit = gitHub.rateLimit(); + assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class)); + assertThat(rateLimit.limit, equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.remaining, equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); + lastReset = rateLimit.getResetDate(); + + assertThat(mockGitHub.getRequestCount(), equalTo(3)); + + // Give this a moment + Thread.sleep(1000); + + // Always requests new info + rateLimit = gitHub.getRateLimit(); + assertThat(mockGitHub.getRequestCount(), equalTo(4)); + + assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class)); + assertThat(rateLimit.limit, equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.remaining, equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); + + // Give this a moment + Thread.sleep(1000); + + // last is still null, because it actually means lastHeaderRateLimit + assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue()); + + // ratelimit() tries not to make additional requests, uses queried rate limit since header not available + Thread.sleep(1000); + assertThat(gitHub.rateLimit(), sameInstance(rateLimit)); + + // ------------------------------------------------------------- + // Second call to /user gets response with rate limit information + gitHub = GitHub.connectToEnterprise(mockGitHub.apiServer().baseUrl(), "bogus", "bogus"); + gitHub.getMyself(); + assertThat(mockGitHub.getRequestCount(), equalTo(5)); + + // Since we already had rate limit info these don't request again + rateLimit = gitHub.lastRateLimit(); + assertThat(rateLimit, notNullValue()); + assertThat(rateLimit.limit, equalTo(5000)); + assertThat(rateLimit.getLimit(), equalTo(5000)); + assertThat(rateLimit.remaining, equalTo(4978)); + assertThat(rateLimit.getRemaining(), equalTo(4978)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), greaterThanOrEqualTo(0)); + lastReset = rateLimit.getResetDate(); + + GHRateLimit headerRateLimit = rateLimit; + + // Give this a moment + Thread.sleep(1000); + + // ratelimit() uses headerRateLimit if available and headerRateLimit is not expired + assertThat(gitHub.rateLimit(), equalTo(headerRateLimit)); + + assertThat(mockGitHub.getRequestCount(), equalTo(5)); + + // Give this a moment + Thread.sleep(1000); + + // Always requests new info + rateLimit = gitHub.getRateLimit(); + assertThat(mockGitHub.getRequestCount(), equalTo(6)); + + assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class)); + assertThat(rateLimit.limit, equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); + assertThat(rateLimit.remaining, equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); + assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); + + // ratelimit() should prefer headerRateLimit when getRateLimit fails and headerRateLimit is not expired + assertThat(gitHub.rateLimit(), equalTo(headerRateLimit)); + + assertThat(mockGitHub.getRequestCount(), equalTo(6)); + + // Wait for the header + Thread.sleep(1000); + } + + // These tests should behave the same, showing server time adjustment working + @Test + public void testGitHubRateLimitExpirationServerFiveMinutesAhead() throws Exception { + executeExpirationTest(); + } + + @Test + public void testGitHubRateLimitExpirationServerFiveMinutesBehind() throws Exception { + executeExpirationTest(); + } + + private void executeExpirationTest() throws Exception { + // Customized response that templates the date to keep things working + snapshotNotAllowed(); + + assertThat(mockGitHub.getRequestCount(), equalTo(0)); + GHRateLimit rateLimit = null; + GHRateLimit headerRateLimit = null; + + // Give this a moment + Thread.sleep(1000); + + // ------------------------------------------------------------- + // /user gets response with rate limit information + gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build(); + gitHub.getMyself(); + + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + + // Since we already had rate limit info these don't request again + headerRateLimit = gitHub.lastRateLimit(); + rateLimit = gitHub.rateLimit(); + + assertThat(rateLimit, notNullValue()); + assertThat("rateLimit() selects header instance when not expired, does not ask server", + rateLimit, + sameInstance(headerRateLimit)); + + // Nothing changes still valid + Thread.sleep(1000); + + assertThat("rateLimit() selects header instance when not expired, does not ask server", + gitHub.rateLimit(), + sameInstance(headerRateLimit)); + assertThat("rateLimit() selects header instance when not expired, does not ask server", + gitHub.lastRateLimit(), + sameInstance(headerRateLimit)); + + assertThat(mockGitHub.getRequestCount(), equalTo(1)); + + // This time, rateLimit() should find an expired record and get a new one. + Thread.sleep(3000); + + assertThat("Header instance has expired", gitHub.lastRateLimit().isExpired(), is(true)); + + assertThat("rateLimit() will ask server when header instance expires and it has not called getRateLimit() yet", + gitHub.rateLimit(), + not(sameInstance(rateLimit))); + + assertThat("lastRateLimit() (header instance) is populated as part of internal call to getRateLimit()", + gitHub.lastRateLimit(), + not(sameInstance(rateLimit))); + + assertThat("After request, rateLimit() selects header instance since it has been refreshed", + gitHub.rateLimit(), + sameInstance(gitHub.lastRateLimit())); + + headerRateLimit = gitHub.lastRateLimit(); + + assertThat(mockGitHub.getRequestCount(), equalTo(2)); + + // This time, rateLimit() should find an expired header record, but a valid returned record + Thread.sleep(4000); + + rateLimit = gitHub.rateLimit(); + + // Using custom data to have a header instance that expires before the queried instance + assertThat( + "if header instance expires but queried instance is valid, ratelimit() uses it without asking server", + gitHub.rateLimit(), + not(sameInstance(gitHub.lastRateLimit()))); + + assertThat("ratelimit() should almost never return a return a GHRateLimit that is already expired", + gitHub.rateLimit().isExpired(), + is(false)); + + assertThat("Header instance hasn't been reloaded", gitHub.lastRateLimit(), sameInstance(headerRateLimit)); + assertThat("Header instance has expired", gitHub.lastRateLimit().isExpired(), is(true)); + + assertThat(mockGitHub.getRequestCount(), equalTo(2)); + + // Finally they both expire and rateLimit() should find both expired and get a new record + Thread.sleep(2000); + + headerRateLimit = gitHub.rateLimit(); + + assertThat("rateLimit() has asked server for new information", + gitHub.rateLimit(), + not(sameInstance(rateLimit))); + assertThat("rateLimit() has asked server for new information", + gitHub.lastRateLimit(), + not(sameInstance(rateLimit))); + + assertThat("rateLimit() selects header instance when not expired, does not ask server", + gitHub.rateLimit(), + sameInstance((gitHub.lastRateLimit()))); + + assertThat(mockGitHub.getRequestCount(), equalTo(3)); + } + + private static GHRepository getRepository(GitHub gitHub) throws IOException { + return gitHub.getOrganization("github-api-test-org").getRepository("github-api"); + } + +} diff --git a/src/test/java/org/kohsuke/github/GHRepositoryStatisticsTest.java b/src/test/java/org/kohsuke/github/GHRepositoryStatisticsTest.java index 71d14d02dc..057a09ee3b 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryStatisticsTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryStatisticsTest.java @@ -14,8 +14,8 @@ public class GHRepositoryStatisticsTest extends AbstractGitHubWireMockTest { @Test public void testContributorStats() throws IOException, InterruptedException { // get the statistics - PagedIterable stats = - getRepository().getStatistics().getContributorStats(); + PagedIterable stats = getRepository().getStatistics() + .getContributorStats(); // check that the statistics were eventually retrieved if (stats == null) { @@ -31,25 +31,22 @@ public void testContributorStats() throws IOException, InterruptedException { // TODO: Add an accessor method for this instead of having use a loop. boolean developerFound = false; final String authorLogin = "kohsuke"; - for (GHRepositoryStatistics.ContributorStats statsForAuthor: list) { + for (GHRepositoryStatistics.ContributorStats statsForAuthor : list) { if (authorLogin.equals(statsForAuthor.getAuthor().getLogin())) { assertEquals(715, statsForAuthor.getTotal()); - List weeks = - statsForAuthor.getWeeks(); + List weeks = statsForAuthor.getWeeks(); assertEquals(494, weeks.size()); try { // check a particular week // TODO: Maybe add a convenience method to get the week // containing a certain date (Java.Util.Date). - GHRepositoryStatistics.ContributorStats.Week week = - statsForAuthor.getWeek(1541289600); + GHRepositoryStatistics.ContributorStats.Week week = statsForAuthor.getWeek(1541289600); assertEquals(63, week.getNumberOfAdditions()); assertEquals(56, week.getNumberOfDeletions()); assertEquals(5, week.getNumberOfCommits()); - } - catch(NoSuchElementException e) { + } catch (NoSuchElementException e) { fail("Did not find week 1546128000"); } developerFound = true; @@ -68,10 +65,9 @@ public void testCommitActivity() throws IOException, InterruptedException { for (int i = 0; i < MAX_ITERATIONS; i += 1) { stats = getRepository().getStatistics().getCommitActivity(); - if(stats == null) { + if (stats == null) { Thread.sleep(SLEEP_INTERVAL); - } - else { + } else { break; } } @@ -88,17 +84,17 @@ public void testCommitActivity() throws IOException, InterruptedException { // TODO: Return this as a map with the timestamp as the key. // Either that or wrap in an object an accessor method. Boolean foundWeek = false; - for (GHRepositoryStatistics.CommitActivity item: list) { + for (GHRepositoryStatistics.CommitActivity item : list) { if (item.getWeek() == 1566691200) { assertEquals(6, item.getTotal()); List days = item.getDays(); - assertEquals(0, (long)days.get(0)); - assertEquals(0, (long)days.get(1)); - assertEquals(1, (long)days.get(2)); - assertEquals(0, (long)days.get(3)); - assertEquals(0, (long)days.get(4)); - assertEquals(1, (long)days.get(5)); - assertEquals(4, (long)days.get(6)); + assertEquals(0, (long) days.get(0)); + assertEquals(0, (long) days.get(1)); + assertEquals(1, (long) days.get(2)); + assertEquals(0, (long) days.get(3)); + assertEquals(0, (long) days.get(4)); + assertEquals(1, (long) days.get(5)); + assertEquals(4, (long) days.get(6)); foundWeek = true; break; } @@ -114,10 +110,9 @@ public void testCodeFrequency() throws IOException, InterruptedException { for (int i = 0; i < MAX_ITERATIONS; i += 1) { stats = getRepository().getStatistics().getCodeFrequency(); - if(stats == null) { + if (stats == null) { Thread.sleep(SLEEP_INTERVAL); - } - else { + } else { break; } } @@ -132,7 +127,7 @@ public void testCodeFrequency() throws IOException, InterruptedException { // TODO: Perhaps return this as a map with the timestamp as the key? // Either that or wrap in an object with accessor methods. Boolean foundWeek = false; - for (GHRepositoryStatistics.CodeFrequency item: stats) { + for (GHRepositoryStatistics.CodeFrequency item : stats) { if (item.getWeekTimestamp() == 1535241600) { assertEquals(185, item.getAdditions()); assertEquals(-243, item.getDeletions()); @@ -150,10 +145,9 @@ public void testParticipation() throws IOException, InterruptedException { for (int i = 0; i < MAX_ITERATIONS; i += 1) { stats = getRepository().getStatistics().getParticipation(); - if(stats == null) { + if (stats == null) { Thread.sleep(SLEEP_INTERVAL); - } - else { + } else { break; } } @@ -167,7 +161,7 @@ public void testParticipation() throws IOException, InterruptedException { // check the statistics are accurate List allCommits = stats.getAllCommits(); assertEquals(52, allCommits.size()); - assertEquals(2, (int)allCommits.get(2)); + assertEquals(2, (int) allCommits.get(2)); List ownerCommits = stats.getOwnerCommits(); assertEquals(52, ownerCommits.size()); @@ -181,11 +175,10 @@ public void testPunchCard() throws IOException, InterruptedException { List stats = null; for (int i = 0; i < MAX_ITERATIONS; i += 1) { - stats = getRepository().getStatistics().getPunchCard(); - if(stats == null) { + stats = getRepository().getStatistics().getPunchCard(); + if (stats == null) { Thread.sleep(SLEEP_INTERVAL); - } - else { + } else { break; } } @@ -198,8 +191,8 @@ public void testPunchCard() throws IOException, InterruptedException { // check the statistics are accurate Boolean hourFound = false; - for (GHRepositoryStatistics.PunchCardItem item: stats) { - if(item.getDayOfWeek() == 2 && item.getHourOfDay() == 10) { + for (GHRepositoryStatistics.PunchCardItem item : stats) { + if (item.getDayOfWeek() == 2 && item.getHourOfDay() == 10) { // TODO: Make an easier access method. Perhaps wrap in an // object and have a method such as GetCommits(1, 16). assertEquals(16, item.getNumberOfCommits()); diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index cb6b52dacc..c27be6732c 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -5,11 +5,12 @@ import java.io.FileNotFoundException; import java.io.IOException; +import java.util.ArrayList; import java.util.List; -import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.*; -import static org.junit.Assume.assumeFalse; /** * @author Liam Newman @@ -24,7 +25,6 @@ private GHRepository getRepository(GitHub gitHub) throws IOException { return gitHub.getOrganization("github-api-test-org").getRepository("github-api"); } - @Test public void archive() throws Exception { snapshotNotAllowed(); @@ -48,6 +48,27 @@ public void getBranch_URLEncoded() throws Exception { assertThat(branch.getName(), is("test/#UrlEncode")); } + // Issue #607 + @Test + public void getBranchNonExistentBut200Status() throws Exception { + // Manually changed the returned status to 200 so dont take a new snapshot + this.snapshotNotAllowed(); + + // This should *never* happen but with mocking it was discovered + GHRepository repo = getRepository(); + try { + GHBranch branch = repo.getBranch("test/NonExistent"); + fail(); + } catch (Exception e) { + // I dont really love this but I wanted to get to the root wrapped cause + assertThat(e, instanceOf(IOException.class)); + assertThat(e.getMessage(), + equalTo("Server returned HTTP response code: 200, message: 'OK' for URL: " + + mockGitHub.apiServer().baseUrl() + + "/repos/github-api-test-org/github-api/branches/test/NonExistent")); + } + } + @Test public void subscription() throws Exception { GHRepository r = getRepository(); @@ -108,7 +129,7 @@ public void getPermission() throws Exception { r.getPermission("jglick"); fail(); } catch (HttpException x) { - //x.printStackTrace(); // good + // x.printStackTrace(); // good assertEquals(403, x.getResponseCode()); } @@ -124,7 +145,6 @@ public void getPermission() throws Exception { } } - @Test public void LatestRepositoryExist() { try { @@ -197,7 +217,11 @@ public void listEmptyContributors() throws IOException { @Test public void searchRepositories() throws Exception { - PagedSearchIterable r = gitHub.searchRepositories().q("tetris").language("assembly").sort(GHRepositorySearchBuilder.Sort.STARS).list(); + PagedSearchIterable r = gitHub.searchRepositories() + .q("tetris") + .language("assembly") + .sort(GHRepositorySearchBuilder.Sort.STARS) + .list(); GHRepository u = r.iterator().next(); // System.out.println(u.getName()); assertNotNull(u.getId()); @@ -205,7 +229,6 @@ public void searchRepositories() throws Exception { assertTrue(r.getTotalCount() > 0); } - @Test // issue #162 public void testIssue162() throws Exception { GHRepository r = gitHub.getRepository("github-api/github-api"); @@ -224,7 +247,8 @@ public void testIssue162() throws Exception { public void markDown() throws Exception { assertEquals("

Test日本語

", IOUtils.toString(gitHub.renderMarkdown("**Test日本語**")).trim()); - String actual = IOUtils.toString(gitHub.getRepository("github-api/github-api").renderMarkdown("@kohsuke to fix issue #1", MarkdownMode.GFM)); + String actual = IOUtils.toString(gitHub.getRepository("github-api/github-api") + .renderMarkdown("@kohsuke to fix issue #1", MarkdownMode.GFM)); // System.out.println(actual); assertTrue(actual.contains("href=\"https://github.com/kohsuke\"")); assertTrue(actual.contains("href=\"https://github.com/github-api/github-api/pull/1\"")); @@ -232,7 +256,7 @@ public void markDown() throws Exception { assertTrue(actual.contains("class=\"issue-link ")); assertTrue(actual.contains("to fix issue")); } - + @Test public void getMergeOptions() throws IOException { GHRepository r = getTempRepository(); @@ -240,7 +264,7 @@ public void getMergeOptions() throws IOException { assertNotNull(r.isAllowRebaseMerge()); assertNotNull(r.isAllowSquashMerge()); } - + @Test public void setMergeOptions() throws IOException { // String repoName = "github-api-test-org/test-mergeoptions"; @@ -270,8 +294,37 @@ public void setMergeOptions() throws IOException { } @Test - public void testListTopics() throws Exception { - List topics = getRepository(gitHub).listTopics(); - assertTrue(topics.contains("api-test-dummy")); + public void testSetTopics() throws Exception { + GHRepository repo = getRepository(gitHub); + + List topics = new ArrayList<>(); + + topics.add("java"); + topics.add("api-test-dummy"); + repo.setTopics(topics); + assertThat("Topics retain input order (are not sort when stored)", + repo.listTopics(), + contains("java", "api-test-dummy")); + + topics = new ArrayList<>(); + topics.add("ordered-state"); + topics.add("api-test-dummy"); + topics.add("java"); + repo.setTopics(topics); + assertThat("Topics behave as a set and retain order from previous calls", + repo.listTopics(), + contains("java", "api-test-dummy", "ordered-state")); + + topics = new ArrayList<>(); + topics.add("ordered-state"); + topics.add("api-test-dummy"); + repo.setTopics(topics); + assertThat("Topics retain order even when some are removed", + repo.listTopics(), + contains("api-test-dummy", "ordered-state")); + + topics = new ArrayList<>(); + repo.setTopics(topics); + assertTrue("Topics can be set to empty", repo.listTopics().isEmpty()); } -} \ No newline at end of file +} diff --git a/src/test/java/org/kohsuke/github/GHTeamTest.java b/src/test/java/org/kohsuke/github/GHTeamTest.java index 208f07f7d1..742d89a3b7 100644 --- a/src/test/java/org/kohsuke/github/GHTeamTest.java +++ b/src/test/java/org/kohsuke/github/GHTeamTest.java @@ -3,7 +3,6 @@ import org.junit.Test; import java.io.IOException; -import java.util.Random; public class GHTeamTest extends AbstractGitHubWireMockTest { @@ -31,5 +30,4 @@ public void testSetDescription() throws IOException { assertEquals(description, team.getDescription()); } - } diff --git a/src/test/java/org/kohsuke/github/GHTreeBuilderTest.java b/src/test/java/org/kohsuke/github/GHTreeBuilderTest.java new file mode 100644 index 0000000000..8ddfc96667 --- /dev/null +++ b/src/test/java/org/kohsuke/github/GHTreeBuilderTest.java @@ -0,0 +1,112 @@ +package org.kohsuke.github; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import java.io.IOException; +import java.util.Arrays; + +public class GHTreeBuilderTest extends AbstractGitHubWireMockTest { + private static String REPO_NAME = "sandboxx/GHTreeBuilderTest"; + + private static String PATH_SCRIPT = "app/run.sh"; + private static String CONTENT_SCRIPT = "#!/bin/bash\necho Hello\n"; + + private static String PATH_README = "doc/readme.txt"; + private static String CONTENT_README = "Thanks for using our application!\n"; + + private static String PATH_DATA1 = "data/val1.dat"; + private static byte[] CONTENT_DATA1 = { 0x01, 0x02, 0x03 }; + + private static String PATH_DATA2 = "data/val2.dat"; + private static byte[] CONTENT_DATA2 = { 0x04, 0x05, 0x06, 0x07 }; + + private GHRepository repo; + private GHRef masterRef; + private GHTreeBuilder treeBuilder; + + @Before + @After + public void cleanup() throws Exception { + if (mockGitHub.isUseProxy()) { + repo = gitHubBeforeAfter.getRepository(REPO_NAME); + Arrays.asList(PATH_SCRIPT, PATH_README, PATH_DATA1, PATH_DATA2).forEach(path -> { + try { + GHContent content = repo.getFileContent(path); + if (content != null) { + content.delete("Cleanup"); + } + } catch (IOException e) { + } + }); + } + } + + @Before + public void setUp() throws Exception { + repo = gitHub.getRepository(REPO_NAME); + masterRef = repo.getRef("heads/master"); + String masterTreeSha = repo.getTreeRecursive("master", 1).getSha(); + treeBuilder = repo.createTree().baseTree(masterTreeSha); + } + + @Test + @Ignore("It seems that GitHub no longer supports the 'content' parameter") + public void testTextEntry() throws Exception { + treeBuilder.textEntry(PATH_SCRIPT, CONTENT_SCRIPT, true); + treeBuilder.textEntry(PATH_README, CONTENT_README, false); + + updateTree(); + + assertEquals(CONTENT_SCRIPT.length(), getFileSize(PATH_SCRIPT)); + assertEquals(CONTENT_README.length(), getFileSize(PATH_README)); + } + + @Test + public void testShaEntry() throws Exception { + String dataSha1 = new GHBlobBuilder(repo).binaryContent(CONTENT_DATA1).create().getSha(); + treeBuilder.shaEntry(PATH_DATA1, dataSha1, false); + + String dataSha2 = new GHBlobBuilder(repo).binaryContent(CONTENT_DATA2).create().getSha(); + treeBuilder.shaEntry(PATH_DATA2, dataSha2, false); + + updateTree(); + + assertEquals(CONTENT_DATA1.length, getFileSize(PATH_DATA1)); + assertEquals(CONTENT_DATA2.length, getFileSize(PATH_DATA2)); + } + + @Test + public void testAdd() throws Exception { + treeBuilder.add(PATH_SCRIPT, CONTENT_SCRIPT, true); + treeBuilder.add(PATH_README, CONTENT_README, false); + treeBuilder.add(PATH_DATA1, CONTENT_DATA1, false); + treeBuilder.add(PATH_DATA2, CONTENT_DATA2, false); + + updateTree(); + + assertEquals(CONTENT_SCRIPT.length(), getFileSize(PATH_SCRIPT)); + assertEquals(CONTENT_README.length(), getFileSize(PATH_README)); + assertEquals(CONTENT_DATA1.length, getFileSize(PATH_DATA1)); + assertEquals(CONTENT_DATA2.length, getFileSize(PATH_DATA2)); + } + + private void updateTree() throws IOException { + String treeSha = treeBuilder.create().getSha(); + String commitSha = new GHCommitBuilder(repo).message("Add files") + .tree(treeSha) + .parent(masterRef.getObject().getSha()) + .create() + .getSHA1(); + masterRef.updateTo(commitSha); + } + + private long getFileSize(String path) throws IOException { + GHContent content = repo.getFileContent(path); + if (content == null) + throw new IOException("File not found: " + path); + return content.getSize(); + } +} diff --git a/src/test/java/org/kohsuke/github/GHUserTest.java b/src/test/java/org/kohsuke/github/GHUserTest.java index bdfa346d2e..e40db4ad2f 100644 --- a/src/test/java/org/kohsuke/github/GHUserTest.java +++ b/src/test/java/org/kohsuke/github/GHUserTest.java @@ -7,14 +7,11 @@ import static org.hamcrest.CoreMatchers.*; - public class GHUserTest extends AbstractGitHubWireMockTest { @Test public void listFollowsAndFollowers() throws IOException { GHUser u = gitHub.getUser("rtyler"); - assertNotEquals( - count30(u.listFollowers()), - count30(u.listFollows())); + assertNotEquals(count30(u.listFollowers()), count30(u.listFollows())); } private Set count30(PagedIterable l) { @@ -40,14 +37,17 @@ public int compare(GHKey ghKey, GHKey t1) { } }); assertEquals(1066173, ghKeys.get(0).getId()); - assertEquals("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAueiy12T5bvFhsc9YjfLc3aVIxgySd3gDxQWy/bletIoZL8omKmzocBYJ7F58U1asoyfWsy2ToTOY8jJp1eToXmbD6L5+xvHba0A7djYh9aQRrFam7doKQ0zp0ZSUF6+R1v0OM4nnWqK4n2ECIYd+Bdzrp+xA5+XlW3ZSNzlnW2BeWznzmgRMcp6wI+zQ9GMHWviR1cxpml5Z6wrxTZ0aX91btvnNPqoOGva976B6e6403FOEkkIFTk6CC1TFKwc/VjbqxYBg4kU0JhiTP+iEZibcQrYjWdYUgAotYbFVe5/DneHMLNsMPdeihba4PUwt62rXyNegenuCRmCntLcaFQ==", - ghKeys.get(0).getKey()); + assertEquals( + "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAueiy12T5bvFhsc9YjfLc3aVIxgySd3gDxQWy/bletIoZL8omKmzocBYJ7F58U1asoyfWsy2ToTOY8jJp1eToXmbD6L5+xvHba0A7djYh9aQRrFam7doKQ0zp0ZSUF6+R1v0OM4nnWqK4n2ECIYd+Bdzrp+xA5+XlW3ZSNzlnW2BeWznzmgRMcp6wI+zQ9GMHWviR1cxpml5Z6wrxTZ0aX91btvnNPqoOGva976B6e6403FOEkkIFTk6CC1TFKwc/VjbqxYBg4kU0JhiTP+iEZibcQrYjWdYUgAotYbFVe5/DneHMLNsMPdeihba4PUwt62rXyNegenuCRmCntLcaFQ==", + ghKeys.get(0).getKey()); assertEquals(28136459, ghKeys.get(1).getId()); - assertEquals("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTU0s5OKCC6VpKZGL9NJD4mNLY0AtujkVB1JkkuQ4OkMi2YGUHJtGhTbTwEVhNxpm0x2dM5KSzse6MLDYuGBW0qkE/VVuD9+9I73hbq461KqP0+WlupNh+Qc86kbiLBDv64+vWc+50mp1dbINpoM5xvaPYxgjnemydPv7vu5bhCHBugW7aN8VcLgfFgcp8vZCEanMtd3hIRjRU8v8Skk233ZGu1bXkG8iIOBQPabvEtZ0VDMg9pT3Q1R6lnnKqfCwHXd6zP6uAtejFSxvKRGKpu3OLGQMHwk7NlImVuhkVdaEFBq7pQtpOaGuP2eLKcN1wy5jsTYE+ZB6pvHCi2ecb", - ghKeys.get(1).getKey()); + assertEquals( + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTU0s5OKCC6VpKZGL9NJD4mNLY0AtujkVB1JkkuQ4OkMi2YGUHJtGhTbTwEVhNxpm0x2dM5KSzse6MLDYuGBW0qkE/VVuD9+9I73hbq461KqP0+WlupNh+Qc86kbiLBDv64+vWc+50mp1dbINpoM5xvaPYxgjnemydPv7vu5bhCHBugW7aN8VcLgfFgcp8vZCEanMtd3hIRjRU8v8Skk233ZGu1bXkG8iIOBQPabvEtZ0VDMg9pT3Q1R6lnnKqfCwHXd6zP6uAtejFSxvKRGKpu3OLGQMHwk7NlImVuhkVdaEFBq7pQtpOaGuP2eLKcN1wy5jsTYE+ZB6pvHCi2ecb", + ghKeys.get(1).getKey()); assertEquals(31452581, ghKeys.get(2).getId()); - assertEquals("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3JhH2FZBDmHLjXTcBoV6tdcYKmsQ7sgu8k1RsUhwxGsXm65+Cuas6GcMVoA1DncKfJGQkulHDFiTxIROIBmedh9/otHWBlZ4HqYZ4MQ1A8W5quULkXwX/kF+UdRBUxFvjigibEbuHB+LARVxRRzFlPnTSE9rAfAv8OOEsb3lNUGT/IGhN8w1vwe8GclB90tgqN1RBDgrVqwLFwn5AfrW9kUIa2f2oT4RjYu1OrhKhVIIzfHADo85aD+s8wEhqwI96BCJG3qTWrypoHwBUoj1O6Ak5CGc1iKz9o8XyTMjudRt2ddCjfOtxsuwSlTbVtQXJGIpgKviX1sgh4pPvGh7BVAFP+mdAK4F+mEugDnuj47GO/K5KGGDRCL56kh9+h28l4q/+fZvp7DhtmSN2EzrVAdQFskF8yY/6Xit/aAvjeKm03DcjbylSXbG26EJefaLHlwYFq2mUFRMak25wuuCZS71GF3RC3Sl/bMoxBKRYkyfYtGafeaYTFNGn8Dbd+hfVUCz31ebI8cvmlQR5b5AbCre3T7HTVgw8FKbAxWRf1Fio56PnqHsj+sT1KVj255Zo1F8iD9GrgERSVAlkh5bY/CKszQ8ZSd01c9Qp2a47/gR7XAAbxhzGHP+cSOlrqDlJ24fbPtcpVsM0llqKUcxpmoOBFNboRmE1QqnSmAf9ww==", - ghKeys.get(2).getKey()); + assertEquals( + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3JhH2FZBDmHLjXTcBoV6tdcYKmsQ7sgu8k1RsUhwxGsXm65+Cuas6GcMVoA1DncKfJGQkulHDFiTxIROIBmedh9/otHWBlZ4HqYZ4MQ1A8W5quULkXwX/kF+UdRBUxFvjigibEbuHB+LARVxRRzFlPnTSE9rAfAv8OOEsb3lNUGT/IGhN8w1vwe8GclB90tgqN1RBDgrVqwLFwn5AfrW9kUIa2f2oT4RjYu1OrhKhVIIzfHADo85aD+s8wEhqwI96BCJG3qTWrypoHwBUoj1O6Ak5CGc1iKz9o8XyTMjudRt2ddCjfOtxsuwSlTbVtQXJGIpgKviX1sgh4pPvGh7BVAFP+mdAK4F+mEugDnuj47GO/K5KGGDRCL56kh9+h28l4q/+fZvp7DhtmSN2EzrVAdQFskF8yY/6Xit/aAvjeKm03DcjbylSXbG26EJefaLHlwYFq2mUFRMak25wuuCZS71GF3RC3Sl/bMoxBKRYkyfYtGafeaYTFNGn8Dbd+hfVUCz31ebI8cvmlQR5b5AbCre3T7HTVgw8FKbAxWRf1Fio56PnqHsj+sT1KVj255Zo1F8iD9GrgERSVAlkh5bY/CKszQ8ZSd01c9Qp2a47/gR7XAAbxhzGHP+cSOlrqDlJ24fbPtcpVsM0llqKUcxpmoOBFNboRmE1QqnSmAf9ww==", + ghKeys.get(2).getKey()); } @Test diff --git a/src/test/java/org/kohsuke/github/GitHubConnectionTest.java b/src/test/java/org/kohsuke/github/GitHubConnectionTest.java index 5db75f6506..5e244da3bf 100644 --- a/src/test/java/org/kohsuke/github/GitHubConnectionTest.java +++ b/src/test/java/org/kohsuke/github/GitHubConnectionTest.java @@ -6,8 +6,6 @@ import java.lang.reflect.Field; import java.util.*; -import static org.hamcrest.CoreMatchers.*; - /** * Unit test for {@link GitHub}. */ @@ -41,11 +39,13 @@ public void testGitHubServerWithHttps() throws Exception { GitHub hub = GitHub.connectToEnterprise("https://enterprise.kohsuke.org/api/v3", "bogus", "bogus"); assertEquals("https://enterprise.kohsuke.org/api/v3/test", hub.getApiURL("/test").toString()); } + @Test public void testGitHubServerWithoutServer() throws Exception { GitHub hub = GitHub.connectUsingPassword("kohsuke", "bogus"); assertEquals("https://api.github.com/test", hub.getApiURL("/test").toString()); } + @Test public void testGitHubBuilderFromEnvironment() throws IOException { @@ -78,256 +78,31 @@ public void testGitHubBuilderFromCustomEnvironment() throws IOException { setupEnvironment(props); - GitHubBuilder builder = GitHubBuilder.fromEnvironment("customLogin", "customPassword", "customOauth", "customEndpoint"); + GitHubBuilder builder = GitHubBuilder + .fromEnvironment("customLogin", "customPassword", "customOauth", "customEndpoint"); assertEquals("bogusLogin", builder.user); assertEquals("bogusOauth", builder.oauthToken); assertEquals("bogusPassword", builder.password); assertEquals("bogusEndpoint", builder.endpoint); } + @Test - public void testGithubBuilderWithAppInstallationToken() throws Exception{ + public void testGithubBuilderWithAppInstallationToken() throws Exception { GitHubBuilder builder = new GitHubBuilder().withAppInstallationToken("bogus"); assertEquals("bogus", builder.oauthToken); assertEquals("", builder.user); // test authorization header is set as in the RFC6749 GitHub github = builder.build(); - assertEquals("token bogus",github.encodedAuthorization); - assertEquals("",github.login); - } - - @Test - public void testGitHubRateLimit() throws Exception { - assertThat(mockGitHub.getRequestCount(), equalTo(0)); - GHRateLimit rateLimit = null; - GitHub hub = null; - Date lastReset = new Date(System.currentTimeMillis() / 1000L); - int lastRemaining = 5000; - - // Give this a moment - Thread.sleep(1000); - - // ------------------------------------------------------------- - // /user gets response with rate limit information - hub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()).build(); - hub.getMyself(); - - assertThat(mockGitHub.getRequestCount(), equalTo(1)); - - // Since we already had rate limit info these don't request again - rateLimit = hub.lastRateLimit(); - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(5000)); - lastRemaining = rateLimit.remaining; - // Because we're gettting this from old mocked info, it will be an older date - //assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(-1)); - lastReset = rateLimit.getResetDate(); - - GHRateLimit headerRateLimit = rateLimit; - - // Give this a moment - Thread.sleep(1000); - - // ratelimit() uses headerRateLimit if available - assertThat(hub.rateLimit(), equalTo(headerRateLimit)); - - assertThat(mockGitHub.getRequestCount(), equalTo(1)); - - // Give this a moment - Thread.sleep(1000); - - // Always requests new info - rateLimit = hub.getRateLimit(); - assertThat(mockGitHub.getRequestCount(), equalTo(2)); - - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(5000)); - // rate limit request is free - assertThat(rateLimit.remaining, equalTo(lastRemaining)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0)); - - // Give this a moment - Thread.sleep(1000); - - // Always requests new info - rateLimit = hub.getRateLimit(); - assertThat(mockGitHub.getRequestCount(), equalTo(3)); - - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(5000)); - // rate limit request is free - assertThat(rateLimit.remaining, equalTo(lastRemaining)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0)); - - - hub.getOrganization(GITHUB_API_TEST_ORG); - assertThat(mockGitHub.getRequestCount(), equalTo(4)); - - - assertThat(hub.lastRateLimit(), not(equalTo(headerRateLimit))); - rateLimit = hub.lastRateLimit(); - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(5000)); - // Org costs limit to query - assertThat(rateLimit.remaining, equalTo(lastRemaining - 1)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0)); - lastReset = rateLimit.getResetDate(); - headerRateLimit = rateLimit; - - // ratelimit() should prefer headerRateLimit when it is most recent - assertThat(hub.rateLimit(), equalTo(headerRateLimit)); - - assertThat(mockGitHub.getRequestCount(), equalTo(4)); - - // Always requests new info - rateLimit = hub.getRateLimit(); - assertThat(mockGitHub.getRequestCount(), equalTo(5)); - - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(5000)); - // Org costs limit to query - assertThat(rateLimit.remaining, equalTo(lastRemaining - 1)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0)); - - // ratelimit() should prefer headerRateLimit when getRateLimit() fails - // BUG: When getRateLimit() succeeds, it should reset the ratelimit() to the new value -// assertThat(hub.rateLimit(), equalTo(rateLimit)); -// assertThat(hub.rateLimit(), not(equalTo(headerRateLimit))); - assertThat(hub.rateLimit(), equalTo(headerRateLimit)); - - assertThat(mockGitHub.getRequestCount(), equalTo(5)); - } - - @Test - public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { - // Customized response that results in file not found the same as GitHub Enterprise - snapshotNotAllowed(); - assertThat(mockGitHub.getRequestCount(), equalTo(0)); - GHRateLimit rateLimit = null; - GitHub hub = null; - - - Date lastReset = new Date(System.currentTimeMillis() / 1000L); - - // Give this a moment - Thread.sleep(1000); - - // ------------------------------------------------------------- - // Before any queries, rate limit starts as null but may be requested - hub = GitHub.connectToEnterprise(mockGitHub.apiServer().baseUrl(), "bogus", "bogus"); - assertThat(mockGitHub.getRequestCount(), equalTo(0)); - - assertThat(hub.lastRateLimit(), nullValue()); - - rateLimit = hub.rateLimit(); - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(1000000)); - assertThat(rateLimit.remaining, equalTo(1000000)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); - lastReset = rateLimit.getResetDate(); - - assertThat(mockGitHub.getRequestCount(), equalTo(1)); - - // last is still null, because it actually means lastHeaderRateLimit - assertThat(hub.lastRateLimit(), nullValue()); - - assertThat(mockGitHub.getRequestCount(), equalTo(1)); - - // Give this a moment - Thread.sleep(1000); - - // ------------------------------------------------------------- - // First call to /user gets response without rate limit information - hub = GitHub.connectToEnterprise(mockGitHub.apiServer().baseUrl(), "bogus", "bogus"); - hub.getMyself(); - assertThat(mockGitHub.getRequestCount(), equalTo(2)); - - assertThat(hub.lastRateLimit(), nullValue()); - - rateLimit = hub.rateLimit(); - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(1000000)); - assertThat(rateLimit.remaining, equalTo(1000000)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); - lastReset = rateLimit.getResetDate(); - - assertThat(mockGitHub.getRequestCount(), equalTo(3)); - - // Give this a moment - Thread.sleep(1000); - - // Always requests new info - rateLimit = hub.getRateLimit(); - assertThat(mockGitHub.getRequestCount(), equalTo(4)); - - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(1000000)); - assertThat(rateLimit.remaining, equalTo(1000000)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); - - // Give this a moment - Thread.sleep(1000); - - - // last is still null, because it actually means lastHeaderRateLimit - assertThat(hub.lastRateLimit(), nullValue()); - - // ratelimit() tries not to make additional requests, uses queried rate limit since header not available - Thread.sleep(1000); - assertThat(hub.rateLimit(), equalTo(rateLimit)); - - // ------------------------------------------------------------- - // Second call to /user gets response with rate limit information - hub = GitHub.connectToEnterprise(mockGitHub.apiServer().baseUrl(), "bogus", "bogus"); - hub.getMyself(); - assertThat(mockGitHub.getRequestCount(), equalTo(5)); - - // Since we already had rate limit info these don't request again - rateLimit = hub.lastRateLimit(); - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(5000)); - assertThat(rateLimit.remaining, equalTo(4978)); - // Because we're gettting this from old mocked info, it will be an older date - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(-1)); - lastReset = rateLimit.getResetDate(); - - GHRateLimit headerRateLimit = rateLimit; - - // Give this a moment - Thread.sleep(1000); - - // ratelimit() uses headerRateLimit if available - assertThat(hub.rateLimit(), equalTo(headerRateLimit)); - - assertThat(mockGitHub.getRequestCount(), equalTo(5)); - - // Give this a moment - Thread.sleep(1000); - - // Always requests new info - rateLimit = hub.getRateLimit(); - assertThat(mockGitHub.getRequestCount(), equalTo(6)); - - assertThat(rateLimit, notNullValue()); - assertThat(rateLimit.limit, equalTo(1000000)); - assertThat(rateLimit.remaining, equalTo(1000000)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); - - // Give this a moment - Thread.sleep(1000); - - // ratelimit() should prefer headerRateLimit when getRateLimit fails - assertThat(hub.rateLimit(), equalTo(headerRateLimit)); - - assertThat(mockGitHub.getRequestCount(), equalTo(6)); + assertEquals("token bogus", github.encodedAuthorization); + assertEquals("", github.login); } @Test public void testGitHubIsApiUrlValid() throws IOException { GitHub hub = GitHub.connectAnonymously(); - //GitHub github = GitHub.connectToEnterpriseAnonymously("https://github.mycompany.com/api/v3/"); + // GitHub github = GitHub.connectToEnterpriseAnonymously("https://github.mycompany.com/api/v3/"); try { hub.checkApiUrlValidity(); } catch (IOException ioe) { @@ -340,7 +115,8 @@ public void testGitHubIsApiUrlValid() throws IOException { * * This allows changing the in memory process environment. * - * Its used to wire in values for the github credentials to test that the GitHubBuilder works properly to resolve them. + * Its used to wire in values for the github credentials to test that the GitHubBuilder works properly to resolve + * them. */ private void setupEnvironment(Map newenv) { try { @@ -349,7 +125,8 @@ private void setupEnvironment(Map newenv) { theEnvironmentField.setAccessible(true); Map env = (Map) theEnvironmentField.get(null); env.putAll(newenv); - Field theCaseInsensitiveEnvironmentField = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment"); + Field theCaseInsensitiveEnvironmentField = processEnvironmentClass + .getDeclaredField("theCaseInsensitiveEnvironment"); theCaseInsensitiveEnvironmentField.setAccessible(true); Map cienv = (Map) theCaseInsensitiveEnvironmentField.get(null); cienv.putAll(newenv); diff --git a/src/test/java/org/kohsuke/github/GitHubStaticTest.java b/src/test/java/org/kohsuke/github/GitHubStaticTest.java index 9c03a3323b..8066dd9f1a 100644 --- a/src/test/java/org/kohsuke/github/GitHubStaticTest.java +++ b/src/test/java/org/kohsuke/github/GitHubStaticTest.java @@ -11,6 +11,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.core.Is.is; /** * Unit test for {@link GitHub} static helpers. @@ -38,29 +39,22 @@ public void timeRoundTrip() throws Exception { String instantSecondsFormatMillis = formatDate(instantSeconds, "yyyy-MM-dd'T'HH:mm:ss.S'Z'"); String instantBadFormat = formatDate(instantMillis, "yy-MM-dd'T'HH:mm'Z'"); - assertThat(GitHub.parseDate(GitHub.printDate(instantSeconds)), - equalTo(GitHub.parseDate(GitHub.printDate(instantMillis)))); + equalTo(GitHub.parseDate(GitHub.printDate(instantMillis)))); - assertThat(instantSeconds, - equalTo(GitHub.parseDate(GitHub.printDate(instantSeconds)))); + assertThat(instantSeconds, equalTo(GitHub.parseDate(GitHub.printDate(instantSeconds)))); // printDate will truncate to the nearest second, so it should not be equal - assertThat(instantMillis, - not(equalTo(GitHub.parseDate(GitHub.printDate(instantMillis))))); + assertThat(instantMillis, not(equalTo(GitHub.parseDate(GitHub.printDate(instantMillis))))); - assertThat(instantSeconds, - equalTo(GitHub.parseDate(instantFormatSlash))); + assertThat(instantSeconds, equalTo(GitHub.parseDate(instantFormatSlash))); - assertThat(instantSeconds, - equalTo(GitHub.parseDate(instantFormatDash))); + assertThat(instantSeconds, equalTo(GitHub.parseDate(instantFormatDash))); // This parser does not truncate to the nearest second, so it will be equal - assertThat(instantMillis, - equalTo(GitHub.parseDate(instantFormatMillis))); + assertThat(instantMillis, equalTo(GitHub.parseDate(instantFormatMillis))); - assertThat(instantSeconds, - equalTo(GitHub.parseDate(instantSecondsFormatMillis))); + assertThat(instantSeconds, equalTo(GitHub.parseDate(instantSecondsFormatMillis))); try { GitHub.parseDate(instantBadFormat); @@ -70,6 +64,64 @@ public void timeRoundTrip() throws Exception { } } + @Test + public void testGitHubRateLimitShouldReplaceRateLimit() throws Exception { + + GHRateLimit.Record unknown0 = GHRateLimit.Unknown().getCore(); + GHRateLimit.Record unknown1 = GHRateLimit.Unknown().getCore(); + + GHRateLimit.Record record0 = new GHRateLimit.Record(10, 10, 10L); + GHRateLimit.Record record1 = new GHRateLimit.Record(10, 9, 10L); + GHRateLimit.Record record2 = new GHRateLimit.Record(10, 2, 10L); + GHRateLimit.Record record3 = new GHRateLimit.Record(10, 10, 20L); + GHRateLimit.Record record4 = new GHRateLimit.Record(10, 5, 20L); + + Thread.sleep(2000); + + GHRateLimit.Record recordWorst = new GHRateLimit.Record(Integer.MAX_VALUE, Integer.MAX_VALUE, Long.MIN_VALUE); + GHRateLimit.Record record00 = new GHRateLimit.Record(10, 10, 10L); + GHRateLimit.Record unknown2 = GHRateLimit.Unknown().getCore(); + + // Rate-limit records maybe created and returned in different orders. + // We should update to the regular records over unknowns. + // After that, we should update to the candidate if its limit is lower or its reset is later. + + assertThat("Equivalent unknown should not replace", GitHub.shouldReplace(unknown0, unknown1), is(false)); + assertThat("Equivalent unknown should not replace", GitHub.shouldReplace(unknown1, unknown0), is(false)); + + assertThat("Later unknown should replace earlier", GitHub.shouldReplace(unknown2, unknown0), is(true)); + assertThat("Earlier unknown should not replace later", GitHub.shouldReplace(unknown0, unknown2), is(false)); + + assertThat("Worst record should replace later unknown", GitHub.shouldReplace(recordWorst, unknown1), is(true)); + assertThat("Unknown should not replace worst record", GitHub.shouldReplace(unknown1, recordWorst), is(false)); + + assertThat("Earlier record should replace later worst", GitHub.shouldReplace(record0, recordWorst), is(true)); + assertThat("Later worst record should not replace earlier", + GitHub.shouldReplace(recordWorst, record0), + is(false)); + + assertThat("Equivalent record should not replace", GitHub.shouldReplace(record0, record00), is(false)); + assertThat("Equivalent record should not replace", GitHub.shouldReplace(record00, record0), is(false)); + + assertThat("Lower limit record should replace higher", GitHub.shouldReplace(record1, record0), is(true)); + assertThat("Lower limit record should replace higher", GitHub.shouldReplace(record2, record1), is(true)); + + assertThat("Higher limit record should not replace lower", GitHub.shouldReplace(record1, record2), is(false)); + + assertThat("Higher limit record with later reset should replace lower", + GitHub.shouldReplace(record3, record2), + is(true)); + + assertThat("Lower limit record with later reset should replace higher", + GitHub.shouldReplace(record4, record1), + is(true)); + + assertThat("Lower limit record with earlier reset should not replace higher", + GitHub.shouldReplace(record2, record4), + is(false)); + + } + static String formatDate(Date dt, String format) { SimpleDateFormat df = new SimpleDateFormat(format); df.setTimeZone(TimeZone.getTimeZone("GMT")); diff --git a/src/test/java/org/kohsuke/github/GitHubTest.java b/src/test/java/org/kohsuke/github/GitHubTest.java index bd37714b41..6b4d3b7a02 100644 --- a/src/test/java/org/kohsuke/github/GitHubTest.java +++ b/src/test/java/org/kohsuke/github/GitHubTest.java @@ -1,18 +1,13 @@ package org.kohsuke.github; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.*; - import com.google.common.collect.Iterables; -import org.apache.commons.io.IOUtils; -import org.junit.Ignore; import org.junit.Test; +import org.kohsuke.github.example.dataobject.ReadOnlyObjects; + +import java.io.IOException; +import java.util.*; import static org.hamcrest.CoreMatchers.*; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; /** * Unit test for {@link GitHub}. @@ -58,10 +53,15 @@ public void testListAllRepositories() throws Exception { assertNotEquals(0L, r.getId()); } } - + @Test public void searchContent() throws Exception { - PagedSearchIterable r = gitHub.searchContent().q("addClass").in("file").language("js").repo("jquery/jquery").list(); + PagedSearchIterable r = gitHub.searchContent() + .q("addClass") + .in("file") + .language("js") + .repo("jquery/jquery") + .list(); GHContent c = r.iterator().next(); // System.out.println(c.getName()); assertNotNull(c.getDownloadUrl()); @@ -71,12 +71,40 @@ public void searchContent() throws Exception { } @Test - public void testListMyAuthorizations() throws IOException - { + public void testListMyAuthorizations() throws IOException { PagedIterable list = gitHub.listMyAuthorizations(); - for (GHAuthorization auth: list) { + for (GHAuthorization auth : list) { assertNotNull(auth.getAppName()); } } + + @Test + public void getMeta() throws IOException { + GHMeta meta = gitHub.getMeta(); + assertTrue(meta.isVerifiablePasswordAuthentication()); + assertEquals(19, meta.getApi().size()); + assertEquals(19, meta.getGit().size()); + assertEquals(3, meta.getHooks().size()); + assertEquals(6, meta.getImporter().size()); + assertEquals(6, meta.getPages().size()); + assertEquals(19, meta.getWeb().size()); + + // Also test examples here + Class[] examples = new Class[]{ ReadOnlyObjects.GHMetaPublic.class, ReadOnlyObjects.GHMetaPackage.class, + ReadOnlyObjects.GHMetaGettersUnmodifiable.class, ReadOnlyObjects.GHMetaGettersFinal.class, + ReadOnlyObjects.GHMetaGettersFinalCreator.class, }; + + for (Class metaClass : examples) { + ReadOnlyObjects.GHMetaExample metaExample = gitHub.retrieve() + .to("/meta", (Class) metaClass); + assertTrue(metaExample.isVerifiablePasswordAuthentication()); + assertEquals(19, metaExample.getApi().size()); + assertEquals(19, metaExample.getGit().size()); + assertEquals(3, metaExample.getHooks().size()); + assertEquals(6, metaExample.getImporter().size()); + assertEquals(6, metaExample.getPages().size()); + assertEquals(19, metaExample.getWeb().size()); + } + } } diff --git a/src/test/java/org/kohsuke/github/Github2faTest.java b/src/test/java/org/kohsuke/github/Github2faTest.java new file mode 100644 index 0000000000..fb3c9cb6bf --- /dev/null +++ b/src/test/java/org/kohsuke/github/Github2faTest.java @@ -0,0 +1,39 @@ +package org.kohsuke.github; + +import org.junit.Test; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +/** + * @author Kevin Harrington mad.hephaestus@gmail.com + */ +public class Github2faTest extends AbstractGitHubWireMockTest { + + @Test + public void test2faToken() throws IOException { + assertFalse("Test only valid when not proxying", mockGitHub.isUseProxy()); + + List asList = Arrays + .asList("repo", "gist", "write:packages", "read:packages", "delete:packages", "user", "delete_repo"); + String nameOfToken = "Test2faTokenCreate";// +timestamp;// use time stamp to ensure the token creations do not + // collide with older tokens + + GHAuthorization token = gitHub + .createToken(asList, nameOfToken, "this is a test token created by a unit test", () -> { + String data = "111878"; + // TO UPDATE run this in debugger mode, put a breakpoint here, and enter the OTP you get into the + // value of Data + return data; + }); + assert token != null; + for (int i = 0; i < asList.size(); i++) { + assertTrue(token.getScopes().get(i).contentEquals(asList.get(i))); + } + + String p = token.getToken(); + + assert p != null; + } +} diff --git a/src/test/java/org/kohsuke/github/LifecycleTest.java b/src/test/java/org/kohsuke/github/LifecycleTest.java index 629ccebc94..1a467c7a31 100644 --- a/src/test/java/org/kohsuke/github/LifecycleTest.java +++ b/src/test/java/org/kohsuke/github/LifecycleTest.java @@ -1,65 +1,42 @@ package org.kohsuke.github; -import org.apache.commons.io.IOUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.dircache.DirCache; -import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.junit.Test; import java.io.File; -import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.List; -import java.util.Properties; -public class LifecycleTest extends AbstractGitHubApiTestBase { +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.core.Is.is; + +public class LifecycleTest extends AbstractGitHubWireMockTest { @Test - public void testCreateRepository() throws IOException, GitAPIException, InterruptedException { + public void testCreateRepository() throws IOException { GHMyself myself = gitHub.getMyself(); - GHOrganization org = gitHub.getOrganization("github-api-test-org"); - GHRepository repository = org.getRepository("github-api-test"); - if (repository != null) { - repository.delete(); - Thread.sleep(1000); - } - repository = org.createRepository("github-api-test", - "a test repository used to test kohsuke's github-api", "http://github-api.kohsuke.org/", "Core Developers", true); - Thread.sleep(1000); // wait for the repository to become ready + // GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); + GHRepository repository = getTempRepository(); assertTrue(repository.getReleases().isEmpty()); - try { - GHMilestone milestone = repository.createMilestone("Initial Release", "first one"); - GHIssue issue = repository.createIssue("Test Issue") + + GHMilestone milestone = repository.createMilestone("Initial Release", "first one"); + GHIssue issue = repository.createIssue("Test Issue") .body("issue body just for grins") .milestone(milestone) .assignee(myself) .label("bug") .create(); - File repoDir = new File(System.getProperty("java.io.tmpdir"), "github-api-test"); - delete(repoDir); - Git origin = Git.cloneRepository() - .setBare(false) - .setURI(repository.getSshUrl()) - .setDirectory(repoDir) - .setCredentialsProvider(getCredentialsProvider(myself)) - .call(); - commitTestFile(myself, repoDir, origin); + assertThat(issue, is(notNullValue())); + GHRelease release = createRelease(repository); - GHRelease release = createRelease(repository); + GHAsset asset = uploadAsset(release); - GHAsset asset = uploadAsset(release); + updateAsset(release, asset); - updateAsset(release, asset); - - deleteAsset(release, asset); - } finally { - repository.delete(); - } + deleteAsset(release, asset); } private void updateAsset(GHRelease release, GHAsset asset) throws IOException { @@ -73,20 +50,20 @@ private void deleteAsset(GHRelease release, GHAsset asset) throws IOException { } private GHAsset uploadAsset(GHRelease release) throws IOException { - GHAsset asset = release.uploadAsset(new File("pom.xml"), "application/text"); + GHAsset asset = release.uploadAsset(new File("LICENSE.txt"), "application/text"); assertNotNull(asset); List assets = release.getAssets(); assertEquals(1, assets.size()); - assertEquals("pom.xml", assets.get(0).getName()); + assertEquals("LICENSE.txt", assets.get(0).getName()); return asset; } private GHRelease createRelease(GHRepository repository) throws IOException { GHRelease builder = repository.createRelease("release_tag") - .name("Test Release") - .body("How exciting! To be able to programmatically create releases is a dream come true!") - .create(); + .name("Test Release") + .body("How exciting! To be able to programmatically create releases is a dream come true!") + .create(); List releases = repository.getReleases(); assertEquals(1, releases.size()); GHRelease release = releases.get(0); @@ -94,25 +71,6 @@ private GHRelease createRelease(GHRepository repository) throws IOException { return release; } - private void commitTestFile(GHMyself myself, File repoDir, Git origin) throws IOException, GitAPIException { - File dummyFile = createDummyFile(repoDir); - DirCache cache = origin.add().addFilepattern(dummyFile.getName()).call(); - origin.commit().setMessage("test commit").call(); - origin.push().setCredentialsProvider(getCredentialsProvider(myself)).call(); - } - - private UsernamePasswordCredentialsProvider getCredentialsProvider(GHMyself myself) throws IOException { - Properties props = new Properties(); - File homeDir = new File(System.getProperty("user.home")); - FileInputStream in = new FileInputStream(new File(homeDir, ".github")); - try { - props.load(in); - } finally { - IOUtils.closeQuietly(in); - } - return new UsernamePasswordCredentialsProvider(props.getProperty("login"), props.getProperty("oauth")); - } - private void delete(File toDelete) { if (toDelete.isDirectory()) { for (File file : toDelete.listFiles()) { diff --git a/src/test/java/org/kohsuke/github/PayloadRule.java b/src/test/java/org/kohsuke/github/PayloadRule.java index 20a6f46acc..063441ccc2 100644 --- a/src/test/java/org/kohsuke/github/PayloadRule.java +++ b/src/test/java/org/kohsuke/github/PayloadRule.java @@ -1,5 +1,10 @@ package org.kohsuke.github; +import org.apache.commons.io.IOUtils; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -7,11 +12,6 @@ import java.io.Reader; import java.nio.charset.Charset; -import org.apache.commons.io.IOUtils; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - /** * @author Stephen Connolly */ @@ -45,8 +45,8 @@ public void evaluate() throws Throwable { public InputStream asInputStream() throws FileNotFoundException { String name = resourceName.startsWith("/") - ? resourceName + type - : testClass.getSimpleName() + "/" + resourceName + type; + ? resourceName + type + : testClass.getSimpleName() + "/" + resourceName + type; InputStream stream = testClass.getResourceAsStream(name); if (stream == null) { throw new FileNotFoundException(String.format("Resource %s from class %s", name, testClass)); diff --git a/src/test/java/org/kohsuke/github/RepositoryMockTest.java b/src/test/java/org/kohsuke/github/RepositoryMockTest.java index c9c65f3c4a..6e8969adae 100644 --- a/src/test/java/org/kohsuke/github/RepositoryMockTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryMockTest.java @@ -25,7 +25,6 @@ public class RepositoryMockTest { @Mock GHRepository mockRepository; - @Before public void setUp() { MockitoAnnotations.initMocks(this); @@ -39,17 +38,13 @@ public void listCollaborators() throws Exception { GHUser user2 = new GHUser(); user2.login = "login2"; - when(iterator.hasNext()).thenReturn(true, false, true); - when(iterator.next()).thenReturn(new GHUser[] {user1}, new GHUser[] {user2}); + when(iterator.next()).thenReturn(new GHUser[]{ user1 }, new GHUser[]{ user2 }); Requester requester = Mockito.mock(Requester.class); when(mockGitHub.retrieve()).thenReturn(requester); - - when(requester.asIterator("/repos/*/*/collaborators", - GHUser[].class, 0)).thenReturn(iterator, iterator); - + when(requester.asIterator("/repos/*/*/collaborators", GHUser[].class, 0)).thenReturn(iterator, iterator); PagedIterable pagedIterable = Mockito.mock(PagedIterable.class); when(mockRepository.listCollaborators()).thenReturn(pagedIterable); @@ -67,21 +62,17 @@ protected void wrapUp(GHUser[] page) { } }; - when(pagedIterable.iterator()).thenReturn(userPagedIterator, userPagedIterator2); Iterator returnIterator1 = mockRepository.listCollaborators().iterator(); - Assert.assertTrue(returnIterator1.hasNext()); GHUser user = returnIterator1.next(); Assert.assertEquals(user, user1); Assert.assertFalse(returnIterator1.hasNext()); - Iterator returnIterator2 = mockRepository.listCollaborators().iterator(); - Assert.assertTrue(returnIterator2.hasNext()); user = returnIterator1.next(); Assert.assertEquals(user, user2); diff --git a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java index 5c8f6d35e3..4ba98b0a7c 100644 --- a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java @@ -22,8 +22,7 @@ public class RepositoryTrafficTest extends AbstractGitHubApiTestBase { @Override protected GitHubBuilder getGitHubBuilder() { - return new GitHubBuilder() - .withPassword(login, null); + return new GitHubBuilder().withPassword(login, null); } @SuppressWarnings("unchecked") @@ -58,30 +57,23 @@ private void testTraffic(T expectedResult) throw GitHub gitHubSpy = Mockito.spy(gitHub); GHRepository repo = gitHubSpy.getUser(login).getRepository(repositoryName); - // accessing traffic info requires push access to the repo // since we don't have that, let the mocking begin... HttpConnector connectorSpy = Mockito.spy(gitHubSpy.getConnector()); Mockito.doReturn(connectorSpy).when(gitHubSpy).getConnector(); - // also known as the "uc" in the Requester class HttpURLConnection mockHttpURLConnection = Mockito.mock(HttpURLConnection.class); - // needed for Requester.setRequestMethod Mockito.doReturn("GET").when(mockHttpURLConnection).getRequestMethod(); - // this covers calls on "uc" in Requester.setupConnection and Requester.buildRequest - URL trafficURL = gitHub.getApiURL( - "/repos/" + login + "/" + repositoryName + "/traffic/" + - ((expectedResult instanceof GHRepositoryViewTraffic) ? "views" : "clones") - ); + URL trafficURL = gitHub.getApiURL("/repos/" + login + "/" + repositoryName + "/traffic/" + + ((expectedResult instanceof GHRepositoryViewTraffic) ? "views" : "clones")); Mockito.doReturn(mockHttpURLConnection).when(connectorSpy).connect(Mockito.eq(trafficURL)); - // make Requester.parse work Mockito.doReturn(200).when(mockHttpURLConnection).getResponseCode(); Mockito.doReturn("OK").when(mockHttpURLConnection).getResponseMessage(); @@ -99,53 +91,45 @@ private void testTraffic(T expectedResult) throw @Test public void testGetViews() throws IOException { - GHRepositoryViewTraffic expectedResult = new GHRepositoryViewTraffic( - 21523359, - 65534, - Arrays.asList( - new GHRepositoryViewTraffic.DailyInfo("2016-10-10T00:00:00Z", 3, 2), - new GHRepositoryViewTraffic.DailyInfo("2016-10-11T00:00:00Z", 9, 4), - new GHRepositoryViewTraffic.DailyInfo("2016-10-12T00:00:00Z", 27, 8), - new GHRepositoryViewTraffic.DailyInfo("2016-10-13T00:00:00Z", 81, 16), - new GHRepositoryViewTraffic.DailyInfo("2016-10-14T00:00:00Z", 243, 32), - new GHRepositoryViewTraffic.DailyInfo("2016-10-15T00:00:00Z", 729, 64), - new GHRepositoryViewTraffic.DailyInfo("2016-10-16T00:00:00Z", 2187, 128), - new GHRepositoryViewTraffic.DailyInfo("2016-10-17T00:00:00Z", 6561, 256), - new GHRepositoryViewTraffic.DailyInfo("2016-10-18T00:00:00Z", 19683, 512), - new GHRepositoryViewTraffic.DailyInfo("2016-10-19T00:00:00Z", 59049, 1024), - new GHRepositoryViewTraffic.DailyInfo("2016-10-20T00:00:00Z", 177147, 2048), - new GHRepositoryViewTraffic.DailyInfo("2016-10-21T00:00:00Z", 531441, 4096), - new GHRepositoryViewTraffic.DailyInfo("2016-10-22T00:00:00Z", 1594323, 8192), - new GHRepositoryViewTraffic.DailyInfo("2016-10-23T00:00:00Z", 4782969, 16384), - new GHRepositoryViewTraffic.DailyInfo("2016-10-24T00:00:00Z", 14348907, 32768) - ) - ); + GHRepositoryViewTraffic expectedResult = new GHRepositoryViewTraffic(21523359, + 65534, + Arrays.asList(new GHRepositoryViewTraffic.DailyInfo("2016-10-10T00:00:00Z", 3, 2), + new GHRepositoryViewTraffic.DailyInfo("2016-10-11T00:00:00Z", 9, 4), + new GHRepositoryViewTraffic.DailyInfo("2016-10-12T00:00:00Z", 27, 8), + new GHRepositoryViewTraffic.DailyInfo("2016-10-13T00:00:00Z", 81, 16), + new GHRepositoryViewTraffic.DailyInfo("2016-10-14T00:00:00Z", 243, 32), + new GHRepositoryViewTraffic.DailyInfo("2016-10-15T00:00:00Z", 729, 64), + new GHRepositoryViewTraffic.DailyInfo("2016-10-16T00:00:00Z", 2187, 128), + new GHRepositoryViewTraffic.DailyInfo("2016-10-17T00:00:00Z", 6561, 256), + new GHRepositoryViewTraffic.DailyInfo("2016-10-18T00:00:00Z", 19683, 512), + new GHRepositoryViewTraffic.DailyInfo("2016-10-19T00:00:00Z", 59049, 1024), + new GHRepositoryViewTraffic.DailyInfo("2016-10-20T00:00:00Z", 177147, 2048), + new GHRepositoryViewTraffic.DailyInfo("2016-10-21T00:00:00Z", 531441, 4096), + new GHRepositoryViewTraffic.DailyInfo("2016-10-22T00:00:00Z", 1594323, 8192), + new GHRepositoryViewTraffic.DailyInfo("2016-10-23T00:00:00Z", 4782969, 16384), + new GHRepositoryViewTraffic.DailyInfo("2016-10-24T00:00:00Z", 14348907, 32768))); testTraffic(expectedResult); } @Test public void testGetClones() throws IOException { - GHRepositoryCloneTraffic expectedResult = new GHRepositoryCloneTraffic( - 1500, - 455, - Arrays.asList( - new GHRepositoryCloneTraffic.DailyInfo("2016-10-10T00:00:00Z", 10, 3), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-11T00:00:00Z", 20, 6), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-12T00:00:00Z", 30, 5), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-13T00:00:00Z", 40, 7), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-14T00:00:00Z", 50, 11), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-15T00:00:00Z", 60, 12), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-16T00:00:00Z", 70, 19), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-17T00:00:00Z", 170, 111), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-18T00:00:00Z", 180, 70), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-19T00:00:00Z", 190, 10), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-20T00:00:00Z", 200, 18), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-21T00:00:00Z", 210, 8), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-22T00:00:00Z", 220, 168), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-23T00:00:00Z", 5, 2), - new GHRepositoryCloneTraffic.DailyInfo("2016-10-24T00:00:00Z", 45, 5) - ) - ); + GHRepositoryCloneTraffic expectedResult = new GHRepositoryCloneTraffic(1500, + 455, + Arrays.asList(new GHRepositoryCloneTraffic.DailyInfo("2016-10-10T00:00:00Z", 10, 3), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-11T00:00:00Z", 20, 6), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-12T00:00:00Z", 30, 5), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-13T00:00:00Z", 40, 7), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-14T00:00:00Z", 50, 11), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-15T00:00:00Z", 60, 12), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-16T00:00:00Z", 70, 19), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-17T00:00:00Z", 170, 111), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-18T00:00:00Z", 180, 70), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-19T00:00:00Z", 190, 10), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-20T00:00:00Z", 200, 18), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-21T00:00:00Z", 210, 8), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-22T00:00:00Z", 220, 168), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-23T00:00:00Z", 5, 2), + new GHRepositoryCloneTraffic.DailyInfo("2016-10-24T00:00:00Z", 45, 5))); testTraffic(expectedResult); } diff --git a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java index f8d21dad5a..843becc145 100644 --- a/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java +++ b/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import org.kohsuke.github.junit.WireMockRule; import org.hamcrest.Matchers; import org.junit.Ignore; import org.junit.Test; @@ -9,7 +8,6 @@ import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; - /** * Tests in this class are meant to show the behavior of {@link AbstractGitHubWireMockTest} with proxying on or off. *

@@ -25,8 +23,9 @@ public void user_whenProxying_AuthCorrectlyConfigured() throws Exception { requireProxy("Tests proper configuration when proxying."); assertThat( - "GitHub connection believes it is anonymous. Make sure you set GITHUB_OAUTH or both GITHUB_USER and GITHUB_PASSWORD environment variables", - gitHub.isAnonymous(), is(false)); + "GitHub connection believes it is anonymous. Make sure you set GITHUB_OAUTH or both GITHUB_USER and GITHUB_PASSWORD environment variables", + gitHub.isAnonymous(), + is(false)); assertThat(gitHub.login, not(equalTo(STUBBED_USER_LOGIN))); @@ -37,7 +36,8 @@ public void user_whenProxying_AuthCorrectlyConfigured() throws Exception { assertThat(user.getLogin(), notNullValue()); // System.out.println(); - // System.out.println("WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user login: " + user.getLogin()); + // System.out.println("WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user + // login: " + user.getLogin()); // System.out.println(); } @@ -121,12 +121,14 @@ public void BasicBehaviors_whenProxying() throws Exception { } assertThat(e, Matchers.instanceOf(GHFileNotFoundException.class)); - assertThat(e.getMessage(), equalTo("{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}")); + assertThat(e.getMessage(), + equalTo("{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}")); } @Test public void whenSnapshot_EnsureProxy() throws Exception { - assumeTrue("Test only valid when Snapshotting (-Dtest.github.takeSnapshot to enable)", mockGitHub.isTakeSnapshot()); + assumeTrue("Test only valid when Snapshotting (-Dtest.github.takeSnapshot to enable)", + mockGitHub.isTakeSnapshot()); assertTrue("When taking a snapshot, proxy should automatically be enabled", mockGitHub.isUseProxy()); } @@ -134,7 +136,8 @@ public void whenSnapshot_EnsureProxy() throws Exception { @Ignore("Not implemented yet") @Test public void whenSnapshot_EnsureRecordToExpectedLocation() throws Exception { - assumeTrue("Test only valid when Snapshotting (-Dtest.github.takeSnapshot to enable)", mockGitHub.isTakeSnapshot()); + assumeTrue("Test only valid when Snapshotting (-Dtest.github.takeSnapshot to enable)", + mockGitHub.isTakeSnapshot()); } } diff --git a/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java b/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java index 381a2c437b..00f85bdfd2 100644 --- a/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/OkHttpConnectorTest.java @@ -2,12 +2,12 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; -import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; -import com.squareup.okhttp.OkUrlFactory; import com.squareup.okhttp.Cache; import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.OkUrlFactory; import org.apache.commons.io.FileUtils; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.kohsuke.github.*; @@ -25,16 +25,16 @@ * Key take aways: * *

    - *
  • These tests are artificial and intended to highlight the differences - * in behavior between scenarios. However, the differences they indicate are stark.
  • + *
  • These tests are artificial and intended to highlight the differences in behavior between scenarios. However, the + * differences they indicate are stark.
  • *
  • Caching reduces rate limit consumption by at least a factor of two in even the simplest case.
  • - *
  • The OkHttp cache is pretty smart and will often connect read and write requests made - * on the same client and invalidate caches.
  • - *
  • Changes made outside the current client cause the OkHttp cache to return stale data. - * This is expected and correct behavior.
  • - *
  • "max-age=0" addresses the problem of external changes by revalidating caches for each request. - * This produces the same number of requests as OkHttp without caching, but those requests only - * count towards the GitHub rate limit if data has changes.
  • + *
  • The OkHttp cache is pretty smart and will often connect read and write requests made on the same client and + * invalidate caches.
  • + *
  • Changes made outside the current client cause the OkHttp cache to return stale data. This is expected and correct + * behavior.
  • + *
  • "max-age=0" addresses the problem of external changes by revalidating caches for each request. This produces the + * same number of requests as OkHttp without caching, but those requests only count towards the GitHub rate limit if + * data has changes.
  • *
* * @author Liam Newman @@ -68,11 +68,7 @@ public OkHttpConnectorTest() { @Override protected WireMockConfiguration getWireMockOptions() { return super.getWireMockOptions() - .extensions(ResponseTemplateTransformer.builder() - .global(true) - .maxCacheEntries(0L) - .build() - ); + .extensions(ResponseTemplateTransformer.builder().global(true).maxCacheEntries(0L).build()); } @Before @@ -90,9 +86,7 @@ public void setupRepo() throws Exception { @Test public void DefaultConnector() throws Exception { - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build(); doTestActions(); @@ -109,10 +103,9 @@ public void OkHttpConnector_NoCache() throws Exception { OkHttpClient client = createClient(false); OkHttpConnector connector = new OkHttpConnector(new OkUrlFactory(client)); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); @@ -136,15 +129,14 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(new OkUrlFactory(client), -1); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); // Testing behavior after change - // NOTE: this is wrong! The live data changed! + // NOTE: this is wrong! The live data changed! // Due to max-age (default 60 from response) the cache returns the old data. assertThat(getRepository(gitHub).getDescription(), is(mockGitHub.getMethodName())); @@ -165,14 +157,12 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { assumeFalse("Test only valid when not taking a snapshot", mockGitHub.isTakeSnapshot()); assumeTrue("Test only valid when proxying (-Dtest.github.useProxy to enable)", mockGitHub.isUseProxy()); - OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(new OkUrlFactory(client), 3); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); @@ -185,6 +175,7 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { assertThat("getHitCount", cache.getHitCount(), is(maxAgeThreeHitCount)); } + @Ignore("ISSUE #597 - Correctly formatted Last-Modified headers cause this test to fail") @Test public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { // The responses were recorded from github, but the Date headers @@ -195,10 +186,9 @@ public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(new OkUrlFactory(client)); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); @@ -214,14 +204,12 @@ public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { private void checkRequestAndLimit(int networkRequestCount, int rateLimitUsed) throws IOException { GHRateLimit rateLimitAfter = gitHub.rateLimit(); - assertThat("Request Count", - mockGitHub.getRequestCount(), - is(networkRequestCount + userRequestCount)); + assertThat("Request Count", mockGitHub.getRequestCount(), is(networkRequestCount + userRequestCount)); // Rate limit must be under this value, but if it wiggles we don't care assertThat("Rate Limit Change", - rateLimitBefore.remaining - rateLimitAfter.remaining, - is(lessThanOrEqualTo(rateLimitUsed + userRequestCount))); + rateLimitBefore.remaining - rateLimitAfter.remaining, + is(lessThanOrEqualTo(rateLimitUsed + userRequestCount))); } @@ -240,7 +228,6 @@ private OkHttpClient createClient(boolean useCache) throws IOException { return client; } - /** * This is a standard set of actions to be performed with each connector * @@ -251,7 +238,6 @@ private void doTestActions() throws Exception { String name = mockGitHub.getMethodName(); - GHRepository repo = getRepository(gitHub); // Testing behavior when nothing has changed. @@ -265,7 +251,6 @@ private void doTestActions() throws Exception { // Test behavior after change assertThat(getRepository(gitHub).getDescription(), is(name)); - // Get Tricky - make a change via a different client if (mockGitHub.isUseProxy()) { GHRepository altRepo = getRepository(gitHubBeforeAfter); @@ -280,14 +265,14 @@ private void pollForChange(String name) throws IOException, InterruptedException getRepository(gitHub).getDescription(); Thread.sleep(500); getRepository(gitHub).getDescription(); - //This is only interesting when running the max-age=3 test which currently only runs with proxy - //Disabled to speed up the tests + // This is only interesting when running the max-age=3 test which currently only runs with proxy + // Disabled to speed up the tests if (mockGitHub.isUseProxy()) { Thread.sleep(1000); } getRepository(gitHub).getDescription(); - //This is only interesting when running the max-age=3 test which currently only runs with proxy - //Disabled to speed up the tests + // This is only interesting when running the max-age=3 test which currently only runs with proxy + // Disabled to speed up the tests if (mockGitHub.isUseProxy()) { Thread.sleep(4000); } diff --git a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java index a8abb68025..a60221f8d4 100644 --- a/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java +++ b/src/test/java/org/kohsuke/github/extras/okhttp3/OkHttpConnectorTest.java @@ -28,16 +28,16 @@ * Key take aways: * *
    - *
  • These tests are artificial and intended to highlight the differences - * in behavior between scenarios. However, the differences they indicate are stark.
  • + *
  • These tests are artificial and intended to highlight the differences in behavior between scenarios. However, the + * differences they indicate are stark.
  • *
  • Caching reduces rate limit consumption by at least a factor of two in even the simplest case.
  • - *
  • The OkHttp cache is pretty smart and will often connect read and write requests made - * on the same client and invalidate caches.
  • - *
  • Changes made outside the current client cause the OkHttp cache to return stale data. - * This is expected and correct behavior.
  • - *
  • "max-age=0" addresses the problem of external changes by revalidating caches for each request. - * This produces the same number of requests as OkHttp without caching, but those requests only - * count towards the GitHub rate limit if data has changes.
  • + *
  • The OkHttp cache is pretty smart and will often connect read and write requests made on the same client and + * invalidate caches.
  • + *
  • Changes made outside the current client cause the OkHttp cache to return stale data. This is expected and correct + * behavior.
  • + *
  • "max-age=0" addresses the problem of external changes by revalidating caches for each request. This produces the + * same number of requests as OkHttp without caching, but those requests only count towards the GitHub rate limit if + * data has changes.
  • *
* * @author Liam Newman @@ -71,13 +71,9 @@ public OkHttpConnectorTest() { @Override protected WireMockConfiguration getWireMockOptions() { return super.getWireMockOptions() - // Use the same data files as the 2.x test - .usingFilesUnderDirectory(baseRecordPath.replace("/okhttp3/", "/")) - .extensions(ResponseTemplateTransformer.builder() - .global(true) - .maxCacheEntries(0L) - .build() - ); + // Use the same data files as the 2.x test + .usingFilesUnderDirectory(baseRecordPath.replace("/okhttp3/", "/")) + .extensions(ResponseTemplateTransformer.builder().global(true).maxCacheEntries(0L).build()); } @Before @@ -95,9 +91,7 @@ public void setupRepo() throws Exception { @Test public void DefaultConnector() throws Exception { - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()).build(); doTestActions(); @@ -114,10 +108,9 @@ public void OkHttpConnector_NoCache() throws Exception { OkHttpClient client = createClient(false); OkHttpConnector connector = new OkHttpConnector(client); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); @@ -141,15 +134,14 @@ public void OkHttpConnector_Cache_MaxAgeNone() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client, -1); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); // Testing behavior after change - // NOTE: this is wrong! The live data changed! + // NOTE: this is wrong! The live data changed! // Due to max-age (default 60 from response) the cache returns the old data. assertThat(getRepository(gitHub).getDescription(), is(mockGitHub.getMethodName())); @@ -170,14 +162,12 @@ public void OkHttpConnector_Cache_MaxAge_Three() throws Exception { assumeFalse("Test only valid when not taking a snapshot", mockGitHub.isTakeSnapshot()); assumeTrue("Test only valid when proxying (-Dtest.github.useProxy to enable)", mockGitHub.isUseProxy()); - OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client, 3); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); @@ -200,10 +190,9 @@ public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { OkHttpClient client = createClient(true); OkHttpConnector connector = new OkHttpConnector(client); - this.gitHub = getGitHubBuilder() - .withEndpoint(mockGitHub.apiServer().baseUrl()) - .withConnector(connector) - .build(); + this.gitHub = getGitHubBuilder().withEndpoint(mockGitHub.apiServer().baseUrl()) + .withConnector(connector) + .build(); doTestActions(); @@ -219,14 +208,12 @@ public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception { private void checkRequestAndLimit(int networkRequestCount, int rateLimitUsed) throws IOException { GHRateLimit rateLimitAfter = gitHub.rateLimit(); - assertThat("Request Count", - getRequestCount(), - is(networkRequestCount + userRequestCount)); + assertThat("Request Count", getRequestCount(), is(networkRequestCount + userRequestCount)); // Rate limit must be under this value, but if it wiggles we don't care assertThat("Rate Limit Change", - rateLimitBefore.remaining - rateLimitAfter.remaining, - is(lessThanOrEqualTo(rateLimitUsed + userRequestCount))); + rateLimitBefore.remaining - rateLimitAfter.remaining, + is(lessThanOrEqualTo(rateLimitUsed + userRequestCount))); } @@ -249,7 +236,6 @@ private OkHttpClient createClient(boolean useCache) throws IOException { return builder.build(); } - /** * This is a standard set of actions to be performed with each connector * @@ -260,7 +246,6 @@ private void doTestActions() throws Exception { String name = mockGitHub.getMethodName(); - GHRepository repo = getRepository(gitHub); // Testing behavior when nothing has changed. @@ -274,7 +259,6 @@ private void doTestActions() throws Exception { // Test behavior after change assertThat(getRepository(gitHub).getDescription(), is(name)); - // Get Tricky - make a change via a different client if (mockGitHub.isUseProxy()) { GHRepository altRepo = getRepository(gitHubBeforeAfter); @@ -289,14 +273,14 @@ private void pollForChange(String name) throws IOException, InterruptedException getRepository(gitHub).getDescription(); Thread.sleep(500); getRepository(gitHub).getDescription(); - //This is only interesting when running the max-age=3 test which currently only runs with proxy - //Disabled to speed up the tests + // This is only interesting when running the max-age=3 test which currently only runs with proxy + // Disabled to speed up the tests if (mockGitHub.isUseProxy()) { Thread.sleep(1000); } getRepository(gitHub).getDescription(); - //This is only interesting when running the max-age=3 test which currently only runs with proxy - //Disabled to speed up the tests + // This is only interesting when running the max-age=3 test which currently only runs with proxy + // Disabled to speed up the tests if (mockGitHub.isUseProxy()) { Thread.sleep(4000); } diff --git a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java index 7d008fdfff..c4059344a6 100644 --- a/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java @@ -1,10 +1,8 @@ package org.kohsuke.github.junit; import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.VerificationException; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.core.Options; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.github.tomakehurst.wiremock.extension.Parameters; import com.github.tomakehurst.wiremock.extension.ResponseTransformer; @@ -12,11 +10,6 @@ import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; import com.github.tomakehurst.wiremock.verification.*; import com.google.gson.*; -import org.junit.rules.MethodRule; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; import java.io.File; import java.io.IOException; @@ -24,16 +17,14 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; -import java.util.List; import java.util.Map; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.common.Gzip.unGzipToString; /** - * The standard WireMockRule eagerly initializes a WireMockServer. - * This version suptakes a laze approach allowing us to automatically isolate snapshots - * for each method. + * The standard WireMockRule eagerly initializes a WireMockServer. This version suptakes a laze approach allowing us to + * automatically isolate snapshots for each method. * * @author Liam Newman */ @@ -44,8 +35,8 @@ public class GitHubWireMockRule extends WireMockMultiServerRule { // You can use the proxy without taking a snapshot while writing and debugging tests. // You cannot take a snapshot without proxying. private final static boolean takeSnapshot = System.getProperty("test.github.takeSnapshot", "false") != "false"; - private final static boolean useProxy = takeSnapshot || System.getProperty("test.github.useProxy", "false") != "false"; - + private final static boolean useProxy = takeSnapshot + || System.getProperty("test.github.useProxy", "false") != "false"; public GitHubWireMockRule() { this(WireMockConfiguration.options()); @@ -67,6 +58,10 @@ public WireMockServer rawServer() { return servers.get("raw"); } + public WireMockServer uploadsServer() { + return servers.get("uploads"); + } + public boolean isUseProxy() { return GitHubWireMockRule.useProxy; } @@ -78,45 +73,69 @@ public boolean isTakeSnapshot() { @Override protected void initializeServers() { super.initializeServers(); - initializeServer("raw"); initializeServer("default", new GitHubApiResponseTransformer(this)); + + // only start non-api servers if we might need them + if (new File(apiServer().getOptions().filesRoot().getPath() + "_raw").exists() || isUseProxy()) { + initializeServer("raw"); + } + if (new File(apiServer().getOptions().filesRoot().getPath() + "_uploads").exists() || isUseProxy()) { + initializeServer("uploads"); + } } @Override protected void before() { super.before(); - if (isUseProxy()) { - this.apiServer().stubFor( - proxyAllTo("https://api.github.com") - .atPriority(100) - ); - this.rawServer().stubFor( - proxyAllTo("https://raw.githubusercontent.com") - .atPriority(100) - ); + if (!isUseProxy()) { + return; + } + + this.apiServer().stubFor(proxyAllTo("https://api.github.com").atPriority(100)); + + if (this.rawServer() != null) { + this.rawServer().stubFor(proxyAllTo("https://raw.githubusercontent.com").atPriority(100)); + } + + if (this.uploadsServer() != null) { + this.uploadsServer().stubFor(proxyAllTo("https://uploads.github.com").atPriority(100)); } } @Override protected void after() { super.after(); - if (isTakeSnapshot()) { - this.apiServer().snapshotRecord(recordSpec() - .forTarget("https://api.github.com") - .captureHeader("If-None-Match") - .extractTextBodiesOver(255)); + if (!isTakeSnapshot()) { + return; + } - this.rawServer().snapshotRecord(recordSpec() - .forTarget("https://raw.githubusercontent.com") - .captureHeader("If-None-Match") - .extractTextBodiesOver(255)); + this.apiServer() + .snapshotRecord(recordSpec().forTarget("https://api.github.com") + .captureHeader("If-None-Match") + .extractTextBodiesOver(255)); - // After taking the snapshot, format the output - formatJsonFiles(new File(this.apiServer().getOptions().filesRoot().getPath()).toPath()); + // After taking the snapshot, format the output + formatJsonFiles(new File(this.apiServer().getOptions().filesRoot().getPath()).toPath()); + + if (this.rawServer() != null) { + this.rawServer() + .snapshotRecord(recordSpec().forTarget("https://raw.githubusercontent.com") + .captureHeader("If-None-Match") + .extractTextBodiesOver(255)); // For raw server, only fix up mapping files formatJsonFiles(new File(this.rawServer().getOptions().filesRoot().child("mappings").getPath()).toPath()); } + + if (this.uploadsServer() != null) { + this.uploadsServer() + .snapshotRecord(recordSpec().forTarget("https://uploads.github.com") + .captureHeader("If-None-Match") + .extractTextBodiesOver(255)); + + formatJsonFiles(new File(this.uploadsServer().getOptions().filesRoot().getPath()).toPath()); + + } } public int getRequestCount() { @@ -127,45 +146,54 @@ public static int getRequestCount(WireMockServer server) { return server.countRequestsMatching(RequestPatternBuilder.allRequests().build()).getCount(); } - private void formatJsonFiles(Path path) { // The more consistent we can make the json output the more meaningful it will be. - Gson g = new Gson().newBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(Double.class, new JsonSerializer() { - @Override - public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { - // Gson by default output numbers as doubles - 0.0 - // Remove the tailing .0, as most most numbers are integer value - if(src == src.longValue()) - return new JsonPrimitive(src.longValue()); - return new JsonPrimitive(src); - } - }) - .create(); + Gson g = new Gson().newBuilder() + .serializeNulls() + .disableHtmlEscaping() + .setPrettyPrinting() + .registerTypeAdapter(Double.class, new JsonSerializer() { + @Override + public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { + // Gson by default output numbers as doubles - 0.0 + // Remove the tailing .0, as most most numbers are integer value + if (src == src.longValue()) + return new JsonPrimitive(src.longValue()); + return new JsonPrimitive(src); + } + }) + .create(); try { - Files.walk(path) - .forEach(filePath -> { - try { - if (filePath.toString().endsWith(".json")) { - String fileText = new String(Files.readAllBytes(filePath)); - // while recording responses we replaced all github calls localhost - // now we reverse that for storage. - fileText = fileText - .replace(this.apiServer().baseUrl(), "https://api.github.com") - .replace(this.rawServer().baseUrl(), "https://raw.githubusercontent.com"); - // Can be Array or Map - Object parsedObject = g.fromJson(fileText, Object.class); - if (parsedObject instanceof Map && filePath.toString().contains("mappings")) { - filePath = renameMappingFile(filePath, (Map) parsedObject); - } - fileText = g.toJson(parsedObject); - Files.write(filePath, fileText.getBytes()); + Files.walk(path).forEach(filePath -> { + try { + if (filePath.toString().endsWith(".json")) { + String fileText = new String(Files.readAllBytes(filePath)); + // while recording responses we replaced all github calls localhost + // now we reverse that for storage. + fileText = fileText.replace(this.apiServer().baseUrl(), "https://api.github.com"); + + if (this.rawServer() != null) { + fileText = fileText.replace(this.rawServer().baseUrl(), + "https://raw.githubusercontent.com"); + } + + if (this.uploadsServer() != null) { + fileText = fileText.replace(this.uploadsServer().baseUrl(), "https://uploads.github.com"); } - } catch (Exception e) { - throw new RuntimeException("Files could not be written", e); + + // Can be Array or Map + Object parsedObject = g.fromJson(fileText, Object.class); + if (parsedObject instanceof Map && filePath.toString().contains("mappings")) { + filePath = renameMappingFile(filePath, (Map) parsedObject); + } + fileText = g.toJson(parsedObject); + Files.write(filePath, fileText.getBytes()); } - }); + } catch (Exception e) { + throw new RuntimeException("Files could not be written", e); + } + }); } catch (IOException e) { throw new RuntimeException("Files could not be written"); } @@ -175,12 +203,13 @@ private Path renameMappingFile(Path filePath, Map parsedObject) // Shorten the file names // For understandability, rename the files to include the response order Path targetPath = filePath; - String id = (String)parsedObject.getOrDefault("id", null); - Long insertionIndex = ((Double)parsedObject.getOrDefault("insertionIndex", 0.0)).longValue(); + String id = (String) parsedObject.getOrDefault("id", null); + Long insertionIndex = ((Double) parsedObject.getOrDefault("insertionIndex", 0.0)).longValue(); if (id != null && insertionIndex > 0) { String filePathString = filePath.toString(); if (filePathString.contains(id)) { - targetPath = new File(filePathString.replace(id, insertionIndex.toString() + "-" + id.substring(0, 6))).toPath(); + targetPath = new File(filePathString.replace(id, insertionIndex.toString() + "-" + id.substring(0, 6))) + .toPath(); Files.move(filePath, targetPath); } } @@ -188,11 +217,9 @@ private Path renameMappingFile(Path filePath, Map parsedObject) return targetPath; } - /** - * A number of modifications are needed as runtime to make responses - * target the WireMock server and not accidentally switch to using the live - * github servers. + * A number of modifications are needed as runtime to make responses target the WireMock server and not accidentally + * switch to using the live github servers. */ private static class GitHubApiResponseTransformer extends ResponseTransformer { private final GitHubWireMockRule rule; @@ -202,22 +229,31 @@ public GitHubApiResponseTransformer(GitHubWireMockRule rule) { } @Override - public Response transform(Request request, Response response, FileSource files, - Parameters parameters) { + public Response transform(Request request, Response response, FileSource files, Parameters parameters) { Response.Builder builder = Response.Builder.like(response); Collection headers = response.getHeaders().all(); fixListTraversalHeader(response, headers); - if ("application/json" - .equals(response.getHeaders().getContentTypeHeader().mimeTypePart())) { + if ("application/json".equals(response.getHeaders().getContentTypeHeader().mimeTypePart())) { String body; body = getBodyAsString(response, headers); + body = body.replace("https://api.github.com", rule.apiServer().baseUrl()); + + if (rule.rawServer() != null) { + body = body.replace("https://raw.githubusercontent.com", rule.rawServer().baseUrl()); + } else { + body = body.replace("https://raw.githubusercontent.com", rule.apiServer().baseUrl() + "/raw"); + } + + if (rule.uploadsServer() != null) { + body = body.replace("https://uploads.github.com", rule.uploadsServer().baseUrl()); + } else { + body = body.replace("https://uploads.github.com", rule.apiServer().baseUrl() + "/uploads"); + } - builder.body(body - .replace("https://api.github.com", rule.apiServer().baseUrl()) - .replace("https://raw.githubusercontent.com", rule.rawServer().baseUrl())); + builder.body(body); } builder.headers(new HttpHeaders(headers)); @@ -240,9 +276,8 @@ private void fixListTraversalHeader(Response response, Collection he HttpHeader linkHeader = response.getHeaders().getHeader("Link"); if (linkHeader.isPresent()) { headers.removeIf(item -> item.keyEquals("Link")); - headers.add(HttpHeader.httpHeader("Link", linkHeader.firstValue() - .replace("https://api.github.com", - rule.apiServer().baseUrl()))); + headers.add(HttpHeader.httpHeader("Link", + linkHeader.firstValue().replace("https://api.github.com", rule.apiServer().baseUrl()))); } } diff --git a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java index 660782272f..81e1a958d8 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockMultiServerRule.java @@ -19,10 +19,8 @@ import java.util.Map; /** - * The standard WireMockRule eagerly initializes a WireMockServer. - * This version supports multiple servers in one rule and - * takes a lazy approach to intitialization allowing us to - * isolate files snapshots for each method. + * The standard WireMockRule eagerly initializes a WireMockServer. This version supports multiple servers in one rule + * and takes a lazy approach to intitialization allowing us to isolate files snapshots for each method. * * @author Liam Newman */ @@ -38,7 +36,6 @@ public String getMethodName() { private String methodName = null; - public WireMockMultiServerRule(Options options) { this(options, true); } @@ -65,8 +62,7 @@ private Statement apply(final Statement base, final String methodName) { public void evaluate() throws Throwable { WireMockMultiServerRule.this.methodName = methodName; initializeServers(); - WireMock.configureFor("localhost", - WireMockMultiServerRule.this.servers.get("default").port()); + WireMock.configureFor("localhost", WireMockMultiServerRule.this.servers.get("default").port()); try { WireMockMultiServerRule.this.before(); @@ -92,9 +88,9 @@ protected final void initializeServer(String serverId, Extension... extensions) directoryName += "_" + serverId; } - final Options localOptions = new WireMockRuleConfiguration( - WireMockMultiServerRule.this.options, - directoryName, extensions); + final Options localOptions = new WireMockRuleConfiguration(WireMockMultiServerRule.this.options, + directoryName, + extensions); new File(localOptions.filesRoot().getPath(), "mappings").mkdirs(); new File(localOptions.filesRoot().getPath(), "__files").mkdirs(); @@ -160,6 +156,4 @@ private void stop() { }); } - - } diff --git a/src/test/java/org/kohsuke/github/junit/WireMockRule.java b/src/test/java/org/kohsuke/github/junit/WireMockRule.java index aa60691379..4ddc9d00ba 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockRule.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockRule.java @@ -7,14 +7,9 @@ import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.*; import com.github.tomakehurst.wiremock.core.*; -import com.github.tomakehurst.wiremock.extension.Extension; import com.github.tomakehurst.wiremock.global.GlobalSettings; import com.github.tomakehurst.wiremock.global.GlobalSettingsHolder; -import com.github.tomakehurst.wiremock.http.CaseInsensitiveKey; -import com.github.tomakehurst.wiremock.http.HttpServerFactory; import com.github.tomakehurst.wiremock.http.RequestListener; -import com.github.tomakehurst.wiremock.http.ThreadPoolFactory; -import com.github.tomakehurst.wiremock.http.trafficlistener.WiremockNetworkTrafficListener; import com.github.tomakehurst.wiremock.junit.Stubbing; import com.github.tomakehurst.wiremock.matching.RequestPattern; import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; @@ -23,27 +18,20 @@ import com.github.tomakehurst.wiremock.recording.RecordSpecBuilder; import com.github.tomakehurst.wiremock.recording.RecordingStatusResult; import com.github.tomakehurst.wiremock.recording.SnapshotRecordResult; -import com.github.tomakehurst.wiremock.security.Authenticator; -import com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource; import com.github.tomakehurst.wiremock.standalone.MappingsLoader; -import com.github.tomakehurst.wiremock.standalone.MappingsSource; import com.github.tomakehurst.wiremock.stubbing.ServeEvent; import com.github.tomakehurst.wiremock.stubbing.StubImport; import com.github.tomakehurst.wiremock.stubbing.StubMapping; import com.github.tomakehurst.wiremock.verification.*; - -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import com.github.tomakehurst.wiremock.verification.notmatched.NotMatchedRenderer; import org.junit.rules.MethodRule; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.Statement; -import wiremock.com.google.common.base.Optional; + +import java.io.File; +import java.util.List; +import java.util.UUID; /** * @author Liam Newman @@ -93,9 +81,7 @@ private Statement apply(final Statement base, final String methodName) { return new Statement() { public void evaluate() throws Throwable { WireMockRule.this.methodName = methodName; - final Options localOptions = new WireMockRuleConfiguration( - WireMockRule.this.options, - methodName); + final Options localOptions = new WireMockRuleConfiguration(WireMockRule.this.options, methodName); new File(localOptions.filesRoot().getPath(), "mappings").mkdirs(); new File(localOptions.filesRoot().getPath(), "__files").mkdirs(); diff --git a/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java b/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java index 330afc2aaf..c8ddbf5f2f 100644 --- a/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java +++ b/src/test/java/org/kohsuke/github/junit/WireMockRuleConfiguration.java @@ -78,14 +78,13 @@ public WireMockRuleConfiguration mappingSource(MappingsSource mappingsSource) { public Map extensionsOfType(Class extensionType) { Map result = Maps.newLinkedHashMap(this.parent.extensionsOfType(extensionType)); - result.putAll((Map)Maps.filterEntries(this.extensions, ExtensionLoader.valueAssignableFrom(extensionType))); + result.putAll((Map) Maps.filterEntries(this.extensions, + ExtensionLoader.valueAssignableFrom(extensionType))); return result; } - // Simple wrappers - public int portNumber() { return parent.portNumber(); } diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-create-installation-accesstokens.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-create-installation-accesstokens.json index 7996662d18..0d124ae6bd 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-create-installation-accesstokens.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-create-installation-accesstokens.json @@ -1,39 +1,44 @@ { - "request" : { - "url" : "/app/installations/11111111/access_tokens", - "method" : "POST", - "bodyPatterns" : [ { - "equalToJson" : "{\"repository_ids\":[111111111],\"permissions\":{\"pull_requests\":\"write\",\"metadata\":\"read\",\"checks\":\"write\",\"contents\":\"read\"}}", - "ignoreArrayOrder" : true, - "ignoreExtraElements" : false - } ], - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "request": { + "url": "/app/installations/11111111/access_tokens", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"repository_ids\":[111111111],\"permissions\":{\"pull_requests\":\"write\",\"metadata\":\"read\",\"checks\":\"write\",\"contents\":\"read\"}}", + "ignoreArrayOrder": true, + "ignoreExtraElements": false + } + ], + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, - "response" : { - "status" : 201, - "bodyFileName" : "body-githubapp-create-installation-accesstokens.json", - "headers" : { - "Date" : "Sat, 10 Aug 2019 04:54:58 GMT", - "Content-Type" : "application/json; charset=utf-8", - "Server" : "GitHub.com", - "Status" : "201 Created", - "Cache-Control" : "public, max-age=60, s-maxage=60", - "Vary" : [ "Accept", "Accept-Encoding" ], - "ETag" : "\"c47070915d3f78d2c4aea4bd8a2c3351\"", - "X-GitHub-Media-Type" : "github.machine-man-preview; format=json", - "Access-Control-Expose-Headers" : "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", - "Access-Control-Allow-Origin" : "*", - "Strict-Transport-Security" : "max-age=31536000; includeSubdomains; preload", - "X-Frame-Options" : "deny", - "X-Content-Type-Options" : "nosniff", - "X-XSS-Protection" : "1; mode=block", - "Referrer-Policy" : "origin-when-cross-origin, strict-origin-when-cross-origin", - "Content-Security-Policy" : "default-src 'none'", - "X-GitHub-Request-Id" : "EEC8:4357:E0DD17:110A2E7:5D4E4E22" + "response": { + "status": 201, + "bodyFileName": "body-githubapp-create-installation-accesstokens.json", + "headers": { + "Date": "Sat, 10 Aug 2019 04:54:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": [ + "Accept", + "Accept-Encoding" + ], + "ETag": "\"c47070915d3f78d2c4aea4bd8a2c3351\"", + "X-GitHub-Media-Type": "github.machine-man-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EEC8:4357:E0DD17:110A2E7:5D4E4E22" } } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-installation-by-user.json index 573705fde7..e554674205 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-installation-by-user.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/createToken/mappings/mapping-githubapp-installation-by-user.json @@ -2,9 +2,9 @@ "request": { "url": "/users/bogus/installation", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-delete-installation.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-delete-installation.json index 4fbf043a8f..ee6d968f16 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-delete-installation.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-delete-installation.json @@ -2,9 +2,9 @@ "request": { "url": "/app/installations/11111111", "method": "DELETE", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.gambit-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.gambit-preview+json" } } }, @@ -16,7 +16,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "204 No Content", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-installation-by-user.json index 573705fde7..e554674205 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-installation-by-user.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/deleteInstallation/mappings/mapping-githubapp-installation-by-user.json @@ -2,9 +2,9 @@ "request": { "url": "/users/bogus/installation", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getGitHubApp/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-installation-by-id.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-installation-by-id.json index 87ba55f445..15b9927ccb 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-installation-by-id.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationById/mappings/mapping-githubapp-installation-by-id.json @@ -2,9 +2,9 @@ "request": { "url": "/app/installations/1111111", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-installation-by-organization.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-installation-by-organization.json index bd94ed4800..a7bef648e6 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-installation-by-organization.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByOrganization/mappings/mapping-githubapp-installation-by-organization.json @@ -2,9 +2,9 @@ "request": { "url": "/orgs/bogus/installation", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-installation-by-repository.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-installation-by-repository.json index 3fd3c011c0..070fe09c5b 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-installation-by-repository.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByRepository/mappings/mapping-githubapp-installation-by-repository.json @@ -2,9 +2,9 @@ "request": { "url": "/repos/bogus/bogus/installation", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-installation-by-user.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-installation-by-user.json index 573705fde7..e554674205 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-installation-by-user.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/getInstallationByUser/mappings/mapping-githubapp-installation-by-user.json @@ -2,9 +2,9 @@ "request": { "url": "/users/bogus/installation", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-installations.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-installations.json index d81bc3786e..4ca1c46c81 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-installations.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/__files/body-mapping-githubapp-installations.json @@ -1,6 +1,6 @@ [ { - "id": 11111111, + "id": 11111111, "account": { "login": "bogus", "id": 111111111, diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-app.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-app.json index 999f4c8286..2e7a553f6d 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-app.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-app.json @@ -2,9 +2,9 @@ "request": { "url": "/app", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-installations.json b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-installations.json index 5b01455c26..87b532643a 100644 --- a/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-installations.json +++ b/src/test/resources/org/kohsuke/github/GHAppTest/wiremock/listInstallations/mappings/mapping-githubapp-installations.json @@ -2,9 +2,9 @@ "request": { "url": "/app/installations", "method": "GET", - "headers" : { - "Accept" : { - "equalTo" : "application/vnd.github.machine-man-preview+json" + "headers": { + "Accept": { + "equalTo": "application/vnd.github.machine-man-preview+json" } } }, @@ -17,7 +17,10 @@ "Content-Type": "application/json; charset=utf-8", "Status": "200 OK", "Cache-Control": "public, max-age=60, s-maxage=60", - "Vary": ["Accept","Accept-Encoding"], + "Vary": [ + "Accept", + "Accept-Encoding" + ], "ETag": "W/\"01163b1a237898d328ed56cd0e9aefca\"", "X-GitHub-Media-Type": "github.machine-man-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json new file mode 100644 index 0000000000..c9f0d6061d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json @@ -0,0 +1,124 @@ +{ + "id": 222596043, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYwNDM=", + "name": "temp-testEnableBranchProtections", + "full_name": "github-api-test-org/temp-testEnableBranchProtections", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections", + "description": "A test repository for testing the github-api project: temp-testEnableBranchProtections", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/deployments", + "created_at": "2019-11-19T03:01:26Z", + "updated_at": "2019-11-19T03:01:31Z", + "pushed_at": "2019-11-19T03:01:27Z", + "git_url": "git://github.com/github-api-test-org/temp-testEnableBranchProtections.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testEnableBranchProtections.git", + "clone_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections.git", + "svn_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json new file mode 100644 index 0000000000..6f6492ef01 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDQzOjI5OGZmZmY5Yzc5MjhiMDZlOWI3NGQwMWFlOGEzNGFiOThlOWI0YzI=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:27Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:27Z" + }, + "message": "Initial commit", + "tree": { + "sha": "3858cfba073ecd82947ddca0dc3613584db75e4c", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/trees/3858cfba073ecd82947ddca0dc3613584db75e4c" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/git/commits/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sHCRBK7hj4Ov3rIwAAdHIIABgp0lFAcHc2m3RCcuCUqfMl\nzfgjjYNYsqyWgwWeB0c44naL8nqhF/a80KlY4+1T2gVR8GOSZNyC8ewDH/6V+X3q\n5MzjTNJBk2ks5oA4bz2fgdsE7fm8kKDZQRqL9+BN4JF9MNps4M2+nR5Rg4sBm2+A\nSZHcdfzZ6ll0ptcTGl7403Xe9irj/V6iymycUapbK4+RHBotrN6kbBGZtjILempU\nMbYrIuqteQF3B2p9FSXFCJ8SpAL/Cq/GkpGvEbYIPdQ2IFQ6ImiRSf6eNTvSXxtG\nLJygBJsaRCH81FEhBfUnbP+stB9x4dloj/yhPLd6BXv1VCuzT2h9roYtaemjb7c=\n=ycC3\n-----END PGP SIGNATURE-----\n", + "payload": "tree 3858cfba073ecd82947ddca0dc3613584db75e4c\nauthor Liam Newman 1574132487 -0800\ncommitter GitHub 1574132487 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/commits/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "html_url": "https://github.com/github-api-test-org/temp-testEnableBranchProtections/commit/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/commits/298ffff9c7928b06e9b74d01ae8a34ab98e9b4c2/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableBranchProtections/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json new file mode 100644 index 0000000000..36fb6cf9bd --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json @@ -0,0 +1,21 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection", + "required_status_checks": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/required_status_checks", + "strict": true, + "contexts": [ + "test-status-check" + ], + "contexts_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/required_status_checks/contexts" + }, + "required_pull_request_reviews": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/required_pull_request_reviews", + "dismiss_stale_reviews": true, + "require_code_owner_reviews": true, + "required_approving_review_count": 2 + }, + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection/enforce_admins", + "enabled": true + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/user-c9f376fa-4819-4dc7-bc79-43cabec4276f.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/user-c38b2b92-6669-42ee-838f-7422bb4f300d.json similarity index 96% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/user-c9f376fa-4819-4dc7-bc79-43cabec4276f.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/user-c38b2b92-6669-42ee-838f-7422bb4f300d.json index 760bd7fb8a..6f84c075f5 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/user-c9f376fa-4819-4dc7-bc79-43cabec4276f.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/__files/user-c38b2b92-6669-42ee-838f-7422bb4f300d.json @@ -24,9 +24,9 @@ "email": "bitwiseman@gmail.com", "hireable": null, "bio": "https://twitter.com/bitwiseman", - "public_repos": 168, - "public_gists": 5, - "followers": 138, + "public_repos": 176, + "public_gists": 7, + "followers": 140, "following": 9, "created_at": "2012-07-11T20:38:33Z", "updated_at": "2019-09-24T19:32:29Z", diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections-2-02ee49.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections-2-02ee49.json new file mode 100644 index 0000000000..834aa92e8e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections-2-02ee49.json @@ -0,0 +1,43 @@ +{ + "id": "02ee4913-4f10-4403-9f86-c911719d8b88", + "name": "repos_github-api-test-org_temp-testenablebranchprotections", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableBranchProtections", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablebranchprotections-02ee4913-4f10-4403-9f86-c911719d8b88.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:32 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4937", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"85ef7d73fa0d8de7e964cdc69d1648a0\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:31 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C495:6994:5EFFF:6F6AF:5DD35B05" + } + }, + "uuid": "02ee4913-4f10-4403-9f86-c911719d8b88", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-3-040c1d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-3-040c1d.json new file mode 100644 index 0000000000..0e79036a26 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master-3-040c1d.json @@ -0,0 +1,42 @@ +{ + "id": "040c1d69-d6af-4a94-b583-7d18957bad10", + "name": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master-040c1d69-d6af-4a94-b583-7d18957bad10.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:32 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4936", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"b4b2b52ee5173543cc0d41dfff61781c\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C495:6994:5F01F:6FB32:5DD35B0C" + } + }, + "uuid": "040c1d69-d6af-4a94-b583-7d18957bad10", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-4-aa97cf.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-4-aa97cf.json new file mode 100644 index 0000000000..090479e8d6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-4-aa97cf.json @@ -0,0 +1,49 @@ +{ + "id": "aa97cf7b-7c9d-4c01-b7c5-bccc62b30873", + "name": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableBranchProtections/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":{\"required_approving_review_count\":2,\"require_code_owner_reviews\":true,\"dismiss_stale_reviews\":true},\"required_status_checks\":{\"contexts\":[\"test-status-check\"],\"strict\":true},\"restrictions\":null,\"enforce_admins\":true}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablebranchprotections_branches_master_protection-aa97cf7b-7c9d-4c01-b7c5-bccc62b30873.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:32 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4935", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"51724a4f269fbb64510394b0e2b948b3\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C495:6994:5F041:6FB54:5DD35B0C" + } + }, + "uuid": "aa97cf7b-7c9d-4c01-b7c5-bccc62b30873", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/user-1-842cc8.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/user-1-c38b2b.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/user-1-842cc8.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/user-1-c38b2b.json index fc31299988..1c3c09fb22 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/user-1-842cc8.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableBranchProtections/mappings/user-1-c38b2b.json @@ -1,5 +1,5 @@ { - "id": "842cc871-f338-4cc0-8fb0-db276fb4224a", + "id": "c38b2b92-6669-42ee-838f-7422bb4f300d", "name": "user", "request": { "url": "/user", @@ -7,18 +7,21 @@ }, "response": { "status": 200, - "bodyFileName": "user-842cc871-f338-4cc0-8fb0-db276fb4224a.json", + "bodyFileName": "user-c38b2b92-6669-42ee-838f-7422bb4f300d.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:35 GMT", + "Date": "Tue, 19 Nov 2019 03:01:25 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4721", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4945", + "X-RateLimit-Reset": "1574135997", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"42eed4772a65221c408dcbe210034076\"", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0E5:4B0B:18399E:2F2026:5DA0FF7F" + "X-GitHub-Request-Id": "C495:6994:5EC24:6F69A:5DD35B04" } }, - "uuid": "842cc871-f338-4cc0-8fb0-db276fb4224a", + "uuid": "c38b2b92-6669-42ee-838f-7422bb4f300d", "persistent": true, "insertionIndex": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json new file mode 100644 index 0000000000..a253c10ac1 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json @@ -0,0 +1,124 @@ +{ + "id": 222596090, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYwOTA=", + "name": "temp-testEnableProtectionOnly", + "full_name": "github-api-test-org/temp-testEnableProtectionOnly", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly", + "description": "A test repository for testing the github-api project: temp-testEnableProtectionOnly", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/deployments", + "created_at": "2019-11-19T03:01:43Z", + "updated_at": "2019-11-19T03:01:49Z", + "pushed_at": "2019-11-19T03:01:45Z", + "git_url": "git://github.com/github-api-test-org/temp-testEnableProtectionOnly.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testEnableProtectionOnly.git", + "clone_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly.git", + "svn_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json new file mode 100644 index 0000000000..d1efd113fc --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "b9a9b314add8ca449fc2de050518c0fad721a60c", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDkwOmI5YTliMzE0YWRkOGNhNDQ5ZmMyZGUwNTA1MThjMGZhZDcyMWE2MGM=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:44Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:44Z" + }, + "message": "Initial commit", + "tree": { + "sha": "c9119b8fcff0b781ab9fd8faf418c42c08593560", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/trees/c9119b8fcff0b781ab9fd8faf418c42c08593560" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sYCRBK7hj4Ov3rIwAAdHIIAILysEwjSJK+Ks9FXnOnzhPY\nM1KpvTeWF1B7HfuExazu185ER/0pvyI6A9WArZaCYoit1tTLFVkUiT0Elnoi+6Wi\nOEbdFmKoIaOf6htKq6GREtT6aCGyLoW9k3kfYuJdRpn5Wu2lgI085pJZc08XsLmj\nTjlK1NvxGKqHJ2tn2wzxfz3AizJhpMn2JEIx8yEHkXBCQLNq9D6f8MyAQRuv6TVd\nVfKgyJGhB6ndz8D+7vXxxDYFw5PAqcOsm8IBHnNTxzwZoNxZ0cTXWPkgZqyRbny1\nN/qRQ3ERkOP0z4hJimXkVYUAgVRUwIVMVwc8TvlluVLZrCYCHRcGKbhD+uH66QM=\n=Cu8z\n-----END PGP SIGNATURE-----\n", + "payload": "tree c9119b8fcff0b781ab9fd8faf418c42c08593560\nauthor Liam Newman 1574132504 -0800\ncommitter GitHub 1574132504 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "html_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/commit/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json new file mode 100644 index 0000000000..be28272ae2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "b9a9b314add8ca449fc2de050518c0fad721a60c", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDkwOmI5YTliMzE0YWRkOGNhNDQ5ZmMyZGUwNTA1MThjMGZhZDcyMWE2MGM=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:44Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:44Z" + }, + "message": "Initial commit", + "tree": { + "sha": "c9119b8fcff0b781ab9fd8faf418c42c08593560", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/trees/c9119b8fcff0b781ab9fd8faf418c42c08593560" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/git/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sYCRBK7hj4Ov3rIwAAdHIIAILysEwjSJK+Ks9FXnOnzhPY\nM1KpvTeWF1B7HfuExazu185ER/0pvyI6A9WArZaCYoit1tTLFVkUiT0Elnoi+6Wi\nOEbdFmKoIaOf6htKq6GREtT6aCGyLoW9k3kfYuJdRpn5Wu2lgI085pJZc08XsLmj\nTjlK1NvxGKqHJ2tn2wzxfz3AizJhpMn2JEIx8yEHkXBCQLNq9D6f8MyAQRuv6TVd\nVfKgyJGhB6ndz8D+7vXxxDYFw5PAqcOsm8IBHnNTxzwZoNxZ0cTXWPkgZqyRbny1\nN/qRQ3ERkOP0z4hJimXkVYUAgVRUwIVMVwc8TvlluVLZrCYCHRcGKbhD+uH66QM=\n=Cu8z\n-----END PGP SIGNATURE-----\n", + "payload": "tree c9119b8fcff0b781ab9fd8faf418c42c08593560\nauthor Liam Newman 1574132504 -0800\ncommitter GitHub 1574132504 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c", + "html_url": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/commit/b9a9b314add8ca449fc2de050518c0fad721a60c", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/commits/b9a9b314add8ca449fc2de050518c0fad721a60c/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableProtectionOnly/tree/master" + }, + "protected": true, + "protection": { + "enabled": true, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json new file mode 100644 index 0000000000..15ca7f2682 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json @@ -0,0 +1,7 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection", + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection/enforce_admins", + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/user-94ede01e-bf08-434a-a769-b1ca13cbbe5c.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json similarity index 96% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/user-94ede01e-bf08-434a-a769-b1ca13cbbe5c.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json index 760bd7fb8a..6f84c075f5 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/user-94ede01e-bf08-434a-a769-b1ca13cbbe5c.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/__files/user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json @@ -24,9 +24,9 @@ "email": "bitwiseman@gmail.com", "hireable": null, "bio": "https://twitter.com/bitwiseman", - "public_repos": 168, - "public_gists": 5, - "followers": 138, + "public_repos": 176, + "public_gists": 7, + "followers": 140, "following": 9, "created_at": "2012-07-11T20:38:33Z", "updated_at": "2019-09-24T19:32:29Z", diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly-2-bc3099.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly-2-bc3099.json new file mode 100644 index 0000000000..ac0603dffa --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly-2-bc3099.json @@ -0,0 +1,43 @@ +{ + "id": "bc30994e-6cf0-42fa-b6e8-7c21803346f0", + "name": "repos_github-api-test-org_temp-testenableprotectiononly", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly-bc30994e-6cf0-42fa-b6e8-7c21803346f0.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:49 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4911", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"5a52275541e01dfed3bd8a7c449f6b0f\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:49 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4A6:4FEE:63367:740CA:5DD35B16" + } + }, + "uuid": "bc30994e-6cf0-42fa-b6e8-7c21803346f0", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-3-883282.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-3-883282.json new file mode 100644 index 0000000000..54e19738d9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-3-883282.json @@ -0,0 +1,45 @@ +{ + "id": "88328244-0928-4737-b1a5-674c59027a58", + "name": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master-88328244-0928-4737-b1a5-674c59027a58.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4910", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"e50899adde0516ef560b178cfb58c9f4\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4A6:4FEE:6338F:74499:5DD35B1D" + } + }, + "uuid": "88328244-0928-4737-b1a5-674c59027a58", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master-2", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-5-90ab1b.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-5-90ab1b.json new file mode 100644 index 0000000000..7e410f2def --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master-5-90ab1b.json @@ -0,0 +1,44 @@ +{ + "id": "90ab1b21-6ee8-4607-bcf5-f14061c3936f", + "name": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master-90ab1b21-6ee8-4607-bcf5-f14061c3936f.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4908", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"6e892f7878965d871f858924a9515a9a\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4A6:4FEE:633CF:744E4:5DD35B1E" + } + }, + "uuid": "90ab1b21-6ee8-4607-bcf5-f14061c3936f", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testEnableProtectionOnly-branches-master-2", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-4-857c66.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-4-857c66.json new file mode 100644 index 0000000000..30591e0826 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-4-857c66.json @@ -0,0 +1,49 @@ +{ + "id": "857c661d-4431-4504-9088-c0bbf3a8d667", + "name": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableProtectionOnly/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenableprotectiononly_branches_master_protection-857c661d-4431-4504-9088-c0bbf3a8d667.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:50 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4909", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"48347246916d88cb97b0bff8a430e78c\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4A6:4FEE:633A5:744B7:5DD35B1E" + } + }, + "uuid": "857c661d-4431-4504-9088-c0bbf3a8d667", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/user-1-94ede0.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/user-1-100e44.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/user-1-94ede0.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/user-1-100e44.json index 5f512a6ed9..49eec8a122 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/user-1-94ede0.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableProtectionOnly/mappings/user-1-100e44.json @@ -1,5 +1,5 @@ { - "id": "94ede01e-bf08-434a-a769-b1ca13cbbe5c", + "id": "100e4407-70e6-4ea4-aad4-70d93d35dd38", "name": "user", "request": { "url": "/user", @@ -7,18 +7,21 @@ }, "response": { "status": 200, - "bodyFileName": "user-94ede01e-bf08-434a-a769-b1ca13cbbe5c.json", + "bodyFileName": "user-100e4407-70e6-4ea4-aad4-70d93d35dd38.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:39 GMT", + "Date": "Tue, 19 Nov 2019 03:01:42 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4705", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4919", + "X-RateLimit-Reset": "1574135997", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"42eed4772a65221c408dcbe210034076\"", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0EE:6185:148366:2A3C4C:5DA0FF83" + "X-GitHub-Request-Id": "C4A6:4FEE:63031:740B3:5DD35B16" } }, - "uuid": "94ede01e-bf08-434a-a769-b1ca13cbbe5c", + "uuid": "100e4407-70e6-4ea4-aad4-70d93d35dd38", "persistent": true, "insertionIndex": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json new file mode 100644 index 0000000000..4d24749b25 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json @@ -0,0 +1,124 @@ +{ + "id": 222596057, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYwNTc=", + "name": "temp-testEnableRequireReviewsOnly", + "full_name": "github-api-test-org/temp-testEnableRequireReviewsOnly", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly", + "description": "A test repository for testing the github-api project: temp-testEnableRequireReviewsOnly", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/deployments", + "created_at": "2019-11-19T03:01:34Z", + "updated_at": "2019-11-19T03:01:40Z", + "pushed_at": "2019-11-19T03:01:36Z", + "git_url": "git://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testEnableRequireReviewsOnly.git", + "clone_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly.git", + "svn_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json new file mode 100644 index 0000000000..e22e3f01c4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "d32e320555f9d47f78e64fc3889e567d5eebee8e", + "node_id": "MDY6Q29tbWl0MjIyNTk2MDU3OmQzMmUzMjA1NTVmOWQ0N2Y3OGU2NGZjMzg4OWU1NjdkNWVlYmVlOGU=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:35Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:35Z" + }, + "message": "Initial commit", + "tree": { + "sha": "32d1abb4db4e0b5f067f13f8ec544e62126ef47a", + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/trees/32d1abb4db4e0b5f067f13f8ec544e62126ef47a" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/git/commits/d32e320555f9d47f78e64fc3889e567d5eebee8e", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01sPCRBK7hj4Ov3rIwAAdHIIADGTF2CM1Q6wUw3RB/sKFvl2\npKkcGV3+0W4+Clnx1k1b60TbjD8hnq+ZtkWxvo3QmUplUapunHoj4zrUkqmzwOVg\nKrCwsvBzSJoRxbKN5j04wCTwB9oUSCEPxs9UxolqCOumwa+GzLv2t4EjGeDEf09S\n18C9Dg9+eiIMaXbO+HXOkltj4V9BTI8+IWA/0EMHVBqeh8daWcbyhQcaHBdkNgR6\nDq9UKMz0Ny2S6/A2v+y8YBj6ftXs+q5/fAPSu6hI4SMAVz26nl1SvkJmR8N79PQ9\nbiybCEzd5is507e8ufr7ElJ/1bfV2z0c0wkXfV6nNX+xYSKP+IfOLAfUljeoCZM=\n=RhfP\n-----END PGP SIGNATURE-----\n", + "payload": "tree 32d1abb4db4e0b5f067f13f8ec544e62126ef47a\nauthor Liam Newman 1574132495 -0800\ncommitter GitHub 1574132495 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/commits/d32e320555f9d47f78e64fc3889e567d5eebee8e", + "html_url": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly/commit/d32e320555f9d47f78e64fc3889e567d5eebee8e", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/commits/d32e320555f9d47f78e64fc3889e567d5eebee8e/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master", + "html": "https://github.com/github-api-test-org/temp-testEnableRequireReviewsOnly/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json new file mode 100644 index 0000000000..1113b5739d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json @@ -0,0 +1,13 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection", + "required_pull_request_reviews": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection/required_pull_request_reviews", + "dismiss_stale_reviews": false, + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + }, + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection/enforce_admins", + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json new file mode 100644 index 0000000000..6f84c075f5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/__files/user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 140, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly-2-318e0a.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly-2-318e0a.json new file mode 100644 index 0000000000..51d26c8131 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly-2-318e0a.json @@ -0,0 +1,43 @@ +{ + "id": "318e0aa4-9fc4-4f30-8174-400001f1bae4", + "name": "repos_github-api-test-org_temp-testenablerequirereviewsonly", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableRequireReviewsOnly", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablerequirereviewsonly-318e0aa4-9fc4-4f30-8174-400001f1bae4.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:41 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4924", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"2b8d8ba2c42054c376d47a34ded30f4b\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:40 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C49E:6D70:39A9D:4459F:5DD35B0D" + } + }, + "uuid": "318e0aa4-9fc4-4f30-8174-400001f1bae4", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-3-0e0c4c.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-3-0e0c4c.json new file mode 100644 index 0000000000..a44e412beb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-3-0e0c4c.json @@ -0,0 +1,42 @@ +{ + "id": "0e0c4c56-198f-4d87-b13e-b146cad7ffdb", + "name": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master-0e0c4c56-198f-4d87-b13e-b146cad7ffdb.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:41 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4923", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"51ae00091b56c866a8b2b00d1a3e57ec\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C49E:6D70:39AA6:447F2:5DD35B15" + } + }, + "uuid": "0e0c4c56-198f-4d87-b13e-b146cad7ffdb", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-4-b57fab.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-4-b57fab.json new file mode 100644 index 0000000000..d4b63f5d20 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-4-b57fab.json @@ -0,0 +1,49 @@ +{ + "id": "b57fab91-f2a6-4d52-b6d4-05e4a8be5df4", + "name": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testEnableRequireReviewsOnly/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":{},\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testenablerequirereviewsonly_branches_master_protection-b57fab91-f2a6-4d52-b6d4-05e4a8be5df4.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:41 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4922", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"b2d6921837e9e4b720085673dae0aa59\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C49E:6D70:39AC3:44807:5DD35B15" + } + }, + "uuid": "b57fab91-f2a6-4d52-b6d4-05e4a8be5df4", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/user-1-00d46d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/user-1-64a678.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/user-1-00d46d.json rename to src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/user-1-64a678.json index ae505d7fc3..b872603f56 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/user-1-00d46d.json +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testEnableRequireReviewsOnly/mappings/user-1-64a678.json @@ -1,5 +1,5 @@ { - "id": "00d46d71-d7b4-430e-948c-8a70ecd0e9b3", + "id": "64a67881-ce5e-4dd2-9d28-af9f67a4d9d1", "name": "user", "request": { "url": "/user", @@ -7,18 +7,21 @@ }, "response": { "status": 200, - "bodyFileName": "user-00d46d71-d7b4-430e-948c-8a70ecd0e9b3.json", + "bodyFileName": "user-64a67881-ce5e-4dd2-9d28-af9f67a4d9d1.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:38 GMT", + "Date": "Tue, 19 Nov 2019 03:01:33 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4713", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4932", + "X-RateLimit-Reset": "1574135997", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"42eed4772a65221c408dcbe210034076\"", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0EA:0DF0:11FEEA:271644:5DA0FF81" + "X-GitHub-Request-Id": "C49E:6D70:398BA:44594:5DD35B0D" } }, - "uuid": "00d46d71-d7b4-430e-948c-8a70ecd0e9b3", + "uuid": "64a67881-ce5e-4dd2-9d28-af9f67a4d9d1", "persistent": true, "insertionIndex": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json new file mode 100644 index 0000000000..9c334614f7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json @@ -0,0 +1,124 @@ +{ + "id": 222596117, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI1OTYxMTc=", + "name": "temp-testSignedCommits", + "full_name": "github-api-test-org/temp-testSignedCommits", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testSignedCommits", + "description": "A test repository for testing the github-api project: temp-testSignedCommits", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/deployments", + "created_at": "2019-11-19T03:01:51Z", + "updated_at": "2019-11-19T03:01:58Z", + "pushed_at": "2019-11-19T03:01:53Z", + "git_url": "git://github.com/github-api-test-org/temp-testSignedCommits.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testSignedCommits.git", + "clone_url": "https://github.com/github-api-test-org/temp-testSignedCommits.git", + "svn_url": "https://github.com/github-api-test-org/temp-testSignedCommits", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json new file mode 100644 index 0000000000..5fa5d2a202 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json @@ -0,0 +1,89 @@ +{ + "name": "master", + "commit": { + "sha": "9ef208e9f31fee7de1f0d10728f914022791e127", + "node_id": "MDY6Q29tbWl0MjIyNTk2MTE3OjllZjIwOGU5ZjMxZmVlN2RlMWYwZDEwNzI4ZjkxNDAyMjc5MWUxMjc=", + "commit": { + "author": { + "name": "Liam Newman", + "email": "bitwiseman@gmail.com", + "date": "2019-11-19T03:01:53Z" + }, + "committer": { + "name": "GitHub", + "email": "noreply@github.com", + "date": "2019-11-19T03:01:53Z" + }, + "message": "Initial commit", + "tree": { + "sha": "5bc9e3c14a62b6c19ec7ea436245290591751fc4", + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/trees/5bc9e3c14a62b6c19ec7ea436245290591751fc4" + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/git/commits/9ef208e9f31fee7de1f0d10728f914022791e127", + "comment_count": 0, + "verification": { + "verified": true, + "reason": "valid", + "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd01shCRBK7hj4Ov3rIwAAdHIIADWylhXW45yghg2gvvoO7JjK\n/0+CpNsQyfSiLQ9hFkAFfWUstUr1DhknQGFWdKKyDEXtPDu0J/Ed/d5yb9ebiz1n\nvCTQcSK0VxNkVVtf1+wYNi8+9OOb+GfAt6pUtqbYzV2pAUdgqsSOO/g/1svGlGPq\nz8+aV17OuGnY+IIB3FA0LWYG4b+b9LmZQHjiWSOpyJvZ+i4JVyJGYokrb4BzhkUy\ng30rjoVw8+q9deJjUAs/p8X0X2VtG3K4BSiIXraF54qi1yoYrjJlMOsGfl1MA4iE\n/Omt7fiVdhfy85+BAPthu4+HssuHgVPbWKU17DF0CMy0HYYiPirY4uioNiXkkT8=\n=p6ni\n-----END PGP SIGNATURE-----\n", + "payload": "tree 5bc9e3c14a62b6c19ec7ea436245290591751fc4\nauthor Liam Newman 1574132513 -0800\ncommitter GitHub 1574132513 -0800\n\nInitial commit" + } + }, + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/commits/9ef208e9f31fee7de1f0d10728f914022791e127", + "html_url": "https://github.com/github-api-test-org/temp-testSignedCommits/commit/9ef208e9f31fee7de1f0d10728f914022791e127", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/commits/9ef208e9f31fee7de1f0d10728f914022791e127/comments", + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "web-flow", + "id": 19864447, + "node_id": "MDQ6VXNlcjE5ODY0NDQ3", + "avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/web-flow", + "html_url": "https://github.com/web-flow", + "followers_url": "https://api.github.com/users/web-flow/followers", + "following_url": "https://api.github.com/users/web-flow/following{/other_user}", + "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", + "organizations_url": "https://api.github.com/users/web-flow/orgs", + "repos_url": "https://api.github.com/users/web-flow/repos", + "events_url": "https://api.github.com/users/web-flow/events{/privacy}", + "received_events_url": "https://api.github.com/users/web-flow/received_events", + "type": "User", + "site_admin": false + }, + "parents": [] + }, + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master", + "html": "https://github.com/github-api-test-org/temp-testSignedCommits/tree/master" + }, + "protected": false, + "protection": { + "enabled": false, + "required_status_checks": { + "enforcement_level": "off", + "contexts": [] + } + }, + "protection_url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json new file mode 100644 index 0000000000..0107dc1a09 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json @@ -0,0 +1,7 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection", + "enforce_admins": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/enforce_admins", + "enabled": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json new file mode 100644 index 0000000000..6f84c075f5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/__files/user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 140, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits-2-126c7a.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits-2-126c7a.json new file mode 100644 index 0000000000..373f2754c1 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits-2-126c7a.json @@ -0,0 +1,43 @@ +{ + "id": "126c7a91-25f8-4610-a015-12535c6f79bd", + "name": "repos_github-api-test-org_temp-testsignedcommits", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testsignedcommits-126c7a91-25f8-4610-a015-12535c6f79bd.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"0f68d4fb4620d1d60575c184b481409e\"", + "Last-Modified": "Tue, 19 Nov 2019 03:01:58 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:205F5:2518C:5DD35B1F" + } + }, + "uuid": "126c7a91-25f8-4610-a015-12535c6f79bd", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master-3-7a0577.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master-3-7a0577.json new file mode 100644 index 0000000000..90da917e2c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master-3-7a0577.json @@ -0,0 +1,42 @@ +{ + "id": "7a0577f3-c41c-4cbe-9965-f6f53aea602d", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testsignedcommits_branches_master-7a0577f3-c41c-4cbe-9965-f6f53aea602d.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4896", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"64cf89312c87f9689cb2a8583eeddda2\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:20604:252C3:5DD35B26" + } + }, + "uuid": "7a0577f3-c41c-4cbe-9965-f6f53aea602d", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4-4b8a92.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4-4b8a92.json new file mode 100644 index 0000000000..621ea86f30 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4-4b8a92.json @@ -0,0 +1,49 @@ +{ + "id": "4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"required_pull_request_reviews\":null,\"required_status_checks\":null,\"restrictions\":null,\"enforce_admins\":false}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection-4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4895", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"da9d21f9528a07ca0c4ac56de0278d58\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.luke-cage-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:2060C:252CE:5DD35B26" + } + }, + "uuid": "4b8a92a8-3dc5-40ba-96aa-f5fcd41eedd5", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-5-c0150d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-5-c0150d.json new file mode 100644 index 0000000000..a82444ecdd --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-5-c0150d.json @@ -0,0 +1,45 @@ +{ + "id": "c0150d3b-dbf8-4426-9a59-af31e3448299", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":false}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4894", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"6381f33d367d1e194e371ef617d6d17f\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:20620:252E1:5DD35B26" + } + }, + "uuid": "c0150d3b-dbf8-4426-9a59-af31e3448299", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-2", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-6-e29707.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-6-e29707.json new file mode 100644 index 0000000000..f2f9c59c84 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-6-e29707.json @@ -0,0 +1,49 @@ +{ + "id": "e2970726-71d5-4880-bd8f-bb6ad1f578a8", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":true}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4893", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"bca005912506b8129cdb5bb65d6b7c0a\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:2062B:252EF:5DD35B27" + } + }, + "uuid": "e2970726-71d5-4880-bd8f-bb6ad1f578a8", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-7-fa5a0d.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-7-fa5a0d.json new file mode 100644 index 0000000000..cded0f0020 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-7-fa5a0d.json @@ -0,0 +1,45 @@ +{ + "id": "fa5a0df8-3cdd-424a-a744-9b96a2455f68", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":true}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4892", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"bca005912506b8129cdb5bb65d6b7c0a\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:20644:25307:5DD35B27" + } + }, + "uuid": "fa5a0df8-3cdd-424a-a744-9b96a2455f68", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-2", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-3", + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-8-8c2a08.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-8-8c2a08.json new file mode 100644 index 0000000000..2a35de7a76 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-8-8c2a08.json @@ -0,0 +1,35 @@ +{ + "id": "8c2a0866-3d67-4b80-a36a-a37714ca5af9", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "DELETE" + }, + "response": { + "status": 204, + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:59 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4891", + "X-RateLimit-Reset": "1574135997", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "C4B1:6D6F:20655:25325:5DD35B27" + } + }, + "uuid": "8c2a0866-3d67-4b80-a36a-a37714ca5af9", + "persistent": true, + "insertionIndex": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-9-c0efc3.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-9-c0efc3.json new file mode 100644 index 0000000000..7f93da8175 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures-9-c0efc3.json @@ -0,0 +1,44 @@ +{ + "id": "c0efc3bb-2eaf-4225-a416-dc9f9371d508", + "name": "repos_github-api-test-org_temp-testsignedcommits_branches_master_protection_required_signatures", + "request": { + "url": "/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"url\":\"https://api.github.com/repos/github-api-test-org/temp-testSignedCommits/branches/master/protection/required_signatures\",\"enabled\":false}", + "headers": { + "Date": "Tue, 19 Nov 2019 03:02:00 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4890", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"6381f33d367d1e194e371ef617d6d17f\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "github.zzzax-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:20668:25337:5DD35B27" + } + }, + "uuid": "c0efc3bb-2eaf-4225-a416-dc9f9371d508", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testSignedCommits-branches-master-protection-required_signatures-3", + "insertionIndex": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/user-1-94ed9a.json b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/user-1-94ed9a.json new file mode 100644 index 0000000000..9dae95e727 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHBranchProtectionTest/wiremock/testSignedCommits/mappings/user-1-94ed9a.json @@ -0,0 +1,43 @@ +{ + "id": "94ed9a81-5dda-4f29-8f0b-18eab8a75f14", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-94ed9a81-5dda-4f29-8f0b-18eab8a75f14.json", + "headers": { + "Date": "Tue, 19 Nov 2019 03:01:51 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4905", + "X-RateLimit-Reset": "1574135997", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a7d3d02f0490e723eacdd27e24979424\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "C4B1:6D6F:204F4:25187:5DD35B1F" + } + }, + "uuid": "94ed9a81-5dda-4f29-8f0b-18eab8a75f14", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest-7b176dc1-41fe-4677-ae9d-f420dfa1153f.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest-e5080341-7377-4f3f-9427-388a105a91a7.json similarity index 99% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest-7b176dc1-41fe-4677-ae9d-f420dfa1153f.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest-e5080341-7377-4f3f-9427-388a105a91a7.json index a2718e2e2d..15b132d251 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest-7b176dc1-41fe-4677-ae9d-f420dfa1153f.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest-e5080341-7377-4f3f-9427-388a105a91a7.json @@ -65,14 +65,14 @@ "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", "created_at": "2015-08-15T14:14:57Z", - "updated_at": "2019-10-11T22:17:07Z", - "pushed_at": "2019-10-11T22:17:06Z", + "updated_at": "2019-11-26T01:09:15Z", + "pushed_at": "2019-11-26T01:09:14Z", "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", "homepage": null, - "size": 38, + "size": 45, "stargazers_count": 1, "watchers_count": 1, "language": null, @@ -81,13 +81,13 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 40, + "forks_count": 41, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 40, + "forks": 41, "open_issues": 0, "watchers": 1, "default_branch": "master", @@ -296,17 +296,17 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 59, + "forks_count": 60, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 59, + "forks": 60, "open_issues": 0, "watchers": 0, "default_branch": "master" }, - "network_count": 59, + "network_count": 60, "subscribers_count": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50-3cdae02b-77ed-4fb7-96fa-fee8aab5e88d.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50-3cdae02b-77ed-4fb7-96fa-fee8aab5e88d.json new file mode 100644 index 0000000000..f2db32f596 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50-3cdae02b-77ed-4fb7-96fa-fee8aab5e88d.json @@ -0,0 +1,18 @@ +[ + { + "name": "test file-to+create-#1.txt", + "path": "test+directory #50/test file-to+create-#1.txt", + "sha": "8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "size": 34, + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", + "git_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", + "type": "file", + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "git": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt" + } + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-30d0709c-ebc9-4631-8f44-bd942c44a711.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-04f85e50-583c-48ad-8d45-55368c542148.json similarity index 54% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-30d0709c-ebc9-4631-8f44-bd942c44a711.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-04f85e50-583c-48ad-8d45-55368c542148.json index ef8e34384d..65c175ff55 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-30d0709c-ebc9-4631-8f44-bd942c44a711.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-04f85e50-583c-48ad-8d45-55368c542148.json @@ -1,45 +1,45 @@ { "content": { - "name": "test-file-to-create.txt", - "path": "test-file-to-create.txt", + "name": "test file-to+create-#1.txt", + "path": "test+directory #50/test file-to+create-#1.txt", "sha": "da2d3cc78776aec68881668775c46a53f0ee2288", "size": 25, - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "git_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/da2d3cc78776aec68881668775c46a53f0ee2288", - "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test-file-to-create.txt", + "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "type": "file", "_links": { - "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", + "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", "git": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/da2d3cc78776aec68881668775c46a53f0ee2288", - "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt" + "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt" } }, "commit": { - "sha": "bc9cda986e02ae2677358a28f9cb6097865b3536", - "node_id": "MDY6Q29tbWl0NDA3NjM1Nzc6YmM5Y2RhOTg2ZTAyYWUyNjc3MzU4YTI4ZjljYjYwOTc4NjViMzUzNg==", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/bc9cda986e02ae2677358a28f9cb6097865b3536", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/bc9cda986e02ae2677358a28f9cb6097865b3536", + "sha": "00c7107a9d00cfd9116747ce61c91f2fd9a7acbc", + "node_id": "MDY6Q29tbWl0NDA3NjM1Nzc6MDBjNzEwN2E5ZDAwY2ZkOTExNjc0N2NlNjFjOTFmMmZkOWE3YWNiYw==", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/00c7107a9d00cfd9116747ce61c91f2fd9a7acbc", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/00c7107a9d00cfd9116747ce61c91f2fd9a7acbc", "author": { "name": "Liam Newman", "email": "bitwiseman@gmail.com", - "date": "2019-10-11T22:17:43Z" + "date": "2019-11-26T01:09:46Z" }, "committer": { "name": "Liam Newman", "email": "bitwiseman@gmail.com", - "date": "2019-10-11T22:17:43Z" + "date": "2019-11-26T01:09:46Z" }, "tree": { - "sha": "7aaee6a6cddcf48f94a40093de05be83c580ce10", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees/7aaee6a6cddcf48f94a40093de05be83c580ce10" + "sha": "50e945108f168faeb2eaf15855904e65e70b9336", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees/50e945108f168faeb2eaf15855904e65e70b9336" }, "message": "Updated file for integration tests.", "parents": [ { - "sha": "88bd1f52fc1e8242758364cee7dce2c82790d272", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/88bd1f52fc1e8242758364cee7dce2c82790d272", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/88bd1f52fc1e8242758364cee7dce2c82790d272" + "sha": "ce407cde9c6e4c970e33a955197512a2c1922ecf", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/ce407cde9c6e4c970e33a955197512a2c1922ecf", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/ce407cde9c6e4c970e33a955197512a2c1922ecf" } ], "verification": { diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-c2b7d86b-e154-4f46-8ab0-f253f77f5dda.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-1d4297f8-515f-48b0-8f13-99894911d416.json similarity index 57% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-c2b7d86b-e154-4f46-8ab0-f253f77f5dda.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-1d4297f8-515f-48b0-8f13-99894911d416.json index b186b542ac..efbda9142c 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-c2b7d86b-e154-4f46-8ab0-f253f77f5dda.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-1d4297f8-515f-48b0-8f13-99894911d416.json @@ -1,18 +1,18 @@ { - "name": "test-file-to-create.txt", - "path": "test-file-to-create.txt", + "name": "test file-to+create-#1.txt", + "path": "test+directory #50/test file-to+create-#1.txt", "sha": "da2d3cc78776aec68881668775c46a53f0ee2288", "size": 25, - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "git_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/da2d3cc78776aec68881668775c46a53f0ee2288", - "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test-file-to-create.txt", + "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "type": "file", "content": "dGhpcyBpcyBzb21lIG5ldyBjb250ZW50Cg==\n", "encoding": "base64", "_links": { - "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", + "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", "git": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/da2d3cc78776aec68881668775c46a53f0ee2288", - "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt" + "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt" } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-67d9bcdb-d0e8-44b0-9077-8530b3b77997.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-4be43bcb-37e3-4c54-8b0a-c190690dc820.json similarity index 58% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-67d9bcdb-d0e8-44b0-9077-8530b3b77997.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-4be43bcb-37e3-4c54-8b0a-c190690dc820.json index 3d20a236e0..7da4fdc6f7 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-67d9bcdb-d0e8-44b0-9077-8530b3b77997.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-4be43bcb-37e3-4c54-8b0a-c190690dc820.json @@ -1,18 +1,18 @@ { - "name": "test-file-to-create.txt", - "path": "test-file-to-create.txt", + "name": "test file-to+create-#1.txt", + "path": "test+directory #50/test file-to+create-#1.txt", "sha": "8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", "size": 34, - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "git_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", - "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test-file-to-create.txt", + "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "type": "file", "content": "dGhpcyBpcyBhbiBhd2Vzb21lIGZpbGUgSSBjcmVhdGVkCg==\n", "encoding": "base64", "_links": { - "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", + "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", "git": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", - "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt" + "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt" } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-5b2d0899-ece6-4a5f-a8dc-4b0f296b21a1.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-5b2d0899-ece6-4a5f-a8dc-4b0f296b21a1.json new file mode 100644 index 0000000000..7da4fdc6f7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-5b2d0899-ece6-4a5f-a8dc-4b0f296b21a1.json @@ -0,0 +1,18 @@ +{ + "name": "test file-to+create-#1.txt", + "path": "test+directory #50/test file-to+create-#1.txt", + "sha": "8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "size": 34, + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", + "git_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", + "type": "file", + "content": "dGhpcyBpcyBhbiBhd2Vzb21lIGZpbGUgSSBjcmVhdGVkCg==\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "git": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-64a83a7d-a195-4f3b-989e-293e3f23611a.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-64a83a7d-a195-4f3b-989e-293e3f23611a.json new file mode 100644 index 0000000000..7da4fdc6f7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-64a83a7d-a195-4f3b-989e-293e3f23611a.json @@ -0,0 +1,18 @@ +{ + "name": "test file-to+create-#1.txt", + "path": "test+directory #50/test file-to+create-#1.txt", + "sha": "8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "size": 34, + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", + "git_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", + "type": "file", + "content": "dGhpcyBpcyBhbiBhd2Vzb21lIGZpbGUgSSBjcmVhdGVkCg==\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "git": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", + "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-5d54ef56-18eb-43d3-9167-bf3bfae69460.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a5a649cc-8b2b-4c58-ba06-8445261108f8.json similarity index 61% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-5d54ef56-18eb-43d3-9167-bf3bfae69460.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a5a649cc-8b2b-4c58-ba06-8445261108f8.json index 8f875233de..44ca7da82f 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-5d54ef56-18eb-43d3-9167-bf3bfae69460.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a5a649cc-8b2b-4c58-ba06-8445261108f8.json @@ -1,19 +1,19 @@ { "content": null, "commit": { - "sha": "9cc8aeb99d67bcbafbf0f5d18bd584ac49758ddd", - "node_id": "MDY6Q29tbWl0NDA3NjM1Nzc6OWNjOGFlYjk5ZDY3YmNiYWZiZjBmNWQxOGJkNTg0YWM0OTc1OGRkZA==", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/9cc8aeb99d67bcbafbf0f5d18bd584ac49758ddd", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/9cc8aeb99d67bcbafbf0f5d18bd584ac49758ddd", + "sha": "b1378c3baae84ff2656bda47f65f4d7dccd5b3df", + "node_id": "MDY6Q29tbWl0NDA3NjM1Nzc6YjEzNzhjM2JhYWU4NGZmMjY1NmJkYTQ3ZjY1ZjRkN2RjY2Q1YjNkZg==", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/b1378c3baae84ff2656bda47f65f4d7dccd5b3df", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/b1378c3baae84ff2656bda47f65f4d7dccd5b3df", "author": { "name": "Liam Newman", "email": "bitwiseman@gmail.com", - "date": "2019-10-11T22:17:44Z" + "date": "2019-11-26T01:09:47Z" }, "committer": { "name": "Liam Newman", "email": "bitwiseman@gmail.com", - "date": "2019-10-11T22:17:44Z" + "date": "2019-11-26T01:09:47Z" }, "tree": { "sha": "7cc7cd2aba0de1a3f684338c892c84b7ebe6635b", @@ -22,9 +22,9 @@ "message": "Enough of this foolishness!", "parents": [ { - "sha": "bc9cda986e02ae2677358a28f9cb6097865b3536", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/bc9cda986e02ae2677358a28f9cb6097865b3536", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/bc9cda986e02ae2677358a28f9cb6097865b3536" + "sha": "00c7107a9d00cfd9116747ce61c91f2fd9a7acbc", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/00c7107a9d00cfd9116747ce61c91f2fd9a7acbc", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/00c7107a9d00cfd9116747ce61c91f2fd9a7acbc" } ], "verification": { diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-fa09f0c6-b78d-4504-b3ab-6050682ab604.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a971220e-d7f0-4919-9963-dbcedf5577e7.json similarity index 53% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-fa09f0c6-b78d-4504-b3ab-6050682ab604.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a971220e-d7f0-4919-9963-dbcedf5577e7.json index 4758568bd0..310135063f 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-fa09f0c6-b78d-4504-b3ab-6050682ab604.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a971220e-d7f0-4919-9963-dbcedf5577e7.json @@ -1,45 +1,45 @@ { "content": { - "name": "test-file-to-create.txt", - "path": "test-file-to-create.txt", + "name": "test file-to+create-#1.txt", + "path": "test+directory #50/test file-to+create-#1.txt", "sha": "8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", "size": 34, - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "git_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", - "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test-file-to-create.txt", + "download_url": "https://raw.githubusercontent.com/github-api-test-org/GHContentIntegrationTest/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt", "type": "file", "_links": { - "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", + "self": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", "git": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs/8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1", - "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test-file-to-create.txt" + "html": "https://github.com/github-api-test-org/GHContentIntegrationTest/blob/master/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt" } }, "commit": { - "sha": "88bd1f52fc1e8242758364cee7dce2c82790d272", - "node_id": "MDY6Q29tbWl0NDA3NjM1Nzc6ODhiZDFmNTJmYzFlODI0Mjc1ODM2NGNlZTdkY2UyYzgyNzkwZDI3Mg==", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/88bd1f52fc1e8242758364cee7dce2c82790d272", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/88bd1f52fc1e8242758364cee7dce2c82790d272", + "sha": "ce407cde9c6e4c970e33a955197512a2c1922ecf", + "node_id": "MDY6Q29tbWl0NDA3NjM1Nzc6Y2U0MDdjZGU5YzZlNGM5NzBlMzNhOTU1MTk3NTEyYTJjMTkyMmVjZg==", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/ce407cde9c6e4c970e33a955197512a2c1922ecf", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/ce407cde9c6e4c970e33a955197512a2c1922ecf", "author": { "name": "Liam Newman", "email": "bitwiseman@gmail.com", - "date": "2019-10-11T22:17:42Z" + "date": "2019-11-26T01:09:45Z" }, "committer": { "name": "Liam Newman", "email": "bitwiseman@gmail.com", - "date": "2019-10-11T22:17:42Z" + "date": "2019-11-26T01:09:45Z" }, "tree": { - "sha": "baa85f9e7c712c76d80024300011226f4b442945", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees/baa85f9e7c712c76d80024300011226f4b442945" + "sha": "1b852519fae94c3bca109754e408016f49fba41b", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees/1b852519fae94c3bca109754e408016f49fba41b" }, "message": "Creating a file for integration tests.", "parents": [ { - "sha": "89ac3f7e8c951288c26f6a80bddbd32ecf28fbba", - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/89ac3f7e8c951288c26f6a80bddbd32ecf28fbba", - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/89ac3f7e8c951288c26f6a80bddbd32ecf28fbba" + "sha": "6b0e644dfd920c634cedba68ace4c50b8b3e5799", + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits/6b0e644dfd920c634cedba68ace4c50b8b3e5799", + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest/commit/6b0e644dfd920c634cedba68ace4c50b8b3e5799" } ], "verification": { diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/user-6cfc78af-700f-404c-aef4-81cb448644d9.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/user-6cfc78af-700f-404c-aef4-81cb448644d9.json new file mode 100644 index 0000000000..37691dd3c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/user-6cfc78af-700f-404c-aef4-81cb448644d9.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 141, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-4f1ed4.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-e50803.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-4f1ed4.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-e50803.json index 744c15f42f..53ae1a6680 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-4f1ed4.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-e50803.json @@ -1,5 +1,5 @@ { - "id": "4f1ed47c-f261-4520-80d7-16b5952dd0e9", + "id": "e5080341-7377-4f3f-9427-388a105a91a7", "name": "repos_github-api-test-org_ghcontentintegrationtest", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-4f1ed47c-f261-4520-80d7-16b5952dd0e9.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-e5080341-7377-4f3f-9427-388a105a91a7.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:42 GMT", + "Date": "Tue, 26 Nov 2019 01:09:44 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4693", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4922", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"7a79bc3c7c98b7f2a0de605eea3ad3f6\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:07 GMT", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"24ee70d5bca0cf60cc0a6c1bafcc7e8c\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:15 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F4:34C4:13C474:28F9B7:5DA0FF85" + "X-GitHub-Request-Id": "EEAB:6915:6C7C5:82505:5DDC7B58" } }, - "uuid": "4f1ed47c-f261-4520-80d7-16b5952dd0e9", + "uuid": "e5080341-7377-4f3f-9427-388a105a91a7", "persistent": true, "insertionIndex": 2 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50-6-3cdae0.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50-6-3cdae0.json new file mode 100644 index 0000000000..0035d15f51 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50-6-3cdae0.json @@ -0,0 +1,43 @@ +{ + "id": "3cdae02b-77ed-4fb7-96fa-fee8aab5e88d", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50", + "request": { + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test+directory%20%2350", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50-3cdae02b-77ed-4fb7-96fa-fee8aab5e88d.json", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:46 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4918", + "X-RateLimit-Reset": "1574734142", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"1b852519fae94c3bca109754e408016f49fba41b\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:15 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EEAB:6915:6C7EE:82553:5DDC7B5A" + } + }, + "uuid": "3cdae02b-77ed-4fb7-96fa-fee8aab5e88d", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-7-5d54ef.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-10-a5a649.json similarity index 62% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-7-5d54ef.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-10-a5a649.json index cf34d0a0b9..ce4be41f98 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-7-5d54ef.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-10-a5a649.json @@ -1,24 +1,27 @@ { - "id": "5d54ef56-18eb-43d3-9167-bf3bfae69460", - "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt", + "id": "a5a649cc-8b2b-4c58-ba06-8445261108f8", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", "request": { - "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?path=test-file-to-create.txt&message=Enough+of+this+foolishness%21&sha=da2d3cc78776aec68881668775c46a53f0ee2288", + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test+directory%20%2350/test%20file-to+create-%231.txt?path=test%2Bdirectory+%2350%2Ftest+file-to%2Bcreate-%231.txt&message=Enough+of+this+foolishness%21&sha=da2d3cc78776aec68881668775c46a53f0ee2288", "method": "DELETE" }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-5d54ef56-18eb-43d3-9167-bf3bfae69460.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a5a649cc-8b2b-4c58-ba06-8445261108f8.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:45 GMT", + "Date": "Tue, 26 Nov 2019 01:09:48 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4688", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4914", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"6d6afdfe857395e134b3708d795d54e9\"", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"4f74f1bbda160bd00a3c565258eefa4e\"", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -30,10 +33,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F4:34C4:13C51E:28FB7B:5DA0FF88" + "X-GitHub-Request-Id": "EEAB:6915:6C813:82585:5DDC7B5B" } }, - "uuid": "5d54ef56-18eb-43d3-9167-bf3bfae69460", + "uuid": "a5a649cc-8b2b-4c58-ba06-8445261108f8", "persistent": true, - "insertionIndex": 7 + "insertionIndex": 10 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-11-47d978.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-11-47d978.json new file mode 100644 index 0000000000..d95c152c3c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-11-47d978.json @@ -0,0 +1,38 @@ +{ + "id": "47d978e6-2ddd-4190-b4ca-c961fe2eeb35", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", + "request": { + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test+directory%20%2350/test%20file-to+create-%231.txt", + "method": "GET" + }, + "response": { + "status": 404, + "body": "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/contents/#get-contents\"}", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:48 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "404 Not Found", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4913", + "X-RateLimit-Reset": "1574734142", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EEAB:6915:6C842:825BC:5DDC7B5C" + } + }, + "uuid": "47d978e6-2ddd-4190-b4ca-c961fe2eeb35", + "persistent": true, + "scenarioName": "scenario-2-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt", + "requiredScenarioState": "scenario-2-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt-2", + "insertionIndex": 11 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-3-fa09f0.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-3-a97122.json similarity index 63% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-3-fa09f0.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-3-a97122.json index 141d49597a..e63f5735d6 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-3-fa09f0.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-3-a97122.json @@ -1,12 +1,12 @@ { - "id": "fa09f0c6-b78d-4504-b3ab-6050682ab604", - "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt", + "id": "a971220e-d7f0-4919-9963-dbcedf5577e7", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", "request": { - "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt", + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test+directory%20%2350/test%20file-to+create-%231.txt", "method": "PUT", "bodyPatterns": [ { - "equalToJson": "{\"path\":\"test-file-to-create.txt\",\"message\":\"Creating a file for integration tests.\",\"content\":\"dGhpcyBpcyBhbiBhd2Vzb21lIGZpbGUgSSBjcmVhdGVkCg==\"}", + "equalToJson": "{\"path\":\"test+directory #50/test file-to+create-#1.txt\",\"message\":\"Creating a file for integration tests.\",\"content\":\"dGhpcyBpcyBhbiBhd2Vzb21lIGZpbGUgSSBjcmVhdGVkCg==\"}", "ignoreArrayOrder": true, "ignoreExtraElements": true } @@ -14,18 +14,21 @@ }, "response": { "status": 201, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-fa09f0c6-b78d-4504-b3ab-6050682ab604.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-a971220e-d7f0-4919-9963-dbcedf5577e7.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:43 GMT", + "Date": "Tue, 26 Nov 2019 01:09:45 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "201 Created", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4692", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4921", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "\"5a65778879e07c7838638cb58a54f72d\"", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"0bd911688cfe01b4461f4a06e76897e7\"", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -37,10 +40,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F4:34C4:13C485:28FA2A:5DA0FF86" + "X-GitHub-Request-Id": "EEAB:6915:6C7D1:82531:5DDC7B58" } }, - "uuid": "fa09f0c6-b78d-4504-b3ab-6050682ab604", + "uuid": "a971220e-d7f0-4919-9963-dbcedf5577e7", "persistent": true, "insertionIndex": 3 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-4-67d9bc.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-4-5b2d08.json similarity index 66% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-4-67d9bc.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-4-5b2d08.json index 47dcccc85d..6c8a644618 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-4-67d9bc.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-4-5b2d08.json @@ -1,25 +1,28 @@ { - "id": "67d9bcdb-d0e8-44b0-9077-8530b3b77997", - "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt", + "id": "5b2d0899-ece6-4a5f-a8dc-4b0f296b21a1", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", "request": { - "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", "method": "GET" }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-67d9bcdb-d0e8-44b0-9077-8530b3b77997.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-5b2d0899-ece6-4a5f-a8dc-4b0f296b21a1.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:43 GMT", + "Date": "Tue, 26 Nov 2019 01:09:46 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4691", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4920", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], "ETag": "W/\"8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:42 GMT", + "Last-Modified": "Tue, 26 Nov 2019 01:09:45 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,13 +34,13 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F4:34C4:13C4C4:28FAA9:5DA0FF87" + "X-GitHub-Request-Id": "EEAB:6915:6C7E7:82549:5DDC7B59" } }, - "uuid": "67d9bcdb-d0e8-44b0-9077-8530b3b77997", + "uuid": "5b2d0899-ece6-4a5f-a8dc-4b0f296b21a1", "persistent": true, - "scenarioName": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test-file-to-create.txt", + "scenarioName": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt", "requiredScenarioState": "Started", - "newScenarioState": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test-file-to-create.txt-2", + "newScenarioState": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt-2", "insertionIndex": 4 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-5-4be43b.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-5-4be43b.json new file mode 100644 index 0000000000..e079fd0e02 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-5-4be43b.json @@ -0,0 +1,46 @@ +{ + "id": "4be43bcb-37e3-4c54-8b0a-c190690dc820", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", + "request": { + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test+directory%20%2350/test%20file-to+create-%231.txt", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-4be43bcb-37e3-4c54-8b0a-c190690dc820.json", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:46 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4919", + "X-RateLimit-Reset": "1574734142", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:45 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EEAB:6915:6C7EA:8254E:5DDC7B5A" + } + }, + "uuid": "4be43bcb-37e3-4c54-8b0a-c190690dc820", + "persistent": true, + "scenarioName": "scenario-2-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-2-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt-2", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-7-64a83a.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-7-64a83a.json new file mode 100644 index 0000000000..cb82e03be6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-7-64a83a.json @@ -0,0 +1,46 @@ +{ + "id": "64a83a7d-a195-4f3b-989e-293e3f23611a", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", + "request": { + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-64a83a7d-a195-4f3b-989e-293e3f23611a.json", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:46 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4917", + "X-RateLimit-Reset": "1574734142", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:45 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EEAB:6915:6C7F4:82559:5DDC7B5A" + } + }, + "uuid": "64a83a7d-a195-4f3b-989e-293e3f23611a", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt-2", + "newScenarioState": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt-3", + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-5-30d070.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-8-04f85e.json similarity index 61% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-5-30d070.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-8-04f85e.json index 07c37aae53..962440311d 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-5-30d070.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-8-04f85e.json @@ -1,12 +1,12 @@ { - "id": "30d0709c-ebc9-4631-8f44-bd942c44a711", - "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt", + "id": "04f85e50-583c-48ad-8d45-55368c542148", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", "request": { - "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt", + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test+directory%20%2350/test%20file-to+create-%231.txt", "method": "PUT", "bodyPatterns": [ { - "equalToJson": "{\"path\":\"test-file-to-create.txt\",\"message\":\"Updated file for integration tests.\",\"sha\":\"8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1\",\"content\":\"dGhpcyBpcyBzb21lIG5ldyBjb250ZW50Cg==\"}", + "equalToJson": "{\"path\":\"test+directory #50/test file-to+create-#1.txt\",\"message\":\"Updated file for integration tests.\",\"sha\":\"8db9c31d79dfb9d0411c7af11b7ec7fabc72c5b1\",\"content\":\"dGhpcyBpcyBzb21lIG5ldyBjb250ZW50Cg==\"}", "ignoreArrayOrder": true, "ignoreExtraElements": true } @@ -14,18 +14,21 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-30d0709c-ebc9-4631-8f44-bd942c44a711.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-04f85e50-583c-48ad-8d45-55368c542148.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:44 GMT", + "Date": "Tue, 26 Nov 2019 01:09:47 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4690", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4916", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"8648a7c6196682f3b051a90fffb4f4e3\"", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"2a8dd77e253917ab99dd7cad259871d3\"", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -37,10 +40,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F4:34C4:13C4D5:28FACF:5DA0FF87" + "X-GitHub-Request-Id": "EEAB:6915:6C7F7:8255E:5DDC7B5A" } }, - "uuid": "30d0709c-ebc9-4631-8f44-bd942c44a711", + "uuid": "04f85e50-583c-48ad-8d45-55368c542148", "persistent": true, - "insertionIndex": 5 + "insertionIndex": 8 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-6-c2b7d8.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-9-1d4297.json similarity index 64% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-6-c2b7d8.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-9-1d4297.json index 34b35eba8f..a445a7e93b 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-6-c2b7d8.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-9-1d4297.json @@ -1,25 +1,28 @@ { - "id": "c2b7d86b-e154-4f46-8ab0-f253f77f5dda", - "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt", + "id": "1d4297f8-515f-48b0-8f13-99894911d416", + "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt", "request": { - "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test-file-to-create.txt?ref=master", + "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/test%2Bdirectory%20%2350/test%20file-to%2Bcreate-%231.txt?ref=master", "method": "GET" }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_test-file-to-createtxt-c2b7d86b-e154-4f46-8ab0-f253f77f5dda.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_testdirectory-50_test-file-tocreate-1txt-1d4297f8-515f-48b0-8f13-99894911d416.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:44 GMT", + "Date": "Tue, 26 Nov 2019 01:09:47 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4689", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4915", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], "ETag": "W/\"da2d3cc78776aec68881668775c46a53f0ee2288\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:43 GMT", + "Last-Modified": "Tue, 26 Nov 2019 01:09:46 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,12 +34,12 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F4:34C4:13C50E:28FB46:5DA0FF88" + "X-GitHub-Request-Id": "EEAB:6915:6C80D:8257B:5DDC7B5B" } }, - "uuid": "c2b7d86b-e154-4f46-8ab0-f253f77f5dda", + "uuid": "1d4297f8-515f-48b0-8f13-99894911d416", "persistent": true, - "scenarioName": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test-file-to-create.txt", - "requiredScenarioState": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test-file-to-create.txt-2", - "insertionIndex": 6 + "scenarioName": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-contents-test+directory #50-test file-to+create-#1.txt-3", + "insertionIndex": 9 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/user-1-6cfc78.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/user-1-6cfc78.json new file mode 100644 index 0000000000..b969fcf3c6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/user-1-6cfc78.json @@ -0,0 +1,43 @@ +{ + "id": "6cfc78af-700f-404c-aef4-81cb448644d9", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-6cfc78af-700f-404c-aef4-81cb448644d9.json", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:44 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4926", + "X-RateLimit-Reset": "1574734142", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"64a234e5bacdc505df16046a440645a9\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EEAB:6915:6C7A3:824FA:5DDC7B57" + } + }, + "uuid": "6cfc78af-700f-404c-aef4-81cb448644d9", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest-4f1ed47c-f261-4520-80d7-16b5952dd0e9.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest-1d1a483f-3df5-43a6-8ce8-63f9772a49f2.json similarity index 99% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest-4f1ed47c-f261-4520-80d7-16b5952dd0e9.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest-1d1a483f-3df5-43a6-8ce8-63f9772a49f2.json index a2718e2e2d..15b132d251 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/__files/repos_github-api-test-org_ghcontentintegrationtest-4f1ed47c-f261-4520-80d7-16b5952dd0e9.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest-1d1a483f-3df5-43a6-8ce8-63f9772a49f2.json @@ -65,14 +65,14 @@ "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", "created_at": "2015-08-15T14:14:57Z", - "updated_at": "2019-10-11T22:17:07Z", - "pushed_at": "2019-10-11T22:17:06Z", + "updated_at": "2019-11-26T01:09:15Z", + "pushed_at": "2019-11-26T01:09:14Z", "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", "homepage": null, - "size": 38, + "size": 45, "stargazers_count": 1, "watchers_count": 1, "language": null, @@ -81,13 +81,13 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 40, + "forks_count": 41, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 40, + "forks": 41, "open_issues": 0, "watchers": 1, "default_branch": "master", @@ -296,17 +296,17 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 59, + "forks_count": 60, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 59, + "forks": 60, "open_issues": 0, "watchers": 0, "default_branch": "master" }, - "network_count": 59, + "network_count": 60, "subscribers_count": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-b4bdb0bb-efdb-4a83-b03e-053ac0e8c56a.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-2d908c73-0706-4af1-86d4-005b3b91adba.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-b4bdb0bb-efdb-4a83-b03e-053ac0e8c56a.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-2d908c73-0706-4af1-86d4-005b3b91adba.json diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/user-34ca1601-0b3c-4808-b51e-b436851e0efd.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/user-34ca1601-0b3c-4808-b51e-b436851e0efd.json new file mode 100644 index 0000000000..37691dd3c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/user-34ca1601-0b3c-4808-b51e-b436851e0efd.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 141, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-5c51b8.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-1d1a48.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-5c51b8.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-1d1a48.json index 2c83c43aa9..74ee8cf0ee 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-5c51b8.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-1d1a48.json @@ -1,5 +1,5 @@ { - "id": "5c51b83e-0d7f-4289-9b1f-fb2a2b15c4ed", + "id": "1d1a483f-3df5-43a6-8ce8-63f9772a49f2", "name": "repos_github-api-test-org_ghcontentintegrationtest", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-5c51b83e-0d7f-4289-9b1f-fb2a2b15c4ed.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-1d1a483f-3df5-43a6-8ce8-63f9772a49f2.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:38 GMT", + "Date": "Tue, 26 Nov 2019 01:09:39 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4709", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4946", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"7a79bc3c7c98b7f2a0de605eea3ad3f6\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:07 GMT", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"24ee70d5bca0cf60cc0a6c1bafcc7e8c\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:15 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0EA:0DF0:11FF02:271656:5DA0FF82" + "X-GitHub-Request-Id": "EE98:52E4:1D4D1:21A8E:5DDC7B51" } }, - "uuid": "5c51b83e-0d7f-4289-9b1f-fb2a2b15c4ed", + "uuid": "1d1a483f-3df5-43a6-8ce8-63f9772a49f2", "persistent": true, "insertionIndex": 2 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-b4bdb0.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-2d908c.json similarity index 74% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-b4bdb0.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-2d908c.json index d85a9bbc67..3d268c85fa 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-b4bdb0.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-2d908c.json @@ -1,5 +1,5 @@ { - "id": "b4bdb0bb-efdb-4a83-b03e-053ac0e8c56a", + "id": "2d908c73-0706-4af1-86d4-005b3b91adba", "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/ghcontent-ro/a-dir-with-3-entries", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-b4bdb0bb-efdb-4a83-b03e-053ac0e8c56a.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-2d908c73-0706-4af1-86d4-005b3b91adba.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:37 GMT", + "Date": "Tue, 26 Nov 2019 01:09:39 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4716", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4945", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], "ETag": "W/\"7cc7cd2aba0de1a3f684338c892c84b7ebe6635b\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:07 GMT", + "Last-Modified": "Tue, 26 Nov 2019 01:09:15 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0E5:4B0B:183A34:2F2135:5DA0FF80" + "X-GitHub-Request-Id": "EE98:52E4:1D4D4:21AA3:5DDC7B53" } }, - "uuid": "b4bdb0bb-efdb-4a83-b03e-053ac0e8c56a", + "uuid": "2d908c73-0706-4af1-86d4-005b3b91adba", "persistent": true, "insertionIndex": 3 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/user-1-34ca16.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/user-1-34ca16.json new file mode 100644 index 0000000000..c4757d8850 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/user-1-34ca16.json @@ -0,0 +1,43 @@ +{ + "id": "34ca1601-0b3c-4808-b51e-b436851e0efd", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-34ca1601-0b3c-4808-b51e-b436851e0efd.json", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:37 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4950", + "X-RateLimit-Reset": "1574734142", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"64a234e5bacdc505df16046a440645a9\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE98:52E4:1D4BD:21A8C:5DDC7B51" + } + }, + "uuid": "34ca1601-0b3c-4808-b51e-b436851e0efd", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest-5c51b83e-0d7f-4289-9b1f-fb2a2b15c4ed.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest-a5c7d08d-fd5b-4564-ac11-03cf714fae84.json similarity index 99% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest-5c51b83e-0d7f-4289-9b1f-fb2a2b15c4ed.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest-a5c7d08d-fd5b-4564-ac11-03cf714fae84.json index a2718e2e2d..15b132d251 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest-5c51b83e-0d7f-4289-9b1f-fb2a2b15c4ed.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest-a5c7d08d-fd5b-4564-ac11-03cf714fae84.json @@ -65,14 +65,14 @@ "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", "created_at": "2015-08-15T14:14:57Z", - "updated_at": "2019-10-11T22:17:07Z", - "pushed_at": "2019-10-11T22:17:06Z", + "updated_at": "2019-11-26T01:09:15Z", + "pushed_at": "2019-11-26T01:09:14Z", "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", "homepage": null, - "size": 38, + "size": 45, "stargazers_count": 1, "watchers_count": 1, "language": null, @@ -81,13 +81,13 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 40, + "forks_count": 41, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 40, + "forks": 41, "open_issues": 0, "watchers": 1, "default_branch": "master", @@ -296,17 +296,17 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 59, + "forks_count": 60, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 59, + "forks": 60, "open_issues": 0, "watchers": 0, "default_branch": "master" }, - "network_count": 59, + "network_count": 60, "subscribers_count": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-29ca1e20-a321-449e-93db-dc5155bb4118.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-462ae734-fe48-4be5-b432-ddd9912ca0e5.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-29ca1e20-a321-449e-93db-dc5155bb4118.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-462ae734-fe48-4be5-b432-ddd9912ca0e5.json diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/user-ebccdfec-1cc2-4880-9f10-a0de20895d1a.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/user-ebccdfec-1cc2-4880-9f10-a0de20895d1a.json new file mode 100644 index 0000000000..37691dd3c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/user-ebccdfec-1cc2-4880-9f10-a0de20895d1a.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 141, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-0c161f.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-a5c7d0.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-0c161f.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-a5c7d0.json index 88d932575c..cdd8b5ffdf 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-0c161f.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-a5c7d0.json @@ -1,5 +1,5 @@ { - "id": "0c161f59-1b24-493e-b05a-cea86caa45a9", + "id": "a5c7d08d-fd5b-4564-ac11-03cf714fae84", "name": "repos_github-api-test-org_ghcontentintegrationtest", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-0c161f59-1b24-493e-b05a-cea86caa45a9.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-a5c7d08d-fd5b-4564-ac11-03cf714fae84.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:40 GMT", + "Date": "Tue, 26 Nov 2019 01:09:41 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4701", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4938", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"7a79bc3c7c98b7f2a0de605eea3ad3f6\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:07 GMT", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"24ee70d5bca0cf60cc0a6c1bafcc7e8c\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:15 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0EE:6185:148394:2A3C68:5DA0FF83" + "X-GitHub-Request-Id": "EE9E:273E:18D5DB:1D4F42:5DDC7B54" } }, - "uuid": "0c161f59-1b24-493e-b05a-cea86caa45a9", + "uuid": "a5c7d08d-fd5b-4564-ac11-03cf714fae84", "persistent": true, "insertionIndex": 2 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-29ca1e.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-462ae7.json similarity index 74% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-29ca1e.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-462ae7.json index a434db307b..7cd6c326c1 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-29ca1e.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-3-462ae7.json @@ -1,5 +1,5 @@ { - "id": "29ca1e20-a321-449e-93db-dc5155bb4118", + "id": "462ae734-fe48-4be5-b432-ddd9912ca0e5", "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/ghcontent-ro/a-dir-with-3-entries?ref=master", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-29ca1e20-a321-449e-93db-dc5155bb4118.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-dir-with-3-entries-462ae734-fe48-4be5-b432-ddd9912ca0e5.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:38 GMT", + "Date": "Tue, 26 Nov 2019 01:09:41 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4708", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4937", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], "ETag": "W/\"7cc7cd2aba0de1a3f684338c892c84b7ebe6635b\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:07 GMT", + "Last-Modified": "Tue, 26 Nov 2019 01:09:15 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0EA:0DF0:11FF0E:27169E:5DA0FF82" + "X-GitHub-Request-Id": "EE9E:273E:18D5FF:1D4FC8:5DDC7B55" } }, - "uuid": "29ca1e20-a321-449e-93db-dc5155bb4118", + "uuid": "462ae734-fe48-4be5-b432-ddd9912ca0e5", "persistent": true, "insertionIndex": 3 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/user-1-ebccdf.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/user-1-ebccdf.json new file mode 100644 index 0000000000..33f60a76e3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/mappings/user-1-ebccdf.json @@ -0,0 +1,43 @@ +{ + "id": "ebccdfec-1cc2-4880-9f10-a0de20895d1a", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-ebccdfec-1cc2-4880-9f10-a0de20895d1a.json", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4942", + "X-RateLimit-Reset": "1574734142", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"64a234e5bacdc505df16046a440645a9\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE9E:273E:18D56B:1D4F25:5DDC7B54" + } + }, + "uuid": "ebccdfec-1cc2-4880-9f10-a0de20895d1a", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-0c161f59-1b24-493e-b05a-cea86caa45a9.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-1279fb1b-4a2a-493a-b29a-96a060e4d3a5.json similarity index 99% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-0c161f59-1b24-493e-b05a-cea86caa45a9.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-1279fb1b-4a2a-493a-b29a-96a060e4d3a5.json index a2718e2e2d..15b132d251 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-0c161f59-1b24-493e-b05a-cea86caa45a9.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-1279fb1b-4a2a-493a-b29a-96a060e4d3a5.json @@ -65,14 +65,14 @@ "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", "created_at": "2015-08-15T14:14:57Z", - "updated_at": "2019-10-11T22:17:07Z", - "pushed_at": "2019-10-11T22:17:06Z", + "updated_at": "2019-11-26T01:09:15Z", + "pushed_at": "2019-11-26T01:09:14Z", "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", "homepage": null, - "size": 38, + "size": 45, "stargazers_count": 1, "watchers_count": 1, "language": null, @@ -81,13 +81,13 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 40, + "forks_count": 41, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 40, + "forks": 41, "open_issues": 0, "watchers": 1, "default_branch": "master", @@ -296,17 +296,17 @@ "has_downloads": true, "has_wiki": true, "has_pages": false, - "forks_count": 59, + "forks_count": 60, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": null, - "forks": 59, + "forks": 60, "open_issues": 0, "watchers": 0, "default_branch": "master" }, - "network_count": 59, + "network_count": 60, "subscribers_count": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-09629f63-a530-4e70-86d7-7c38d409c649.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-a4535a71-fd6d-464c-a1e0-efa719b10411.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-09629f63-a530-4e70-86d7-7c38d409c649.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-a4535a71-fd6d-464c-a1e0-efa719b10411.json diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/user-afa831d7-4300-49c9-8451-d76fecb86330.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/user-afa831d7-4300-49c9-8451-d76fecb86330.json new file mode 100644 index 0000000000..37691dd3c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/__files/user-afa831d7-4300-49c9-8451-d76fecb86330.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 141, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-7b176d.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-1279fb.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-7b176d.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-1279fb.json index fc626d3292..87f357029e 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-7b176d.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-1279fb.json @@ -1,5 +1,5 @@ { - "id": "7b176dc1-41fe-4677-ae9d-f420dfa1153f", + "id": "1279fb1b-4a2a-493a-b29a-96a060e4d3a5", "name": "repos_github-api-test-org_ghcontentintegrationtest", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-7b176dc1-41fe-4677-ae9d-f420dfa1153f.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-1279fb1b-4a2a-493a-b29a-96a060e4d3a5.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:36 GMT", + "Date": "Tue, 26 Nov 2019 01:09:42 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4717", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4930", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"7a79bc3c7c98b7f2a0de605eea3ad3f6\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:07 GMT", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"24ee70d5bca0cf60cc0a6c1bafcc7e8c\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:15 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0E5:4B0B:183A14:2F203B:5DA0FF7F" + "X-GitHub-Request-Id": "EEA5:25D8:19CAB6:1E5EE4:5DDC7B56" } }, - "uuid": "7b176dc1-41fe-4677-ae9d-f420dfa1153f", + "uuid": "1279fb1b-4a2a-493a-b29a-96a060e4d3a5", "persistent": true, "insertionIndex": 2 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-3-09629f.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-3-a4535a.json similarity index 74% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-3-09629f.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-3-a4535a.json index 5a8fccd58a..9cd86db684 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-3-09629f.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-3-a4535a.json @@ -1,5 +1,5 @@ { - "id": "09629f63-a530-4e70-86d7-7c38d409c649", + "id": "a4535a71-fd6d-464c-a1e0-efa719b10411", "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/ghcontent-ro/an-empty-file", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-09629f63-a530-4e70-86d7-7c38d409c649.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_an-empty-file-a4535a71-fd6d-464c-a1e0-efa719b10411.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:40 GMT", + "Date": "Tue, 26 Nov 2019 01:09:43 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4700", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4929", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], "ETag": "W/\"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:05 GMT", + "Last-Modified": "Tue, 26 Nov 2019 01:09:13 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0EE:6185:1483AF:2A3CE5:5DA0FF84" + "X-GitHub-Request-Id": "EEA5:25D8:19CACE:1E5F69:5DDC7B56" } }, - "uuid": "09629f63-a530-4e70-86d7-7c38d409c649", + "uuid": "a4535a71-fd6d-464c-a1e0-efa719b10411", "persistent": true, "insertionIndex": 3 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/user-1-afa831.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/user-1-afa831.json new file mode 100644 index 0000000000..22a9dfe164 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetEmptyFileContent/mappings/user-1-afa831.json @@ -0,0 +1,43 @@ +{ + "id": "afa831d7-4300-49c9-8451-d76fecb86330", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-afa831d7-4300-49c9-8451-d76fecb86330.json", + "headers": { + "Date": "Tue, 26 Nov 2019 01:09:42 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4934", + "X-RateLimit-Reset": "1574734142", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"64a234e5bacdc505df16046a440645a9\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EEA5:25D8:19CA50:1E5ECF:5DDC7B55" + } + }, + "uuid": "afa831d7-4300-49c9-8451-d76fecb86330", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-54fda8c5-462b-477f-be65-918b40f75fa5.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-54fda8c5-462b-477f-be65-918b40f75fa5.json new file mode 100644 index 0000000000..16577a96d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-54fda8c5-462b-477f-be65-918b40f75fa5.json @@ -0,0 +1,312 @@ +{ + "id": 40763577, + "node_id": "MDEwOlJlcG9zaXRvcnk0MDc2MzU3Nw==", + "name": "GHContentIntegrationTest", + "full_name": "github-api-test-org/GHContentIntegrationTest", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", + "description": "Repository used for integration test of github-api", + "fork": true, + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest", + "forks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", + "created_at": "2015-08-15T14:14:57Z", + "updated_at": "2019-11-26T01:09:49Z", + "pushed_at": "2019-11-26T01:09:48Z", + "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", + "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", + "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", + "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", + "homepage": null, + "size": 45, + "stargazers_count": 1, + "watchers_count": 1, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 41, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 41, + "open_issues": 0, + "watchers": 1, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 19653852, + "node_id": "MDEwOlJlcG9zaXRvcnkxOTY1Mzg1Mg==", + "name": "GHContentIntegrationTest", + "full_name": "kohsuke2/GHContentIntegrationTest", + "private": false, + "owner": { + "login": "kohsuke2", + "id": 1329242, + "node_id": "MDQ6VXNlcjEzMjkyNDI=", + "avatar_url": "https://avatars2.githubusercontent.com/u/1329242?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke2", + "html_url": "https://github.com/kohsuke2", + "followers_url": "https://api.github.com/users/kohsuke2/followers", + "following_url": "https://api.github.com/users/kohsuke2/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke2/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke2/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke2/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke2/orgs", + "repos_url": "https://api.github.com/users/kohsuke2/repos", + "events_url": "https://api.github.com/users/kohsuke2/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke2/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/kohsuke2/GHContentIntegrationTest", + "description": "Repository used for integration test of github-api", + "fork": true, + "url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest", + "forks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/forks", + "keys_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/teams", + "hooks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/hooks", + "issue_events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/events{/number}", + "events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/events", + "assignees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/assignees{/user}", + "branches_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/branches{/branch}", + "tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/tags", + "blobs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/languages", + "stargazers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/stargazers", + "contributors_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contributors", + "subscribers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscribers", + "subscription_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscription", + "commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contents/{+path}", + "compare_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/merges", + "archive_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/downloads", + "issues_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues{/number}", + "pulls_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/labels{/name}", + "releases_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/releases{/id}", + "deployments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/deployments", + "created_at": "2014-05-10T22:50:30Z", + "updated_at": "2018-11-07T15:36:19Z", + "pushed_at": "2018-11-07T15:36:18Z", + "git_url": "git://github.com/kohsuke2/GHContentIntegrationTest.git", + "ssh_url": "git@github.com:kohsuke2/GHContentIntegrationTest.git", + "clone_url": "https://github.com/kohsuke2/GHContentIntegrationTest.git", + "svn_url": "https://github.com/kohsuke2/GHContentIntegrationTest", + "homepage": null, + "size": 111, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 1, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "source": { + "id": 14779458, + "node_id": "MDEwOlJlcG9zaXRvcnkxNDc3OTQ1OA==", + "name": "github-api-test-1", + "full_name": "farmdawgnation/github-api-test-1", + "private": false, + "owner": { + "login": "farmdawgnation", + "id": 620189, + "node_id": "MDQ6VXNlcjYyMDE4OQ==", + "avatar_url": "https://avatars2.githubusercontent.com/u/620189?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/farmdawgnation", + "html_url": "https://github.com/farmdawgnation", + "followers_url": "https://api.github.com/users/farmdawgnation/followers", + "following_url": "https://api.github.com/users/farmdawgnation/following{/other_user}", + "gists_url": "https://api.github.com/users/farmdawgnation/gists{/gist_id}", + "starred_url": "https://api.github.com/users/farmdawgnation/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/farmdawgnation/subscriptions", + "organizations_url": "https://api.github.com/users/farmdawgnation/orgs", + "repos_url": "https://api.github.com/users/farmdawgnation/repos", + "events_url": "https://api.github.com/users/farmdawgnation/events{/privacy}", + "received_events_url": "https://api.github.com/users/farmdawgnation/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/farmdawgnation/github-api-test-1", + "description": "Repository used for integration test of github-api", + "fork": false, + "url": "https://api.github.com/repos/farmdawgnation/github-api-test-1", + "forks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/forks", + "keys_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/teams", + "hooks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/hooks", + "issue_events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/events{/number}", + "events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/events", + "assignees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/assignees{/user}", + "branches_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/branches{/branch}", + "tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/tags", + "blobs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/statuses/{sha}", + "languages_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/languages", + "stargazers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/stargazers", + "contributors_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contributors", + "subscribers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscribers", + "subscription_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscription", + "commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contents/{+path}", + "compare_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/merges", + "archive_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/downloads", + "issues_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues{/number}", + "pulls_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/pulls{/number}", + "milestones_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/milestones{/number}", + "notifications_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/labels{/name}", + "releases_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/releases{/id}", + "deployments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/deployments", + "created_at": "2013-11-28T14:46:38Z", + "updated_at": "2016-02-05T13:33:23Z", + "pushed_at": "2013-11-28T14:55:36Z", + "git_url": "git://github.com/farmdawgnation/github-api-test-1.git", + "ssh_url": "git@github.com:farmdawgnation/github-api-test-1.git", + "clone_url": "https://github.com/farmdawgnation/github-api-test-1.git", + "svn_url": "https://github.com/farmdawgnation/github-api-test-1", + "homepage": null, + "size": 89, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 60, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 60, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "network_count": 60, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-788adbe0-455b-4ba5-b05e-f485ea1874a7.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-788adbe0-455b-4ba5-b05e-f485ea1874a7.json new file mode 100644 index 0000000000..16577a96d7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-788adbe0-455b-4ba5-b05e-f485ea1874a7.json @@ -0,0 +1,312 @@ +{ + "id": 40763577, + "node_id": "MDEwOlJlcG9zaXRvcnk0MDc2MzU3Nw==", + "name": "GHContentIntegrationTest", + "full_name": "github-api-test-org/GHContentIntegrationTest", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", + "description": "Repository used for integration test of github-api", + "fork": true, + "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest", + "forks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", + "created_at": "2015-08-15T14:14:57Z", + "updated_at": "2019-11-26T01:09:49Z", + "pushed_at": "2019-11-26T01:09:48Z", + "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", + "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", + "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", + "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", + "homepage": null, + "size": 45, + "stargazers_count": 1, + "watchers_count": 1, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 41, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 41, + "open_issues": 0, + "watchers": 1, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 19653852, + "node_id": "MDEwOlJlcG9zaXRvcnkxOTY1Mzg1Mg==", + "name": "GHContentIntegrationTest", + "full_name": "kohsuke2/GHContentIntegrationTest", + "private": false, + "owner": { + "login": "kohsuke2", + "id": 1329242, + "node_id": "MDQ6VXNlcjEzMjkyNDI=", + "avatar_url": "https://avatars2.githubusercontent.com/u/1329242?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kohsuke2", + "html_url": "https://github.com/kohsuke2", + "followers_url": "https://api.github.com/users/kohsuke2/followers", + "following_url": "https://api.github.com/users/kohsuke2/following{/other_user}", + "gists_url": "https://api.github.com/users/kohsuke2/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kohsuke2/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kohsuke2/subscriptions", + "organizations_url": "https://api.github.com/users/kohsuke2/orgs", + "repos_url": "https://api.github.com/users/kohsuke2/repos", + "events_url": "https://api.github.com/users/kohsuke2/events{/privacy}", + "received_events_url": "https://api.github.com/users/kohsuke2/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/kohsuke2/GHContentIntegrationTest", + "description": "Repository used for integration test of github-api", + "fork": true, + "url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest", + "forks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/forks", + "keys_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/teams", + "hooks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/hooks", + "issue_events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/events{/number}", + "events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/events", + "assignees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/assignees{/user}", + "branches_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/branches{/branch}", + "tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/tags", + "blobs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/languages", + "stargazers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/stargazers", + "contributors_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contributors", + "subscribers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscribers", + "subscription_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscription", + "commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contents/{+path}", + "compare_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/merges", + "archive_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/downloads", + "issues_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues{/number}", + "pulls_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/labels{/name}", + "releases_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/releases{/id}", + "deployments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/deployments", + "created_at": "2014-05-10T22:50:30Z", + "updated_at": "2018-11-07T15:36:19Z", + "pushed_at": "2018-11-07T15:36:18Z", + "git_url": "git://github.com/kohsuke2/GHContentIntegrationTest.git", + "ssh_url": "git@github.com:kohsuke2/GHContentIntegrationTest.git", + "clone_url": "https://github.com/kohsuke2/GHContentIntegrationTest.git", + "svn_url": "https://github.com/kohsuke2/GHContentIntegrationTest", + "homepage": null, + "size": 111, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 1, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "source": { + "id": 14779458, + "node_id": "MDEwOlJlcG9zaXRvcnkxNDc3OTQ1OA==", + "name": "github-api-test-1", + "full_name": "farmdawgnation/github-api-test-1", + "private": false, + "owner": { + "login": "farmdawgnation", + "id": 620189, + "node_id": "MDQ6VXNlcjYyMDE4OQ==", + "avatar_url": "https://avatars2.githubusercontent.com/u/620189?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/farmdawgnation", + "html_url": "https://github.com/farmdawgnation", + "followers_url": "https://api.github.com/users/farmdawgnation/followers", + "following_url": "https://api.github.com/users/farmdawgnation/following{/other_user}", + "gists_url": "https://api.github.com/users/farmdawgnation/gists{/gist_id}", + "starred_url": "https://api.github.com/users/farmdawgnation/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/farmdawgnation/subscriptions", + "organizations_url": "https://api.github.com/users/farmdawgnation/orgs", + "repos_url": "https://api.github.com/users/farmdawgnation/repos", + "events_url": "https://api.github.com/users/farmdawgnation/events{/privacy}", + "received_events_url": "https://api.github.com/users/farmdawgnation/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/farmdawgnation/github-api-test-1", + "description": "Repository used for integration test of github-api", + "fork": false, + "url": "https://api.github.com/repos/farmdawgnation/github-api-test-1", + "forks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/forks", + "keys_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/teams", + "hooks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/hooks", + "issue_events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/events{/number}", + "events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/events", + "assignees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/assignees{/user}", + "branches_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/branches{/branch}", + "tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/tags", + "blobs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/statuses/{sha}", + "languages_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/languages", + "stargazers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/stargazers", + "contributors_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contributors", + "subscribers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscribers", + "subscription_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscription", + "commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contents/{+path}", + "compare_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/merges", + "archive_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/downloads", + "issues_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues{/number}", + "pulls_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/pulls{/number}", + "milestones_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/milestones{/number}", + "notifications_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/labels{/name}", + "releases_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/releases{/id}", + "deployments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/deployments", + "created_at": "2013-11-28T14:46:38Z", + "updated_at": "2016-02-05T13:33:23Z", + "pushed_at": "2013-11-28T14:55:36Z", + "git_url": "git://github.com/farmdawgnation/github-api-test-1.git", + "ssh_url": "git@github.com:farmdawgnation/github-api-test-1.git", + "clone_url": "https://github.com/farmdawgnation/github-api-test-1.git", + "svn_url": "https://github.com/farmdawgnation/github-api-test-1", + "homepage": null, + "size": 89, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 60, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 60, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "network_count": 60, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-a9082058-4cee-4bf3-8d5f-c1b7d7ca1f0f.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-a9082058-4cee-4bf3-8d5f-c1b7d7ca1f0f.json deleted file mode 100644 index 819dcde4e7..0000000000 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-a9082058-4cee-4bf3-8d5f-c1b7d7ca1f0f.json +++ /dev/null @@ -1,312 +0,0 @@ -{ - "id": 40763577, - "node_id": "MDEwOlJlcG9zaXRvcnk0MDc2MzU3Nw==", - "name": "GHContentIntegrationTest", - "full_name": "github-api-test-org/GHContentIntegrationTest", - "private": false, - "owner": { - "login": "github-api-test-org", - "id": 7544739, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", - "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-api-test-org", - "html_url": "https://github.com/github-api-test-org", - "followers_url": "https://api.github.com/users/github-api-test-org/followers", - "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", - "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", - "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", - "repos_url": "https://api.github.com/users/github-api-test-org/repos", - "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", - "type": "Organization", - "site_admin": false - }, - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", - "description": "Repository used for integration test of github-api", - "fork": true, - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest", - "forks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/forks", - "keys_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/teams", - "hooks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/hooks", - "issue_events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/events{/number}", - "events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/events", - "assignees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/assignees{/user}", - "branches_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/branches{/branch}", - "tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/tags", - "blobs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/statuses/{sha}", - "languages_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/languages", - "stargazers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/stargazers", - "contributors_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contributors", - "subscribers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscribers", - "subscription_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscription", - "commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/{+path}", - "compare_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/merges", - "archive_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/downloads", - "issues_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues{/number}", - "pulls_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/pulls{/number}", - "milestones_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/milestones{/number}", - "notifications_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/labels{/name}", - "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", - "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", - "created_at": "2015-08-15T14:14:57Z", - "updated_at": "2019-10-11T22:17:44Z", - "pushed_at": "2019-10-11T22:17:45Z", - "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", - "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", - "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", - "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", - "homepage": null, - "size": 38, - "stargazers_count": 1, - "watchers_count": 1, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "forks_count": 40, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "forks": 40, - "open_issues": 0, - "watchers": 1, - "default_branch": "master", - "permissions": { - "admin": true, - "push": true, - "pull": true - }, - "allow_squash_merge": true, - "allow_merge_commit": true, - "allow_rebase_merge": true, - "organization": { - "login": "github-api-test-org", - "id": 7544739, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", - "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-api-test-org", - "html_url": "https://github.com/github-api-test-org", - "followers_url": "https://api.github.com/users/github-api-test-org/followers", - "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", - "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", - "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", - "repos_url": "https://api.github.com/users/github-api-test-org/repos", - "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", - "type": "Organization", - "site_admin": false - }, - "parent": { - "id": 19653852, - "node_id": "MDEwOlJlcG9zaXRvcnkxOTY1Mzg1Mg==", - "name": "GHContentIntegrationTest", - "full_name": "kohsuke2/GHContentIntegrationTest", - "private": false, - "owner": { - "login": "kohsuke2", - "id": 1329242, - "node_id": "MDQ6VXNlcjEzMjkyNDI=", - "avatar_url": "https://avatars2.githubusercontent.com/u/1329242?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/kohsuke2", - "html_url": "https://github.com/kohsuke2", - "followers_url": "https://api.github.com/users/kohsuke2/followers", - "following_url": "https://api.github.com/users/kohsuke2/following{/other_user}", - "gists_url": "https://api.github.com/users/kohsuke2/gists{/gist_id}", - "starred_url": "https://api.github.com/users/kohsuke2/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/kohsuke2/subscriptions", - "organizations_url": "https://api.github.com/users/kohsuke2/orgs", - "repos_url": "https://api.github.com/users/kohsuke2/repos", - "events_url": "https://api.github.com/users/kohsuke2/events{/privacy}", - "received_events_url": "https://api.github.com/users/kohsuke2/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/kohsuke2/GHContentIntegrationTest", - "description": "Repository used for integration test of github-api", - "fork": true, - "url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest", - "forks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/forks", - "keys_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/teams", - "hooks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/hooks", - "issue_events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/events{/number}", - "events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/events", - "assignees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/assignees{/user}", - "branches_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/branches{/branch}", - "tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/tags", - "blobs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/statuses/{sha}", - "languages_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/languages", - "stargazers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/stargazers", - "contributors_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contributors", - "subscribers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscribers", - "subscription_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscription", - "commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contents/{+path}", - "compare_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/merges", - "archive_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/downloads", - "issues_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues{/number}", - "pulls_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/pulls{/number}", - "milestones_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/milestones{/number}", - "notifications_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/labels{/name}", - "releases_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/releases{/id}", - "deployments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/deployments", - "created_at": "2014-05-10T22:50:30Z", - "updated_at": "2018-11-07T15:36:19Z", - "pushed_at": "2018-11-07T15:36:18Z", - "git_url": "git://github.com/kohsuke2/GHContentIntegrationTest.git", - "ssh_url": "git@github.com:kohsuke2/GHContentIntegrationTest.git", - "clone_url": "https://github.com/kohsuke2/GHContentIntegrationTest.git", - "svn_url": "https://github.com/kohsuke2/GHContentIntegrationTest", - "homepage": null, - "size": 111, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "forks_count": 1, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "forks": 1, - "open_issues": 0, - "watchers": 0, - "default_branch": "master" - }, - "source": { - "id": 14779458, - "node_id": "MDEwOlJlcG9zaXRvcnkxNDc3OTQ1OA==", - "name": "github-api-test-1", - "full_name": "farmdawgnation/github-api-test-1", - "private": false, - "owner": { - "login": "farmdawgnation", - "id": 620189, - "node_id": "MDQ6VXNlcjYyMDE4OQ==", - "avatar_url": "https://avatars2.githubusercontent.com/u/620189?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/farmdawgnation", - "html_url": "https://github.com/farmdawgnation", - "followers_url": "https://api.github.com/users/farmdawgnation/followers", - "following_url": "https://api.github.com/users/farmdawgnation/following{/other_user}", - "gists_url": "https://api.github.com/users/farmdawgnation/gists{/gist_id}", - "starred_url": "https://api.github.com/users/farmdawgnation/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/farmdawgnation/subscriptions", - "organizations_url": "https://api.github.com/users/farmdawgnation/orgs", - "repos_url": "https://api.github.com/users/farmdawgnation/repos", - "events_url": "https://api.github.com/users/farmdawgnation/events{/privacy}", - "received_events_url": "https://api.github.com/users/farmdawgnation/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/farmdawgnation/github-api-test-1", - "description": "Repository used for integration test of github-api", - "fork": false, - "url": "https://api.github.com/repos/farmdawgnation/github-api-test-1", - "forks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/forks", - "keys_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/teams", - "hooks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/hooks", - "issue_events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/events{/number}", - "events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/events", - "assignees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/assignees{/user}", - "branches_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/branches{/branch}", - "tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/tags", - "blobs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/statuses/{sha}", - "languages_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/languages", - "stargazers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/stargazers", - "contributors_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contributors", - "subscribers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscribers", - "subscription_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscription", - "commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contents/{+path}", - "compare_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/merges", - "archive_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/downloads", - "issues_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues{/number}", - "pulls_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/pulls{/number}", - "milestones_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/milestones{/number}", - "notifications_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/labels{/name}", - "releases_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/releases{/id}", - "deployments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/deployments", - "created_at": "2013-11-28T14:46:38Z", - "updated_at": "2016-02-05T13:33:23Z", - "pushed_at": "2013-11-28T14:55:36Z", - "git_url": "git://github.com/farmdawgnation/github-api-test-1.git", - "ssh_url": "git@github.com:farmdawgnation/github-api-test-1.git", - "clone_url": "https://github.com/farmdawgnation/github-api-test-1.git", - "svn_url": "https://github.com/farmdawgnation/github-api-test-1", - "homepage": null, - "size": 89, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "forks_count": 59, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "forks": 59, - "open_issues": 0, - "watchers": 0, - "default_branch": "master" - }, - "network_count": 59, - "subscribers_count": 1 -} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-fbcbe20f-df3f-4011-9340-bb9be7b2c36e.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-fbcbe20f-df3f-4011-9340-bb9be7b2c36e.json deleted file mode 100644 index 819dcde4e7..0000000000 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest-fbcbe20f-df3f-4011-9340-bb9be7b2c36e.json +++ /dev/null @@ -1,312 +0,0 @@ -{ - "id": 40763577, - "node_id": "MDEwOlJlcG9zaXRvcnk0MDc2MzU3Nw==", - "name": "GHContentIntegrationTest", - "full_name": "github-api-test-org/GHContentIntegrationTest", - "private": false, - "owner": { - "login": "github-api-test-org", - "id": 7544739, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", - "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-api-test-org", - "html_url": "https://github.com/github-api-test-org", - "followers_url": "https://api.github.com/users/github-api-test-org/followers", - "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", - "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", - "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", - "repos_url": "https://api.github.com/users/github-api-test-org/repos", - "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", - "type": "Organization", - "site_admin": false - }, - "html_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", - "description": "Repository used for integration test of github-api", - "fork": true, - "url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest", - "forks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/forks", - "keys_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/teams", - "hooks_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/hooks", - "issue_events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/events{/number}", - "events_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/events", - "assignees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/assignees{/user}", - "branches_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/branches{/branch}", - "tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/tags", - "blobs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/statuses/{sha}", - "languages_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/languages", - "stargazers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/stargazers", - "contributors_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contributors", - "subscribers_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscribers", - "subscription_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/subscription", - "commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/contents/{+path}", - "compare_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/merges", - "archive_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/downloads", - "issues_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/issues{/number}", - "pulls_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/pulls{/number}", - "milestones_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/milestones{/number}", - "notifications_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/labels{/name}", - "releases_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/releases{/id}", - "deployments_url": "https://api.github.com/repos/github-api-test-org/GHContentIntegrationTest/deployments", - "created_at": "2015-08-15T14:14:57Z", - "updated_at": "2019-10-11T22:17:44Z", - "pushed_at": "2019-10-11T22:17:45Z", - "git_url": "git://github.com/github-api-test-org/GHContentIntegrationTest.git", - "ssh_url": "git@github.com:github-api-test-org/GHContentIntegrationTest.git", - "clone_url": "https://github.com/github-api-test-org/GHContentIntegrationTest.git", - "svn_url": "https://github.com/github-api-test-org/GHContentIntegrationTest", - "homepage": null, - "size": 38, - "stargazers_count": 1, - "watchers_count": 1, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "forks_count": 40, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "forks": 40, - "open_issues": 0, - "watchers": 1, - "default_branch": "master", - "permissions": { - "admin": true, - "push": true, - "pull": true - }, - "allow_squash_merge": true, - "allow_merge_commit": true, - "allow_rebase_merge": true, - "organization": { - "login": "github-api-test-org", - "id": 7544739, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", - "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-api-test-org", - "html_url": "https://github.com/github-api-test-org", - "followers_url": "https://api.github.com/users/github-api-test-org/followers", - "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", - "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", - "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", - "repos_url": "https://api.github.com/users/github-api-test-org/repos", - "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", - "type": "Organization", - "site_admin": false - }, - "parent": { - "id": 19653852, - "node_id": "MDEwOlJlcG9zaXRvcnkxOTY1Mzg1Mg==", - "name": "GHContentIntegrationTest", - "full_name": "kohsuke2/GHContentIntegrationTest", - "private": false, - "owner": { - "login": "kohsuke2", - "id": 1329242, - "node_id": "MDQ6VXNlcjEzMjkyNDI=", - "avatar_url": "https://avatars2.githubusercontent.com/u/1329242?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/kohsuke2", - "html_url": "https://github.com/kohsuke2", - "followers_url": "https://api.github.com/users/kohsuke2/followers", - "following_url": "https://api.github.com/users/kohsuke2/following{/other_user}", - "gists_url": "https://api.github.com/users/kohsuke2/gists{/gist_id}", - "starred_url": "https://api.github.com/users/kohsuke2/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/kohsuke2/subscriptions", - "organizations_url": "https://api.github.com/users/kohsuke2/orgs", - "repos_url": "https://api.github.com/users/kohsuke2/repos", - "events_url": "https://api.github.com/users/kohsuke2/events{/privacy}", - "received_events_url": "https://api.github.com/users/kohsuke2/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/kohsuke2/GHContentIntegrationTest", - "description": "Repository used for integration test of github-api", - "fork": true, - "url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest", - "forks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/forks", - "keys_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/teams", - "hooks_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/hooks", - "issue_events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/events{/number}", - "events_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/events", - "assignees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/assignees{/user}", - "branches_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/branches{/branch}", - "tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/tags", - "blobs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/statuses/{sha}", - "languages_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/languages", - "stargazers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/stargazers", - "contributors_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contributors", - "subscribers_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscribers", - "subscription_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/subscription", - "commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/contents/{+path}", - "compare_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/merges", - "archive_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/downloads", - "issues_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/issues{/number}", - "pulls_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/pulls{/number}", - "milestones_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/milestones{/number}", - "notifications_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/labels{/name}", - "releases_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/releases{/id}", - "deployments_url": "https://api.github.com/repos/kohsuke2/GHContentIntegrationTest/deployments", - "created_at": "2014-05-10T22:50:30Z", - "updated_at": "2018-11-07T15:36:19Z", - "pushed_at": "2018-11-07T15:36:18Z", - "git_url": "git://github.com/kohsuke2/GHContentIntegrationTest.git", - "ssh_url": "git@github.com:kohsuke2/GHContentIntegrationTest.git", - "clone_url": "https://github.com/kohsuke2/GHContentIntegrationTest.git", - "svn_url": "https://github.com/kohsuke2/GHContentIntegrationTest", - "homepage": null, - "size": 111, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "forks_count": 1, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "forks": 1, - "open_issues": 0, - "watchers": 0, - "default_branch": "master" - }, - "source": { - "id": 14779458, - "node_id": "MDEwOlJlcG9zaXRvcnkxNDc3OTQ1OA==", - "name": "github-api-test-1", - "full_name": "farmdawgnation/github-api-test-1", - "private": false, - "owner": { - "login": "farmdawgnation", - "id": 620189, - "node_id": "MDQ6VXNlcjYyMDE4OQ==", - "avatar_url": "https://avatars2.githubusercontent.com/u/620189?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/farmdawgnation", - "html_url": "https://github.com/farmdawgnation", - "followers_url": "https://api.github.com/users/farmdawgnation/followers", - "following_url": "https://api.github.com/users/farmdawgnation/following{/other_user}", - "gists_url": "https://api.github.com/users/farmdawgnation/gists{/gist_id}", - "starred_url": "https://api.github.com/users/farmdawgnation/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/farmdawgnation/subscriptions", - "organizations_url": "https://api.github.com/users/farmdawgnation/orgs", - "repos_url": "https://api.github.com/users/farmdawgnation/repos", - "events_url": "https://api.github.com/users/farmdawgnation/events{/privacy}", - "received_events_url": "https://api.github.com/users/farmdawgnation/received_events", - "type": "User", - "site_admin": false - }, - "html_url": "https://github.com/farmdawgnation/github-api-test-1", - "description": "Repository used for integration test of github-api", - "fork": false, - "url": "https://api.github.com/repos/farmdawgnation/github-api-test-1", - "forks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/forks", - "keys_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/teams", - "hooks_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/hooks", - "issue_events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/events{/number}", - "events_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/events", - "assignees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/assignees{/user}", - "branches_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/branches{/branch}", - "tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/tags", - "blobs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/statuses/{sha}", - "languages_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/languages", - "stargazers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/stargazers", - "contributors_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contributors", - "subscribers_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscribers", - "subscription_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/subscription", - "commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/contents/{+path}", - "compare_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/merges", - "archive_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/downloads", - "issues_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/issues{/number}", - "pulls_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/pulls{/number}", - "milestones_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/milestones{/number}", - "notifications_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/labels{/name}", - "releases_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/releases{/id}", - "deployments_url": "https://api.github.com/repos/farmdawgnation/github-api-test-1/deployments", - "created_at": "2013-11-28T14:46:38Z", - "updated_at": "2016-02-05T13:33:23Z", - "pushed_at": "2013-11-28T14:55:36Z", - "git_url": "git://github.com/farmdawgnation/github-api-test-1.git", - "ssh_url": "git@github.com:farmdawgnation/github-api-test-1.git", - "clone_url": "https://github.com/farmdawgnation/github-api-test-1.git", - "svn_url": "https://github.com/farmdawgnation/github-api-test-1", - "homepage": null, - "size": 89, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": false, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "forks_count": 59, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "forks": 59, - "open_issues": 0, - "watchers": 0, - "default_branch": "master" - }, - "network_count": 59, - "subscribers_count": 1 -} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-cf14dc4b-72ea-4159-bc7a-4d10a2ebb43e.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-3e4aa25e-6949-43de-b9e8-bafb84e4b2a5.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-cf14dc4b-72ea-4159-bc7a-4d10a2ebb43e.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-3e4aa25e-6949-43de-b9e8-bafb84e4b2a5.json diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/user-59f0edb6-895f-402d-946f-77e7511a9a27.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/user-59f0edb6-895f-402d-946f-77e7511a9a27.json new file mode 100644 index 0000000000..37691dd3c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/user-59f0edb6-895f-402d-946f-77e7511a9a27.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 141, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/user-8aeceae0-b015-47cc-9b83-17411b8d4bbd.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/user-8aeceae0-b015-47cc-9b83-17411b8d4bbd.json deleted file mode 100644 index 760bd7fb8a..0000000000 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/__files/user-8aeceae0-b015-47cc-9b83-17411b8d4bbd.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "login": "bitwiseman", - "id": 1958953, - "node_id": "MDQ6VXNlcjE5NTg5NTM=", - "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/bitwiseman", - "html_url": "https://github.com/bitwiseman", - "followers_url": "https://api.github.com/users/bitwiseman/followers", - "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", - "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", - "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", - "organizations_url": "https://api.github.com/users/bitwiseman/orgs", - "repos_url": "https://api.github.com/users/bitwiseman/repos", - "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", - "received_events_url": "https://api.github.com/users/bitwiseman/received_events", - "type": "User", - "site_admin": false, - "name": "Liam Newman", - "company": "Cloudbees, Inc.", - "blog": "", - "location": "Seattle, WA, USA", - "email": "bitwiseman@gmail.com", - "hireable": null, - "bio": "https://twitter.com/bitwiseman", - "public_repos": 168, - "public_gists": 5, - "followers": 138, - "following": 9, - "created_at": "2012-07-11T20:38:33Z", - "updated_at": "2019-09-24T19:32:29Z", - "private_gists": 7, - "total_private_repos": 9, - "owned_private_repos": 0, - "disk_usage": 33697, - "collaborators": 0, - "two_factor_authentication": true, - "plan": { - "name": "free", - "space": 976562499, - "collaborators": 0, - "private_repos": 10000 - } -} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-fbcbe2.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-788adb.json similarity index 74% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-fbcbe2.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-788adb.json index a1d9141a9d..05e1c8ac22 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-fbcbe2.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-2-788adb.json @@ -1,5 +1,5 @@ { - "id": "fbcbe20f-df3f-4011-9340-bb9be7b2c36e", + "id": "788adbe0-455b-4ba5-b05e-f485ea1874a7", "name": "repos_github-api-test-org_ghcontentintegrationtest", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-fbcbe20f-df3f-4011-9340-bb9be7b2c36e.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-788adbe0-455b-4ba5-b05e-f485ea1874a7.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:46 GMT", + "Date": "Tue, 26 Nov 2019 01:09:50 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4681", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4906", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"81a0a47733535ab0417cce462ddb54d6\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:44 GMT", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"4e6f5ec425012ce415fba01219503e19\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:49 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F9:5709:1995AA:2FA20A:5DA0FF8A" + "X-GitHub-Request-Id": "EEB0:9734:178F:1EB8:5DDC7B5D" } }, - "uuid": "fbcbe20f-df3f-4011-9340-bb9be7b2c36e", + "uuid": "788adbe0-455b-4ba5-b05e-f485ea1874a7", "persistent": true, "scenarioName": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest", "requiredScenarioState": "Started", diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-3-a90820.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-3-54fda8.json similarity index 74% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-3-a90820.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-3-54fda8.json index 6643f82624..c966c1af67 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-3-a90820.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest-3-54fda8.json @@ -1,5 +1,5 @@ { - "id": "a9082058-4cee-4bf3-8d5f-c1b7d7ca1f0f", + "id": "54fda8c5-462b-477f-be65-918b40f75fa5", "name": "repos_github-api-test-org_ghcontentintegrationtest", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-a9082058-4cee-4bf3-8d5f-c1b7d7ca1f0f.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-54fda8c5-462b-477f-be65-918b40f75fa5.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:47 GMT", + "Date": "Tue, 26 Nov 2019 01:09:51 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4680", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4905", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"81a0a47733535ab0417cce462ddb54d6\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:44 GMT", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"4e6f5ec425012ce415fba01219503e19\"", + "Last-Modified": "Tue, 26 Nov 2019 01:09:49 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F9:5709:1995BD:2FA293:5DA0FF8A" + "X-GitHub-Request-Id": "EEB0:9734:179A:1EDE:5DDC7B5E" } }, - "uuid": "a9082058-4cee-4bf3-8d5f-c1b7d7ca1f0f", + "uuid": "54fda8c5-462b-477f-be65-918b40f75fa5", "persistent": true, "scenarioName": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest", "requiredScenarioState": "scenario-1-repos-github-api-test-org-GHContentIntegrationTest-2", diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-4-cf14dc.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-4-3e4aa2.json similarity index 74% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-4-cf14dc.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-4-3e4aa2.json index bddc7150ba..8f48026f55 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-4-cf14dc.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-4-3e4aa2.json @@ -1,5 +1,5 @@ { - "id": "cf14dc4b-72ea-4159-bc7a-4d10a2ebb43e", + "id": "3e4aa25e-6949-43de-b9e8-bafb84e4b2a5", "name": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content", "request": { "url": "/repos/github-api-test-org/GHContentIntegrationTest/contents/ghcontent-ro/a-file-with-content", @@ -7,19 +7,22 @@ }, "response": { "status": 200, - "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-cf14dc4b-72ea-4159-bc7a-4d10a2ebb43e.json", + "bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest_contents_ghcontent-ro_a-file-with-content-3e4aa25e-6949-43de-b9e8-bafb84e4b2a5.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:47 GMT", + "Date": "Tue, 26 Nov 2019 01:09:51 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4679", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4904", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], "ETag": "W/\"901fd87750a8e53fe39a219cad50d4f7c80ca272\"", - "Last-Modified": "Fri, 11 Oct 2019 22:17:44 GMT", + "Last-Modified": "Tue, 26 Nov 2019 01:09:47 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "unknown, github.v3", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F9:5709:1995E5:2FA2CC:5DA0FF8B" + "X-GitHub-Request-Id": "EEB0:9734:17A0:1EEA:5DDC7B5F" } }, - "uuid": "cf14dc4b-72ea-4159-bc7a-4d10a2ebb43e", + "uuid": "3e4aa25e-6949-43de-b9e8-bafb84e4b2a5", "persistent": true, "insertionIndex": 4 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/user-1-c9f376.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/user-1-59f0ed.json similarity index 71% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/user-1-c9f376.json rename to src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/user-1-59f0ed.json index 1cd6ddcf17..bf4d337635 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testCRUDContent/mappings/user-1-c9f376.json +++ b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/user-1-59f0ed.json @@ -1,5 +1,5 @@ { - "id": "c9f376fa-4819-4dc7-bc79-43cabec4276f", + "id": "59f0edb6-895f-402d-946f-77e7511a9a27", "name": "user", "request": { "url": "/user", @@ -7,18 +7,21 @@ }, "response": { "status": 200, - "bodyFileName": "user-c9f376fa-4819-4dc7-bc79-43cabec4276f.json", + "bodyFileName": "user-59f0edb6-895f-402d-946f-77e7511a9a27.json", "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:41 GMT", + "Date": "Tue, 26 Nov 2019 01:09:49 GMT", "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4697", - "X-RateLimit-Reset": "1570835121", + "X-RateLimit-Remaining": "4910", + "X-RateLimit-Reset": "1574734142", "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"42eed4772a65221c408dcbe210034076\"", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"64a234e5bacdc505df16046a440645a9\"", "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", @@ -31,10 +34,10 @@ "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F4:34C4:13C437:28F99B:5DA0FF85" + "X-GitHub-Request-Id": "EEB0:9734:1774:1EB2:5DDC7B5D" } }, - "uuid": "c9f376fa-4819-4dc7-bc79-43cabec4276f", + "uuid": "59f0edb6-895f-402d-946f-77e7511a9a27", "persistent": true, "insertionIndex": 1 } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/user-1-8aecea.json b/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/user-1-8aecea.json deleted file mode 100644 index 4dc6bc2737..0000000000 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetFileContent/mappings/user-1-8aecea.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "id": "8aeceae0-b015-47cc-9b83-17411b8d4bbd", - "name": "user", - "request": { - "url": "/user", - "method": "GET" - }, - "response": { - "status": 200, - "bodyFileName": "user-8aeceae0-b015-47cc-9b83-17411b8d4bbd.json", - "headers": { - "Server": "GitHub.com", - "Date": "Fri, 11 Oct 2019 22:17:46 GMT", - "Content-Type": "application/json; charset=utf-8", - "Status": "200 OK", - "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4685", - "X-RateLimit-Reset": "1570835121", - "Cache-Control": "private, max-age=60, s-maxage=60", - "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", - "ETag": "W/\"42eed4772a65221c408dcbe210034076\"", - "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", - "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", - "X-Accepted-OAuth-Scopes": "", - "X-GitHub-Media-Type": "unknown, github.v3", - "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", - "Access-Control-Allow-Origin": "*", - "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", - "X-Frame-Options": "deny", - "X-Content-Type-Options": "nosniff", - "X-XSS-Protection": "1; mode=block", - "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", - "Content-Security-Policy": "default-src 'none'", - "X-GitHub-Request-Id": "C0F9:5709:199567:2FA1F1:5DA0FF89" - } - }, - "uuid": "8aeceae0-b015-47cc-9b83-17411b8d4bbd", - "persistent": true, - "insertionIndex": 1 -} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/gists_9903708-c3067d66-2bb0-4af7-b7d4-98032571c5d0.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/__files/user-9226d6ed-a52d-4b08-9402-f1cfc2dbf0e1.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/gists_9903708-2-c3067d.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/user-1-9226d6.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/user-1-9226d6.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/gistFile/mappings/user-1-9226d6.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/gistFile/mappings/user-1-9226d6.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/gists-2f93eec6-32ad-4c3d-a7bf-33a134d16dbe.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/__files/user-3380f859-169e-41b0-9a8a-aa66277dfb8b.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists-2-2f93ee.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/gists_9faa55cd67b21a789bb44e34e5e41f72-3-26c314.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/lifecycleTest/mappings/user-1-3380f8.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708-ab2c9d06-edf6-4875-b402-7c99a529b19a.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-42d6e404-71e3-42cc-b415-f42dfab9d45e.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/gists_9903708_forks-992bf599-2e87-4fb0-b610-7c2e1fc00398.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/__files/user-07500425-69d3-4dd0-8519-628a92aa66c5.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_8edf855833a05ce8730d609fe8bd803a-9-e0907c.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708-2-ab2c9d.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-7-42d6e4.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_forks-8-992bf5.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-3-dc6fd4.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-4-680201.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-5-c7d88c.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/gists_9903708_star-6-584dc0.json diff --git a/src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/user-1-075004.json b/src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/user-1-075004.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GistTest/wiremock/starTest/mappings/user-1-075004.json rename to src/test/resources/org/kohsuke/github/GHGistTest/wiremock/starTest/mappings/user-1-075004.json diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/orgs_github-api-test-org-b46fc09e-f6b1-470b-b070-d37c25eb5096.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/orgs_github-api-test-org-b46fc09e-f6b1-470b-b070-d37c25eb5096.json new file mode 100644 index 0000000000..d8cf8e232f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/orgs_github-api-test-org-b46fc09e-f6b1-470b-b070-d37c25eb5096.json @@ -0,0 +1,41 @@ +{ + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "url": "https://api.github.com/orgs/github-api-test-org", + "repos_url": "https://api.github.com/orgs/github-api-test-org/repos", + "events_url": "https://api.github.com/orgs/github-api-test-org/events", + "hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks", + "issues_url": "https://api.github.com/orgs/github-api-test-org/issues", + "members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}", + "public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "description": null, + "is_verified": false, + "has_organization_projects": true, + "has_repository_projects": true, + "public_repos": 10, + "public_gists": 0, + "followers": 0, + "following": 0, + "html_url": "https://github.com/github-api-test-org", + "created_at": "2014-05-10T19:39:11Z", + "updated_at": "2015-04-20T00:42:30Z", + "type": "Organization", + "total_private_repos": 0, + "owned_private_repos": 0, + "private_gists": 0, + "disk_usage": 132, + "collaborators": 0, + "billing_email": "kk@kohsuke.org", + "default_repository_permission": "none", + "members_can_create_repositories": false, + "two_factor_requirement_enabled": false, + "plan": { + "name": "free", + "space": 976562499, + "private_repos": 0, + "filled_seats": 9, + "seats": 0 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/orgs_github-api-test-org_teams-93bbb3e2-5dd1-41f1-b527-1e431a0213b7.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/orgs_github-api-test-org_teams-93bbb3e2-5dd1-41f1-b527-1e431a0213b7.json new file mode 100644 index 0000000000..98179e8768 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/orgs_github-api-test-org_teams-93bbb3e2-5dd1-41f1-b527-1e431a0213b7.json @@ -0,0 +1,42 @@ +{ + "name": "create-team-test", + "id": 3531422, + "node_id": "MDQ6VGVhbTM1MzE0MjI=", + "slug": "create-team-test", + "description": null, + "privacy": "secret", + "url": "https://api.github.com/teams/3531422", + "html_url": "https://github.com/orgs/github-api-test-org/teams/create-team-test", + "members_url": "https://api.github.com/teams/3531422/members{/member}", + "repositories_url": "https://api.github.com/teams/3531422/repos", + "permission": "pull", + "created_at": "2019-11-20T01:07:57Z", + "updated_at": "2019-11-20T01:07:57Z", + "members_count": 0, + "repos_count": 1, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "url": "https://api.github.com/orgs/github-api-test-org", + "repos_url": "https://api.github.com/orgs/github-api-test-org/repos", + "events_url": "https://api.github.com/orgs/github-api-test-org/events", + "hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks", + "issues_url": "https://api.github.com/orgs/github-api-test-org/issues", + "members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}", + "public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "description": null, + "is_verified": false, + "has_organization_projects": true, + "has_repository_projects": true, + "public_repos": 10, + "public_gists": 0, + "followers": 0, + "following": 0, + "html_url": "https://github.com/github-api-test-org", + "created_at": "2014-05-10T19:39:11Z", + "updated_at": "2015-04-20T00:42:30Z", + "type": "Organization" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/repos_github-api-test-org_github-api-8907242a-a66e-45d4-a01e-3f12bfa099a2.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/repos_github-api-test-org_github-api-8907242a-a66e-45d4-a01e-3f12bfa099a2.json new file mode 100644 index 0000000000..82cd4e12b9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/repos_github-api-test-org_github-api-8907242a-a66e-45d4-a01e-3f12bfa099a2.json @@ -0,0 +1,330 @@ +{ + "id": 206888201, + "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=", + "name": "github-api", + "full_name": "github-api-test-org/github-api", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/github-api", + "description": "Resetting", + "fork": true, + "url": "https://api.github.com/repos/github-api-test-org/github-api", + "forks_url": "https://api.github.com/repos/github-api-test-org/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/github-api/deployments", + "created_at": "2019-09-06T23:26:04Z", + "updated_at": "2019-11-07T22:27:11Z", + "pushed_at": "2019-10-21T22:34:49Z", + "git_url": "git://github.com/github-api-test-org/github-api.git", + "ssh_url": "git@github.com:github-api-test-org/github-api.git", + "clone_url": "https://github.com/github-api-test-org/github-api.git", + "svn_url": "https://github.com/github-api-test-org/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 11391, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-19T06:48:53Z", + "pushed_at": "2019-11-19T04:03:23Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15749, + "stargazers_count": 580, + "watchers_count": 580, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 443, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 52, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 443, + "open_issues": 52, + "watchers": 580, + "default_branch": "master" + }, + "source": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-19T06:48:53Z", + "pushed_at": "2019-11-19T04:03:23Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15749, + "stargazers_count": 580, + "watchers_count": 580, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 443, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 52, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 443, + "open_issues": 52, + "watchers": 580, + "default_branch": "master" + }, + "network_count": 443, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/teams_3531422_repos-9893d54e-bc2f-4246-ba25-b9c157b22845.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/teams_3531422_repos-9893d54e-bc2f-4246-ba25-b9c157b22845.json new file mode 100644 index 0000000000..0f89f8ce12 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/teams_3531422_repos-9893d54e-bc2f-4246-ba25-b9c157b22845.json @@ -0,0 +1,107 @@ +[ + { + "id": 206888201, + "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=", + "name": "github-api", + "full_name": "github-api-test-org/github-api", + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/github-api-test-org/github-api", + "description": "Resetting", + "fork": true, + "url": "https://api.github.com/repos/github-api-test-org/github-api", + "forks_url": "https://api.github.com/repos/github-api-test-org/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/github-api/deployments", + "created_at": "2019-09-06T23:26:04Z", + "updated_at": "2019-11-07T22:27:11Z", + "pushed_at": "2019-10-21T22:34:49Z", + "git_url": "git://github.com/github-api-test-org/github-api.git", + "ssh_url": "git@github.com:github-api-test-org/github-api.git", + "clone_url": "https://github.com/github-api-test-org/github-api.git", + "svn_url": "https://github.com/github-api-test-org/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 11391, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "pull": true, + "push": false, + "admin": false + } + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/user-3a6b16d8-0d7e-4409-bb25-07ac6103a4fd.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/user-3a6b16d8-0d7e-4409-bb25-07ac6103a4fd.json new file mode 100644 index 0000000000..ee0bf1e3a3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/__files/user-3a6b16d8-0d7e-4409-bb25-07ac6103a4fd.json @@ -0,0 +1,45 @@ +{ + "login": "asthinasthi", + "id": 4577101, + "node_id": "MDQ6VXNlcjQ1NzcxMDE=", + "avatar_url": "https://avatars1.githubusercontent.com/u/4577101?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/asthinasthi", + "html_url": "https://github.com/asthinasthi", + "followers_url": "https://api.github.com/users/asthinasthi/followers", + "following_url": "https://api.github.com/users/asthinasthi/following{/other_user}", + "gists_url": "https://api.github.com/users/asthinasthi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/asthinasthi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/asthinasthi/subscriptions", + "organizations_url": "https://api.github.com/users/asthinasthi/orgs", + "repos_url": "https://api.github.com/users/asthinasthi/repos", + "events_url": "https://api.github.com/users/asthinasthi/events{/privacy}", + "received_events_url": "https://api.github.com/users/asthinasthi/received_events", + "type": "User", + "site_admin": false, + "name": "Anirudh Mathad", + "company": "Adobe", + "blog": "", + "location": "San Jose", + "email": "anirudh.mathad@gmail.com", + "hireable": null, + "bio": "Backend Engineer", + "public_repos": 43, + "public_gists": 1, + "followers": 12, + "following": 35, + "created_at": "2013-05-31T05:50:17Z", + "updated_at": "2019-11-19T18:23:21Z", + "private_gists": 3, + "total_private_repos": 1, + "owned_private_repos": 1, + "disk_usage": 122519, + "collaborators": 0, + "two_factor_authentication": false, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/orgs_github-api-test-org-2-b46fc0.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/orgs_github-api-test-org-2-b46fc0.json new file mode 100644 index 0000000000..c48153d52b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/orgs_github-api-test-org-2-b46fc0.json @@ -0,0 +1,43 @@ +{ + "id": "b46fc09e-f6b1-470b-b070-d37c25eb5096", + "name": "orgs_github-api-test-org", + "request": { + "url": "/orgs/github-api-test-org", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "orgs_github-api-test-org-b46fc09e-f6b1-470b-b070-d37c25eb5096.json", + "headers": { + "Date": "Wed, 20 Nov 2019 01:07:56 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4941", + "X-RateLimit-Reset": "1574215499", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"06bf8d27c18bdcae52cacdb1c04e5618\"", + "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "84E8:8C36:9EA5B0:B90507:5DD491EC" + } + }, + "uuid": "b46fc09e-f6b1-470b-b070-d37c25eb5096", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/orgs_github-api-test-org_teams-4-93bbb3.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/orgs_github-api-test-org_teams-4-93bbb3.json new file mode 100644 index 0000000000..92078b54d6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/orgs_github-api-test-org_teams-4-93bbb3.json @@ -0,0 +1,50 @@ +{ + "id": "93bbb3e2-5dd1-41f1-b527-1e431a0213b7", + "name": "orgs_github-api-test-org_teams", + "request": { + "url": "/orgs/github-api-test-org/teams", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"name\":\"create-team-test\",\"repo_names\":[\"github-api-test-org/github-api\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "orgs_github-api-test-org_teams-93bbb3e2-5dd1-41f1-b527-1e431a0213b7.json", + "headers": { + "Date": "Wed, 20 Nov 2019 01:07:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4939", + "X-RateLimit-Reset": "1574215499", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"454ab73d1808f8bc3abc9478505ad221\"", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:org, repo", + "Location": "https://api.github.com/teams/3531422", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "84E8:8C36:9EA5E9:B90588:5DD491ED" + } + }, + "uuid": "93bbb3e2-5dd1-41f1-b527-1e431a0213b7", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/repos_github-api-test-org_github-api-3-890724.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/repos_github-api-test-org_github-api-3-890724.json new file mode 100644 index 0000000000..43017fe7c1 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/repos_github-api-test-org_github-api-3-890724.json @@ -0,0 +1,43 @@ +{ + "id": "8907242a-a66e-45d4-a01e-3f12bfa099a2", + "name": "repos_github-api-test-org_github-api", + "request": { + "url": "/repos/github-api-test-org/github-api", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_github-api-8907242a-a66e-45d4-a01e-3f12bfa099a2.json", + "headers": { + "Date": "Wed, 20 Nov 2019 01:07:57 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4940", + "X-RateLimit-Reset": "1574215499", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"5f93d5d1afae66d9e8f982e4cad293b6\"", + "Last-Modified": "Thu, 07 Nov 2019 22:27:11 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "84E8:8C36:9EA5C8:B9056B:5DD491EC" + } + }, + "uuid": "8907242a-a66e-45d4-a01e-3f12bfa099a2", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/teams_3531422_repos-5-9893d5.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/teams_3531422_repos-5-9893d5.json new file mode 100644 index 0000000000..a2c5168514 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/teams_3531422_repos-5-9893d5.json @@ -0,0 +1,42 @@ +{ + "id": "9893d54e-bc2f-4246-ba25-b9c157b22845", + "name": "teams_3531422_repos", + "request": { + "url": "/teams/3531422/repos", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "teams_3531422_repos-9893d54e-bc2f-4246-ba25-b9c157b22845.json", + "headers": { + "Date": "Wed, 20 Nov 2019 01:07:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4938", + "X-RateLimit-Reset": "1574215499", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"56e4bb5283d34fc86bf30247ae56cfbd\"", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "84E8:8C36:9EA654:B9060A:5DD491EE" + } + }, + "uuid": "9893d54e-bc2f-4246-ba25-b9c157b22845", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/user-1-3a6b16.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/user-1-3a6b16.json new file mode 100644 index 0000000000..d7d8ce78b0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testCreateTeam/mappings/user-1-3a6b16.json @@ -0,0 +1,43 @@ +{ + "id": "3a6b16d8-0d7e-4409-bb25-07ac6103a4fd", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-3a6b16d8-0d7e-4409-bb25-07ac6103a4fd.json", + "headers": { + "Date": "Wed, 20 Nov 2019 01:07:56 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4945", + "X-RateLimit-Reset": "1574215499", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"3d6980508567a2e87daa452d20106bcd\"", + "Last-Modified": "Tue, 19 Nov 2019 18:23:21 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "84E8:8C36:9EA55D:B904F1:5DD491EC" + } + }, + "uuid": "3a6b16d8-0d7e-4409-bb25-07ac6103a4fd", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testInviteUser/__files/user-7e6e7d53-a5ae-46b0-afc0-a73258da075d.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testInviteUser/__files/user-7e6e7d53-a5ae-46b0-afc0-a73258da075d.json new file mode 100644 index 0000000000..ee0bf1e3a3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testInviteUser/__files/user-7e6e7d53-a5ae-46b0-afc0-a73258da075d.json @@ -0,0 +1,45 @@ +{ + "login": "asthinasthi", + "id": 4577101, + "node_id": "MDQ6VXNlcjQ1NzcxMDE=", + "avatar_url": "https://avatars1.githubusercontent.com/u/4577101?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/asthinasthi", + "html_url": "https://github.com/asthinasthi", + "followers_url": "https://api.github.com/users/asthinasthi/followers", + "following_url": "https://api.github.com/users/asthinasthi/following{/other_user}", + "gists_url": "https://api.github.com/users/asthinasthi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/asthinasthi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/asthinasthi/subscriptions", + "organizations_url": "https://api.github.com/users/asthinasthi/orgs", + "repos_url": "https://api.github.com/users/asthinasthi/repos", + "events_url": "https://api.github.com/users/asthinasthi/events{/privacy}", + "received_events_url": "https://api.github.com/users/asthinasthi/received_events", + "type": "User", + "site_admin": false, + "name": "Anirudh Mathad", + "company": "Adobe", + "blog": "", + "location": "San Jose", + "email": "anirudh.mathad@gmail.com", + "hireable": null, + "bio": "Backend Engineer", + "public_repos": 43, + "public_gists": 1, + "followers": 12, + "following": 35, + "created_at": "2013-05-31T05:50:17Z", + "updated_at": "2019-11-19T18:23:21Z", + "private_gists": 3, + "total_private_repos": 1, + "owned_private_repos": 1, + "disk_usage": 122519, + "collaborators": 0, + "two_factor_authentication": false, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testInviteUser/mappings/user-6-7e6e7d.json b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testInviteUser/mappings/user-6-7e6e7d.json new file mode 100644 index 0000000000..c53b130248 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHOrganizationTest/wiremock/testInviteUser/mappings/user-6-7e6e7d.json @@ -0,0 +1,43 @@ +{ + "id": "7e6e7d53-a5ae-46b0-afc0-a73258da075d", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-7e6e7d53-a5ae-46b0-afc0-a73258da075d.json", + "headers": { + "Date": "Wed, 20 Nov 2019 01:07:55 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4950", + "X-RateLimit-Reset": "1574215499", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"3d6980508567a2e87daa452d20106bcd\"", + "Last-Modified": "Tue, 19 Nov 2019 18:23:21 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "A230:58D9:963D8A:AF4500:5DD491EB" + } + }, + "uuid": "7e6e7d53-a5ae-46b0-afc0-a73258da075d", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/__files/user-a0bafdae-2f0d-4d0b-966b-f2408c1240bd.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/__files/user-a0bafdae-2f0d-4d0b-966b-f2408c1240bd.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/__files/user-a0bafdae-2f0d-4d0b-966b-f2408c1240bd.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/__files/user-a0bafdae-2f0d-4d0b-966b-f2408c1240bd.json diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/rate_limit2-2-445e28.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/rate_limit2-2-445e28.json similarity index 89% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/rate_limit2-2-445e28.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/rate_limit2-2-445e28.json index 92ea20aee9..b38677c477 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/rate_limit2-2-445e28.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/rate_limit2-2-445e28.json @@ -9,13 +9,10 @@ "status": 404, "body": "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3\"}", "headers": { - "Date": "Mon, 07 Oct 2019 17:05:48 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "404 Not Found", - "X-RateLimit-Limit": "5000", - "X-RateLimit-Remaining": "4976", - "X-RateLimit-Reset": "1570470839", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "unknown, github.v3", diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-0-a0bafd.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-0-a0bafd.json similarity index 95% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-0-a0bafd.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-0-a0bafd.json index bbae6112f7..2cae4ea333 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-0-a0bafd.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-0-a0bafd.json @@ -9,7 +9,7 @@ "status": 200, "bodyFileName": "user-a0bafdae-2f0d-4d0b-966b-f2408c1240bd.json", "headers": { - "Date": "Mon, 07 Oct 2019 17:05:48 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-1-a0bafd.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-1-a0bafd.json similarity index 92% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-1-a0bafd.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-1-a0bafd.json index 48693a69fa..babc41d792 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-1-a0bafd.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubEnterpriseDoesNotHaveRateLimit/mappings/user-1-a0bafd.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "user-a0bafdae-2f0d-4d0b-966b-f2408c1240bd.json", "headers": { - "Date": "Mon, 07 Oct 2019 17:05:48 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4978", - "X-RateLimit-Reset": "1570470839", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/orgs_github-api-test-org-7ea37b72-8b01-4ed5-a63d-98d32b2faa0f.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/orgs_github-api-test-org-7ea37b72-8b01-4ed5-a63d-98d32b2faa0f.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/orgs_github-api-test-org-7ea37b72-8b01-4ed5-a63d-98d32b2faa0f.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/orgs_github-api-test-org-7ea37b72-8b01-4ed5-a63d-98d32b2faa0f.json diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json similarity index 64% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json index 3f8b93b91d..607385447e 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json @@ -3,22 +3,22 @@ "core": { "limit": 5000, "remaining": 4896, - "reset": 1570478899 + "reset": {{now offset='1 hours' format='unix'}} }, "search": { "limit": 30, "remaining": 30, - "reset": 1570478180 + "reset": {{now offset='1 hours' format='unix'}} }, "graphql": { "limit": 5000, "remaining": 5000, - "reset": 1570481642 + "reset": {{now offset='1 hours' format='unix'}} }, "integration_manifest": { "limit": 5000, "remaining": 5000, - "reset": 1570481642 + "reset": {{now offset='1 hours' format='unix'}} } }, "rate": { diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json similarity index 64% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json index c08b3c7e2c..e5881bcd4d 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json @@ -3,22 +3,22 @@ "core": { "limit": 5000, "remaining": 4897, - "reset": 1570478899 + "reset": {{now offset='1 hours' format='unix'}} }, "search": { "limit": 30, "remaining": 30, - "reset": 1570478180 + "reset": {{now offset='1 hours' format='unix'}} }, "graphql": { "limit": 5000, "remaining": 5000, - "reset": 1570481642 + "reset": {{now offset='1 hours' format='unix'}} }, "integration_manifest": { "limit": 5000, "remaining": 5000, - "reset": 1570481642 + "reset": {{now offset='1 hours' format='unix'}} } }, "rate": { diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json similarity index 64% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json index c08b3c7e2c..e5881bcd4d 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json @@ -3,22 +3,22 @@ "core": { "limit": 5000, "remaining": 4897, - "reset": 1570478899 + "reset": {{now offset='1 hours' format='unix'}} }, "search": { "limit": 30, "remaining": 30, - "reset": 1570478180 + "reset": {{now offset='1 hours' format='unix'}} }, "graphql": { "limit": 5000, "remaining": 5000, - "reset": 1570481642 + "reset": {{now offset='1 hours' format='unix'}} }, "integration_manifest": { "limit": 5000, "remaining": 5000, - "reset": 1570481642 + "reset": {{now offset='1 hours' format='unix'}} } }, "rate": { diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json similarity index 100% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/orgs_github-api-test-org-4-7ea37b.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/orgs_github-api-test-org-4-7ea37b.json similarity index 92% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/orgs_github-api-test-org-4-7ea37b.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/orgs_github-api-test-org-4-7ea37b.json index b76c260d2e..b5f378c49b 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/orgs_github-api-test-org-4-7ea37b.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/orgs_github-api-test-org-4-7ea37b.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "orgs_github-api-test-org-7ea37b72-8b01-4ed5-a63d-98d32b2faa0f.json", "headers": { - "Date": "Mon, 07 Oct 2019 19:55:56 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4896", - "X-RateLimit-Reset": "1570478899", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-2-f22b1c.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-2-f22b1c.json similarity index 92% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-2-f22b1c.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-2-f22b1c.json index 8eccbac04f..8a9c8a5e9b 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-2-f22b1c.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-2-f22b1c.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json", "headers": { - "Date": "Mon, 07 Oct 2019 19:55:54 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4897", - "X-RateLimit-Reset": "1570478899", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "no-cache", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-3-a1f82a.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-3-a1f82a.json similarity index 92% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-3-a1f82a.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-3-a1f82a.json index 1b64a50322..b1fd79e743 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-3-a1f82a.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-3-a1f82a.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json", "headers": { - "Date": "Mon, 07 Oct 2019 19:55:55 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4897", - "X-RateLimit-Reset": "1570478899", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "no-cache", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-5-4e2fc3.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-5-4e2fc3.json similarity index 91% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-5-4e2fc3.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-5-4e2fc3.json index 5cead1be21..e1c2d63015 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/rate_limit-5-4e2fc3.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/rate_limit-5-4e2fc3.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json", "headers": { - "Date": "Mon, 07 Oct 2019 19:55:56 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4896", - "X-RateLimit-Reset": "1570478899", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "no-cache", "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", "X-Accepted-OAuth-Scopes": "", diff --git a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/user-1-a460fd.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/user-1-a460fd.json similarity index 92% rename from src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/user-1-a460fd.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/user-1-a460fd.json index 3c300dfc2f..2c080409ae 100644 --- a/src/test/resources/org/kohsuke/github/GitHubConnectionTest/wiremock/testGitHubRateLimit/mappings/user-1-a460fd.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimit/mappings/user-1-a460fd.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json", "headers": { - "Date": "Mon, 07 Oct 2019 19:55:52 GMT", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4897", - "X-RateLimit-Reset": "1570478899", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json new file mode 100644 index 0000000000..404ebd4de8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json @@ -0,0 +1,29 @@ +{ + "resources": { + "core": { + "limit": 5000, + "remaining": 4896, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "search": { + "limit": 30, + "remaining": 30, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "graphql": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "integration_manifest": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='305 seconds' format='unix'}} + } + }, + "rate": { + "limit": 5000, + "remaining": 4896, + "reset": 1570478899 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json new file mode 100644 index 0000000000..bacd79c0f2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json @@ -0,0 +1,29 @@ +{ + "resources": { + "core": { + "limit": 5000, + "remaining": 4897, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "search": { + "limit": 30, + "remaining": 30, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "graphql": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "integration_manifest": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='305 seconds' format='unix'}} + } + }, + "rate": { + "limit": 5000, + "remaining": 4897, + "reset": 1570478899 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json new file mode 100644 index 0000000000..bacd79c0f2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json @@ -0,0 +1,29 @@ +{ + "resources": { + "core": { + "limit": 5000, + "remaining": 4897, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "search": { + "limit": 30, + "remaining": 30, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "graphql": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='305 seconds' format='unix'}} + }, + "integration_manifest": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='305 seconds' format='unix'}} + } + }, + "rate": { + "limit": 5000, + "remaining": 4897, + "reset": 1570478899 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/user-842cc871-f338-4cc0-8fb0-db276fb4224a.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json similarity index 97% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/user-842cc871-f338-4cc0-8fb0-db276fb4224a.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json index 760bd7fb8a..41fc9e3d00 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContent/__files/user-842cc871-f338-4cc0-8fb0-db276fb4224a.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json @@ -25,8 +25,8 @@ "hireable": null, "bio": "https://twitter.com/bitwiseman", "public_repos": 168, - "public_gists": 5, - "followers": 138, + "public_gists": 4, + "followers": 136, "following": 9, "created_at": "2012-07-11T20:38:33Z", "updated_at": "2019-09-24T19:32:29Z", diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-2-f22b1c.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-2-f22b1c.json new file mode 100644 index 0000000000..843d08823e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-2-f22b1c.json @@ -0,0 +1,41 @@ +{ + "id": "f22b1cea-3679-481d-8b95-459b2c47bf98", + "name": "rate_limit", + "request": { + "url": "/rate_limit", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json", + "headers": { + "Date": "{{now offset='5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "{{now offset='303 seconds' format='unix'}}", + "Cache-Control": "no-cache", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "E39F:3620:2D9D346:369B91A:5D9B9848" + } + }, + "uuid": "f22b1cea-3679-481d-8b95-459b2c47bf98", + "persistent": true, + "scenarioName": "scenario-1-rate_limit", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-rate_limit-2", + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-3-a1f82a.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-3-a1f82a.json new file mode 100644 index 0000000000..12709f27a2 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-3-a1f82a.json @@ -0,0 +1,41 @@ +{ + "id": "a1f82a96-500c-4462-ae7b-e0159afa8208", + "name": "rate_limit", + "request": { + "url": "/rate_limit", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json", + "headers": { + "Date": "{{now offset='5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "{{now offset='303 seconds' format='unix'}}", + "Cache-Control": "no-cache", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "E39F:3620:2D9D3B3:369BA1D:5D9B984A" + } + }, + "uuid": "a1f82a96-500c-4462-ae7b-e0159afa8208", + "persistent": true, + "scenarioName": "scenario-1-rate_limit", + "requiredScenarioState": "scenario-1-rate_limit-2", + "newScenarioState": "scenario-1-rate_limit-3", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-5-4e2fc3.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-5-4e2fc3.json new file mode 100644 index 0000000000..66f9990ea7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/rate_limit-5-4e2fc3.json @@ -0,0 +1,40 @@ +{ + "id": "4e2fc33b-fb25-4dfc-9d56-34f9b4d707be", + "name": "rate_limit", + "request": { + "url": "/rate_limit", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json", + "headers": { + "Date": "{{now offset='5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4896", + "X-RateLimit-Reset": "{{now offset='303 seconds' format='unix'}}", + "Cache-Control": "no-cache", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "E39F:3620:2D9D3D1:369BAD1:5D9B984C" + } + }, + "uuid": "4e2fc33b-fb25-4dfc-9d56-34f9b4d707be", + "persistent": true, + "scenarioName": "scenario-1-rate_limit", + "requiredScenarioState": "scenario-1-rate_limit-3", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/user-1-a460fd.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/user-1-a460fd.json new file mode 100644 index 0000000000..9bf4f2edab --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesAhead/mappings/user-1-a460fd.json @@ -0,0 +1,43 @@ +{ + "id": "a460fd69-99f3-46c7-aeb1-888c34085d4a", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json", + "headers": { + "Date": "{{now offset='5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "{{now offset='303 seconds' format='unix'}}", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"af0c41afcacb8ceee14b7d896719c3bd\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E39F:3620:2D9D266:369B909:5D9B9848" + } + }, + "uuid": "a460fd69-99f3-46c7-aeb1-888c34085d4a", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json new file mode 100644 index 0000000000..9d326f28a6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json @@ -0,0 +1,29 @@ +{ + "resources": { + "core": { + "limit": 5000, + "remaining": 4896, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "search": { + "limit": 30, + "remaining": 30, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "graphql": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "integration_manifest": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='-295 seconds' format='unix'}} + } + }, + "rate": { + "limit": 5000, + "remaining": 4896, + "reset": 1570478899 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json new file mode 100644 index 0000000000..c18f00dbb3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json @@ -0,0 +1,29 @@ +{ + "resources": { + "core": { + "limit": 5000, + "remaining": 4897, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "search": { + "limit": 30, + "remaining": 30, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "graphql": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "integration_manifest": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='-295 seconds' format='unix'}} + } + }, + "rate": { + "limit": 5000, + "remaining": 4897, + "reset": 1570478899 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json new file mode 100644 index 0000000000..c18f00dbb3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json @@ -0,0 +1,29 @@ +{ + "resources": { + "core": { + "limit": 5000, + "remaining": 4897, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "search": { + "limit": 30, + "remaining": 30, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "graphql": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='-295 seconds' format='unix'}} + }, + "integration_manifest": { + "limit": 5000, + "remaining": 5000, + "reset": {{now offset='-295 seconds' format='unix'}} + } + }, + "rate": { + "limit": 5000, + "remaining": 4897, + "reset": 1570478899 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/user-00d46d71-d7b4-430e-948c-8a70ecd0e9b3.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json similarity index 97% rename from src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/user-00d46d71-d7b4-430e-948c-8a70ecd0e9b3.json rename to src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json index 760bd7fb8a..41fc9e3d00 100644 --- a/src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetDirectoryContentTrailingSlash/__files/user-00d46d71-d7b4-430e-948c-8a70ecd0e9b3.json +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/__files/user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json @@ -25,8 +25,8 @@ "hireable": null, "bio": "https://twitter.com/bitwiseman", "public_repos": 168, - "public_gists": 5, - "followers": 138, + "public_gists": 4, + "followers": 136, "following": 9, "created_at": "2012-07-11T20:38:33Z", "updated_at": "2019-09-24T19:32:29Z", diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-2-f22b1c.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-2-f22b1c.json new file mode 100644 index 0000000000..8fc9db6ad9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-2-f22b1c.json @@ -0,0 +1,41 @@ +{ + "id": "f22b1cea-3679-481d-8b95-459b2c47bf98", + "name": "rate_limit", + "request": { + "url": "/rate_limit", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "rate_limit-f22b1cea-3679-481d-8b95-459b2c47bf98.json", + "headers": { + "Date": "{{now offset='-5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "{{now offset='-297 seconds' format='unix'}}", + "Cache-Control": "no-cache", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "E39F:3620:2D9D346:369B91A:5D9B9848" + } + }, + "uuid": "f22b1cea-3679-481d-8b95-459b2c47bf98", + "persistent": true, + "scenarioName": "scenario-1-rate_limit", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-rate_limit-2", + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-3-a1f82a.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-3-a1f82a.json new file mode 100644 index 0000000000..2931529a81 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-3-a1f82a.json @@ -0,0 +1,41 @@ +{ + "id": "a1f82a96-500c-4462-ae7b-e0159afa8208", + "name": "rate_limit", + "request": { + "url": "/rate_limit", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "rate_limit-a1f82a96-500c-4462-ae7b-e0159afa8208.json", + "headers": { + "Date": "{{now offset='-5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "{{now offset='-297 seconds' format='unix'}}", + "Cache-Control": "no-cache", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "E39F:3620:2D9D3B3:369BA1D:5D9B984A" + } + }, + "uuid": "a1f82a96-500c-4462-ae7b-e0159afa8208", + "persistent": true, + "scenarioName": "scenario-1-rate_limit", + "requiredScenarioState": "scenario-1-rate_limit-2", + "newScenarioState": "scenario-1-rate_limit-3", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-5-4e2fc3.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-5-4e2fc3.json new file mode 100644 index 0000000000..8af77db960 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/rate_limit-5-4e2fc3.json @@ -0,0 +1,40 @@ +{ + "id": "4e2fc33b-fb25-4dfc-9d56-34f9b4d707be", + "name": "rate_limit", + "request": { + "url": "/rate_limit", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "rate_limit-4e2fc33b-fb25-4dfc-9d56-34f9b4d707be.json", + "headers": { + "Date": "{{now offset='-5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4896", + "X-RateLimit-Reset": "{{now offset='-297 seconds' format='unix'}}", + "Cache-Control": "no-cache", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "E39F:3620:2D9D3D1:369BAD1:5D9B984C" + } + }, + "uuid": "4e2fc33b-fb25-4dfc-9d56-34f9b4d707be", + "persistent": true, + "scenarioName": "scenario-1-rate_limit", + "requiredScenarioState": "scenario-1-rate_limit-3", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/user-1-a460fd.json b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/user-1-a460fd.json new file mode 100644 index 0000000000..f5a7183ffb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRateLimitTest/wiremock/testGitHubRateLimitExpirationServerFiveMinutesBehind/mappings/user-1-a460fd.json @@ -0,0 +1,43 @@ +{ + "id": "a460fd69-99f3-46c7-aeb1-888c34085d4a", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-a460fd69-99f3-46c7-aeb1-888c34085d4a.json", + "headers": { + "Date": "{{now offset='-5 minutes' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4897", + "X-RateLimit-Reset": "{{now offset='-297 seconds' format='unix'}}", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"af0c41afcacb8ceee14b7d896719c3bd\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "E39F:3620:2D9D266:369B909:5D9B9848" + } + }, + "uuid": "a460fd69-99f3-46c7-aeb1-888c34085d4a", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json new file mode 100644 index 0000000000..e57a3a127b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json @@ -0,0 +1,25 @@ +{ + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "url": "https://api.github.com/orgs/github-api-test-org", + "repos_url": "https://api.github.com/orgs/github-api-test-org/repos", + "events_url": "https://api.github.com/orgs/github-api-test-org/events", + "hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks", + "issues_url": "https://api.github.com/orgs/github-api-test-org/issues", + "members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}", + "public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "description": null, + "is_verified": false, + "has_organization_projects": true, + "has_repository_projects": true, + "public_repos": 10, + "public_gists": 0, + "followers": 0, + "following": 0, + "html_url": "https://github.com/github-api-test-org", + "created_at": "2014-05-10T19:39:11Z", + "updated_at": "2015-04-20T00:42:30Z", + "type": "Organization" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json new file mode 100644 index 0000000000..784d00e066 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json @@ -0,0 +1,327 @@ +{ + "id": 206888201, + "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=", + "name": "github-api", + "full_name": "github-api-test-org/github-api", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/github-api", + "description": "Resetting", + "fork": true, + "url": "https://api.github.com/repos/github-api-test-org/github-api", + "forks_url": "https://api.github.com/repos/github-api-test-org/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/github-api/deployments", + "created_at": "2019-09-06T23:26:04Z", + "updated_at": "2019-11-07T22:27:11Z", + "pushed_at": "2019-10-21T22:34:49Z", + "git_url": "git://github.com/github-api-test-org/github-api.git", + "ssh_url": "git@github.com:github-api-test-org/github-api.git", + "clone_url": "https://github.com/github-api-test-org/github-api.git", + "svn_url": "https://github.com/github-api-test-org/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 11391, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-13T17:48:29Z", + "pushed_at": "2019-11-13T17:48:26Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15308, + "stargazers_count": 579, + "watchers_count": 579, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 441, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 55, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 441, + "open_issues": 55, + "watchers": 579, + "default_branch": "master" + }, + "source": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-13T17:48:29Z", + "pushed_at": "2019-11-13T17:48:26Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15308, + "stargazers_count": 579, + "watchers_count": 579, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 441, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 55, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 441, + "open_issues": 55, + "watchers": 579, + "default_branch": "master" + }, + "network_count": 441, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/user-87afc711-0c63-4cc6-96b5-26eb391105de.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/user-87afc711-0c63-4cc6-96b5-26eb391105de.json new file mode 100644 index 0000000000..d41ddd34b1 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/__files/user-87afc711-0c63-4cc6-96b5-26eb391105de.json @@ -0,0 +1,45 @@ +{ + "login": "alexanderrtaylor", + "id": 852179, + "node_id": "MDQ6VXNlcjg1MjE3OQ==", + "avatar_url": "https://avatars0.githubusercontent.com/u/852179?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/alexanderrtaylor", + "html_url": "https://github.com/alexanderrtaylor", + "followers_url": "https://api.github.com/users/alexanderrtaylor/followers", + "following_url": "https://api.github.com/users/alexanderrtaylor/following{/other_user}", + "gists_url": "https://api.github.com/users/alexanderrtaylor/gists{/gist_id}", + "starred_url": "https://api.github.com/users/alexanderrtaylor/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/alexanderrtaylor/subscriptions", + "organizations_url": "https://api.github.com/users/alexanderrtaylor/orgs", + "repos_url": "https://api.github.com/users/alexanderrtaylor/repos", + "events_url": "https://api.github.com/users/alexanderrtaylor/events{/privacy}", + "received_events_url": "https://api.github.com/users/alexanderrtaylor/received_events", + "type": "User", + "site_admin": false, + "name": "Alex Taylor", + "company": "Cloudbees", + "blog": "", + "location": null, + "email": null, + "hireable": null, + "bio": null, + "public_repos": 39, + "public_gists": 1, + "followers": 5, + "following": 0, + "created_at": "2011-06-15T16:35:58Z", + "updated_at": "2019-07-23T14:01:42Z", + "private_gists": 1, + "total_private_repos": 13, + "owned_private_repos": 0, + "disk_usage": 265, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/orgs_github-api-test-org-2-cadf65.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/orgs_github-api-test-org-2-cadf65.json new file mode 100644 index 0000000000..7c7fc05d34 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/orgs_github-api-test-org-2-cadf65.json @@ -0,0 +1,40 @@ +{ + "id": "cadf65cc-4434-4d3a-b4cf-4b1b79272f46", + "name": "orgs_github-api-test-org", + "request": { + "url": "/orgs/github-api-test-org", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "orgs_github-api-test-org-cadf65cc-4434-4d3a-b4cf-4b1b79272f46.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4976", + "X-RateLimit-Reset": "1573678486", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag": "W/\"46db056d052e79900ccf2bffefb0e863\"", + "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F3E5:680D:1B5AF:4044E:5DCC5FBB" + } + }, + "uuid": "cadf65cc-4434-4d3a-b4cf-4b1b79272f46", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api-3-228f03.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api-3-228f03.json new file mode 100644 index 0000000000..3d3853a5b4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api-3-228f03.json @@ -0,0 +1,40 @@ +{ + "id": "228f0322-215d-487e-9132-17bc4c3bf020", + "name": "repos_github-api-test-org_github-api", + "request": { + "url": "/repos/github-api-test-org/github-api", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_github-api-228f0322-215d-487e-9132-17bc4c3bf020.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4975", + "X-RateLimit-Reset": "1573678486", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag": "W/\"30a14752ec6a3eede9a30843cc286a50\"", + "Last-Modified": "Thu, 07 Nov 2019 22:27:11 GMT", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F3E5:680D:1B5B8:4048B:5DCC5FBC" + } + }, + "uuid": "228f0322-215d-487e-9132-17bc4c3bf020", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api_branches_test_nonexistent-4-b14df6.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api_branches_test_nonexistent-4-b14df6.json new file mode 100644 index 0000000000..858f3e25d8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/repos_github-api-test-org_github-api_branches_test_nonexistent-4-b14df6.json @@ -0,0 +1,36 @@ +{ + "id": "b14df6ec-ff32-4838-8b38-934766abd880", + "name": "repos_github-api-test-org_github-api_branches_test_nonexistent", + "request": { + "url": "/repos/github-api-test-org/github-api/branches/test/NonExistent", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"message\":\"Branch not found\",\"documentation_url\":\"https://developer.github.com/v3/repos/branches/#get-branch\"}", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:40 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "404 Not Found", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4974", + "X-RateLimit-Reset": "1573678486", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F3E5:680D:1B5C1:4049C:5DCC5FBC" + } + }, + "uuid": "b14df6ec-ff32-4838-8b38-934766abd880", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/user-1-87afc7.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/user-1-87afc7.json new file mode 100644 index 0000000000..3a4488a2c6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranchNonExistentBut200Status/mappings/user-1-87afc7.json @@ -0,0 +1,40 @@ +{ + "id": "87afc711-0c63-4cc6-96b5-26eb391105de", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-87afc711-0c63-4cc6-96b5-26eb391105de.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 13 Nov 2019 19:55:39 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4978", + "X-RateLimit-Reset": "1573678486", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag": "W/\"38c5719328738c2ec6c612f367ae1b59\"", + "Last-Modified": "Tue, 23 Jul 2019 14:01:42 GMT", + "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F3E5:680D:1B592:40447:5DCC5FBB" + } + }, + "uuid": "87afc711-0c63-4cc6-96b5-26eb391105de", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranch_URLEncoded/mappings/repos_github-api-test-org_github-api_branches_test_urlencode-4-ed8bf5.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranch_URLEncoded/mappings/repos_github-api-test-org_github-api_branches_test_urlencode-4-ed8bf5.json index fd3245a1c7..e554ef80f2 100644 --- a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranch_URLEncoded/mappings/repos_github-api-test-org_github-api_branches_test_urlencode-4-ed8bf5.json +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/getBranch_URLEncoded/mappings/repos_github-api-test-org_github-api_branches_test_urlencode-4-ed8bf5.json @@ -2,7 +2,7 @@ "id": "ed8bf5ba-65e0-47d8-bb4d-614063828c87", "name": "repos_github-api-test-org_github-api_branches_test_urlencode", "request": { - "url": "/repos/github-api-test-org/github-api/branches/test%2F%23UrlEncode", + "url": "/repos/github-api-test-org/github-api/branches/test/%23UrlEncode", "method": "GET" }, "response": { diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/orgs_github-api-test-org-0774979f-2840-46c6-ac31-ea9ebea16a15.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/orgs_github-api-test-org-0774979f-2840-46c6-ac31-ea9ebea16a15.json new file mode 100644 index 0000000000..99b5920ccb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/orgs_github-api-test-org-0774979f-2840-46c6-ac31-ea9ebea16a15.json @@ -0,0 +1,41 @@ +{ + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "url": "https://api.github.com/orgs/github-api-test-org", + "repos_url": "https://api.github.com/orgs/github-api-test-org/repos", + "events_url": "https://api.github.com/orgs/github-api-test-org/events", + "hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks", + "issues_url": "https://api.github.com/orgs/github-api-test-org/issues", + "members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}", + "public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "description": null, + "is_verified": false, + "has_organization_projects": true, + "has_repository_projects": true, + "public_repos": 10, + "public_gists": 0, + "followers": 0, + "following": 0, + "html_url": "https://github.com/github-api-test-org", + "created_at": "2014-05-10T19:39:11Z", + "updated_at": "2015-04-20T00:42:30Z", + "type": "Organization", + "total_private_repos": 0, + "owned_private_repos": 0, + "private_gists": 0, + "disk_usage": 132, + "collaborators": 0, + "billing_email": "kk@kohsuke.org", + "default_repository_permission": "none", + "members_can_create_repositories": false, + "two_factor_requirement_enabled": false, + "plan": { + "name": "free", + "space": 976562499, + "private_repos": 0, + "filled_seats": 7, + "seats": 0 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/repos_github-api-test-org_github-api-6396d3b5-36ad-4990-a691-55a3bca11280.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/repos_github-api-test-org_github-api-6396d3b5-36ad-4990-a691-55a3bca11280.json new file mode 100644 index 0000000000..ce49021e8b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/repos_github-api-test-org_github-api-6396d3b5-36ad-4990-a691-55a3bca11280.json @@ -0,0 +1,330 @@ +{ + "id": 206888201, + "node_id": "MDEwOlJlcG9zaXRvcnkyMDY4ODgyMDE=", + "name": "github-api", + "full_name": "github-api-test-org/github-api", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/github-api", + "description": "Tricky", + "fork": true, + "url": "https://api.github.com/repos/github-api-test-org/github-api", + "forks_url": "https://api.github.com/repos/github-api-test-org/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/github-api/deployments", + "created_at": "2019-09-06T23:26:04Z", + "updated_at": "2019-11-07T05:19:07Z", + "pushed_at": "2019-10-21T22:34:49Z", + "git_url": "git://github.com/github-api-test-org/github-api.git", + "ssh_url": "git@github.com:github-api-test-org/github-api.git", + "clone_url": "https://github.com/github-api-test-org/github-api.git", + "svn_url": "https://github.com/github-api-test-org/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 11391, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-06T12:09:45Z", + "pushed_at": "2019-11-07T04:38:19Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15301, + "stargazers_count": 575, + "watchers_count": 575, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 437, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 60, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 437, + "open_issues": 60, + "watchers": 575, + "default_branch": "master" + }, + "source": { + "id": 617210, + "node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=", + "name": "github-api", + "full_name": "github-api/github-api", + "private": false, + "owner": { + "login": "github-api", + "id": 54909825, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1", + "avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api", + "html_url": "https://github.com/github-api", + "followers_url": "https://api.github.com/users/github-api/followers", + "following_url": "https://api.github.com/users/github-api/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api/subscriptions", + "organizations_url": "https://api.github.com/users/github-api/orgs", + "repos_url": "https://api.github.com/users/github-api/repos", + "events_url": "https://api.github.com/users/github-api/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api/github-api", + "description": "Java API for GitHub", + "fork": false, + "url": "https://api.github.com/repos/github-api/github-api", + "forks_url": "https://api.github.com/repos/github-api/github-api/forks", + "keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api/github-api/teams", + "hooks_url": "https://api.github.com/repos/github-api/github-api/hooks", + "issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api/github-api/events", + "assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api/github-api/tags", + "blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api/github-api/languages", + "stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers", + "contributors_url": "https://api.github.com/repos/github-api/github-api/contributors", + "subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers", + "subscription_url": "https://api.github.com/repos/github-api/github-api/subscription", + "commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api/github-api/merges", + "archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api/github-api/downloads", + "issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api/github-api/deployments", + "created_at": "2010-04-19T04:13:03Z", + "updated_at": "2019-11-06T12:09:45Z", + "pushed_at": "2019-11-07T04:38:19Z", + "git_url": "git://github.com/github-api/github-api.git", + "ssh_url": "git@github.com:github-api/github-api.git", + "clone_url": "https://github.com/github-api/github-api.git", + "svn_url": "https://github.com/github-api/github-api", + "homepage": "http://github-api.kohsuke.org/", + "size": 15301, + "stargazers_count": 575, + "watchers_count": 575, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 437, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 60, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 437, + "open_issues": 60, + "watchers": 575, + "default_branch": "master" + }, + "network_count": 437, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/user-489e213c-810a-407d-b9aa-f7b00cdc8995.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/user-489e213c-810a-407d-b9aa-f7b00cdc8995.json new file mode 100644 index 0000000000..c70bfef17b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/__files/user-489e213c-810a-407d-b9aa-f7b00cdc8995.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 174, + "public_gists": 7, + "followers": 139, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-09-24T19:32:29Z", + "private_gists": 7, + "total_private_repos": 9, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/orgs_github-api-test-org-2-077497.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/orgs_github-api-test-org-2-077497.json new file mode 100644 index 0000000000..167ffc6d40 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/orgs_github-api-test-org-2-077497.json @@ -0,0 +1,43 @@ +{ + "id": "0774979f-2840-46c6-ac31-ea9ebea16a15", + "name": "orgs_github-api-test-org", + "request": { + "url": "/orgs/github-api-test-org", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "orgs_github-api-test-org-0774979f-2840-46c6-ac31-ea9ebea16a15.json", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4934", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"bbee0a14a82ca84871298052e1bcb545\"", + "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF992:2298B7D:5DC3A95E" + } + }, + "uuid": "0774979f-2840-46c6-ac31-ea9ebea16a15", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api-3-6396d3.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api-3-6396d3.json new file mode 100644 index 0000000000..94adf7776d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api-3-6396d3.json @@ -0,0 +1,43 @@ +{ + "id": "6396d3b5-36ad-4990-a691-55a3bca11280", + "name": "repos_github-api-test-org_github-api", + "request": { + "url": "/repos/github-api-test-org/github-api", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_github-api-6396d3b5-36ad-4990-a691-55a3bca11280.json", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4933", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7998c1d58ba95b2e4a1c263537718671\"", + "Last-Modified": "Thu, 07 Nov 2019 05:19:07 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF99E:2298BA4:5DC3A95F" + } + }, + "uuid": "6396d3b5-36ad-4990-a691-55a3bca11280", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-10-d74974.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-10-d74974.json new file mode 100644 index 0000000000..dbaee8f759 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-10-d74974.json @@ -0,0 +1,49 @@ +{ + "id": "d7497474-d02e-4ff8-bd80-d0309cc549ee", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"names\":[]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "body": "{\"names\":[]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:30 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4926", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"df993ad275c898093787f01e3ed7a555\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDFA26:2298C44:5DC3A961" + } + }, + "uuid": "d7497474-d02e-4ff8-bd80-d0309cc549ee", + "persistent": true, + "insertionIndex": 10 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-11-57a970.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-11-57a970.json new file mode 100644 index 0000000000..04a783da84 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-11-57a970.json @@ -0,0 +1,44 @@ +{ + "id": "57a97040-b886-484e-ae11-9274c28a57fa", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"names\":[]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:30 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4925", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"df993ad275c898093787f01e3ed7a555\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDFA4D:2298C66:5DC3A962" + } + }, + "uuid": "57a97040-b886-484e-ae11-9274c28a57fa", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-github-api-topics", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-github-api-topics-4", + "insertionIndex": 11 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-4-e6442e.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-4-e6442e.json new file mode 100644 index 0000000000..afd81a019a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-4-e6442e.json @@ -0,0 +1,49 @@ +{ + "id": "e6442e95-3680-401a-a9e9-722c7cff3a8c", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"names\":[\"java\",\"api-test-dummy\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "body": "{\"names\":[\"java\",\"api-test-dummy\"]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4932", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"ea65e8cf500f844d9fc218733c1732b8\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF9AA:2298BB0:5DC3A95F" + } + }, + "uuid": "e6442e95-3680-401a-a9e9-722c7cff3a8c", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-5-2dc36e.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-5-2dc36e.json new file mode 100644 index 0000000000..89f7bc8afe --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-5-2dc36e.json @@ -0,0 +1,45 @@ +{ + "id": "2dc36e0e-a168-491c-a8f5-4c118c78babd", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"names\":[\"java\",\"api-test-dummy\"]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:28 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4931", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"ea65e8cf500f844d9fc218733c1732b8\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF9BE:2298BC5:5DC3A95F" + } + }, + "uuid": "2dc36e0e-a168-491c-a8f5-4c118c78babd", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-github-api-topics", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-github-api-topics-2", + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-6-83a58f.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-6-83a58f.json new file mode 100644 index 0000000000..273d1ecd27 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-6-83a58f.json @@ -0,0 +1,49 @@ +{ + "id": "83a58ffe-c7c7-40f7-9799-0690e352466f", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"names\":[\"ordered-state\",\"api-test-dummy\",\"java\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "body": "{\"names\":[\"java\",\"api-test-dummy\",\"ordered-state\"]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:28 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4930", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a917b5929ad915f6d77f47f9626ee739\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF9CB:2298BD7:5DC3A960" + } + }, + "uuid": "83a58ffe-c7c7-40f7-9799-0690e352466f", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-7-eed846.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-7-eed846.json new file mode 100644 index 0000000000..c5457405c0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-7-eed846.json @@ -0,0 +1,45 @@ +{ + "id": "eed8467b-8135-4bb0-aa71-e4c7f6c38edc", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"names\":[\"java\",\"api-test-dummy\",\"ordered-state\"]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:28 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4929", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a917b5929ad915f6d77f47f9626ee739\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF9E1:2298BF2:5DC3A960" + } + }, + "uuid": "eed8467b-8135-4bb0-aa71-e4c7f6c38edc", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-github-api-topics", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-github-api-topics-2", + "newScenarioState": "scenario-1-repos-github-api-test-org-github-api-topics-3", + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-8-df3c07.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-8-df3c07.json new file mode 100644 index 0000000000..3277b2e4eb --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-8-df3c07.json @@ -0,0 +1,49 @@ +{ + "id": "df3c075d-0311-4a33-bbc5-bb9146c0eb8c", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "PUT", + "bodyPatterns": [ + { + "equalToJson": "{\"names\":[\"ordered-state\",\"api-test-dummy\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "body": "{\"names\":[\"api-test-dummy\",\"ordered-state\"]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:29 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4928", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7cf11892f99547fa0b0870388bfd00f7\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF9F0:2298C05:5DC3A960" + } + }, + "uuid": "df3c075d-0311-4a33-bbc5-bb9146c0eb8c", + "persistent": true, + "insertionIndex": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-9-6159ab.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-9-6159ab.json new file mode 100644 index 0000000000..0347bc5a3c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/repos_github-api-test-org_github-api_topics-9-6159ab.json @@ -0,0 +1,45 @@ +{ + "id": "6159ab53-1522-4d89-933a-734578f4481a", + "name": "repos_github-api-test-org_github-api_topics", + "request": { + "url": "/repos/github-api-test-org/github-api/topics", + "method": "GET" + }, + "response": { + "status": 200, + "body": "{\"names\":[\"api-test-dummy\",\"ordered-state\"]}", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:29 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4927", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"7cf11892f99547fa0b0870388bfd00f7\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "github.mercy-preview; format=json", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDFA1A:2298C33:5DC3A961" + } + }, + "uuid": "6159ab53-1522-4d89-933a-734578f4481a", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-github-api-topics", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-github-api-topics-3", + "newScenarioState": "scenario-1-repos-github-api-test-org-github-api-topics-4", + "insertionIndex": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/user-1-489e21.json b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/user-1-489e21.json new file mode 100644 index 0000000000..9caeb5b937 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHRepositoryTest/wiremock/testSetTopics/mappings/user-1-489e21.json @@ -0,0 +1,43 @@ +{ + "id": "489e213c-810a-407d-b9aa-f7b00cdc8995", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-489e213c-810a-407d-b9aa-f7b00cdc8995.json", + "headers": { + "Date": "Thu, 07 Nov 2019 05:19:26 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4936", + "X-RateLimit-Reset": "1573107045", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"a789c1045b95bcbfa3f1d935ffbc801c\"", + "Last-Modified": "Tue, 24 Sep 2019 19:32:29 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EE66:9B40:1DDF971:2298B77:5DC3A95E" + } + }, + "uuid": "489e213c-810a-407d-b9aa-f7b00cdc8995", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest-3141cdb7-8380-4ac9-8b69-a83dd419abfc.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest-3141cdb7-8380-4ac9-8b69-a83dd419abfc.json new file mode 100644 index 0000000000..5a154a6a89 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest-3141cdb7-8380-4ac9-8b69-a83dd419abfc.json @@ -0,0 +1,124 @@ +{ + "id": 222874396, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI4NzQzOTY=", + "name": "GHTreeBuilderTest", + "full_name": "sandboxx/GHTreeBuilderTest", + "private": false, + "owner": { + "login": "sandboxx", + "id": 7226712, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjcyMjY3MTI=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7226712?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sandboxx", + "html_url": "https://github.com/sandboxx", + "followers_url": "https://api.github.com/users/sandboxx/followers", + "following_url": "https://api.github.com/users/sandboxx/following{/other_user}", + "gists_url": "https://api.github.com/users/sandboxx/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sandboxx/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sandboxx/subscriptions", + "organizations_url": "https://api.github.com/users/sandboxx/orgs", + "repos_url": "https://api.github.com/users/sandboxx/repos", + "events_url": "https://api.github.com/users/sandboxx/events{/privacy}", + "received_events_url": "https://api.github.com/users/sandboxx/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest", + "forks_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/forks", + "keys_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/teams", + "hooks_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/hooks", + "issue_events_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/issues/events{/number}", + "events_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/events", + "assignees_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/assignees{/user}", + "branches_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/branches{/branch}", + "tags_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/tags", + "blobs_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/statuses/{sha}", + "languages_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/languages", + "stargazers_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/stargazers", + "contributors_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contributors", + "subscribers_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/subscribers", + "subscription_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/subscription", + "commits_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/{+path}", + "compare_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/merges", + "archive_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/downloads", + "issues_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/issues{/number}", + "pulls_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/pulls{/number}", + "milestones_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/milestones{/number}", + "notifications_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/labels{/name}", + "releases_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/releases{/id}", + "deployments_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/deployments", + "created_at": "2019-11-20T07:14:14Z", + "updated_at": "2019-11-20T22:28:18Z", + "pushed_at": "2019-11-20T22:28:16Z", + "git_url": "git://github.com/sandboxx/GHTreeBuilderTest.git", + "ssh_url": "git@github.com:sandboxx/GHTreeBuilderTest.git", + "clone_url": "https://github.com/sandboxx/GHTreeBuilderTest.git", + "svn_url": "https://github.com/sandboxx/GHTreeBuilderTest", + "homepage": null, + "size": 10, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Shell", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "sandboxx", + "id": 7226712, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjcyMjY3MTI=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7226712?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sandboxx", + "html_url": "https://github.com/sandboxx", + "followers_url": "https://api.github.com/users/sandboxx/followers", + "following_url": "https://api.github.com/users/sandboxx/following{/other_user}", + "gists_url": "https://api.github.com/users/sandboxx/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sandboxx/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sandboxx/subscriptions", + "organizations_url": "https://api.github.com/users/sandboxx/orgs", + "repos_url": "https://api.github.com/users/sandboxx/repos", + "events_url": "https://api.github.com/users/sandboxx/events{/privacy}", + "received_events_url": "https://api.github.com/users/sandboxx/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_app_runsh-b4be45dc-29b9-4277-86c2-4c3d2f5a6dde.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_app_runsh-b4be45dc-29b9-4277-86c2-4c3d2f5a6dde.json new file mode 100644 index 0000000000..9cd993cb88 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_app_runsh-b4be45dc-29b9-4277-86c2-4c3d2f5a6dde.json @@ -0,0 +1,18 @@ +{ + "name": "run.sh", + "path": "app/run.sh", + "sha": "e9ba7ba07276a794d493db90e0384940ce2b757b", + "size": 23, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/app/run.sh?ref=master", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/app/run.sh", + "git_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/e9ba7ba07276a794d493db90e0384940ce2b757b", + "download_url": "https://raw.githubusercontent.com/sandboxx/GHTreeBuilderTest/master/app/run.sh", + "type": "file", + "content": "IyEvYmluL2Jhc2gKZWNobyBIZWxsbwo=\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/app/run.sh?ref=master", + "git": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/e9ba7ba07276a794d493db90e0384940ce2b757b", + "html": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/app/run.sh" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-28e82475-8019-411b-b8e6-7608d2696b5a.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-28e82475-8019-411b-b8e6-7608d2696b5a.json new file mode 100644 index 0000000000..ac8156eb7c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-28e82475-8019-411b-b8e6-7608d2696b5a.json @@ -0,0 +1,18 @@ +{ + "name": "val1.dat", + "path": "data/val1.dat", + "sha": "aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "size": 3, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val1.dat?ref=master", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val1.dat", + "git_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "download_url": "https://raw.githubusercontent.com/sandboxx/GHTreeBuilderTest/master/data/val1.dat", + "type": "file", + "content": "AQID\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val1.dat?ref=master", + "git": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "html": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val1.dat" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-3f36235e-a0d2-4503-8b43-b4605097cccc.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-3f36235e-a0d2-4503-8b43-b4605097cccc.json new file mode 100644 index 0000000000..94f936f17f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-3f36235e-a0d2-4503-8b43-b4605097cccc.json @@ -0,0 +1,18 @@ +{ + "name": "val2.dat", + "path": "data/val2.dat", + "sha": "5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "size": 4, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val2.dat?ref=master", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val2.dat", + "git_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "download_url": "https://raw.githubusercontent.com/sandboxx/GHTreeBuilderTest/master/data/val2.dat", + "type": "file", + "content": "BAUGBw==\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val2.dat?ref=master", + "git": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "html": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val2.dat" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt-dccdb6e5-9343-48a2-ba57-3c699ad0c2a9.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt-dccdb6e5-9343-48a2-ba57-3c699ad0c2a9.json new file mode 100644 index 0000000000..0afc99196a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt-dccdb6e5-9343-48a2-ba57-3c699ad0c2a9.json @@ -0,0 +1,18 @@ +{ + "name": "readme.txt", + "path": "doc/readme.txt", + "sha": "fbbc875b17d1e17da06b4ee8fda46e2596c41f3c", + "size": 34, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/doc/readme.txt?ref=master", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/doc/readme.txt", + "git_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/fbbc875b17d1e17da06b4ee8fda46e2596c41f3c", + "download_url": "https://raw.githubusercontent.com/sandboxx/GHTreeBuilderTest/master/doc/readme.txt", + "type": "file", + "content": "VGhhbmtzIGZvciB1c2luZyBvdXIgYXBwbGljYXRpb24hCg==\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/doc/readme.txt?ref=master", + "git": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/fbbc875b17d1e17da06b4ee8fda46e2596c41f3c", + "html": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/doc/readme.txt" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_commits-8bc63891-9ab6-400c-8e56-3d6341321ad5.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_commits-8bc63891-9ab6-400c-8e56-3d6341321ad5.json new file mode 100644 index 0000000000..a275d96d9e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_commits-8bc63891-9ab6-400c-8e56-3d6341321ad5.json @@ -0,0 +1,34 @@ +{ + "sha": "c2066e756eb2185ed12419f790af4375c8b91e7b", + "node_id": "MDY6Q29tbWl0MjIyODc0Mzk2OmMyMDY2ZTc1NmViMjE4NWVkMTI0MTlmNzkwYWY0Mzc1YzhiOTFlN2I=", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/c2066e756eb2185ed12419f790af4375c8b91e7b", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/commit/c2066e756eb2185ed12419f790af4375c8b91e7b", + "author": { + "name": "Serban Iordache", + "email": "iordache@hotmail.com", + "date": "2019-11-20T22:34:55Z" + }, + "committer": { + "name": "Serban Iordache", + "email": "iordache@hotmail.com", + "date": "2019-11-20T22:34:55Z" + }, + "tree": { + "sha": "b09a1698f3aeb1d462c3492007760e2579734c74", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/b09a1698f3aeb1d462c3492007760e2579734c74" + }, + "message": "Add files", + "parents": [ + { + "sha": "737e00d471104660a7e8177fd5deb58fc46bbbec", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/737e00d471104660a7e8177fd5deb58fc46bbbec", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/commit/737e00d471104660a7e8177fd5deb58fc46bbbec" + } + ], + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-94235700-4c9d-4f6a-8e8d-086accc7c1ae.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-94235700-4c9d-4f6a-8e8d-086accc7c1ae.json new file mode 100644 index 0000000000..d7f1c18dea --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-94235700-4c9d-4f6a-8e8d-086accc7c1ae.json @@ -0,0 +1,10 @@ +{ + "ref": "refs/heads/master", + "node_id": "MDM6UmVmMjIyODc0Mzk2Om1hc3Rlcg==", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "object": { + "sha": "c2066e756eb2185ed12419f790af4375c8b91e7b", + "type": "commit", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/c2066e756eb2185ed12419f790af4375c8b91e7b" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-b289fa26-22c8-425e-9415-a4df170ba914.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-b289fa26-22c8-425e-9415-a4df170ba914.json new file mode 100644 index 0000000000..d9072b5ad8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-b289fa26-22c8-425e-9415-a4df170ba914.json @@ -0,0 +1,10 @@ +{ + "ref": "refs/heads/master", + "node_id": "MDM6UmVmMjIyODc0Mzk2Om1hc3Rlcg==", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "object": { + "sha": "737e00d471104660a7e8177fd5deb58fc46bbbec", + "type": "commit", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/737e00d471104660a7e8177fd5deb58fc46bbbec" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_trees-ca576479-28d9-4c2d-8ecb-743fc3cce5c5.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_trees-ca576479-28d9-4c2d-8ecb-743fc3cce5c5.json new file mode 100644 index 0000000000..749fa9fcef --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_trees-ca576479-28d9-4c2d-8ecb-743fc3cce5c5.json @@ -0,0 +1,36 @@ +{ + "sha": "b09a1698f3aeb1d462c3492007760e2579734c74", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/b09a1698f3aeb1d462c3492007760e2579734c74", + "tree": [ + { + "path": "README.md", + "mode": "100644", + "type": "blob", + "sha": "958337fe1f522a58e5e7098cc61a2917db1c9643", + "size": 19, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/958337fe1f522a58e5e7098cc61a2917db1c9643" + }, + { + "path": "app", + "mode": "040000", + "type": "tree", + "sha": "710159eba36105e7d2257b282b9bdc8e3f337f16", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/710159eba36105e7d2257b282b9bdc8e3f337f16" + }, + { + "path": "data", + "mode": "040000", + "type": "tree", + "sha": "d872fa75a4eb3747d627d4b355887e2285ae5603", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/d872fa75a4eb3747d627d4b355887e2285ae5603" + }, + { + "path": "doc", + "mode": "040000", + "type": "tree", + "sha": "30bda54e864ecafd021698ddf75bb9378dd755e5", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/30bda54e864ecafd021698ddf75bb9378dd755e5" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_trees_master-f5388f1c-ce2e-477d-a2d3-7db5b5403871.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_trees_master-f5388f1c-ce2e-477d-a2d3-7db5b5403871.json new file mode 100644 index 0000000000..60f07ef09b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/repos_sandboxx_ghtreebuildertest_git_trees_master-f5388f1c-ce2e-477d-a2d3-7db5b5403871.json @@ -0,0 +1,68 @@ +{ + "sha": "737e00d471104660a7e8177fd5deb58fc46bbbec", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/737e00d471104660a7e8177fd5deb58fc46bbbec", + "tree": [ + { + "path": "README.md", + "mode": "100644", + "type": "blob", + "sha": "958337fe1f522a58e5e7098cc61a2917db1c9643", + "size": 19, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/958337fe1f522a58e5e7098cc61a2917db1c9643" + }, + { + "path": "app", + "mode": "040000", + "type": "tree", + "sha": "710159eba36105e7d2257b282b9bdc8e3f337f16", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/710159eba36105e7d2257b282b9bdc8e3f337f16" + }, + { + "path": "app/run.sh", + "mode": "100755", + "type": "blob", + "sha": "e9ba7ba07276a794d493db90e0384940ce2b757b", + "size": 23, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/e9ba7ba07276a794d493db90e0384940ce2b757b" + }, + { + "path": "data", + "mode": "040000", + "type": "tree", + "sha": "d872fa75a4eb3747d627d4b355887e2285ae5603", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/d872fa75a4eb3747d627d4b355887e2285ae5603" + }, + { + "path": "data/val1.dat", + "mode": "100644", + "type": "blob", + "sha": "aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "size": 3, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74" + }, + { + "path": "data/val2.dat", + "mode": "100644", + "type": "blob", + "sha": "5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "size": 4, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817" + }, + { + "path": "doc", + "mode": "040000", + "type": "tree", + "sha": "30bda54e864ecafd021698ddf75bb9378dd755e5", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/30bda54e864ecafd021698ddf75bb9378dd755e5" + }, + { + "path": "doc/readme.txt", + "mode": "100644", + "type": "blob", + "sha": "fbbc875b17d1e17da06b4ee8fda46e2596c41f3c", + "size": 34, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/fbbc875b17d1e17da06b4ee8fda46e2596c41f3c" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/user-b274914f-f936-424a-8f43-e2ce99db089e.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/user-b274914f-f936-424a-8f43-e2ce99db089e.json new file mode 100644 index 0000000000..74334d1cc5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/__files/user-b274914f-f936-424a-8f43-e2ce99db089e.json @@ -0,0 +1,33 @@ +{ + "login": "siordache", + "id": 1158863, + "node_id": "MDQ6VXNlcjExNTg4NjM=", + "avatar_url": "https://avatars1.githubusercontent.com/u/1158863?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/siordache", + "html_url": "https://github.com/siordache", + "followers_url": "https://api.github.com/users/siordache/followers", + "following_url": "https://api.github.com/users/siordache/following{/other_user}", + "gists_url": "https://api.github.com/users/siordache/gists{/gist_id}", + "starred_url": "https://api.github.com/users/siordache/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/siordache/subscriptions", + "organizations_url": "https://api.github.com/users/siordache/orgs", + "repos_url": "https://api.github.com/users/siordache/repos", + "events_url": "https://api.github.com/users/siordache/events{/privacy}", + "received_events_url": "https://api.github.com/users/siordache/received_events", + "type": "User", + "site_admin": false, + "name": "Serban Iordache", + "company": null, + "blog": "https://beryx.org", + "location": "Bonn, Germany", + "email": null, + "hireable": null, + "bio": null, + "public_repos": 0, + "public_gists": 11, + "followers": 12, + "following": 9, + "created_at": "2011-10-28T23:00:26Z", + "updated_at": "2019-10-03T16:12:56Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest-2-3141cd.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest-2-3141cd.json new file mode 100644 index 0000000000..ebea0f7279 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest-2-3141cd.json @@ -0,0 +1,43 @@ +{ + "id": "3141cdb7-8380-4ac9-8b69-a83dd419abfc", + "name": "repos_sandboxx_ghtreebuildertest", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest-3141cdb7-8380-4ac9-8b69-a83dd419abfc.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:52 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4715", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"fecff15f20feef5bf1374acb97566d99\"", + "Last-Modified": "Wed, 20 Nov 2019 22:28:18 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6D734:473BE61:5DD5BF8B" + } + }, + "uuid": "3141cdb7-8380-4ac9-8b69-a83dd419abfc", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_app_runsh-12-b4be45.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_app_runsh-12-b4be45.json new file mode 100644 index 0000000000..d32449f292 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_app_runsh-12-b4be45.json @@ -0,0 +1,43 @@ +{ + "id": "b4be45dc-29b9-4277-86c2-4c3d2f5a6dde", + "name": "repos_sandboxx_ghtreebuildertest_contents_app_runsh", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/contents/app/run.sh", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_contents_app_runsh-b4be45dc-29b9-4277-86c2-4c3d2f5a6dde.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:56 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4705", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"e9ba7ba07276a794d493db90e0384940ce2b757b\"", + "Last-Modified": "Wed, 20 Nov 2019 22:34:55 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DDA9:473C7F3:5DD5BF90" + } + }, + "uuid": "b4be45dc-29b9-4277-86c2-4c3d2f5a6dde", + "persistent": true, + "insertionIndex": 12 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-14-28e824.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-14-28e824.json new file mode 100644 index 0000000000..d325463769 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-14-28e824.json @@ -0,0 +1,43 @@ +{ + "id": "28e82475-8019-411b-b8e6-7608d2696b5a", + "name": "repos_sandboxx_ghtreebuildertest_contents_data_val1dat", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/contents/data/val1.dat", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_contents_data_val1dat-28e82475-8019-411b-b8e6-7608d2696b5a.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:57 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4703", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\"", + "Last-Modified": "Wed, 20 Nov 2019 22:34:55 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DE7F:473C8F2:5DD5BF91" + } + }, + "uuid": "28e82475-8019-411b-b8e6-7608d2696b5a", + "persistent": true, + "insertionIndex": 14 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-15-3f3623.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-15-3f3623.json new file mode 100644 index 0000000000..4e072972d5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-15-3f3623.json @@ -0,0 +1,43 @@ +{ + "id": "3f36235e-a0d2-4503-8b43-b4605097cccc", + "name": "repos_sandboxx_ghtreebuildertest_contents_data_val2dat", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/contents/data/val2.dat", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_contents_data_val2dat-3f36235e-a0d2-4503-8b43-b4605097cccc.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:57 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4702", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"5bd8bb897b13225c93a1d26baa88c96b7bd5d817\"", + "Last-Modified": "Wed, 20 Nov 2019 22:34:55 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DEE8:473C963:5DD5BF91" + } + }, + "uuid": "3f36235e-a0d2-4503-8b43-b4605097cccc", + "persistent": true, + "insertionIndex": 15 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt-13-dccdb6.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt-13-dccdb6.json new file mode 100644 index 0000000000..63c6ec09e5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt-13-dccdb6.json @@ -0,0 +1,43 @@ +{ + "id": "dccdb6e5-9343-48a2-ba57-3c699ad0c2a9", + "name": "repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/contents/doc/readme.txt", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_contents_doc_readmetxt-dccdb6e5-9343-48a2-ba57-3c699ad0c2a9.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:57 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4704", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"fbbc875b17d1e17da06b4ee8fda46e2596c41f3c\"", + "Last-Modified": "Wed, 20 Nov 2019 22:34:55 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DE29:473C87F:5DD5BF90" + } + }, + "uuid": "dccdb6e5-9343-48a2-ba57-3c699ad0c2a9", + "persistent": true, + "insertionIndex": 13 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-5-ea9e4f.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-5-ea9e4f.json new file mode 100644 index 0000000000..f4c93f253b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-5-ea9e4f.json @@ -0,0 +1,50 @@ +{ + "id": "ea9e4f5e-4a10-41d1-8ed3-749ea8cca9e3", + "name": "repos_sandboxx_ghtreebuildertest_git_blobs", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/blobs", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"encoding\":\"base64\",\"content\":\"IyEvYmluL2Jhc2gKZWNobyBIZWxsbwo=\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "body": "{\"sha\":\"e9ba7ba07276a794d493db90e0384940ce2b757b\",\"url\":\"https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/e9ba7ba07276a794d493db90e0384940ce2b757b\"}", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:53 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4712", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"f80ff7160573e37d360284243aaa5ff1\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/e9ba7ba07276a794d493db90e0384940ce2b757b", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6D855:473C1BC:5DD5BF8D" + } + }, + "uuid": "ea9e4f5e-4a10-41d1-8ed3-749ea8cca9e3", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-6-2c952c.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-6-2c952c.json new file mode 100644 index 0000000000..c332bbe45d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-6-2c952c.json @@ -0,0 +1,50 @@ +{ + "id": "2c952cd9-a3bd-4ec0-bb20-9a5b3ba75925", + "name": "repos_sandboxx_ghtreebuildertest_git_blobs", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/blobs", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"encoding\":\"base64\",\"content\":\"VGhhbmtzIGZvciB1c2luZyBvdXIgYXBwbGljYXRpb24hCg==\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "body": "{\"sha\":\"fbbc875b17d1e17da06b4ee8fda46e2596c41f3c\",\"url\":\"https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/fbbc875b17d1e17da06b4ee8fda46e2596c41f3c\"}", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:54 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4711", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"740cb5b52bc136124875e9c2ee4a7b8b\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/fbbc875b17d1e17da06b4ee8fda46e2596c41f3c", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6D8E0:473C265:5DD5BF8D" + } + }, + "uuid": "2c952cd9-a3bd-4ec0-bb20-9a5b3ba75925", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-7-8650c5.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-7-8650c5.json new file mode 100644 index 0000000000..37f6149340 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-7-8650c5.json @@ -0,0 +1,50 @@ +{ + "id": "8650c55c-fb8e-40a2-b71e-77605e53d5aa", + "name": "repos_sandboxx_ghtreebuildertest_git_blobs", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/blobs", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"encoding\":\"base64\",\"content\":\"AQID\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "body": "{\"sha\":\"aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\",\"url\":\"https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\"}", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:54 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4710", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"1aab18e796329a5c589e9b4bd3c4a535\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6D9D0:473C37B:5DD5BF8E" + } + }, + "uuid": "8650c55c-fb8e-40a2-b71e-77605e53d5aa", + "persistent": true, + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-8-91c550.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-8-91c550.json new file mode 100644 index 0000000000..80a387da39 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-8-91c550.json @@ -0,0 +1,50 @@ +{ + "id": "91c55034-8227-45cb-b751-e2b38a4d5640", + "name": "repos_sandboxx_ghtreebuildertest_git_blobs", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/blobs", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"encoding\":\"base64\",\"content\":\"BAUGBw==\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "body": "{\"sha\":\"5bd8bb897b13225c93a1d26baa88c96b7bd5d817\",\"url\":\"https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817\"}", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:54 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4709", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"507659676883bfb2fa1248dea0630607\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DA51:473C407:5DD5BF8E" + } + }, + "uuid": "91c55034-8227-45cb-b751-e2b38a4d5640", + "persistent": true, + "insertionIndex": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_commits-10-8bc638.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_commits-10-8bc638.json new file mode 100644 index 0000000000..a2a5dce933 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_commits-10-8bc638.json @@ -0,0 +1,50 @@ +{ + "id": "8bc63891-9ab6-400c-8e56-3d6341321ad5", + "name": "repos_sandboxx_ghtreebuildertest_git_commits", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/commits", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"tree\":\"b09a1698f3aeb1d462c3492007760e2579734c74\",\"message\":\"Add files\",\"parents\":[\"737e00d471104660a7e8177fd5deb58fc46bbbec\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_commits-8bc63891-9ab6-400c-8e56-3d6341321ad5.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:55 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4707", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"9f4c2f913d0329e7d30b95700ad8b557\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/c2066e756eb2185ed12419f790af4375c8b91e7b", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DB69:473C557:5DD5BF8F" + } + }, + "uuid": "8bc63891-9ab6-400c-8e56-3d6341321ad5", + "persistent": true, + "insertionIndex": 10 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-11-942357.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-11-942357.json new file mode 100644 index 0000000000..fa16b3049d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-11-942357.json @@ -0,0 +1,49 @@ +{ + "id": "94235700-4c9d-4f6a-8e8d-086accc7c1ae", + "name": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "method": "PATCH", + "bodyPatterns": [ + { + "equalToJson": "{\"force\":false,\"sha\":\"c2066e756eb2185ed12419f790af4375c8b91e7b\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master-94235700-4c9d-4f6a-8e8d-086accc7c1ae.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:56 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4706", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"ad6fda806e5fe0c31d7fbab5ef478ca3\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DC73:473C687:5DD5BF8F" + } + }, + "uuid": "94235700-4c9d-4f6a-8e8d-086accc7c1ae", + "persistent": true, + "insertionIndex": 11 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-3-b289fa.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-3-b289fa.json new file mode 100644 index 0000000000..8585e5107f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-3-b289fa.json @@ -0,0 +1,44 @@ +{ + "id": "b289fa26-22c8-425e-9415-a4df170ba914", + "name": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master-b289fa26-22c8-425e-9415-a4df170ba914.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:52 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4714", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"18accc45906d96acc177c075f8b2abe2\"", + "Last-Modified": "Wed, 20 Nov 2019 22:28:18 GMT", + "X-Poll-Interval": "300", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6D7A2:473C0E3:5DD5BF8C" + } + }, + "uuid": "b289fa26-22c8-425e-9415-a4df170ba914", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_trees-9-ca5764.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_trees-9-ca5764.json new file mode 100644 index 0000000000..a06c36551e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_trees-9-ca5764.json @@ -0,0 +1,50 @@ +{ + "id": "ca576479-28d9-4c2d-8ecb-743fc3cce5c5", + "name": "repos_sandboxx_ghtreebuildertest_git_trees", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/trees", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"base_tree\":\"737e00d471104660a7e8177fd5deb58fc46bbbec\",\"tree\":[{\"path\":\"app/run.sh\",\"mode\":\"100755\",\"type\":\"blob\",\"sha\":\"e9ba7ba07276a794d493db90e0384940ce2b757b\",\"content\":null},{\"path\":\"doc/readme.txt\",\"mode\":\"100644\",\"type\":\"blob\",\"sha\":\"fbbc875b17d1e17da06b4ee8fda46e2596c41f3c\",\"content\":null},{\"path\":\"data/val1.dat\",\"mode\":\"100644\",\"type\":\"blob\",\"sha\":\"aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\",\"content\":null},{\"path\":\"data/val2.dat\",\"mode\":\"100644\",\"type\":\"blob\",\"sha\":\"5bd8bb897b13225c93a1d26baa88c96b7bd5d817\",\"content\":null}]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_trees-ca576479-28d9-4c2d-8ecb-743fc3cce5c5.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:55 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4708", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"92cf0d1a217625c7fe445408ddf2b0d6\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/b09a1698f3aeb1d462c3492007760e2579734c74", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6DADC:473C49F:5DD5BF8E" + } + }, + "uuid": "ca576479-28d9-4c2d-8ecb-743fc3cce5c5", + "persistent": true, + "insertionIndex": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_trees_master-4-f5388f.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_trees_master-4-f5388f.json new file mode 100644 index 0000000000..95112a8e5a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/repos_sandboxx_ghtreebuildertest_git_trees_master-4-f5388f.json @@ -0,0 +1,43 @@ +{ + "id": "f5388f1c-ce2e-477d-a2d3-7db5b5403871", + "name": "repos_sandboxx_ghtreebuildertest_git_trees_master", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/trees/master?recursive=1", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_trees_master-f5388f1c-ce2e-477d-a2d3-7db5b5403871.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:53 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4713", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"6bb65715be2246ab8e33e0a557c0621a\"", + "Last-Modified": "Wed, 20 Nov 2019 22:28:18 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6D805:473C15A:5DD5BF8C" + } + }, + "uuid": "f5388f1c-ce2e-477d-a2d3-7db5b5403871", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/user-1-b27491.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/user-1-b27491.json new file mode 100644 index 0000000000..b53c5ba7ca --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testAdd/mappings/user-1-b27491.json @@ -0,0 +1,43 @@ +{ + "id": "b274914f-f936-424a-8f43-e2ce99db089e", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-b274914f-f936-424a-8f43-e2ce99db089e.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:51 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4717", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"034648c48243ad5329d74005351432a0\"", + "Last-Modified": "Thu, 03 Oct 2019 16:12:56 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6ED:87DD:3B6D516:473BE1A:5DD5BF8A" + } + }, + "uuid": "b274914f-f936-424a-8f43-e2ce99db089e", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest-c4c87cb2-e534-42ee-a265-707089fd382f.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest-c4c87cb2-e534-42ee-a265-707089fd382f.json new file mode 100644 index 0000000000..48399b7e91 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest-c4c87cb2-e534-42ee-a265-707089fd382f.json @@ -0,0 +1,124 @@ +{ + "id": 222874396, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjI4NzQzOTY=", + "name": "GHTreeBuilderTest", + "full_name": "sandboxx/GHTreeBuilderTest", + "private": false, + "owner": { + "login": "sandboxx", + "id": 7226712, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjcyMjY3MTI=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7226712?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sandboxx", + "html_url": "https://github.com/sandboxx", + "followers_url": "https://api.github.com/users/sandboxx/followers", + "following_url": "https://api.github.com/users/sandboxx/following{/other_user}", + "gists_url": "https://api.github.com/users/sandboxx/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sandboxx/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sandboxx/subscriptions", + "organizations_url": "https://api.github.com/users/sandboxx/orgs", + "repos_url": "https://api.github.com/users/sandboxx/repos", + "events_url": "https://api.github.com/users/sandboxx/events{/privacy}", + "received_events_url": "https://api.github.com/users/sandboxx/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest", + "forks_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/forks", + "keys_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/teams", + "hooks_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/hooks", + "issue_events_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/issues/events{/number}", + "events_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/events", + "assignees_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/assignees{/user}", + "branches_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/branches{/branch}", + "tags_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/tags", + "blobs_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/statuses/{sha}", + "languages_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/languages", + "stargazers_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/stargazers", + "contributors_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contributors", + "subscribers_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/subscribers", + "subscription_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/subscription", + "commits_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/{+path}", + "compare_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/merges", + "archive_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/downloads", + "issues_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/issues{/number}", + "pulls_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/pulls{/number}", + "milestones_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/milestones{/number}", + "notifications_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/labels{/name}", + "releases_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/releases{/id}", + "deployments_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/deployments", + "created_at": "2019-11-20T07:14:14Z", + "updated_at": "2019-11-20T22:34:58Z", + "pushed_at": "2019-11-20T22:34:56Z", + "git_url": "git://github.com/sandboxx/GHTreeBuilderTest.git", + "ssh_url": "git@github.com:sandboxx/GHTreeBuilderTest.git", + "clone_url": "https://github.com/sandboxx/GHTreeBuilderTest.git", + "svn_url": "https://github.com/sandboxx/GHTreeBuilderTest", + "homepage": null, + "size": 10, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Shell", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "sandboxx", + "id": 7226712, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjcyMjY3MTI=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7226712?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sandboxx", + "html_url": "https://github.com/sandboxx", + "followers_url": "https://api.github.com/users/sandboxx/followers", + "following_url": "https://api.github.com/users/sandboxx/following{/other_user}", + "gists_url": "https://api.github.com/users/sandboxx/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sandboxx/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sandboxx/subscriptions", + "organizations_url": "https://api.github.com/users/sandboxx/orgs", + "repos_url": "https://api.github.com/users/sandboxx/repos", + "events_url": "https://api.github.com/users/sandboxx/events{/privacy}", + "received_events_url": "https://api.github.com/users/sandboxx/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-fce51658-4eef-4dca-a01f-8294f3aea064.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-fce51658-4eef-4dca-a01f-8294f3aea064.json new file mode 100644 index 0000000000..ac8156eb7c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-fce51658-4eef-4dca-a01f-8294f3aea064.json @@ -0,0 +1,18 @@ +{ + "name": "val1.dat", + "path": "data/val1.dat", + "sha": "aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "size": 3, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val1.dat?ref=master", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val1.dat", + "git_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "download_url": "https://raw.githubusercontent.com/sandboxx/GHTreeBuilderTest/master/data/val1.dat", + "type": "file", + "content": "AQID\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val1.dat?ref=master", + "git": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "html": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val1.dat" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-1c94ff2b-4511-44a0-b99a-774dc2258930.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-1c94ff2b-4511-44a0-b99a-774dc2258930.json new file mode 100644 index 0000000000..94f936f17f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-1c94ff2b-4511-44a0-b99a-774dc2258930.json @@ -0,0 +1,18 @@ +{ + "name": "val2.dat", + "path": "data/val2.dat", + "sha": "5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "size": 4, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val2.dat?ref=master", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val2.dat", + "git_url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "download_url": "https://raw.githubusercontent.com/sandboxx/GHTreeBuilderTest/master/data/val2.dat", + "type": "file", + "content": "BAUGBw==\n", + "encoding": "base64", + "_links": { + "self": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/contents/data/val2.dat?ref=master", + "git": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "html": "https://github.com/sandboxx/GHTreeBuilderTest/blob/master/data/val2.dat" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_commits-29661c59-1d26-4d1d-88ce-59bc36a8c9e6.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_commits-29661c59-1d26-4d1d-88ce-59bc36a8c9e6.json new file mode 100644 index 0000000000..9e018d4ad4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_commits-29661c59-1d26-4d1d-88ce-59bc36a8c9e6.json @@ -0,0 +1,34 @@ +{ + "sha": "450446ed2e0bcd2074ca54c0060e0a4b88d34aca", + "node_id": "MDY6Q29tbWl0MjIyODc0Mzk2OjQ1MDQ0NmVkMmUwYmNkMjA3NGNhNTRjMDA2MGUwYTRiODhkMzRhY2E=", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/450446ed2e0bcd2074ca54c0060e0a4b88d34aca", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/commit/450446ed2e0bcd2074ca54c0060e0a4b88d34aca", + "author": { + "name": "Serban Iordache", + "email": "iordache@hotmail.com", + "date": "2019-11-20T22:35:02Z" + }, + "committer": { + "name": "Serban Iordache", + "email": "iordache@hotmail.com", + "date": "2019-11-20T22:35:02Z" + }, + "tree": { + "sha": "b09a1698f3aeb1d462c3492007760e2579734c74", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/b09a1698f3aeb1d462c3492007760e2579734c74" + }, + "message": "Add files", + "parents": [ + { + "sha": "c2066e756eb2185ed12419f790af4375c8b91e7b", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/c2066e756eb2185ed12419f790af4375c8b91e7b", + "html_url": "https://github.com/sandboxx/GHTreeBuilderTest/commit/c2066e756eb2185ed12419f790af4375c8b91e7b" + } + ], + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-6d634ae7-130f-4165-93f7-d39de13e13a3.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-6d634ae7-130f-4165-93f7-d39de13e13a3.json new file mode 100644 index 0000000000..d7f1c18dea --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-6d634ae7-130f-4165-93f7-d39de13e13a3.json @@ -0,0 +1,10 @@ +{ + "ref": "refs/heads/master", + "node_id": "MDM6UmVmMjIyODc0Mzk2Om1hc3Rlcg==", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "object": { + "sha": "c2066e756eb2185ed12419f790af4375c8b91e7b", + "type": "commit", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/c2066e756eb2185ed12419f790af4375c8b91e7b" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-9f6c9be9-f494-4986-ac09-541270d2f047.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-9f6c9be9-f494-4986-ac09-541270d2f047.json new file mode 100644 index 0000000000..ab0d285722 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-9f6c9be9-f494-4986-ac09-541270d2f047.json @@ -0,0 +1,10 @@ +{ + "ref": "refs/heads/master", + "node_id": "MDM6UmVmMjIyODc0Mzk2Om1hc3Rlcg==", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "object": { + "sha": "450446ed2e0bcd2074ca54c0060e0a4b88d34aca", + "type": "commit", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/450446ed2e0bcd2074ca54c0060e0a4b88d34aca" + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_trees-1c90d00b-61e3-4e1b-ad2d-f184bdd2f766.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_trees-1c90d00b-61e3-4e1b-ad2d-f184bdd2f766.json new file mode 100644 index 0000000000..749fa9fcef --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_trees-1c90d00b-61e3-4e1b-ad2d-f184bdd2f766.json @@ -0,0 +1,36 @@ +{ + "sha": "b09a1698f3aeb1d462c3492007760e2579734c74", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/b09a1698f3aeb1d462c3492007760e2579734c74", + "tree": [ + { + "path": "README.md", + "mode": "100644", + "type": "blob", + "sha": "958337fe1f522a58e5e7098cc61a2917db1c9643", + "size": 19, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/958337fe1f522a58e5e7098cc61a2917db1c9643" + }, + { + "path": "app", + "mode": "040000", + "type": "tree", + "sha": "710159eba36105e7d2257b282b9bdc8e3f337f16", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/710159eba36105e7d2257b282b9bdc8e3f337f16" + }, + { + "path": "data", + "mode": "040000", + "type": "tree", + "sha": "d872fa75a4eb3747d627d4b355887e2285ae5603", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/d872fa75a4eb3747d627d4b355887e2285ae5603" + }, + { + "path": "doc", + "mode": "040000", + "type": "tree", + "sha": "30bda54e864ecafd021698ddf75bb9378dd755e5", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/30bda54e864ecafd021698ddf75bb9378dd755e5" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_trees_master-94505509-cb10-428c-afa6-8b680402568b.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_trees_master-94505509-cb10-428c-afa6-8b680402568b.json new file mode 100644 index 0000000000..c29ca883ab --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/repos_sandboxx_ghtreebuildertest_git_trees_master-94505509-cb10-428c-afa6-8b680402568b.json @@ -0,0 +1,68 @@ +{ + "sha": "c2066e756eb2185ed12419f790af4375c8b91e7b", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/c2066e756eb2185ed12419f790af4375c8b91e7b", + "tree": [ + { + "path": "README.md", + "mode": "100644", + "type": "blob", + "sha": "958337fe1f522a58e5e7098cc61a2917db1c9643", + "size": 19, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/958337fe1f522a58e5e7098cc61a2917db1c9643" + }, + { + "path": "app", + "mode": "040000", + "type": "tree", + "sha": "710159eba36105e7d2257b282b9bdc8e3f337f16", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/710159eba36105e7d2257b282b9bdc8e3f337f16" + }, + { + "path": "app/run.sh", + "mode": "100755", + "type": "blob", + "sha": "e9ba7ba07276a794d493db90e0384940ce2b757b", + "size": 23, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/e9ba7ba07276a794d493db90e0384940ce2b757b" + }, + { + "path": "data", + "mode": "040000", + "type": "tree", + "sha": "d872fa75a4eb3747d627d4b355887e2285ae5603", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/d872fa75a4eb3747d627d4b355887e2285ae5603" + }, + { + "path": "data/val1.dat", + "mode": "100644", + "type": "blob", + "sha": "aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "size": 3, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74" + }, + { + "path": "data/val2.dat", + "mode": "100644", + "type": "blob", + "sha": "5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "size": 4, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817" + }, + { + "path": "doc", + "mode": "040000", + "type": "tree", + "sha": "30bda54e864ecafd021698ddf75bb9378dd755e5", + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/30bda54e864ecafd021698ddf75bb9378dd755e5" + }, + { + "path": "doc/readme.txt", + "mode": "100644", + "type": "blob", + "sha": "fbbc875b17d1e17da06b4ee8fda46e2596c41f3c", + "size": 34, + "url": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/fbbc875b17d1e17da06b4ee8fda46e2596c41f3c" + } + ], + "truncated": false +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/user-1c35124b-49f8-4c65-a0eb-a3e807cfb4f4.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/user-1c35124b-49f8-4c65-a0eb-a3e807cfb4f4.json new file mode 100644 index 0000000000..74334d1cc5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/__files/user-1c35124b-49f8-4c65-a0eb-a3e807cfb4f4.json @@ -0,0 +1,33 @@ +{ + "login": "siordache", + "id": 1158863, + "node_id": "MDQ6VXNlcjExNTg4NjM=", + "avatar_url": "https://avatars1.githubusercontent.com/u/1158863?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/siordache", + "html_url": "https://github.com/siordache", + "followers_url": "https://api.github.com/users/siordache/followers", + "following_url": "https://api.github.com/users/siordache/following{/other_user}", + "gists_url": "https://api.github.com/users/siordache/gists{/gist_id}", + "starred_url": "https://api.github.com/users/siordache/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/siordache/subscriptions", + "organizations_url": "https://api.github.com/users/siordache/orgs", + "repos_url": "https://api.github.com/users/siordache/repos", + "events_url": "https://api.github.com/users/siordache/events{/privacy}", + "received_events_url": "https://api.github.com/users/siordache/received_events", + "type": "User", + "site_admin": false, + "name": "Serban Iordache", + "company": null, + "blog": "https://beryx.org", + "location": "Bonn, Germany", + "email": null, + "hireable": null, + "bio": null, + "public_repos": 0, + "public_gists": 11, + "followers": 12, + "following": 9, + "created_at": "2011-10-28T23:00:26Z", + "updated_at": "2019-10-03T16:12:56Z" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest-2-c4c87c.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest-2-c4c87c.json new file mode 100644 index 0000000000..15fd09698f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest-2-c4c87c.json @@ -0,0 +1,43 @@ +{ + "id": "c4c87cb2-e534-42ee-a265-707089fd382f", + "name": "repos_sandboxx_ghtreebuildertest", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest-c4c87cb2-e534-42ee-a265-707089fd382f.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4699", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"1a96bb0f20676f0b09795bc85a68b804\"", + "Last-Modified": "Wed, 20 Nov 2019 22:34:58 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C83077:3563EF0:5DD5BF92" + } + }, + "uuid": "c4c87cb2-e534-42ee-a265-707089fd382f", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-10-fce516.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-10-fce516.json new file mode 100644 index 0000000000..075e1283c8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val1dat-10-fce516.json @@ -0,0 +1,43 @@ +{ + "id": "fce51658-4eef-4dca-a01f-8294f3aea064", + "name": "repos_sandboxx_ghtreebuildertest_contents_data_val1dat", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/contents/data/val1.dat", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_contents_data_val1dat-fce51658-4eef-4dca-a01f-8294f3aea064.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:03 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4691", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\"", + "Last-Modified": "Wed, 20 Nov 2019 22:35:02 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C8369B:3564663:5DD5BF97" + } + }, + "uuid": "fce51658-4eef-4dca-a01f-8294f3aea064", + "persistent": true, + "insertionIndex": 10 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-11-1c94ff.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-11-1c94ff.json new file mode 100644 index 0000000000..10db945005 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_contents_data_val2dat-11-1c94ff.json @@ -0,0 +1,43 @@ +{ + "id": "1c94ff2b-4511-44a0-b99a-774dc2258930", + "name": "repos_sandboxx_ghtreebuildertest_contents_data_val2dat", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/contents/data/val2.dat", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_contents_data_val2dat-1c94ff2b-4511-44a0-b99a-774dc2258930.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:04 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4690", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"5bd8bb897b13225c93a1d26baa88c96b7bd5d817\"", + "Last-Modified": "Wed, 20 Nov 2019 22:35:02 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C836F2:35646CB:5DD5BF97" + } + }, + "uuid": "1c94ff2b-4511-44a0-b99a-774dc2258930", + "persistent": true, + "insertionIndex": 11 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-5-319a22.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-5-319a22.json new file mode 100644 index 0000000000..a56e8d93f6 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-5-319a22.json @@ -0,0 +1,50 @@ +{ + "id": "319a22ee-2aa7-4a18-bdfd-b8f6c71d6d4a", + "name": "repos_sandboxx_ghtreebuildertest_git_blobs", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/blobs", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"encoding\":\"base64\",\"content\":\"AQID\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "body": "{\"sha\":\"aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\",\"url\":\"https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\"}", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:01 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4696", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"1aab18e796329a5c589e9b4bd3c4a535\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C831B0:35640AB:5DD5BF94" + } + }, + "uuid": "319a22ee-2aa7-4a18-bdfd-b8f6c71d6d4a", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-6-3b8b1b.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-6-3b8b1b.json new file mode 100644 index 0000000000..b285740c70 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_blobs-6-3b8b1b.json @@ -0,0 +1,50 @@ +{ + "id": "3b8b1b6c-8f39-4c7d-800d-dc3726045ab5", + "name": "repos_sandboxx_ghtreebuildertest_git_blobs", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/blobs", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"encoding\":\"base64\",\"content\":\"BAUGBw==\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "body": "{\"sha\":\"5bd8bb897b13225c93a1d26baa88c96b7bd5d817\",\"url\":\"https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817\"}", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:01 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4695", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"507659676883bfb2fa1248dea0630607\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/blobs/5bd8bb897b13225c93a1d26baa88c96b7bd5d817", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C832B8:35641D6:5DD5BF95" + } + }, + "uuid": "3b8b1b6c-8f39-4c7d-800d-dc3726045ab5", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_commits-8-29661c.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_commits-8-29661c.json new file mode 100644 index 0000000000..3aa2833de8 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_commits-8-29661c.json @@ -0,0 +1,50 @@ +{ + "id": "29661c59-1d26-4d1d-88ce-59bc36a8c9e6", + "name": "repos_sandboxx_ghtreebuildertest_git_commits", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/commits", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"tree\":\"b09a1698f3aeb1d462c3492007760e2579734c74\",\"message\":\"Add files\",\"parents\":[\"c2066e756eb2185ed12419f790af4375c8b91e7b\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_commits-29661c59-1d26-4d1d-88ce-59bc36a8c9e6.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:02 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4693", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"f74db913dc9b7aa48c673d8363abde18\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/commits/450446ed2e0bcd2074ca54c0060e0a4b88d34aca", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C8341A:356437F:5DD5BF95" + } + }, + "uuid": "29661c59-1d26-4d1d-88ce-59bc36a8c9e6", + "persistent": true, + "insertionIndex": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-3-6d634a.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-3-6d634a.json new file mode 100644 index 0000000000..dffa49e2fe --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-3-6d634a.json @@ -0,0 +1,44 @@ +{ + "id": "6d634ae7-130f-4165-93f7-d39de13e13a3", + "name": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master-6d634ae7-130f-4165-93f7-d39de13e13a3.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:59 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4698", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"ad6fda806e5fe0c31d7fbab5ef478ca3\"", + "Last-Modified": "Wed, 20 Nov 2019 22:34:58 GMT", + "X-Poll-Interval": "300", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C830BB:3563F76:5DD5BF93" + } + }, + "uuid": "6d634ae7-130f-4165-93f7-d39de13e13a3", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-9-9f6c9b.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-9-9f6c9b.json new file mode 100644 index 0000000000..9b549a273a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_refs_heads_master-9-9f6c9b.json @@ -0,0 +1,49 @@ +{ + "id": "9f6c9be9-f494-4986-ac09-541270d2f047", + "name": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/refs/heads/master", + "method": "PATCH", + "bodyPatterns": [ + { + "equalToJson": "{\"force\":false,\"sha\":\"450446ed2e0bcd2074ca54c0060e0a4b88d34aca\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_refs_heads_master-9f6c9be9-f494-4986-ac09-541270d2f047.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:03 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4692", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"e048451acb30e8c42c7e6793e5d05916\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C834DC:3564464:5DD5BF96" + } + }, + "uuid": "9f6c9be9-f494-4986-ac09-541270d2f047", + "persistent": true, + "insertionIndex": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_trees-7-1c90d0.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_trees-7-1c90d0.json new file mode 100644 index 0000000000..9c98e2d15d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_trees-7-1c90d0.json @@ -0,0 +1,50 @@ +{ + "id": "1c90d00b-61e3-4e1b-ad2d-f184bdd2f766", + "name": "repos_sandboxx_ghtreebuildertest_git_trees", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/trees", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"base_tree\":\"c2066e756eb2185ed12419f790af4375c8b91e7b\",\"tree\":[{\"path\":\"data/val1.dat\",\"mode\":\"100644\",\"type\":\"blob\",\"sha\":\"aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74\",\"content\":null},{\"path\":\"data/val2.dat\",\"mode\":\"100644\",\"type\":\"blob\",\"sha\":\"5bd8bb897b13225c93a1d26baa88c96b7bd5d817\",\"content\":null}]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_trees-1c90d00b-61e3-4e1b-ad2d-f184bdd2f766.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:01 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4694", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"92cf0d1a217625c7fe445408ddf2b0d6\"", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/sandboxx/GHTreeBuilderTest/git/trees/b09a1698f3aeb1d462c3492007760e2579734c74", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C83381:35642C5:5DD5BF95" + } + }, + "uuid": "1c90d00b-61e3-4e1b-ad2d-f184bdd2f766", + "persistent": true, + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_trees_master-4-945055.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_trees_master-4-945055.json new file mode 100644 index 0000000000..b6448f6dea --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/repos_sandboxx_ghtreebuildertest_git_trees_master-4-945055.json @@ -0,0 +1,43 @@ +{ + "id": "94505509-cb10-428c-afa6-8b680402568b", + "name": "repos_sandboxx_ghtreebuildertest_git_trees_master", + "request": { + "url": "/repos/sandboxx/GHTreeBuilderTest/git/trees/master?recursive=1", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_sandboxx_ghtreebuildertest_git_trees_master-94505509-cb10-428c-afa6-8b680402568b.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:35:00 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4697", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"abf9e0d5dc4408a9836362e8a8c13743\"", + "Last-Modified": "Wed, 20 Nov 2019 22:34:58 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C830FB:3563FBB:5DD5BF93" + } + }, + "uuid": "94505509-cb10-428c-afa6-8b680402568b", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/user-1-1c3512.json b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/user-1-1c3512.json new file mode 100644 index 0000000000..807f938eed --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHTreeBuilderTest/wiremock/testShaEntry/mappings/user-1-1c3512.json @@ -0,0 +1,43 @@ +{ + "id": "1c35124b-49f8-4c65-a0eb-a3e807cfb4f4", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-1c35124b-49f8-4c65-a0eb-a3e807cfb4f4.json", + "headers": { + "Date": "Wed, 20 Nov 2019 22:34:58 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4701", + "X-RateLimit-Reset": "1574292484", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"034648c48243ad5329d74005351432a0\"", + "Last-Modified": "Thu, 03 Oct 2019 16:12:56 GMT", + "X-OAuth-Scopes": "public_repo", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "F6F4:35260:2C83019:3563ECC:5DD5BF92" + } + }, + "uuid": "1c35124b-49f8-4c65-a0eb-a3e807cfb4f4", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GitHubTest/wiremock/getMeta/__files/meta-d7546658-0019-4aac-ad1a-502d7abd8050.json b/src/test/resources/org/kohsuke/github/GitHubTest/wiremock/getMeta/__files/meta-d7546658-0019-4aac-ad1a-502d7abd8050.json new file mode 100644 index 0000000000..02db520957 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GitHubTest/wiremock/getMeta/__files/meta-d7546658-0019-4aac-ad1a-502d7abd8050.json @@ -0,0 +1,87 @@ +{ + "verifiable_password_authentication": true, + "hooks": [ + "192.30.252.0/22", + "185.199.108.0/22", + "140.82.112.0/20" + ], + "web": [ + "192.30.252.0/22", + "185.199.108.0/22", + "140.82.112.0/20", + "13.114.40.48/32", + "13.229.188.59/32", + "13.234.176.102/32", + "13.234.210.38/32", + "13.236.229.21/32", + "13.237.44.5/32", + "13.250.177.223/32", + "15.164.81.167/32", + "18.194.104.89/32", + "18.195.85.27/32", + "35.159.8.160/32", + "52.192.72.89/32", + "52.64.108.95/32", + "52.69.186.44/32", + "52.74.223.119/32", + "52.78.231.108/32" + ], + "api": [ + "192.30.252.0/22", + "185.199.108.0/22", + "140.82.112.0/20", + "13.209.163.61/32", + "13.230.158.120/32", + "13.233.76.15/32", + "13.234.168.60/32", + "13.236.14.80/32", + "13.238.54.232/32", + "13.250.168.23/32", + "13.250.94.254/32", + "18.179.245.253/32", + "18.194.201.191/32", + "18.195.135.122/32", + "52.58.203.252/32", + "52.63.231.178/32", + "52.69.239.207/32", + "54.169.195.247/32", + "54.180.75.25/32" + ], + "git": [ + "192.30.252.0/22", + "185.199.108.0/22", + "140.82.112.0/20", + "13.114.40.48/32", + "13.229.188.59/32", + "13.234.176.102/32", + "13.234.210.38/32", + "13.236.229.21/32", + "13.237.44.5/32", + "13.250.177.223/32", + "15.164.81.167/32", + "18.194.104.89/32", + "18.195.85.27/32", + "35.159.8.160/32", + "52.192.72.89/32", + "52.64.108.95/32", + "52.69.186.44/32", + "52.74.223.119/32", + "52.78.231.108/32" + ], + "pages": [ + "192.30.252.153/32", + "192.30.252.154/32", + "185.199.108.153/32", + "185.199.109.153/32", + "185.199.110.153/32", + "185.199.111.153/32" + ], + "importer": [ + "54.87.5.173", + "54.166.52.62", + "23.20.92.3", + "192.30.252.0/22", + "185.199.108.0/22", + "140.82.112.0/20" + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GitHubTest/wiremock/getMeta/mappings/meta-1-d75466.json b/src/test/resources/org/kohsuke/github/GitHubTest/wiremock/getMeta/mappings/meta-1-d75466.json new file mode 100644 index 0000000000..37c886c2cc --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GitHubTest/wiremock/getMeta/mappings/meta-1-d75466.json @@ -0,0 +1,40 @@ +{ + "id": "d7546658-0019-4aac-ad1a-502d7abd8050", + "name": "meta", + "request": { + "url": "/meta", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "meta-d7546658-0019-4aac-ad1a-502d7abd8050.json", + "headers": { + "Date": "Thu, 14 Nov 2019 02:46:14 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "60", + "X-RateLimit-Remaining": "59", + "X-RateLimit-Reset": "1573703174", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": [ + "Accept", + "Accept-Encoding" + ], + "ETag": "W/\"eb00a8c05920e4cb21eb0d018c339fe1\"", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "FC2E:3B7E:AD9E9:C9032:5DCCBFF6" + } + }, + "uuid": "d7546658-0019-4aac-ad1a-502d7abd8050", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/__files/authorizations-3f50c6b0-2730-45e7-9c94-f4f71bf61db2.json b/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/__files/authorizations-3f50c6b0-2730-45e7-9c94-f4f71bf61db2.json new file mode 100644 index 0000000000..edd1c21b4e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/__files/authorizations-3f50c6b0-2730-45e7-9c94-f4f71bf61db2.json @@ -0,0 +1,26 @@ +{ + "id": 350917110, + "url": "https://api.github.com/authorizations/350917110", + "app": { + "name": "Test2faTokenCreate", + "url": "this is a test token created by a unit test", + "client_id": "00000000000000000000" + }, + "token": "63042a99d88bf138e6d6cf5788e0dc4e7a5d7309", + "hashed_token": "12b727a23cad7c5a5caabb806d88e722794dede98464aed7f77cbc00dbf031a2", + "token_last_eight": "7a5d7309", + "note": "Test2faTokenCreate", + "note_url": "this is a test token created by a unit test", + "created_at": "2019-11-12T23:04:13Z", + "updated_at": "2019-11-12T23:04:13Z", + "scopes": [ + "repo", + "gist", + "write:packages", + "read:packages", + "delete:packages", + "user", + "delete_repo" + ], + "fingerprint": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/mappings/authorizations-1-cdda4d.json b/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/mappings/authorizations-1-cdda4d.json new file mode 100644 index 0000000000..eeb0a4b70e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/mappings/authorizations-1-cdda4d.json @@ -0,0 +1,45 @@ +{ + "id": "cdda4d8e-7412-4b68-84ea-4d691fc8ccb8", + "name": "authorizations", + "request": { + "url": "/authorizations", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"note\":\"Test2faTokenCreate\",\"note_url\":\"this is a test token created by a unit test\",\"scopes\":[\"repo\",\"gist\",\"write:packages\",\"read:packages\",\"delete:packages\",\"user\",\"delete_repo\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 401, + "body": "{\"message\":\"Must specify two-factor authentication OTP code.\",\"documentation_url\":\"https://developer.github.com/v3/auth#working-with-two-factor-authentication\"}", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 12 Nov 2019 23:03:53 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "401 Unauthorized", + "X-GitHub-OTP": "required; sms", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "60", + "X-RateLimit-Remaining": "59", + "X-RateLimit-Reset": "1573603433", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EA5C:557C:1271013:29480B4:5DCB3A59" + } + }, + "uuid": "cdda4d8e-7412-4b68-84ea-4d691fc8ccb8", + "persistent": true, + "scenarioName": "scenario-1-authorizations", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-authorizations-2", + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/mappings/authorizations-2-3f50c6.json b/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/mappings/authorizations-2-3f50c6.json new file mode 100644 index 0000000000..0a093d4343 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/Github2faTest/wiremock/test2faToken/mappings/authorizations-2-3f50c6.json @@ -0,0 +1,47 @@ +{ + "id": "3f50c6b0-2730-45e7-9c94-f4f71bf61db2", + "name": "authorizations", + "request": { + "url": "/authorizations", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"note\":\"Test2faTokenCreate\",\"note_url\":\"this is a test token created by a unit test\",\"scopes\":[\"repo\",\"gist\",\"write:packages\",\"read:packages\",\"delete:packages\",\"user\",\"delete_repo\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "authorizations-3f50c6b0-2730-45e7-9c94-f4f71bf61db2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 12 Nov 2019 23:04:13 GMT", + "Content-Type": "application/json; charset=utf-8", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4999", + "X-RateLimit-Reset": "1573603453", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag": "\"a13c56b386b13166f07b380d02243b12\"", + "Location": "https://api.github.com/authorizations/350917110", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "EA5C:557C:1271445:29480C8:5DCB3A59" + } + }, + "uuid": "3f50c6b0-2730-45e7-9c94-f4f71bf61db2", + "persistent": true, + "scenarioName": "scenario-1-authorizations", + "requiredScenarioState": "scenario-1-authorizations-2", + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository-7e3d0849-0e5e-4f69-a836-1dddb01af7e0.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository-7e3d0849-0e5e-4f69-a836-1dddb01af7e0.json new file mode 100644 index 0000000000..96f0445414 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository-7e3d0849-0e5e-4f69-a836-1dddb01af7e0.json @@ -0,0 +1,124 @@ +{ + "id": 224320760, + "node_id": "MDEwOlJlcG9zaXRvcnkyMjQzMjA3NjA=", + "name": "temp-testCreateRepository", + "full_name": "github-api-test-org/temp-testCreateRepository", + "private": false, + "owner": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/github-api-test-org/temp-testCreateRepository", + "description": "A test repository for testing the github-api project: temp-testCreateRepository", + "fork": false, + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository", + "forks_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/forks", + "keys_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/teams", + "hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/hooks", + "issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues/events{/number}", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/events", + "assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/assignees{/user}", + "branches_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/branches{/branch}", + "tags_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/tags", + "blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/languages", + "stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/stargazers", + "contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/contributors", + "subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/subscribers", + "subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/subscription", + "commits_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/contents/{+path}", + "compare_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/merges", + "archive_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/downloads", + "issues_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues{/number}", + "pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/labels{/name}", + "releases_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases{/id}", + "deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/deployments", + "created_at": "2019-11-27T01:45:21Z", + "updated_at": "2019-11-27T01:45:25Z", + "pushed_at": "2019-11-27T01:45:23Z", + "git_url": "git://github.com/github-api-test-org/temp-testCreateRepository.git", + "ssh_url": "git@github.com:github-api-test-org/temp-testCreateRepository.git", + "clone_url": "https://github.com/github-api-test-org/temp-testCreateRepository.git", + "svn_url": "https://github.com/github-api-test-org/temp-testCreateRepository", + "homepage": "http://github-api.kohsuke.org/", + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "github-api-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github-api-test-org", + "html_url": "https://github.com/github-api-test-org", + "followers_url": "https://api.github.com/users/github-api-test-org/followers", + "following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/github-api-test-org/orgs", + "repos_url": "https://api.github.com/users/github-api-test-org/repos", + "events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/github-api-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_issues-606626d3-4ec8-4550-ae51-635d1b33f18a.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_issues-606626d3-4ec8-4550-ae51-635d1b33f18a.json new file mode 100644 index 0000000000..bf14460628 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_issues-606626d3-4ec8-4550-ae51-635d1b33f18a.json @@ -0,0 +1,131 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues/1", + "repository_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues/1/labels{/name}", + "comments_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues/1/comments", + "events_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues/1/events", + "html_url": "https://github.com/github-api-test-org/temp-testCreateRepository/issues/1", + "id": 529065389, + "node_id": "MDU6SXNzdWU1MjkwNjUzODk=", + "number": 1, + "title": "Test Issue", + "user": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 1700362801, + "node_id": "MDU6TGFiZWwxNzAwMzYyODAx", + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/labels/bug", + "name": "bug", + "color": "d73a4a", + "default": true, + "description": "Something isn't working" + } + ], + "state": "open", + "locked": false, + "assignee": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + } + ], + "milestone": { + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/milestones/1", + "html_url": "https://github.com/github-api-test-org/temp-testCreateRepository/milestone/1", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/milestones/1/labels", + "id": 4883069, + "node_id": "MDk6TWlsZXN0b25lNDg4MzA2OQ==", + "number": 1, + "title": "Initial Release", + "description": "first one", + "creator": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "open_issues": 1, + "closed_issues": 0, + "state": "open", + "created_at": "2019-11-27T01:45:27Z", + "updated_at": "2019-11-27T01:45:28Z", + "due_on": null, + "closed_at": null + }, + "comments": 0, + "created_at": "2019-11-27T01:45:27Z", + "updated_at": "2019-11-27T01:45:28Z", + "closed_at": null, + "author_association": "MEMBER", + "body": "issue body just for grins", + "closed_by": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_milestones-c1bb6957-ff70-4683-b8fd-4b7988cddf30.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_milestones-c1bb6957-ff70-4683-b8fd-4b7988cddf30.json new file mode 100644 index 0000000000..0c9a1d9b36 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_milestones-c1bb6957-ff70-4683-b8fd-4b7988cddf30.json @@ -0,0 +1,37 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/milestones/1", + "html_url": "https://github.com/github-api-test-org/temp-testCreateRepository/milestone/1", + "labels_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/milestones/1/labels", + "id": 4883069, + "node_id": "MDk6TWlsZXN0b25lNDg4MzA2OQ==", + "number": 1, + "title": "Initial Release", + "description": "first one", + "creator": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "open_issues": 0, + "closed_issues": 0, + "state": "open", + "created_at": "2019-11-27T01:45:27Z", + "updated_at": "2019-11-27T01:45:27Z", + "due_on": null, + "closed_at": null +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases-dc00c291-6359-453c-b7d9-ffc7e2c99ddb.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases-dc00c291-6359-453c-b7d9-ffc7e2c99ddb.json new file mode 100644 index 0000000000..8e6eb52635 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases-dc00c291-6359-453c-b7d9-ffc7e2c99ddb.json @@ -0,0 +1,39 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/21786739", + "assets_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets", + "upload_url": "https://uploads.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets{?name,label}", + "html_url": "https://github.com/github-api-test-org/temp-testCreateRepository/releases/tag/release_tag", + "id": 21786739, + "node_id": "MDc6UmVsZWFzZTIxNzg2NzM5", + "tag_name": "release_tag", + "target_commitish": "master", + "name": "Test Release", + "draft": false, + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "prerelease": false, + "created_at": "2019-11-27T01:45:22Z", + "published_at": "2019-11-27T01:45:29Z", + "assets": [], + "tarball_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/tarball/release_tag", + "zipball_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/zipball/release_tag", + "body": "How exciting! To be able to programmatically create releases is a dream come true!" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases-dc82f39e-dd3d-4d58-b635-761bb93f77c7.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases-dc82f39e-dd3d-4d58-b635-761bb93f77c7.json new file mode 100644 index 0000000000..5f90ff1212 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases-dc82f39e-dd3d-4d58-b635-761bb93f77c7.json @@ -0,0 +1,41 @@ +[ + { + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/21786739", + "assets_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets", + "upload_url": "https://uploads.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets{?name,label}", + "html_url": "https://github.com/github-api-test-org/temp-testCreateRepository/releases/tag/release_tag", + "id": 21786739, + "node_id": "MDc6UmVsZWFzZTIxNzg2NzM5", + "tag_name": "release_tag", + "target_commitish": "master", + "name": "Test Release", + "draft": false, + "author": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "prerelease": false, + "created_at": "2019-11-27T01:45:22Z", + "published_at": "2019-11-27T01:45:29Z", + "assets": [], + "tarball_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/tarball/release_tag", + "zipball_url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/zipball/release_tag", + "body": "How exciting! To be able to programmatically create releases is a dream come true!" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-42bb605f-8031-41c8-9749-2c23af78edee.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-42bb605f-8031-41c8-9749-2c23af78edee.json new file mode 100644 index 0000000000..aba3aa2582 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-42bb605f-8031-41c8-9749-2c23af78edee.json @@ -0,0 +1,36 @@ +[ + { + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/assets/16422841", + "id": 16422841, + "node_id": "MDEyOlJlbGVhc2VBc3NldDE2NDIyODQx", + "name": "LICENSE.txt", + "label": "", + "uploader": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "content_type": "application/text", + "state": "uploaded", + "size": 1104, + "download_count": 0, + "created_at": "2019-11-27T01:45:30Z", + "updated_at": "2019-11-27T01:45:30Z", + "browser_download_url": "https://github.com/github-api-test-org/temp-testCreateRepository/releases/download/release_tag/LICENSE.txt" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-ed473c58-ee06-4632-a9fd-99a3972024c5.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-ed473c58-ee06-4632-a9fd-99a3972024c5.json new file mode 100644 index 0000000000..c8f3cfcd0c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-ed473c58-ee06-4632-a9fd-99a3972024c5.json @@ -0,0 +1,36 @@ +[ + { + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/assets/16422841", + "id": 16422841, + "node_id": "MDEyOlJlbGVhc2VBc3NldDE2NDIyODQx", + "name": "LICENSE.txt", + "label": "test label", + "uploader": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "content_type": "application/text", + "state": "uploaded", + "size": 1104, + "download_count": 0, + "created_at": "2019-11-27T01:45:30Z", + "updated_at": "2019-11-27T01:45:30Z", + "browser_download_url": "https://github.com/github-api-test-org/temp-testCreateRepository/releases/download/release_tag/LICENSE.txt" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-7f61d00c-320b-417f-b155-39a8ff3c33ae.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-7f61d00c-320b-417f-b155-39a8ff3c33ae.json new file mode 100644 index 0000000000..6ba47b731c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-7f61d00c-320b-417f-b155-39a8ff3c33ae.json @@ -0,0 +1,34 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/assets/16422841", + "id": 16422841, + "node_id": "MDEyOlJlbGVhc2VBc3NldDE2NDIyODQx", + "name": "LICENSE.txt", + "label": "test label", + "uploader": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "content_type": "application/text", + "state": "uploaded", + "size": 1104, + "download_count": 0, + "created_at": "2019-11-27T01:45:30Z", + "updated_at": "2019-11-27T01:45:30Z", + "browser_download_url": "https://github.com/github-api-test-org/temp-testCreateRepository/releases/download/release_tag/LICENSE.txt" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/user-864ebeb8-bf07-40c2-a910-3a3e54f81865.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/user-864ebeb8-bf07-40c2-a910-3a3e54f81865.json new file mode 100644 index 0000000000..a45e820c9e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/__files/user-864ebeb8-bf07-40c2-a910-3a3e54f81865.json @@ -0,0 +1,45 @@ +{ + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false, + "name": "Liam Newman", + "company": "Cloudbees, Inc.", + "blog": "", + "location": "Seattle, WA, USA", + "email": "bitwiseman@gmail.com", + "hireable": null, + "bio": "https://twitter.com/bitwiseman", + "public_repos": 176, + "public_gists": 7, + "followers": 141, + "following": 9, + "created_at": "2012-07-11T20:38:33Z", + "updated_at": "2019-11-26T22:02:50Z", + "private_gists": 7, + "total_private_repos": 10, + "owned_private_repos": 0, + "disk_usage": 33697, + "collaborators": 0, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository-2-7e3d08.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository-2-7e3d08.json new file mode 100644 index 0000000000..b93d76698b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository-2-7e3d08.json @@ -0,0 +1,43 @@ +{ + "id": "7e3d0849-0e5e-4f69-a836-1dddb01af7e0", + "name": "repos_github-api-test-org_temp-testcreaterepository", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository-7e3d0849-0e5e-4f69-a836-1dddb01af7e0.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4958", + "X-RateLimit-Reset": "1574822592", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"26a7f16664bd9308808198d8736328f3\"", + "Last-Modified": "Wed, 27 Nov 2019 01:45:25 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963C68:B1F2CA:5DDDD530" + } + }, + "uuid": "7e3d0849-0e5e-4f69-a836-1dddb01af7e0", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_issues-5-606626.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_issues-5-606626.json new file mode 100644 index 0000000000..7e1999e3b7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_issues-5-606626.json @@ -0,0 +1,50 @@ +{ + "id": "606626d3-4ec8-4550-ae51-635d1b33f18a", + "name": "repos_github-api-test-org_temp-testcreaterepository_issues", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/issues", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"milestone\":1,\"assignees\":[\"bitwiseman\"],\"title\":\"Test Issue\",\"body\":\"issue body just for grins\",\"labels\":[\"bug\"]}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_issues-606626d3-4ec8-4550-ae51-635d1b33f18a.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:28 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4955", + "X-RateLimit-Reset": "1574822592", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"fa9abaea430d18c8d1b0d2f82c0bd613\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/issues/1", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963CDA:B1F69F:5DDDD537" + } + }, + "uuid": "606626d3-4ec8-4550-ae51-635d1b33f18a", + "persistent": true, + "insertionIndex": 5 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_milestones-4-c1bb69.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_milestones-4-c1bb69.json new file mode 100644 index 0000000000..9dd90c5456 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_milestones-4-c1bb69.json @@ -0,0 +1,50 @@ +{ + "id": "c1bb6957-ff70-4683-b8fd-4b7988cddf30", + "name": "repos_github-api-test-org_temp-testcreaterepository_milestones", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/milestones", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"description\":\"first one\",\"title\":\"Initial Release\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_milestones-c1bb6957-ff70-4683-b8fd-4b7988cddf30.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4956", + "X-RateLimit-Reset": "1574822592", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"66e9f2e4ba2293ac0ee410e8ab549de7\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "Location": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/milestones/1", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963CA7:B1F675:5DDDD537" + } + }, + "uuid": "c1bb6957-ff70-4683-b8fd-4b7988cddf30", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-3-16498f.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-3-16498f.json new file mode 100644 index 0000000000..84d00a2bd5 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-3-16498f.json @@ -0,0 +1,45 @@ +{ + "id": "16498f3d-170c-4920-9e95-00361a9cbb22", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases", + "method": "GET" + }, + "response": { + "status": 200, + "body": "[]", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:27 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4957", + "X-RateLimit-Reset": "1574822592", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"ad5808b0a5d75d70a16a73b8e9763e19\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963C96:B1F660:5DDDD537" + } + }, + "uuid": "16498f3d-170c-4920-9e95-00361a9cbb22", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testCreateRepository-releases", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-1-repos-github-api-test-org-temp-testCreateRepository-releases-2", + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-6-dc00c2.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-6-dc00c2.json new file mode 100644 index 0000000000..1df7eed391 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-6-dc00c2.json @@ -0,0 +1,50 @@ +{ + "id": "dc00c291-6359-453c-b7d9-ffc7e2c99ddb", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases", + "method": "POST", + "bodyPatterns": [ + { + "equalToJson": "{\"tag_name\":\"release_tag\",\"name\":\"Test Release\",\"body\":\"How exciting! To be able to programmatically create releases is a dream come true!\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_releases-dc00c291-6359-453c-b7d9-ffc7e2c99ddb.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:29 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "201 Created", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4954", + "X-RateLimit-Reset": "1574822592", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"097682b0eaf95e24f2e37354b14a84b6\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "Location": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/21786739", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963D68:B1F730:5DDDD538" + } + }, + "uuid": "dc00c291-6359-453c-b7d9-ffc7e2c99ddb", + "persistent": true, + "insertionIndex": 6 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-7-dc82f3.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-7-dc82f3.json new file mode 100644 index 0000000000..973ca3267d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases-7-dc82f3.json @@ -0,0 +1,44 @@ +{ + "id": "dc82f39e-dd3d-4d58-b635-761bb93f77c7", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_releases-dc82f39e-dd3d-4d58-b635-761bb93f77c7.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:29 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4953", + "X-RateLimit-Reset": "1574822592", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8ba99dc2aba2d236a6eed851e1821baa\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963DE7:B1F7E8:5DDDD539" + } + }, + "uuid": "dc82f39e-dd3d-4d58-b635-761bb93f77c7", + "persistent": true, + "scenarioName": "scenario-1-repos-github-api-test-org-temp-testCreateRepository-releases", + "requiredScenarioState": "scenario-1-repos-github-api-test-org-temp-testCreateRepository-releases-2", + "insertionIndex": 7 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-10-ed473c.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-10-ed473c.json new file mode 100644 index 0000000000..acfcdee190 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-10-ed473c.json @@ -0,0 +1,45 @@ +{ + "id": "ed473c58-ee06-4632-a9fd-99a3972024c5", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-ed473c58-ee06-4632-a9fd-99a3972024c5.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:30 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4948", + "X-RateLimit-Reset": "1574822730", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"42d2858298a35fd3f7212f4db9d44606\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963E64:B1F87B:5DDDD53A" + } + }, + "uuid": "ed473c58-ee06-4632-a9fd-99a3972024c5", + "persistent": true, + "scenarioName": "scenario-2-repos-github-api-test-org-temp-testCreateRepository-releases-21786739-assets", + "requiredScenarioState": "scenario-2-repos-github-api-test-org-temp-testCreateRepository-releases-21786739-assets-2", + "newScenarioState": "scenario-2-repos-github-api-test-org-temp-testCreateRepository-releases-21786739-assets-3", + "insertionIndex": 10 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-12-383e6f.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-12-383e6f.json new file mode 100644 index 0000000000..c12b39c44e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-12-383e6f.json @@ -0,0 +1,44 @@ +{ + "id": "383e6f78-e9cd-4bdb-ab09-4c762507b52c", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets", + "method": "GET" + }, + "response": { + "status": 200, + "body": "[]", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:31 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4946", + "X-RateLimit-Reset": "1574822730", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "\"ad5808b0a5d75d70a16a73b8e9763e19\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963E98:B1F8BC:5DDDD53B" + } + }, + "uuid": "383e6f78-e9cd-4bdb-ab09-4c762507b52c", + "persistent": true, + "scenarioName": "scenario-2-repos-github-api-test-org-temp-testCreateRepository-releases-21786739-assets", + "requiredScenarioState": "scenario-2-repos-github-api-test-org-temp-testCreateRepository-releases-21786739-assets-3", + "insertionIndex": 12 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-8-42bb60.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-8-42bb60.json new file mode 100644 index 0000000000..be001dffea --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-8-42bb60.json @@ -0,0 +1,45 @@ +{ + "id": "42bb605f-8031-41c8-9749-2c23af78edee", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-42bb605f-8031-41c8-9749-2c23af78edee.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:30 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4950", + "X-RateLimit-Reset": "1574822730", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"dd403348ea8675e7ee90b23ee54cbd2a\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963E2E:B1F801:5DDDD539" + } + }, + "uuid": "42bb605f-8031-41c8-9749-2c23af78edee", + "persistent": true, + "scenarioName": "scenario-2-repos-github-api-test-org-temp-testCreateRepository-releases-21786739-assets", + "requiredScenarioState": "Started", + "newScenarioState": "scenario-2-repos-github-api-test-org-temp-testCreateRepository-releases-21786739-assets-2", + "insertionIndex": 8 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-11-864573.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-11-864573.json new file mode 100644 index 0000000000..057d7d5371 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-11-864573.json @@ -0,0 +1,35 @@ +{ + "id": "8645733e-5fdb-4f17-8567-a67c64ec1b52", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases/assets/16422841", + "method": "DELETE" + }, + "response": { + "status": 204, + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:31 GMT", + "Server": "GitHub.com", + "Status": "204 No Content", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4947", + "X-RateLimit-Reset": "1574822730", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "Vary": "Accept-Encoding", + "X-GitHub-Request-Id": "D729:3497:963E7D:B1F89D:5DDDD53A" + } + }, + "uuid": "8645733e-5fdb-4f17-8567-a67c64ec1b52", + "persistent": true, + "insertionIndex": 11 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-9-7f61d0.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-9-7f61d0.json new file mode 100644 index 0000000000..cf2bf015fa --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-9-7f61d0.json @@ -0,0 +1,50 @@ +{ + "id": "7f61d00c-320b-417f-b155-39a8ff3c33ae", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases/assets/16422841", + "method": "PATCH", + "bodyPatterns": [ + { + "equalToJson": "{\"label\":\"test label\"}", + "ignoreArrayOrder": true, + "ignoreExtraElements": true + } + ] + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_releases_assets_16422841-7f61d00c-320b-417f-b155-39a8ff3c33ae.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:30 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4949", + "X-RateLimit-Reset": "1574822730", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"8729ae6ac53a5f39f6482a17fa071cf2\"", + "Last-Modified": "Wed, 27 Nov 2019 01:45:30 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963E41:B1F853:5DDDD53A" + } + }, + "uuid": "7f61d00c-320b-417f-b155-39a8ff3c33ae", + "persistent": true, + "insertionIndex": 9 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/user-1-864ebe.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/user-1-864ebe.json new file mode 100644 index 0000000000..ffc561e948 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository/mappings/user-1-864ebe.json @@ -0,0 +1,43 @@ +{ + "id": "864ebeb8-bf07-40c2-a910-3a3e54f81865", + "name": "user", + "request": { + "url": "/user", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "user-864ebeb8-bf07-40c2-a910-3a3e54f81865.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:20 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4963", + "X-RateLimit-Reset": "1574822592", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"072b29f799172fd1523e04ec9f30fc24\"", + "Last-Modified": "Tue, 26 Nov 2019 22:02:50 GMT", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options": "deny", + "X-Content-Type-Options": "nosniff", + "X-XSS-Protection": "1; mode=block", + "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy": "default-src 'none'", + "X-GitHub-Request-Id": "D729:3497:963963:B1F2A7:5DDDD530" + } + }, + "uuid": "864ebeb8-bf07-40c2-a910-3a3e54f81865", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository_uploads/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-3069f0eb-aba0-4cc2-9bad-8aaa4e27e676.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository_uploads/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-3069f0eb-aba0-4cc2-9bad-8aaa4e27e676.json new file mode 100644 index 0000000000..e47170dbb0 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository_uploads/__files/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-3069f0eb-aba0-4cc2-9bad-8aaa4e27e676.json @@ -0,0 +1,34 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/temp-testCreateRepository/releases/assets/16422841", + "id": 16422841, + "node_id": "MDEyOlJlbGVhc2VBc3NldDE2NDIyODQx", + "name": "LICENSE.txt", + "label": "", + "uploader": { + "login": "bitwiseman", + "id": 1958953, + "node_id": "MDQ6VXNlcjE5NTg5NTM=", + "avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bitwiseman", + "html_url": "https://github.com/bitwiseman", + "followers_url": "https://api.github.com/users/bitwiseman/followers", + "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", + "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", + "organizations_url": "https://api.github.com/users/bitwiseman/orgs", + "repos_url": "https://api.github.com/users/bitwiseman/repos", + "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", + "received_events_url": "https://api.github.com/users/bitwiseman/received_events", + "type": "User", + "site_admin": false + }, + "content_type": "application/text", + "state": "uploaded", + "size": 1104, + "download_count": 0, + "created_at": "2019-11-27T01:45:30Z", + "updated_at": "2019-11-27T01:45:30Z", + "browser_download_url": "https://github.com/github-api-test-org/temp-testCreateRepository/releases/download/release_tag/LICENSE.txt" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository_uploads/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-1-3069f0.json b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository_uploads/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-1-3069f0.json new file mode 100644 index 0000000000..8f12c3f0ba --- /dev/null +++ b/src/test/resources/org/kohsuke/github/LifecycleTest/wiremock/testCreateRepository_uploads/mappings/repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-1-3069f0.json @@ -0,0 +1,41 @@ +{ + "id": "3069f0eb-aba0-4cc2-9bad-8aaa4e27e676", + "name": "repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets", + "request": { + "url": "/repos/github-api-test-org/temp-testCreateRepository/releases/21786739/assets?name=LICENSE.txt", + "method": "POST", + "bodyPatterns": [ + { + "equalTo": " Copyright (c) 2011- Kohsuke Kawaguchi and other contributors\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n", + "caseInsensitive": false + } + ] + }, + "response": { + "status": 201, + "bodyFileName": "repos_github-api-test-org_temp-testcreaterepository_releases_21786739_assets-3069f0eb-aba0-4cc2-9bad-8aaa4e27e676.json", + "headers": { + "Date": "Wed, 27 Nov 2019 01:45:30 GMT", + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "no-cache", + "Content-Security-Policy": "default-src 'none'", + "Etag": "W/\"037b49f1c38e9e0af7ed5a2978c5989d\"", + "Last-Modified": "Wed, 27 Nov 2019 01:45:30 GMT", + "Strict-Transport-Security": "max-age=31557600", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "X-Accepted-Oauth-Scopes": "repo", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-Github-Media-Type": "unknown, github.v3", + "X-Oauth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion", + "X-Xss-Protection": "1; mode=block", + "X-GitHub-Request-Id": "D72F:3D33:27CEE:309FD:5DDDD53A" + } + }, + "uuid": "3069f0eb-aba0-4cc2-9bad-8aaa4e27e676", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/DefaultConnector/__files/rate_limit-56a45440-7250-4615-9e39-f32ed5f24d40.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/DefaultConnector/__files/rate_limit-56a45440-7250-4615-9e39-f32ed5f24d40.json index 14af865bef..9c4d188862 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/DefaultConnector/__files/rate_limit-56a45440-7250-4615-9e39-f32ed5f24d40.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/DefaultConnector/__files/rate_limit-56a45440-7250-4615-9e39-f32ed5f24d40.json @@ -24,6 +24,6 @@ "rate": { "limit": 5000, "remaining": 4717, - "reset": 1569866107 + "reset": {{now offset='1 hours' format='unix'}} } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/__files/rate_limit-36588a64-cb68-4ea5-8995-c2cdced6b84a.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/__files/rate_limit-36588a64-cb68-4ea5-8995-c2cdced6b84a.json index c92888ad30..691e616302 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/__files/rate_limit-36588a64-cb68-4ea5-8995-c2cdced6b84a.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/__files/rate_limit-36588a64-cb68-4ea5-8995-c2cdced6b84a.json @@ -24,6 +24,6 @@ "rate": { "limit": 5000, "remaining": 4970, - "reset": 1569875630 + "reset": {{now offset='1 hours' format='unix'}} } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/orgs_github-api-test-org-3-ec2931.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/orgs_github-api-test-org-3-ec2931.json index 1f6737caba..3d34b760c0 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/orgs_github-api-test-org-3-ec2931.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/orgs_github-api-test-org-3-ec2931.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "orgs_github-api-test-org-ec2931f3-a8cd-4482-a866-aca52276d270.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4969", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/rate_limit-2-36588a.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/rate_limit-2-36588a.json index 6ffb0c6a47..08a11e6529 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/rate_limit-2-36588a.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/rate_limit-2-36588a.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "rate_limit-36588a64-cb68-4ea5-8995-c2cdced6b84a.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4970", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "no-cache", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-10-10-5432b2.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-10-10-5432b2.json index 7369bc5f11..dba271c2c4 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-10-10-5432b2.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-10-10-5432b2.json @@ -9,20 +9,20 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_github-api-5432b23c-70f2-4ecf-a380-a232afeef015.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4966", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "W/\"4f508593b64df214fee8f6ab42df633c\"", - "Last-Modified": "{{now offset='-1 seconds'}}", + "Last-Modified": "{{now offset='-1 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; format=json", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-11-11-2e2a6e.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-11-11-2e2a6e.json index ecac014b94..dced67fa86 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-11-11-2e2a6e.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-11-11-2e2a6e.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4966", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"4f508593b64df214fee8f6ab42df633c\"", - "Last-Modified": "{{now offset='-1 seconds'}}", + "Last-Modified": "{{now offset='-1 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-12-12-a9ae79.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-12-12-a9ae79.json index 1ad843af66..1e8ce06c50 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-12-12-a9ae79.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-12-12-a9ae79.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4966", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"4f508593b64df214fee8f6ab42df633c\"", - "Last-Modified": "{{now offset='-2 seconds'}}", + "Last-Modified": "{{now offset='-2 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-13-13-b2221a.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-13-13-b2221a.json index d5cdf22a5c..acb7ad2f40 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-13-13-b2221a.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-13-13-b2221a.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4966", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"4f508593b64df214fee8f6ab42df633c\"", - "Last-Modified": "{{now offset='-3 seconds'}}", + "Last-Modified": "{{now offset='-3 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-14-14-7e396e.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-14-14-7e396e.json index 02c96fcb9f..60b0f9d689 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-14-14-7e396e.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-14-14-7e396e.json @@ -14,20 +14,20 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_github-api-7e396e4c-c5eb-4bc0-a5cd-3d9f75fac0f0.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4963", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "W/\"31f73a7ecc35bbecec125851ce166af4\"", - "Last-Modified": "{{now offset='-7 seconds'}}", + "Last-Modified": "{{now offset='-7 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; format=json", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-15-15-bc8d8b.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-15-15-bc8d8b.json index 6dd2a15977..de8d4d88e5 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-15-15-bc8d8b.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-15-15-bc8d8b.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4963", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"31f73a7ecc35bbecec125851ce166af4\"", - "Last-Modified": "{{now offset='-10 seconds'}}", + "Last-Modified": "{{now offset='-10 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-16-16-3857dc.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-16-16-3857dc.json index a18687c281..6a3e0f838d 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-16-16-3857dc.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-16-16-3857dc.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4963", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"31f73a7ecc35bbecec125851ce166af4\"", - "Last-Modified": "{{now offset='-15 seconds'}}", + "Last-Modified": "{{now offset='-15 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-17-17-4d123b.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-17-17-4d123b.json index 49e0235004..45a36468b3 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-17-17-4d123b.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-17-17-4d123b.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4963", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"31f73a7ecc35bbecec125851ce166af4\"", - "Last-Modified": "{{now offset='-20 seconds'}}", + "Last-Modified": "{{now offset='-20 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-4-4-b99f84.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-4-4-b99f84.json index 8fea8fa13b..66a8fdf139 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-4-4-b99f84.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-4-4-b99f84.json @@ -9,20 +9,20 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_github-api-b99f84bd-4eaa-4aeb-8f1c-ba64e617d15f.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4968", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "W/\"295ae3430c604f3d10b6eb145fe511b5\"", - "Last-Modified": "{{now offset='-1 seconds'}}", + "Last-Modified": "{{now offset='-1 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; format=json", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-5-5-5e7b86.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-5-5-5e7b86.json index 2d95e4c8b9..3e52b56a20 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-5-5-5e7b86.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-5-5-5e7b86.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4968", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"295ae3430c604f3d10b6eb145fe511b5\"", - "Last-Modified": "{{now offset='-1 seconds'}}", + "Last-Modified": "{{now offset='-1 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-6-6-e20958.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-6-6-e20958.json index 1cb35daa7e..d149984df5 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-6-6-e20958.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-6-6-e20958.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4968", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"295ae3430c604f3d10b6eb145fe511b5\"", - "Last-Modified": "{{now offset='-2 seconds'}}", + "Last-Modified": "{{now offset='-2 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-7-7-597005.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-7-7-597005.json index 4830f0a132..ad98cf9598 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-7-7-597005.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-7-7-597005.json @@ -13,19 +13,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4968", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"295ae3430c604f3d10b6eb145fe511b5\"", - "Last-Modified": "{{now offset='-3 seconds'}}", + "Last-Modified": "{{now offset='-3 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-8-8-441d13.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-8-8-441d13.json index 817466b7bf..fdc4080985 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-8-8-441d13.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-8-8-441d13.json @@ -8,19 +8,19 @@ "response": { "status": 304, "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Server": "GitHub.com", "Status": "304 Not Modified", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4968", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "\"295ae3430c604f3d10b6eb145fe511b5\"", - "Last-Modified": "{{now offset='-7 seconds'}}", + "Last-Modified": "{{now offset='-7 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-9-9-0db057.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-9-9-0db057.json index 1807eb30c9..8f6b66fbd7 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-9-9-0db057.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/repos_github-api-test-org_github-api-9-9-0db057.json @@ -16,13 +16,13 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_github-api-0db05723-d8ab-412d-bcaf-fa416eb44138.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4967", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/user-1-5dbb2b.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/user-1-5dbb2b.json index f3aede2877..3911393e7e 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/user-1-5dbb2b.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeDefault_Zero/mappings/user-1-5dbb2b.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "user-5dbb2b95-e55b-4185-b143-ec3f21495fa6.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4970", - "X-RateLimit-Reset": "1569875630", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/__files/rate_limit-b23929e7-7216-403a-b1c4-1b0c2ecf6f85.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/__files/rate_limit-b23929e7-7216-403a-b1c4-1b0c2ecf6f85.json index d885b3c295..bb5f85483b 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/__files/rate_limit-b23929e7-7216-403a-b1c4-1b0c2ecf6f85.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/__files/rate_limit-b23929e7-7216-403a-b1c4-1b0c2ecf6f85.json @@ -24,6 +24,6 @@ "rate": { "limit": 5000, "remaining": 4984, - "reset": 1569872730 + "reset": {{now offset='1 hours' format='unix'}} } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/orgs_github-api-test-org-3-1d3815.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/orgs_github-api-test-org-3-1d3815.json index 339fbf6348..1f56b43aba 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/orgs_github-api-test-org-3-1d3815.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/orgs_github-api-test-org-3-1d3815.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "orgs_github-api-test-org-1d3815b7-1441-4a5d-a4eb-ffa13c700503.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4983", - "X-RateLimit-Reset": "1569872730", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/rate_limit-2-b23929.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/rate_limit-2-b23929.json index 45879bdab1..16bbe025c8 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/rate_limit-2-b23929.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/rate_limit-2-b23929.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "rate_limit-b23929e7-7216-403a-b1c4-1b0c2ecf6f85.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4984", - "X-RateLimit-Reset": "1569872730", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "no-cache", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-4-ec57e1.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-4-ec57e1.json index 36ef6465fb..59a97b08f2 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-4-ec57e1.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-4-ec57e1.json @@ -9,20 +9,20 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_github-api-ec57e178-8204-439b-b45a-58c773fa46f6.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4982", - "X-RateLimit-Reset": "1569872730", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "W/\"ef30773e1dfdb07ba4ea64143df970ab\"", - "Last-Modified": "{{now offset='-20 seconds'}}", + "Last-Modified": "{{now offset='-20 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; format=json", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-5-82db63.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-5-82db63.json index 54af1a90bb..d3f787386f 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-5-82db63.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-5-82db63.json @@ -16,13 +16,13 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_github-api-82db6373-85d8-4fc9-97c7-b98612c52402.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4981", - "X-RateLimit-Reset": "1569872730", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-6-02d53c.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-6-02d53c.json index 368f1bd68c..01da361c2c 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-6-02d53c.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/repos_github-api-test-org_github-api-6-02d53c.json @@ -9,20 +9,20 @@ "status": 200, "bodyFileName": "repos_github-api-test-org_github-api-02d53c37-9838-422a-9184-a08ef1487126.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4980", - "X-RateLimit-Reset": "1569872730", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding" ], "ETag": "W/\"ff0623de72a672b583e0f4473a5bb57c\"", - "Last-Modified": "{{now offset='-20 seconds'}}", + "Last-Modified": "{{now offset='-20 seconds' timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; format=json", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/user-1-d95886.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/user-1-d95886.json index fe8650d263..73d821da0c 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/user-1-d95886.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_Cache_MaxAgeNone/mappings/user-1-d95886.json @@ -9,13 +9,13 @@ "status": 200, "bodyFileName": "user-d958863f-a1fb-4a46-bc43-aeccd3eef451.json", "headers": { - "Date": "{{now}}", + "Date": "{{now timezone='GMT' format='EEE, dd MMM yyyy HH:mm:ss z'}}", "Content-Type": "application/json; charset=utf-8", "Server": "GitHub.com", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4984", - "X-RateLimit-Reset": "1569872730", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/__files/rate_limit-e76bb3c7-edf0-4cc4-9e62-0163e5910625.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/__files/rate_limit-e76bb3c7-edf0-4cc4-9e62-0163e5910625.json index 10296fcf9b..da242c2e5f 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/__files/rate_limit-e76bb3c7-edf0-4cc4-9e62-0163e5910625.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/__files/rate_limit-e76bb3c7-edf0-4cc4-9e62-0163e5910625.json @@ -24,6 +24,6 @@ "rate": { "limit": 5000, "remaining": 4995, - "reset": 1569867392 + "reset": {{now offset='1 hours' format='unix'}} } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/orgs_github-api-test-org-3-82590d.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/orgs_github-api-test-org-3-82590d.json index 06a0126e75..bb80d4aaaa 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/orgs_github-api-test-org-3-82590d.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/orgs_github-api-test-org-3-82590d.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4994", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/rate_limit-2-e76bb3.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/rate_limit-2-e76bb3.json index 9e8977e212..2fa7be150e 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/rate_limit-2-e76bb3.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/rate_limit-2-e76bb3.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4995", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "no-cache", "X-OAuth-Scopes": "gist, notifications, read:org, read:public_key, read:repo_hook, repo", "X-Accepted-OAuth-Scopes": "", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-10-d7826a.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-10-d7826a.json index 611730932b..bf7ce092b2 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-10-d7826a.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-10-d7826a.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4987", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-11-144773.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-11-144773.json index 4d563b8c97..d82af3faf0 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-11-144773.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-11-144773.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4986", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-12-49fce6.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-12-49fce6.json index 91270e3ce0..b5f0dd01e3 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-12-49fce6.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-12-49fce6.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4985", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-13-31849f.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-13-31849f.json index c304cf21e9..36ec73fca9 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-13-31849f.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-13-31849f.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4984", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-14-8a71a8.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-14-8a71a8.json index 8c46f65c56..a191d6e9cc 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-14-8a71a8.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-14-8a71a8.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4981", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-15-e6a8cc.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-15-e6a8cc.json index 85ab4310d8..12277b13dd 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-15-e6a8cc.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-15-e6a8cc.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4980", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-16-1ec048.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-16-1ec048.json index d3aa16206d..546ad809c2 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-16-1ec048.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-16-1ec048.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4979", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-17-3e8ef8.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-17-3e8ef8.json index ac4b7ea0eb..e7b8c20ea4 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-17-3e8ef8.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-17-3e8ef8.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4978", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-4-99fb84.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-4-99fb84.json index 4696f564de..972b0b0eb1 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-4-99fb84.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-4-99fb84.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4993", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-5-57466b.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-5-57466b.json index 16a69f3c80..a81675ba61 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-5-57466b.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-5-57466b.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4992", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-6-766326.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-6-766326.json index b21ebb471b..b9b2fe4b89 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-6-766326.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-6-766326.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4991", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-7-720bd2.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-7-720bd2.json index 75c141a5ec..404ad47bd2 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-7-720bd2.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-7-720bd2.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4990", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-8-50e14b.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-8-50e14b.json index f994f53133..12ade21c18 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-8-50e14b.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-8-50e14b.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4989", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-9-703fd1.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-9-703fd1.json index e7d51ba493..aca31b695f 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-9-703fd1.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/repos_github-api-test-org_github-api-9-703fd1.json @@ -22,7 +22,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4988", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP", diff --git a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/user-1-754481.json b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/user-1-754481.json index 080eba4944..c983a164eb 100644 --- a/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/user-1-754481.json +++ b/src/test/resources/org/kohsuke/github/extras/OkHttpConnectorTest/wiremock/OkHttpConnector_NoCache/mappings/user-1-754481.json @@ -15,7 +15,7 @@ "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4995", - "X-RateLimit-Reset": "1569867392", + "X-RateLimit-Reset": "{{now offset='1 hours' format='unix'}}", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": [ "Accept, Authorization, Cookie, X-GitHub-OTP",