Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/main/java/org/kohsuke/github/GHPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public abstract class GHPerson extends GHObject {
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, type;
protected String html_url;
protected int followers, following, public_repos, public_gists;
protected boolean site_admin;

GHPerson wrapUp(GitHub root) {
this.root = root;
Expand Down Expand Up @@ -316,4 +317,28 @@ public int getFollowersCount() throws IOException {
populate();
return followers;
}

/**
* Gets the type. This is either "User" or "Organization".
*
* @return the type
* @throws IOException
* the io exception
*/
public String getType() throws IOException {
populate();
return type;
}

/**
* Gets the site_admin field
*
* @return the site_admin field
* @throws IOException
* the io exception
*/
public boolean isSiteAdmin() throws IOException {
populate();
return site_admin;
}
}
33 changes: 33 additions & 0 deletions src/test/java/org/kohsuke/github/GHPersonTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.kohsuke.github;

import org.junit.Test;

import java.io.IOException;

/**
* @author Martin van Zijl
*/
public class GHPersonTest extends AbstractGitHubWireMockTest {
@Test
public void testFieldsForOrganization() throws Exception {
GHRepository repo = getRepository();
GHUser owner = repo.getOwner();
assertEquals("Organization", owner.getType());
assertNotNull(owner.isSiteAdmin());
}

@Test
public void testFieldsForUser() throws Exception {
GHUser user = gitHub.getUser("kohsuke2");
assertEquals("User", user.getType());
assertNotNull(user.isSiteAdmin());
}

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": 9,
"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": 10,
"seats": 0
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"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,
"name": null,
"company": null,
"blog": "",
"location": null,
"email": null,
"hireable": null,
"bio": null,
"public_repos": 9,
"public_gists": 0,
"followers": 0,
"following": 0,
"created_at": "2014-05-10T19:39:11Z",
"updated_at": "2015-04-20T00:42:30Z",
"plan": {
"name": "free",
"space": 976562499,
"collaborators": 0,
"private_repos": 10000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "13f85dbd-5b52-49ce-b65b-bac7d3069c78",
"name": "orgs_github-api-test-org",
"request": {
"url": "/orgs/github-api-test-org",
"method": "GET"
},
"response": {
"status": 200,
"bodyFileName": "orgs_github-api-test-org-13f85dbd-5b52-49ce-b65b-bac7d3069c78.json",
"headers": {
"Date": "Fri, 13 Dec 2019 18:23:29 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4995",
"X-RateLimit-Reset": "1576264896",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding"
],
"ETag": "W/\"30cb8c7d1f87f6928d9c05fbc522398f\"",
"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": "A5F1:7711:F051A3:112CE43:5DF3D720"
}
},
"uuid": "13f85dbd-5b52-49ce-b65b-bac7d3069c78",
"persistent": true,
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "b3a3dea9-68c7-40d4-8f70-3dddff42e983",
"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-b3a3dea9-68c7-40d4-8f70-3dddff42e983.json",
"headers": {
"Date": "Fri, 13 Dec 2019 18:23:30 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4994",
"X-RateLimit-Reset": "1576264896",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding"
],
"ETag": "W/\"3bab3de79c7a97496a9a2ee8ae63fc60\"",
"Last-Modified": "Thu, 07 Nov 2019 22:27:11 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": "A5F1:7711:F051B2:112CE47:5DF3D721"
}
},
"uuid": "b3a3dea9-68c7-40d4-8f70-3dddff42e983",
"persistent": true,
"insertionIndex": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "9edc4a69-96e0-4db6-8469-85483d9ef2c5",
"name": "users_github-api-test-org",
"request": {
"url": "/users/github-api-test-org",
"method": "GET"
},
"response": {
"status": 200,
"bodyFileName": "users_github-api-test-org-9edc4a69-96e0-4db6-8469-85483d9ef2c5.json",
"headers": {
"Date": "Fri, 13 Dec 2019 18:23:30 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4993",
"X-RateLimit-Reset": "1576264896",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding"
],
"ETag": "W/\"5b2acfd788622a6e0078da036013a0eb\"",
"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": "A5F1:7711:F051B7:112CE55:5DF3D722"
}
},
"uuid": "9edc4a69-96e0-4db6-8469-85483d9ef2c5",
"persistent": true,
"insertionIndex": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"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,
"name": "Fake 川口耕介",
"company": null,
"blog": "",
"location": null,
"email": null,
"hireable": null,
"bio": null,
"public_repos": 19,
"public_gists": 0,
"followers": 1,
"following": 0,
"created_at": "2012-01-14T01:58:59Z",
"updated_at": "2019-05-16T20:59:50Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "be47bccc-9404-4fe4-be81-ae86857a3c99",
"name": "users_kohsuke2",
"request": {
"url": "/users/kohsuke2",
"method": "GET"
},
"response": {
"status": 200,
"bodyFileName": "users_kohsuke2-be47bccc-9404-4fe4-be81-ae86857a3c99.json",
"headers": {
"Date": "Fri, 13 Dec 2019 18:23:31 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4992",
"X-RateLimit-Reset": "1576264896",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding"
],
"ETag": "W/\"d7eece591c3ac8f84be4eede2c45cddf\"",
"Last-Modified": "Thu, 16 May 2019 20:59:50 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": "A5F3:771A:2C88B78:32D2E33:5DF3D723"
}
},
"uuid": "be47bccc-9404-4fe4-be81-ae86857a3c99",
"persistent": true,
"insertionIndex": 1
}