Skip to content

Commit c763c02

Browse files
committed
[added] unit tests for getUserPublicOrganizations(...)
1 parent eb36cb4 commit c763c02

4 files changed

Lines changed: 236 additions & 0 deletions

File tree

src/test/java/org/kohsuke/github/AppTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,26 @@ public void testMyTeamsShouldIncludeMyself() throws IOException {
217217
}
218218
}
219219
}
220+
221+
@Test
222+
public void testUserPublicOrganizationsWhenThereAreSome() throws IOException {
223+
// kohsuke had some public org memberships at the time Wiremock recorded the GitHub API responses
224+
GHUser user = new GHUser();
225+
user.login = "kohsuke";
226+
227+
Map<String, GHOrganization> orgs = gitHub.getUserPublicOrganizations( user );
228+
assertFalse(orgs.isEmpty());
229+
}
230+
231+
@Test
232+
public void testUserPublicOrganizationsWhenThereAreNone() throws IOException {
233+
// bitwiseman had no public org memberships at the time Wiremock recorded the GitHub API responses
234+
GHUser user = new GHUser();
235+
user.login = "bitwiseman";
236+
237+
Map<String, GHOrganization> orgs = gitHub.getUserPublicOrganizations( user );
238+
assertTrue(orgs.isEmpty());
239+
}
220240

221241
private boolean shouldBelongToTeam(String organizationName, String teamName) throws IOException {
222242
GHOrganization org = gitHub.getOrganization(organizationName);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"id": "94ce7391-a312-48e7-b869-ce2f16838e60",
3+
"name": "users_bitwiseman_orgs",
4+
"request": {
5+
"url": "/users/bitwiseman/orgs",
6+
"method": "GET"
7+
},
8+
"response": {
9+
"status": 200,
10+
"body": "[]",
11+
"headers": {
12+
"Server": "GitHub.com",
13+
"Date": "Thu, 24 Oct 2019 15:49:23 GMT",
14+
"Content-Type": "application/json; charset=utf-8",
15+
"Status": "200 OK",
16+
"X-RateLimit-Limit": "60",
17+
"X-RateLimit-Remaining": "27",
18+
"X-RateLimit-Reset": "1571934805",
19+
"Cache-Control": "public, max-age=60, s-maxage=60",
20+
"Vary": "Accept",
21+
"ETag": "\"80b190627d4c87e9a37c34e20ea246a1\"",
22+
"X-GitHub-Media-Type": "unknown, github.v3",
23+
"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",
24+
"Access-Control-Allow-Origin": "*",
25+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
26+
"X-Frame-Options": "deny",
27+
"X-Content-Type-Options": "nosniff",
28+
"X-XSS-Protection": "1; mode=block",
29+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
30+
"Content-Security-Policy": "default-src 'none'",
31+
"X-GitHub-Request-Id": "6970:40D4:19AB38:31CA07:5DB1C803"
32+
}
33+
},
34+
"uuid": "94ce7391-a312-48e7-b869-ce2f16838e60",
35+
"persistent": true,
36+
"insertionIndex": 1
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
[
2+
{
3+
"login": "jenkinsci",
4+
"id": 107424,
5+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjEwNzQyNA==",
6+
"url": "https://api.github.com/orgs/jenkinsci",
7+
"repos_url": "https://api.github.com/orgs/jenkinsci/repos",
8+
"events_url": "https://api.github.com/orgs/jenkinsci/events",
9+
"hooks_url": "https://api.github.com/orgs/jenkinsci/hooks",
10+
"issues_url": "https://api.github.com/orgs/jenkinsci/issues",
11+
"members_url": "https://api.github.com/orgs/jenkinsci/members{/member}",
12+
"public_members_url": "https://api.github.com/orgs/jenkinsci/public_members{/member}",
13+
"avatar_url": "https://avatars0.githubusercontent.com/u/107424?v=4",
14+
"description": "Jenkins is an open source automation server with an unparalleled plugin ecosystem to support practically every tool as part of your delivery pipelines"
15+
},
16+
{
17+
"login": "cloudbees",
18+
"id": 235526,
19+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjIzNTUyNg==",
20+
"url": "https://api.github.com/orgs/cloudbees",
21+
"repos_url": "https://api.github.com/orgs/cloudbees/repos",
22+
"events_url": "https://api.github.com/orgs/cloudbees/events",
23+
"hooks_url": "https://api.github.com/orgs/cloudbees/hooks",
24+
"issues_url": "https://api.github.com/orgs/cloudbees/issues",
25+
"members_url": "https://api.github.com/orgs/cloudbees/members{/member}",
26+
"public_members_url": "https://api.github.com/orgs/cloudbees/public_members{/member}",
27+
"avatar_url": "https://avatars3.githubusercontent.com/u/235526?v=4",
28+
"description": ""
29+
},
30+
{
31+
"login": "infradna",
32+
"id": 266075,
33+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjI2NjA3NQ==",
34+
"url": "https://api.github.com/orgs/infradna",
35+
"repos_url": "https://api.github.com/orgs/infradna/repos",
36+
"events_url": "https://api.github.com/orgs/infradna/events",
37+
"hooks_url": "https://api.github.com/orgs/infradna/hooks",
38+
"issues_url": "https://api.github.com/orgs/infradna/issues",
39+
"members_url": "https://api.github.com/orgs/infradna/members{/member}",
40+
"public_members_url": "https://api.github.com/orgs/infradna/public_members{/member}",
41+
"avatar_url": "https://avatars3.githubusercontent.com/u/266075?v=4",
42+
"description": null
43+
},
44+
{
45+
"login": "stapler",
46+
"id": 700341,
47+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjcwMDM0MQ==",
48+
"url": "https://api.github.com/orgs/stapler",
49+
"repos_url": "https://api.github.com/orgs/stapler/repos",
50+
"events_url": "https://api.github.com/orgs/stapler/events",
51+
"hooks_url": "https://api.github.com/orgs/stapler/hooks",
52+
"issues_url": "https://api.github.com/orgs/stapler/issues",
53+
"members_url": "https://api.github.com/orgs/stapler/members{/member}",
54+
"public_members_url": "https://api.github.com/orgs/stapler/public_members{/member}",
55+
"avatar_url": "https://avatars1.githubusercontent.com/u/700341?v=4",
56+
"description": null
57+
},
58+
{
59+
"login": "java-schema-utilities",
60+
"id": 709081,
61+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjcwOTA4MQ==",
62+
"url": "https://api.github.com/orgs/java-schema-utilities",
63+
"repos_url": "https://api.github.com/orgs/java-schema-utilities/repos",
64+
"events_url": "https://api.github.com/orgs/java-schema-utilities/events",
65+
"hooks_url": "https://api.github.com/orgs/java-schema-utilities/hooks",
66+
"issues_url": "https://api.github.com/orgs/java-schema-utilities/issues",
67+
"members_url": "https://api.github.com/orgs/java-schema-utilities/members{/member}",
68+
"public_members_url": "https://api.github.com/orgs/java-schema-utilities/public_members{/member}",
69+
"avatar_url": "https://avatars0.githubusercontent.com/u/709081?v=4",
70+
"description": null
71+
},
72+
{
73+
"login": "CloudBees-community",
74+
"id": 1225740,
75+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjEyMjU3NDA=",
76+
"url": "https://api.github.com/orgs/CloudBees-community",
77+
"repos_url": "https://api.github.com/orgs/CloudBees-community/repos",
78+
"events_url": "https://api.github.com/orgs/CloudBees-community/events",
79+
"hooks_url": "https://api.github.com/orgs/CloudBees-community/hooks",
80+
"issues_url": "https://api.github.com/orgs/CloudBees-community/issues",
81+
"members_url": "https://api.github.com/orgs/CloudBees-community/members{/member}",
82+
"public_members_url": "https://api.github.com/orgs/CloudBees-community/public_members{/member}",
83+
"avatar_url": "https://avatars0.githubusercontent.com/u/1225740?v=4",
84+
"description": ""
85+
},
86+
{
87+
"login": "cloudbeers",
88+
"id": 4181899,
89+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQxODE4OTk=",
90+
"url": "https://api.github.com/orgs/cloudbeers",
91+
"repos_url": "https://api.github.com/orgs/cloudbeers/repos",
92+
"events_url": "https://api.github.com/orgs/cloudbeers/events",
93+
"hooks_url": "https://api.github.com/orgs/cloudbeers/hooks",
94+
"issues_url": "https://api.github.com/orgs/cloudbeers/issues",
95+
"members_url": "https://api.github.com/orgs/cloudbeers/members{/member}",
96+
"public_members_url": "https://api.github.com/orgs/cloudbeers/public_members{/member}",
97+
"avatar_url": "https://avatars3.githubusercontent.com/u/4181899?v=4",
98+
"description": ""
99+
},
100+
{
101+
"login": "jenkins-infra",
102+
"id": 7422698,
103+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc0MjI2OTg=",
104+
"url": "https://api.github.com/orgs/jenkins-infra",
105+
"repos_url": "https://api.github.com/orgs/jenkins-infra/repos",
106+
"events_url": "https://api.github.com/orgs/jenkins-infra/events",
107+
"hooks_url": "https://api.github.com/orgs/jenkins-infra/hooks",
108+
"issues_url": "https://api.github.com/orgs/jenkins-infra/issues",
109+
"members_url": "https://api.github.com/orgs/jenkins-infra/members{/member}",
110+
"public_members_url": "https://api.github.com/orgs/jenkins-infra/public_members{/member}",
111+
"avatar_url": "https://avatars2.githubusercontent.com/u/7422698?v=4",
112+
"description": "Repositories owned by the Jenkins project infrastructure team"
113+
},
114+
{
115+
"login": "LegoMatterhorn",
116+
"id": 9170491,
117+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjkxNzA0OTE=",
118+
"url": "https://api.github.com/orgs/LegoMatterhorn",
119+
"repos_url": "https://api.github.com/orgs/LegoMatterhorn/repos",
120+
"events_url": "https://api.github.com/orgs/LegoMatterhorn/events",
121+
"hooks_url": "https://api.github.com/orgs/LegoMatterhorn/hooks",
122+
"issues_url": "https://api.github.com/orgs/LegoMatterhorn/issues",
123+
"members_url": "https://api.github.com/orgs/LegoMatterhorn/members{/member}",
124+
"public_members_url": "https://api.github.com/orgs/LegoMatterhorn/public_members{/member}",
125+
"avatar_url": "https://avatars2.githubusercontent.com/u/9170491?v=4",
126+
"description": ""
127+
},
128+
{
129+
"login": "jenkinsci-cert",
130+
"id": 9285726,
131+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjkyODU3MjY=",
132+
"url": "https://api.github.com/orgs/jenkinsci-cert",
133+
"repos_url": "https://api.github.com/orgs/jenkinsci-cert/repos",
134+
"events_url": "https://api.github.com/orgs/jenkinsci-cert/events",
135+
"hooks_url": "https://api.github.com/orgs/jenkinsci-cert/hooks",
136+
"issues_url": "https://api.github.com/orgs/jenkinsci-cert/issues",
137+
"members_url": "https://api.github.com/orgs/jenkinsci-cert/members{/member}",
138+
"public_members_url": "https://api.github.com/orgs/jenkinsci-cert/public_members{/member}",
139+
"avatar_url": "https://avatars2.githubusercontent.com/u/9285726?v=4",
140+
"description": "Private repositories for the Jenkins CERT team"
141+
}
142+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"id": "7ef9c5df-d48e-44be-ba15-e880b8e9558d",
3+
"name": "users_kohsuke_orgs",
4+
"request": {
5+
"url": "/users/kohsuke/orgs",
6+
"method": "GET"
7+
},
8+
"response": {
9+
"status": 200,
10+
"bodyFileName": "users_kohsuke_orgs-7ef9c5df-d48e-44be-ba15-e880b8e9558d.json",
11+
"headers": {
12+
"Server": "GitHub.com",
13+
"Date": "Thu, 24 Oct 2019 15:50:04 GMT",
14+
"Content-Type": "application/json; charset=utf-8",
15+
"Status": "200 OK",
16+
"X-RateLimit-Limit": "60",
17+
"X-RateLimit-Remaining": "25",
18+
"X-RateLimit-Reset": "1571934805",
19+
"Cache-Control": "public, max-age=60, s-maxage=60",
20+
"Vary": "Accept",
21+
"ETag": "W/\"5c5a7fc59f333fbeda60ffeefc546a8a\"",
22+
"X-GitHub-Media-Type": "unknown, github.v3",
23+
"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",
24+
"Access-Control-Allow-Origin": "*",
25+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
26+
"X-Frame-Options": "deny",
27+
"X-Content-Type-Options": "nosniff",
28+
"X-XSS-Protection": "1; mode=block",
29+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
30+
"Content-Security-Policy": "default-src 'none'",
31+
"X-GitHub-Request-Id": "5EE8:1F70:C0C53:1D07EC:5DB1C82C"
32+
}
33+
},
34+
"uuid": "7ef9c5df-d48e-44be-ba15-e880b8e9558d",
35+
"persistent": true,
36+
"insertionIndex": 1
37+
}

0 commit comments

Comments
 (0)