Skip to content

Commit dd274c3

Browse files
authored
Merge pull request #1832 from kozmic/patch-1
Add GHOrganization.listSecurityManagers()
2 parents e0edb9d + 92112af commit dd274c3

File tree

6 files changed

+185
-0
lines changed

6 files changed

+185
-0
lines changed

src/main/java/org/kohsuke/github/GHOrganization.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,19 @@ private PagedIterable<GHUser> listMembers(final String suffix, final String filt
450450
.toIterable(GHUser[].class, null);
451451
}
452452

453+
/**
454+
* List up all the security managers.
455+
*
456+
* @return the paged iterable
457+
* @throws IOException
458+
* the io exception
459+
*/
460+
public PagedIterable<GHTeam> listSecurityManagers() throws IOException {
461+
return root().createRequest()
462+
.withUrlPath(String.format("/orgs/%s/security-managers", login))
463+
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
464+
}
465+
453466
/**
454467
* Conceals the membership.
455468
*

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,25 @@ public void testListMembersWithRole() throws IOException {
335335
"timja"));
336336
}
337337

338+
/**
339+
* Test list security managers.
340+
*
341+
* @throws IOException
342+
* Signals that an I/O exception has occurred.
343+
*/
344+
@Test
345+
public void testListSecurityManagers() throws IOException {
346+
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
347+
348+
List<GHTeam> securityManagers = org.listSecurityManagers().toList();
349+
350+
assertThat(securityManagers, notNullValue());
351+
// In case more are added in the future
352+
assertThat(securityManagers.size(), greaterThanOrEqualTo(1));
353+
assertThat(securityManagers.stream().map(GHTeam::getName).collect(Collectors.toList()),
354+
hasItems("security team"));
355+
}
356+
338357
/**
339358
* Test list outside collaborators.
340359
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"name": "security team",
4+
"id": 31337,
5+
"node_id": "MDQ6VGVhbTMxMzM3",
6+
"slug": "security-team",
7+
"description": "Security manager role access to all git repositories",
8+
"privacy": "closed",
9+
"notification_setting": "notifications_enabled",
10+
"url": "https://api.github.com/organizations/7544739/team/31337",
11+
"html_url": "https://api.github.com/orgs/hub4j-test-org/teams/schibsted-data-security-team",
12+
"members_url": "https://api.github.com/api/v3/organizations/7544739/team/31337/members{/member}",
13+
"repositories_url": "https://api.github.com/api/v3/organizations/7544739/team/31337/repos",
14+
"permission": "pull"
15+
}
16+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"login": "hub4j-test-org",
3+
"id": 7544739,
4+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
5+
"url": "https://api.github.com/orgs/hub4j-test-org",
6+
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
7+
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
8+
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
9+
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
10+
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
11+
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
12+
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
13+
"description": null,
14+
"is_verified": false,
15+
"has_organization_projects": true,
16+
"has_repository_projects": true,
17+
"public_repos": 11,
18+
"public_gists": 0,
19+
"followers": 0,
20+
"following": 0,
21+
"html_url": "https://github.com/hub4j-test-org",
22+
"created_at": "2014-05-10T19:39:11Z",
23+
"updated_at": "2015-04-20T00:42:30Z",
24+
"type": "Organization",
25+
"total_private_repos": 0,
26+
"owned_private_repos": 0,
27+
"private_gists": 0,
28+
"disk_usage": 147,
29+
"collaborators": 0,
30+
"billing_email": "kk@kohsuke.org",
31+
"default_repository_permission": "none",
32+
"members_can_create_repositories": false,
33+
"two_factor_requirement_enabled": false,
34+
"plan": {
35+
"name": "free",
36+
"space": 976562499,
37+
"private_repos": 0,
38+
"filled_seats": 12,
39+
"seats": 0
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"id": "a3604d73-d76d-4f3e-8f7f-cecee94c5cef",
3+
"name": "user",
4+
"request": {
5+
"url": "/orgs/hub4j-test-org/security-managers",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github.v3+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "1-security-managers.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Tue, 25 Feb 2020 14:27:54 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Status": "200 OK",
21+
"X-RateLimit-Limit": "5000",
22+
"X-RateLimit-Remaining": "4999",
23+
"X-RateLimit-Reset": "1582644474",
24+
"Cache-Control": "private, max-age=60, s-maxage=60",
25+
"Vary": [
26+
"Accept, Authorization, Cookie, X-GitHub-OTP",
27+
"Accept-Encoding, Accept, X-Requested-With"
28+
],
29+
"ETag": "W/\"9adfa44fe91fb698b5fd807d9471afc3\"",
30+
"Last-Modified": "Tue, 18 Feb 2020 13:29:56 GMT",
31+
"X-OAuth-Scopes": "delete_repo, repo, user",
32+
"X-Accepted-OAuth-Scopes": "",
33+
"X-GitHub-Media-Type": "unknown, github.v3",
34+
"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",
35+
"Access-Control-Allow-Origin": "*",
36+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
37+
"X-Frame-Options": "deny",
38+
"X-Content-Type-Options": "nosniff",
39+
"X-XSS-Protection": "1; mode=block",
40+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
41+
"Content-Security-Policy": "default-src 'none'",
42+
"X-GitHub-Request-Id": "E686:35E3:5882BF:ABE338:5E552EEA"
43+
}
44+
},
45+
"uuid": "a3604d73-d76d-4f3e-8f7f-cecee94c5cef",
46+
"persistent": true,
47+
"insertionIndex": 1
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"id": "6682f58b-c93b-4525-9e99-485e631aaaab",
3+
"name": "orgs_hub4j-test-org",
4+
"request": {
5+
"url": "/orgs/hub4j-test-org",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github.v3+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "2-orgs_hub4j-test-org.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Tue, 25 Feb 2020 14:29:12 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Status": "200 OK",
21+
"X-RateLimit-Limit": "5000",
22+
"X-RateLimit-Remaining": "4991",
23+
"X-RateLimit-Reset": "1582644474",
24+
"Cache-Control": "private, max-age=60, s-maxage=60",
25+
"Vary": [
26+
"Accept, Authorization, Cookie, X-GitHub-OTP",
27+
"Accept-Encoding, Accept, X-Requested-With"
28+
],
29+
"ETag": "W/\"712644daa44df3089a27d6ef60979929\"",
30+
"Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
31+
"X-OAuth-Scopes": "delete_repo, repo, user",
32+
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
33+
"X-GitHub-Media-Type": "unknown, github.v3",
34+
"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",
35+
"Access-Control-Allow-Origin": "*",
36+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
37+
"X-Frame-Options": "deny",
38+
"X-Content-Type-Options": "nosniff",
39+
"X-XSS-Protection": "1; mode=block",
40+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
41+
"Content-Security-Policy": "default-src 'none'",
42+
"X-GitHub-Request-Id": "E7D4:4A52:336FA3:797A80:5E552F38"
43+
}
44+
},
45+
"uuid": "6682f58b-c93b-4525-9e99-485e631aaaab",
46+
"persistent": true,
47+
"insertionIndex": 2
48+
}

0 commit comments

Comments
 (0)