Skip to content

Commit

Permalink
Fix for getting deployment by id.
Browse files Browse the repository at this point in the history
Fixes hub4j#529.
  • Loading branch information
martinvanzijl committed Oct 30, 2019
1 parent efb87c5 commit 9f29d46
Show file tree
Hide file tree
Showing 8 changed files with 558 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public PagedIterable<GHDeployment> listDeployments(String sha,String ref,String
* 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<String> params, String joinStr) {
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/org/kohsuke/github/GHDeploymentTest.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 9f29d46

Please sign in to comment.