Skip to content

Commit

Permalink
Merge pull request #1832 from kozmic/patch-1
Browse files Browse the repository at this point in the history
Add GHOrganization.listSecurityManagers()
  • Loading branch information
bitwiseman committed Jun 17, 2024
2 parents e0edb9d + 92112af commit dd274c3
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/kohsuke/github/GHOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,19 @@ private PagedIterable<GHUser> listMembers(final String suffix, final String filt
.toIterable(GHUser[].class, null);
}

/**
* List up all the security managers.
*
* @return the paged iterable
* @throws IOException
* the io exception
*/
public PagedIterable<GHTeam> listSecurityManagers() throws IOException {
return root().createRequest()
.withUrlPath(String.format("/orgs/%s/security-managers", login))
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
}

/**
* Conceals the membership.
*
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/org/kohsuke/github/GHOrganizationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,25 @@ public void testListMembersWithRole() throws IOException {
"timja"));
}

/**
* Test list security managers.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testListSecurityManagers() throws IOException {
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);

List<GHTeam> securityManagers = org.listSecurityManagers().toList();

assertThat(securityManagers, notNullValue());
// In case more are added in the future
assertThat(securityManagers.size(), greaterThanOrEqualTo(1));
assertThat(securityManagers.stream().map(GHTeam::getName).collect(Collectors.toList()),
hasItems("security team"));
}

/**
* Test list outside collaborators.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"name": "security team",
"id": 31337,
"node_id": "MDQ6VGVhbTMxMzM3",
"slug": "security-team",
"description": "Security manager role access to all git repositories",
"privacy": "closed",
"notification_setting": "notifications_enabled",
"url": "https://api.github.com/organizations/7544739/team/31337",
"html_url": "https://api.github.com/orgs/hub4j-test-org/teams/schibsted-data-security-team",
"members_url": "https://api.github.com/api/v3/organizations/7544739/team/31337/members{/member}",
"repositories_url": "https://api.github.com/api/v3/organizations/7544739/team/31337/repos",
"permission": "pull"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"url": "https://api.github.com/orgs/hub4j-test-org",
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
"public_members_url": "https://api.github.com/orgs/hub4j-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": 11,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/hub4j-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": 147,
"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": 12,
"seats": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "a3604d73-d76d-4f3e-8f7f-cecee94c5cef",
"name": "user",
"request": {
"url": "/orgs/hub4j-test-org/security-managers",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github.v3+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "1-security-managers.json",
"headers": {
"Server": "GitHub.com",
"Date": "Tue, 25 Feb 2020 14:27:54 GMT",
"Content-Type": "application/json; charset=utf-8",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4999",
"X-RateLimit-Reset": "1582644474",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"9adfa44fe91fb698b5fd807d9471afc3\"",
"Last-Modified": "Tue, 18 Feb 2020 13:29:56 GMT",
"X-OAuth-Scopes": "delete_repo, repo, user",
"X-Accepted-OAuth-Scopes": "",
"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": "E686:35E3:5882BF:ABE338:5E552EEA"
}
},
"uuid": "a3604d73-d76d-4f3e-8f7f-cecee94c5cef",
"persistent": true,
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "6682f58b-c93b-4525-9e99-485e631aaaab",
"name": "orgs_hub4j-test-org",
"request": {
"url": "/orgs/hub4j-test-org",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github.v3+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "2-orgs_hub4j-test-org.json",
"headers": {
"Server": "GitHub.com",
"Date": "Tue, 25 Feb 2020 14:29:12 GMT",
"Content-Type": "application/json; charset=utf-8",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4991",
"X-RateLimit-Reset": "1582644474",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"712644daa44df3089a27d6ef60979929\"",
"Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
"X-OAuth-Scopes": "delete_repo, repo, user",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"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": "E7D4:4A52:336FA3:797A80:5E552F38"
}
},
"uuid": "6682f58b-c93b-4525-9e99-485e631aaaab",
"persistent": true,
"insertionIndex": 2
}

0 comments on commit dd274c3

Please sign in to comment.