Skip to content

Commit

Permalink
feat: Remove the connection between an external group and a team
Browse files Browse the repository at this point in the history
  • Loading branch information
mestebangutierrez committed Apr 20, 2024
1 parent 457df48 commit 8b4b8c5
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/kohsuke/github/GHTeam.java
Expand Up @@ -494,6 +494,18 @@ public GHExternalGroup connectToExternalGroup(final long group_id) throws IOExce
}
}

/**
* Remove the connection of the team to an external group
*
* @throws IOException
* in case of failure
* @see <a href=
* "https://docs.github.com/en/enterprise-cloud@latest/rest/teams/external-groups?apiVersion=2022-11-28#remove-the-connection-between-an-external-group-and-a-team">documentation</a>
*/
public void deleteExternalGroupConnection() throws IOException {
root().createRequest().method("DELETE").withUrlPath(publicApi(EXTERNAL_GROUPS)).send();
}

/**
* Gets organization.
*
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/org/kohsuke/github/GHTeamTest.java
Expand Up @@ -8,6 +8,8 @@
import java.util.List;
import java.util.Set;

import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThrows;
Expand Down Expand Up @@ -411,4 +413,25 @@ public void testFailConnectToExternalGroupTeamIsNotAvailableInOrg() throws IOExc
assertThrows(GHFileNotFoundException.class, () -> team.connectToExternalGroup(12345));
}

/**
* Test delete connection to external group
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testDeleteExternalGroupConnection() throws IOException {
String teamSlug = "acme-developers";

GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);
GHTeam team = org.getTeamBySlug(teamSlug);

team.deleteExternalGroupConnection();

mockGitHub.apiServer()
.verify(1,
deleteRequestedFor(urlPathEqualTo("/orgs/" + team.getOrganization().getLogin() + "/teams/"
+ team.getSlug() + "/external-groups")));
}

}
@@ -0,0 +1,55 @@
{
"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://avatars.githubusercontent.com/u/7544739?v=4",
"description": "Hub4j Test Org Description (this could be null or blank too)",
"name": "Hub4j Test Org Name (this could be null or blank too)",
"company": null,
"blog": "https://hub4j.url.io/could/be/null",
"location": "Hub4j Test Org Location (this could be null or blank too)",
"email": "hub4jtestorgemail@could.be.null.com",
"twitter_username": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 49,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/hub4j-test-org",
"created_at": "2014-05-10T19:39:11Z",
"updated_at": "2020-06-04T05:56:10Z",
"type": "Organization",
"total_private_repos": 3,
"owned_private_repos": 3,
"private_gists": 0,
"disk_usage": 11979,
"collaborators": 0,
"billing_email": "kk@kohsuke.org",
"default_repository_permission": "none",
"members_can_create_repositories": false,
"two_factor_requirement_enabled": false,
"members_allowed_repository_creation_type": "none",
"members_can_create_public_repositories": false,
"members_can_create_private_repositories": false,
"members_can_create_internal_repositories": false,
"members_can_create_pages": true,
"members_can_fork_private_repositories": false,
"members_can_create_public_pages": true,
"members_can_create_private_pages": true,
"plan": {
"name": "free",
"space": 976562499,
"private_repos": 10000,
"filled_seats": 35,
"seats": 3
}
}
@@ -0,0 +1,49 @@
{
"name": "acme-developers",
"id": 34519961,
"node_id": "MDQ6VGVhbTM0NTE5OTY=",
"slug": "acme-developers",
"description": "Updated by API TestModified",
"privacy": "closed",
"url": "https://api.github.com/organizations/7544739/team/3451996",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/acme-developers",
"members_url": "https://api.github.com/organizations/7544739/team/3451996/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/3451996/repos",
"permission": "pull",
"created_at": "2019-10-03T21:46:12Z",
"updated_at": "2022-03-04T10:36:59Z",
"members_count": 1,
"repos_count": 1,
"organization": {
"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://avatars.githubusercontent.com/u/7544739?v=4",
"description": "Hub4j Test Org Description (this could be null or blank too)",
"name": "Hub4j Test Org Name (this could be null or blank too)",
"company": null,
"blog": "https://hub4j.url.io/could/be/null",
"location": "Hub4j Test Org Location (this could be null or blank too)",
"email": "hub4jtestorgemail@could.be.null.com",
"twitter_username": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 49,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/hub4j-test-org",
"created_at": "2014-05-10T19:39:11Z",
"updated_at": "2020-06-04T05:56:10Z",
"type": "Organization"
},
"parent": null
}
@@ -0,0 +1,47 @@
{
"id": "780bda7a-e76d-4840-87e4-ba6411cfc9c2",
"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": "1-orgs_hub4j-test-org.json",
"headers": {
"Server": "GitHub.com",
"Date": "Fri, 04 Mar 2022 10:36:59 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"861b38147d37bd59e507771e76ec048def20dd6e5ac5b75aceb01c8b9f0ef4f5\"",
"Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4990",
"X-RateLimit-Reset": "1646393817",
"X-RateLimit-Used": "10",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "B9F4:5E65:1A3BC41:1AAFE9E:6221EBCB"
}
},
"uuid": "780bda7a-e76d-4840-87e4-ba6411cfc9c2",
"persistent": true,
"insertionIndex": 1
}
@@ -0,0 +1,47 @@
{
"id": "e688e202-0c96-4144-b415-cb16f315d478",
"name": "orgs_hub4j-test-org_teams_acme-developers",
"request": {
"url": "/orgs/hub4j-test-org/teams/acme-developers",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github.v3+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "2-o_h_t_acme-developers.json",
"headers": {
"Server": "GitHub.com",
"Date": "Fri, 04 Mar 2022 10:37:00 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"1fbce0cbfea113fefff1877b37929ef1d7cb9c8989a5b223df3e9ea092502191\"",
"Last-Modified": "Fri, 04 Mar 2022 10:36:59 GMT",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4989",
"X-RateLimit-Reset": "1646393817",
"X-RateLimit-Used": "11",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "B9F6:361D:2C7B93A:2D76BBD:6221EBCB"
}
},
"uuid": "e688e202-0c96-4144-b415-cb16f315d478",
"persistent": true,
"insertionIndex": 2
}
@@ -0,0 +1,45 @@
{
"id": "100fc073-1fdc-4715-94c1-fbf410d74da0",
"name": "orgs_hub4j-test-org_teams_acme-developers_external-groups",
"request": {
"url": "/orgs/hub4j-test-org/teams/acme-developers/external-groups",
"method": "DELETE",
"headers": {
"Accept": {
"equalTo": "application/vnd.github.v3+json"
}
}
},
"response": {
"status": 204,
"headers": {
"Server": "GitHub.com",
"Date": "Fri, 04 Mar 2022 10:37:00 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"1f1e7f72a8c1d013af016c2df9831d999124f580cd508cb53404fdd0981ef698\"",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4988",
"X-RateLimit-Reset": "1646393817",
"X-RateLimit-Used": "12",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "B9F8:BF13:1A327EC:1B0A6BE:6221EBCC"
}
},
"uuid": "100fc073-1fdc-4715-94c1-fbf410d74da0",
"persistent": true,
"insertionIndex": 3
}

0 comments on commit 8b4b8c5

Please sign in to comment.