diff --git a/pom.xml b/pom.xml index e1b62de1c..4f1be9cf7 100644 --- a/pom.xml +++ b/pom.xml @@ -14,8 +14,8 @@ GitHub API for Java - scm:git:git@github.com/kohsuke/${project.artifactId}.git - scm:git:ssh://git@github.com/kohsuke/${project.artifactId}.git + 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/ HEAD @@ -23,7 +23,7 @@ github-pages - gitsite:git@github.com/kohsuke/${project.artifactId}.git + gitsite:git@github.com/github-api/${project.artifactId}.git diff --git a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java index cf19dd99a..807ebcf10 100644 --- a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java +++ b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java @@ -35,7 +35,7 @@ public class GHAppCreateTokenBuilder { * */ @Preview @Deprecated - public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) { + public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) { this.builder.with("repository_ids",repositoryIds); return this; } diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 91c5c206d..b5922bc98 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -129,7 +129,7 @@ public class GHRepository extends GHObject { * Obtains a single {@link GHDeployment} by its ID. */ public GHDeployment getDeployment(long id) throws IOException { - return root.retrieve().to("deployments/" + id, GHDeployment.class).wrap(this); + return root.retrieve().to(getApiTailUrl("deployments/" + id), GHDeployment.class).wrap(this); } private String join(List params, String joinStr) { diff --git a/src/main/java/org/kohsuke/github/GitHubBuilder.java b/src/main/java/org/kohsuke/github/GitHubBuilder.java index e299e7340..f5e640c1a 100644 --- a/src/main/java/org/kohsuke/github/GitHubBuilder.java +++ b/src/main/java/org/kohsuke/github/GitHubBuilder.java @@ -180,6 +180,18 @@ public class GitHubBuilder implements Cloneable { this.user = user; return this; } + + /** + * Configures {@link GitHubBuilder} with Installation Token generated by the GitHub Application + * + * @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) + */ + public GitHubBuilder withAppInstallationToken(String appInstallationToken){ + return withOAuthToken(appInstallationToken, ""); + } + public GitHubBuilder withJwtToken(String jwtToken){ this.jwtToken = jwtToken; return this; diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt new file mode 100644 index 000000000..e76dd4710 --- /dev/null +++ b/src/site/apt/index.apt @@ -0,0 +1,154 @@ +What is this? + + This library defines an object oriented representation of the GitHub API. By "object oriented" we mean + there are classes that correspond to the domain model of GitHub (such as <<>> and <<>>), + operations that act on them as defined as methods (such as <<>>), and those object references + are used in favor of using string handle (such as <<>> instead of + <<>>) + + The library supports both github.com and GitHub Enterprise. + + Most of the GitHub APIs are covered, although there are some corners that are still not yet implemented. + +Sample Usage + ++-----+ +GitHub github = GitHub.connect(); + +GHRepository repo = github.createRepository( + "new-repository","this is my new repository", + "http://www.kohsuke.org/",true/*public*/); +repo.addCollaborators(github.getUser("abayer"),github.getUser("rtyler")); +repo.delete(); ++-----+ + +Authentication + + The library allows connecting to GitHub via several different authentication mechanisms. + +* Programmatically + + To connect via Username and Password (not recommended): + ++-----+ +GitHub github = new GitHubBuilder().withPassword("my_user", "my_passwd").build(); ++-----+ + + To connect via Personal access token: + ++-----+ +// If you don't specify the GitHub user id then the sdk will retrieve it via /user endpoint +GitHub github = new GitHubBuilder().withOAuthToken("my_personal_token").build(); + +// If the token has access to an organization, you can specify it here. +GitHub github = new GitHubBuilder().withOAuthToken("my_personal_token","user_id_OR_org_name").build(); ++-----+ + + To connect via JWT token as a GitHub App: + ++-----+ +GitHub github = new GitHubBuilder().withJwtToken("my_jwt_token").build(); ++-----+ + + To connect via GitHub App installation token on behalf of a user or organization: + ++-----+ +GitHub github = new GitHubBuilder().withAppInstallationToken("my_installation_token").build(); ++-----+ + +* Property file + + This library defines a common convention so that applications using this library will look at a consistent location. + In this convention, the library looks at <<<~/.github>>> property file. The content of the files depends on the way + you want this library to authenticate as shown below: + + + To connect via Username and Password (not recommended): + ++-----+ +login=kohsuke +password=012345678 ++-----+ + + To connect via Personal access token: + ++-----+ +oauth=4d98173f7c075527cb64878561d1fe70 ++-----+ + + To connect via Personal access token as a user or organization: + ++-----+ +login=my_org +oauth=4d98173f7c075527cb64878561d1fe70 ++-----+ + + To connect via JWT token as a GitHub App: + ++-----+ +jwt=my_jwt_token ++-----+ + + Once your <<<~/.github>>> property file is properly configured, you can obtain a <<>> instance using: + ++-----+ +// if you are using the default configuration file +GitHub github = new GitHubBuilder().fromPropertyFile().build(); + +// if you need to use a separate configuration file +GitHub github = new GitHubBuilder().fromPropertyFile("location/my_custom_github.properties").build(); ++-----+ + +* Environmental variables + + This library also allows developers to authenticate GitHub with environmental variables. + + To connect via Username and Password (not recommended): + ++-----+ +export GITHUB_LOGIN=kohsuke +export GITHUB_PASSWORD=012345678 ++-----+ + + To connect via Personal access token: + ++-----+ +export GITHUB_OAUTH=4d98173f7c075527cb64878561d1fe70 ++-----+ + + To connect via Personal access token as a user or organization: + ++-----+ +export GITHUB_LOGIN=my_org +export GITHUB_OAUTH=4d98173f7c075527cb64878561d1fe70 ++-----+ + + To connect via JWT token as a GitHub App: + ++-----+ +export GITHUB_JWT=my_jwt_token ++-----+ + + Once exported, you can obtain a <<>> instance using: + ++-----+ +GitHub github = new GitHubBuilder().fromEnvironment().build(); ++-----+ + + +Pluggable HTTP client + + This library comes with a pluggable connector to use different HTTP client implementations + through <<>>. In particular, this means you can use {{{http://square.github.io/okhttp/}OkHttp}}, + so we can make use of it's HTTP response cache. + Making a conditional request against the GitHub API and receiving a 304 response + {{{http://developer.github.com/v3/#conditional-requests}does not count against the rate limit}}. + + The following code shows an example of how to set up persistent cache on the disk: + ++-----+ +Cache cache = new Cache(cacheDirectory, 10 * 1024 * 1024); // 10MB cache +GitHub gitHub = GitHubBuilder.fromCredentials() + .withConnector(new OkHttpConnector(new OkUrlFactory(new OkHttpClient().setCache(cache)))) + .build(); ++-----+ diff --git a/src/site/site.xml b/src/site/site.xml index 01eda5ec1..3553fd23b 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -9,12 +9,13 @@ maven-skin 1.2 + - + diff --git a/src/test/java/org/kohsuke/github/GHAppTest.java b/src/test/java/org/kohsuke/github/GHAppTest.java index baf5a12cf..3c9bd0ff0 100644 --- a/src/test/java/org/kohsuke/github/GHAppTest.java +++ b/src/test/java/org/kohsuke/github/GHAppTest.java @@ -103,7 +103,7 @@ public class GHAppTest extends AbstractGitHubWireMockTest { permissions.put("metadata", GHPermissionType.READ); GHAppInstallationToken installationToken = installation.createToken(permissions) - .repositoryIds(Arrays.asList(111111111)) + .repositoryIds(Arrays.asList((long)111111111)) .create(); assertThat(installationToken.getToken(), is("bogus")); diff --git a/src/test/java/org/kohsuke/github/GHDeploymentTest.java b/src/test/java/org/kohsuke/github/GHDeploymentTest.java new file mode 100644 index 000000000..1c228c7aa --- /dev/null +++ b/src/test/java/org/kohsuke/github/GHDeploymentTest.java @@ -0,0 +1,27 @@ +package org.kohsuke.github; + +import org.junit.Test; + +import java.io.IOException; +import static org.junit.Assert.assertNotNull; + +/** + * @author Martin van Zijl + */ +public class GHDeploymentTest extends AbstractGitHubWireMockTest { + + @Test + public void testGetDeploymentById() throws IOException { + GHRepository repo = getRepository(); + GHDeployment deployment = repo.getDeployment(178653229); + assertNotNull(deployment); + } + + protected GHRepository getRepository() throws IOException { + return getRepository(gitHub); + } + + private 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/GitHubConnectionTest.java b/src/test/java/org/kohsuke/github/GitHubConnectionTest.java index 61753e94d..5db75f650 100644 --- a/src/test/java/org/kohsuke/github/GitHubConnectionTest.java +++ b/src/test/java/org/kohsuke/github/GitHubConnectionTest.java @@ -46,7 +46,6 @@ public class GitHubConnectionTest extends AbstractGitHubWireMockTest { GitHub hub = GitHub.connectUsingPassword("kohsuke", "bogus"); assertEquals("https://api.github.com/test", hub.getApiURL("/test").toString()); } - @Test public void testGitHubBuilderFromEnvironment() throws IOException { @@ -86,6 +85,17 @@ public class GitHubConnectionTest extends AbstractGitHubWireMockTest { assertEquals("bogusPassword", builder.password); assertEquals("bogusEndpoint", builder.endpoint); } + @Test + 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 { diff --git a/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/orgs_github-api-test-org-4def936c-47fd-43aa-851a-f9dd06f236b5.json b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/orgs_github-api-test-org-4def936c-47fd-43aa-851a-f9dd06f236b5.json new file mode 100644 index 000000000..99b5920cc --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/orgs_github-api-test-org-4def936c-47fd-43aa-851a-f9dd06f236b5.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/GHDeploymentTest/wiremock/testGetDeploymentById/__files/repos_github-api-test-org_github-api-a1a9ff0a-2e37-4803-a9de-fb8fffd45f41.json b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/repos_github-api-test-org_github-api-a1a9ff0a-2e37-4803-a9de-fb8fffd45f41.json new file mode 100644 index 000000000..d2b06356d --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/repos_github-api-test-org_github-api-a1a9ff0a-2e37-4803-a9de-fb8fffd45f41.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-09-30T22:36:47Z", + "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": 1, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 0, + "open_issues": 1, + "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-10-28T06:11:20Z", + "pushed_at": "2019-10-29T23:24:04Z", + "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": 14742, + "stargazers_count": 568, + "watchers_count": 568, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 433, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 66, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 433, + "open_issues": 66, + "watchers": 568, + "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-10-28T06:11:20Z", + "pushed_at": "2019-10-29T23:24:04Z", + "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": 14742, + "stargazers_count": 568, + "watchers_count": 568, + "language": "Java", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 433, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 66, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "forks": 433, + "open_issues": 66, + "watchers": 568, + "default_branch": "master" + }, + "network_count": 433, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/repos_github-api-test-org_github-api_deployments_178653229-d1d9d992-25e4-4a4b-8710-5b0c57e99a64.json b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/repos_github-api-test-org_github-api_deployments_178653229-d1d9d992-25e4-4a4b-8710-5b0c57e99a64.json new file mode 100644 index 000000000..1eea36725 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/__files/repos_github-api-test-org_github-api_deployments_178653229-d1d9d992-25e4-4a4b-8710-5b0c57e99a64.json @@ -0,0 +1,36 @@ +{ + "url": "https://api.github.com/repos/github-api-test-org/github-api/deployments/178653229", + "id": 178653229, + "node_id": "MDEwOkRlcGxveW1lbnQxNzg2NTMyMjk=", + "sha": "3a09d2de4a9a1322a0ba2c3e2f54a919ca8fe353", + "ref": "master", + "task": "deploy", + "payload": {}, + "original_environment": "production", + "environment": "production", + "description": null, + "creator": { + "login": "martinvanzijl", + "id": 24422213, + "node_id": "MDQ6VXNlcjI0NDIyMjEz", + "avatar_url": "https://avatars0.githubusercontent.com/u/24422213?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/martinvanzijl", + "html_url": "https://github.com/martinvanzijl", + "followers_url": "https://api.github.com/users/martinvanzijl/followers", + "following_url": "https://api.github.com/users/martinvanzijl/following{/other_user}", + "gists_url": "https://api.github.com/users/martinvanzijl/gists{/gist_id}", + "starred_url": "https://api.github.com/users/martinvanzijl/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/martinvanzijl/subscriptions", + "organizations_url": "https://api.github.com/users/martinvanzijl/orgs", + "repos_url": "https://api.github.com/users/martinvanzijl/repos", + "events_url": "https://api.github.com/users/martinvanzijl/events{/privacy}", + "received_events_url": "https://api.github.com/users/martinvanzijl/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2019-10-30T00:03:34Z", + "updated_at": "2019-10-30T00:03:34Z", + "statuses_url": "https://api.github.com/repos/github-api-test-org/github-api/deployments/178653229/statuses", + "repository_url": "https://api.github.com/repos/github-api-test-org/github-api" +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/orgs_github-api-test-org-1-4def93.json b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/orgs_github-api-test-org-1-4def93.json new file mode 100644 index 000000000..a1f19b6ef --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/orgs_github-api-test-org-1-4def93.json @@ -0,0 +1,41 @@ +{ + "id": "4def936c-47fd-43aa-851a-f9dd06f236b5", + "name": "orgs_github-api-test-org", + "request": { + "url": "/orgs/github-api-test-org", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "orgs_github-api-test-org-4def936c-47fd-43aa-851a-f9dd06f236b5.json", + "headers": { + "Date": "Wed, 30 Oct 2019 00:11:46 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4980", + "X-RateLimit-Reset": "1572397284", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"4342e0e7004c1a50986c767513fe857d\"", + "Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT", + "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": "DFCA:4866:E50AD:103D70:5DB8D541" + } + }, + "uuid": "4def936c-47fd-43aa-851a-f9dd06f236b5", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/repos_github-api-test-org_github-api-2-a1a9ff.json b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/repos_github-api-test-org_github-api-2-a1a9ff.json new file mode 100644 index 000000000..8a1f12ec4 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/repos_github-api-test-org_github-api-2-a1a9ff.json @@ -0,0 +1,41 @@ +{ + "id": "a1a9ff0a-2e37-4803-a9de-fb8fffd45f41", + "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-a1a9ff0a-2e37-4803-a9de-fb8fffd45f41.json", + "headers": { + "Date": "Wed, 30 Oct 2019 00:11:47 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4979", + "X-RateLimit-Reset": "1572397284", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"4ef7d9ee7bc7f4f32000eb0720da5bf1\"", + "Last-Modified": "Mon, 30 Sep 2019 22:36:47 GMT", + "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": "DFCA:4866:E50D8:103D81:5DB8D542" + } + }, + "uuid": "a1a9ff0a-2e37-4803-a9de-fb8fffd45f41", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/repos_github-api-test-org_github-api_deployments_178653229-3-d1d9d9.json b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/repos_github-api-test-org_github-api_deployments_178653229-3-d1d9d9.json new file mode 100644 index 000000000..0686b5e78 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHDeploymentTest/wiremock/testGetDeploymentById/mappings/repos_github-api-test-org_github-api_deployments_178653229-3-d1d9d9.json @@ -0,0 +1,41 @@ +{ + "id": "d1d9d992-25e4-4a4b-8710-5b0c57e99a64", + "name": "repos_github-api-test-org_github-api_deployments_178653229", + "request": { + "url": "/repos/github-api-test-org/github-api/deployments/178653229", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "repos_github-api-test-org_github-api_deployments_178653229-d1d9d992-25e4-4a4b-8710-5b0c57e99a64.json", + "headers": { + "Date": "Wed, 30 Oct 2019 00:11:48 GMT", + "Content-Type": "application/json; charset=utf-8", + "Server": "GitHub.com", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4978", + "X-RateLimit-Reset": "1572397284", + "Cache-Control": "private, max-age=60, s-maxage=60", + "Vary": [ + "Accept, Authorization, Cookie, X-GitHub-OTP", + "Accept-Encoding" + ], + "ETag": "W/\"e1b3c1f524645e959b25405131fba656\"", + "Last-Modified": "Wed, 30 Oct 2019 00:03:34 GMT", + "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": "DFCA:4866:E50EA:103DAF:5DB8D543" + } + }, + "uuid": "d1d9d992-25e4-4a4b-8710-5b0c57e99a64", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file