Repository: hub4j/github-api
Pull request #1438 (2022-04-21 11:05:36)

Fix GHTeam#remove(GHUser) and add tests
I included the original commit of https://github.com/hub4j/github-api/pull/1437 with the original author (just reworded the commit message for more clarity).

My advice would be to release something right away as this could be considered as a security issue given we are not removing people from teams appropriately.

Note that it was broken anyway since GH retired the old Teams API.


Patch:
diff --git a/src/main/java/org/kohsuke/github/GHTeam.java b/src/main/java/org/kohsuke/github/GHTeam.java
index 054889ce4..c0f7cade3 100644
--- a/src/main/java/org/kohsuke/github/GHTeam.java
+++ b/src/main/java/org/kohsuke/github/GHTeam.java
@@ -13,6 +13,8 @@ import java.util.TreeMap;
 
 import javax.annotation.Nonnull;
 
+import static org.kohsuke.github.GitHubRequest.transformEnum;
+
 /**
  * A team in GitHub organization.
  *
@@ -151,6 +153,19 @@ public class GHTeam extends GHObject implements Refreshable {
         return root().createRequest().withUrlPath(api("/members")).with("role", role).toIterable(GHUser[].class, null);
     }
 
+    /**
+     * List members with specified role paged iterable.
+     *
+     * @param role
+     *            the role
+     * @return the paged iterable
+     * @throws IOException
+     *             the io exception
+     */
+    public PagedIterable<GHUser> listMembers(Role role) throws IOException {
+        return listMembers(transformEnum(role));
+    }
+
     /**
      * Gets a single discussion by ID.
      *
@@ -288,7 +303,7 @@ public class GHTeam extends GHObject implements Refreshable {
      *             the io exception
      */
     public void remove(GHUser u) throws IOException {
-        root().createRequest().method("DELETE").withUrlPath(api("/members/" + u.getLogin())).send();
+        root().createRequest().method("DELETE").withUrlPath(api("/memberships/" + u.getLogin())).send();
     }
 
     /**


Test patch:
diff --git a/src/test/java/org/kohsuke/github/GHTeamTest.java b/src/test/java/org/kohsuke/github/GHTeamTest.java
index eb81c0cae..0a741a405 100644
--- a/src/test/java/org/kohsuke/github/GHTeamTest.java
+++ b/src/test/java/org/kohsuke/github/GHTeamTest.java
@@ -2,12 +2,18 @@ package org.kohsuke.github;
 
 import org.junit.Test;
 import org.kohsuke.github.GHTeam.Privacy;
+import org.kohsuke.github.GHTeam.Role;
 
 import java.io.IOException;
 import java.util.List;
 import java.util.Set;
 
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
 
 public class GHTeamTest extends AbstractGitHubWireMockTest {
 
@@ -137,4 +143,66 @@ public class GHTeamTest extends AbstractGitHubWireMockTest {
         assertThat(result, is(empty()));
     }
 
+    @Test
+    public void addRemoveMember() throws IOException {
+        String teamSlug = "dummy-team";
+
+        GHTeam team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
+
+        List<GHUser> members = team.listMembers().toList();
+
+        assertThat(members, notNullValue());
+        assertThat("One admin in dummy team", members.size(), equalTo(1));
+        assertThat("Specific user in admin team",
+                members.stream().anyMatch(ghUser -> ghUser.getLogin().equals("bitwiseman")));
+
+        GHUser user = gitHub.getUser("gsmet");
+
+        try {
+            team.add(user, Role.MAINTAINER);
+
+            // test all
+            members = team.listMembers().toList();
+
+            assertThat(members, notNullValue());
+            assertThat("Two members for all roles in dummy team", members.size(), equalTo(2));
+            assertThat("Specific users in team",
+                    members,
+                    containsInAnyOrder(hasProperty("login", equalTo("bitwiseman")),
+                            hasProperty("login", equalTo("gsmet"))));
+
+            // test maintainer role filter
+            members = team.listMembers(Role.MAINTAINER).toList();
+
+            assertThat(members, notNullValue());
+            assertThat("Two members for all roles in dummy team", members.size(), equalTo(2));
+            assertThat("Specific users in team",
+                    members,
+                    containsInAnyOrder(hasProperty("login", equalTo("bitwiseman")),
+                            hasProperty("login", equalTo("gsmet"))));
+
+            // test member role filter
+            // it's hard to test this as owner of the org are automatically made maintainer
+            // so let's just test that we don't have any members around
+            members = team.listMembers(Role.MEMBER).toList();
+
+            assertThat(members, notNullValue());
+            assertThat("No members in dummy team", members.size(), equalTo(0));
+
+            // test removing the user has effect
+            team.remove(user);
+
+            members = team.listMembers().toList();
+
+            assertThat(members, notNullValue());
+            assertThat("One member for all roles in dummy team", members.size(), equalTo(1));
+            assertThat("Specific user in team",
+                    members,
+                    containsInAnyOrder(hasProperty("login", equalTo("bitwiseman"))));
+        } finally {
+            if (team.hasMember(user)) {
+                team.remove(user);
+            }
+        }
+    }
 }
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-10.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-10.json
new file mode 100644
index 000000000..10e9756d2
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-10.json
@@ -0,0 +1,22 @@
+[
+  {
+    "login": "bitwiseman",
+    "id": 1958953,
+    "node_id": "MDQ6VXNlcjE5NTg5NTM=",
+    "avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/bitwiseman",
+    "html_url": "https://github.com/bitwiseman",
+    "followers_url": "https://api.github.com/users/bitwiseman/followers",
+    "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
+    "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
+    "organizations_url": "https://api.github.com/users/bitwiseman/orgs",
+    "repos_url": "https://api.github.com/users/bitwiseman/repos",
+    "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/bitwiseman/received_events",
+    "type": "User",
+    "site_admin": false
+  }
+]
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-3.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-3.json
new file mode 100644
index 000000000..10e9756d2
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-3.json
@@ -0,0 +1,22 @@
+[
+  {
+    "login": "bitwiseman",
+    "id": 1958953,
+    "node_id": "MDQ6VXNlcjE5NTg5NTM=",
+    "avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/bitwiseman",
+    "html_url": "https://github.com/bitwiseman",
+    "followers_url": "https://api.github.com/users/bitwiseman/followers",
+    "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
+    "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
+    "organizations_url": "https://api.github.com/users/bitwiseman/orgs",
+    "repos_url": "https://api.github.com/users/bitwiseman/repos",
+    "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/bitwiseman/received_events",
+    "type": "User",
+    "site_admin": false
+  }
+]
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-6.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-6.json
new file mode 100644
index 000000000..d66fd5807
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-6.json
@@ -0,0 +1,42 @@
+[
+  {
+    "login": "gsmet",
+    "id": 1279749,
+    "node_id": "MDQ6VXNlcjEyNzk3NDk=",
+    "avatar_url": "https://avatars.githubusercontent.com/u/1279749?u=e462a6165ea17647aed446ca31fae604338ae18c&v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/gsmet",
+    "html_url": "https://github.com/gsmet",
+    "followers_url": "https://api.github.com/users/gsmet/followers",
+    "following_url": "https://api.github.com/users/gsmet/following{/other_user}",
+    "gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
+    "organizations_url": "https://api.github.com/users/gsmet/orgs",
+    "repos_url": "https://api.github.com/users/gsmet/repos",
+    "events_url": "https://api.github.com/users/gsmet/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/gsmet/received_events",
+    "type": "User",
+    "site_admin": false
+  },
+  {
+    "login": "bitwiseman",
+    "id": 1958953,
+    "node_id": "MDQ6VXNlcjE5NTg5NTM=",
+    "avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/bitwiseman",
+    "html_url": "https://github.com/bitwiseman",
+    "followers_url": "https://api.github.com/users/bitwiseman/followers",
+    "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
+    "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
+    "organizations_url": "https://api.github.com/users/bitwiseman/orgs",
+    "repos_url": "https://api.github.com/users/bitwiseman/repos",
+    "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/bitwiseman/received_events",
+    "type": "User",
+    "site_admin": false
+  }
+]
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-7.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-7.json
new file mode 100644
index 000000000..d66fd5807
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/organizations_7544739_team_3451996_members-7.json
@@ -0,0 +1,42 @@
+[
+  {
+    "login": "gsmet",
+    "id": 1279749,
+    "node_id": "MDQ6VXNlcjEyNzk3NDk=",
+    "avatar_url": "https://avatars.githubusercontent.com/u/1279749?u=e462a6165ea17647aed446ca31fae604338ae18c&v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/gsmet",
+    "html_url": "https://github.com/gsmet",
+    "followers_url": "https://api.github.com/users/gsmet/followers",
+    "following_url": "https://api.github.com/users/gsmet/following{/other_user}",
+    "gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
+    "organizations_url": "https://api.github.com/users/gsmet/orgs",
+    "repos_url": "https://api.github.com/users/gsmet/repos",
+    "events_url": "https://api.github.com/users/gsmet/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/gsmet/received_events",
+    "type": "User",
+    "site_admin": false
+  },
+  {
+    "login": "bitwiseman",
+    "id": 1958953,
+    "node_id": "MDQ6VXNlcjE5NTg5NTM=",
+    "avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
+    "gravatar_id": "",
+    "url": "https://api.github.com/users/bitwiseman",
+    "html_url": "https://github.com/bitwiseman",
+    "followers_url": "https://api.github.com/users/bitwiseman/followers",
+    "following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
+    "gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
+    "starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
+    "subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
+    "organizations_url": "https://api.github.com/users/bitwiseman/orgs",
+    "repos_url": "https://api.github.com/users/bitwiseman/repos",
+    "events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
+    "received_events_url": "https://api.github.com/users/bitwiseman/received_events",
+    "type": "User",
+    "site_admin": false
+  }
+]
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/orgs_hub4j-test-org-1.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/orgs_hub4j-test-org-1.json
new file mode 100644
index 000000000..1fc92f22b
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/orgs_hub4j-test-org-1.json
@@ -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": 4,
+  "owned_private_repos": 4,
+  "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": 37,
+    "seats": 3
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/orgs_hub4j-test-org_teams_dummy-team-2.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/orgs_hub4j-test-org_teams_dummy-team-2.json
new file mode 100644
index 000000000..ce21071d5
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/orgs_hub4j-test-org_teams_dummy-team-2.json
@@ -0,0 +1,49 @@
+{
+  "name": "dummy-team",
+  "id": 3451996,
+  "node_id": "MDQ6VGVhbTM0NTE5OTY=",
+  "slug": "dummy-team",
+  "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/dummy-team",
+  "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
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/users_gsmet-4.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/users_gsmet-4.json
new file mode 100644
index 000000000..f87cbe41e
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/__files/users_gsmet-4.json
@@ -0,0 +1,46 @@
+{
+  "login": "gsmet",
+  "id": 1279749,
+  "node_id": "MDQ6VXNlcjEyNzk3NDk=",
+  "avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4",
+  "gravatar_id": "",
+  "url": "https://api.github.com/users/gsmet",
+  "html_url": "https://github.com/gsmet",
+  "followers_url": "https://api.github.com/users/gsmet/followers",
+  "following_url": "https://api.github.com/users/gsmet/following{/other_user}",
+  "gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}",
+  "starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}",
+  "subscriptions_url": "https://api.github.com/users/gsmet/subscriptions",
+  "organizations_url": "https://api.github.com/users/gsmet/orgs",
+  "repos_url": "https://api.github.com/users/gsmet/repos",
+  "events_url": "https://api.github.com/users/gsmet/events{/privacy}",
+  "received_events_url": "https://api.github.com/users/gsmet/received_events",
+  "type": "User",
+  "site_admin": false,
+  "name": "Guillaume Smet",
+  "company": "Red Hat",
+  "blog": "https://lesincroyableslivres.fr/",
+  "location": "Lyon, France",
+  "email": "guillaume.smet@gmail.com",
+  "hireable": null,
+  "bio": "Happy camper at Red Hat, working on Quarkus and the Hibernate portfolio.",
+  "twitter_username": "gsmet_",
+  "public_repos": 152,
+  "public_gists": 15,
+  "followers": 174,
+  "following": 3,
+  "created_at": "2011-12-22T11:03:22Z",
+  "updated_at": "2022-04-14T20:01:34Z",
+  "private_gists": 14,
+  "total_private_repos": 4,
+  "owned_private_repos": 1,
+  "disk_usage": 70883,
+  "collaborators": 1,
+  "two_factor_authentication": true,
+  "plan": {
+    "name": "free",
+    "space": 976562499,
+    "collaborators": 0,
+    "private_repos": 10000
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-10.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-10.json
new file mode 100644
index 000000000..26db3e84a
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-10.json
@@ -0,0 +1,48 @@
+{
+  "id": "424c6f1d-3e8a-4153-803c-38fa04347733",
+  "name": "organizations_7544739_team_3451996_members",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/members?role=all",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "organizations_7544739_team_3451996_members-10.json",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:53 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/\"8bded93da98ec3ba7968a4518dc805d37d535c798a700a1616ec568c70b76aae\"",
+      "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": "4973",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "27",
+      "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": "C192:1227A:CA2E10:CE35A1:62613875"
+    }
+  },
+  "uuid": "424c6f1d-3e8a-4153-803c-38fa04347733",
+  "persistent": true,
+  "scenarioName": "scenario-1-organizations-7544739-team-3451996-members",
+  "requiredScenarioState": "scenario-1-organizations-7544739-team-3451996-members-3",
+  "insertionIndex": 10
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-3.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-3.json
new file mode 100644
index 000000000..20df19ea8
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-3.json
@@ -0,0 +1,49 @@
+{
+  "id": "c2ad8b47-3d58-484d-91db-32576d8ec1cb",
+  "name": "organizations_7544739_team_3451996_members",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/members?role=all",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "organizations_7544739_team_3451996_members-3.json",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:50 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/\"8bded93da98ec3ba7968a4518dc805d37d535c798a700a1616ec568c70b76aae\"",
+      "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": "4980",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "20",
+      "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": "C182:B3FE:126871A:12B1E66:62613872"
+    }
+  },
+  "uuid": "c2ad8b47-3d58-484d-91db-32576d8ec1cb",
+  "persistent": true,
+  "scenarioName": "scenario-1-organizations-7544739-team-3451996-members",
+  "requiredScenarioState": "Started",
+  "newScenarioState": "scenario-1-organizations-7544739-team-3451996-members-2",
+  "insertionIndex": 3
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-6.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-6.json
new file mode 100644
index 000000000..0eb3f92af
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-6.json
@@ -0,0 +1,49 @@
+{
+  "id": "e0b9766d-ff6d-4e8e-a3bb-d645297d18be",
+  "name": "organizations_7544739_team_3451996_members",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/members?role=all",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "organizations_7544739_team_3451996_members-6.json",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:51 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/\"da8fb970de728aff6154c2f2a9083e384ea024b402424bc8456f0c4117a6deaf\"",
+      "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": "4977",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "23",
+      "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": "C18A:4960:8D57BF:8FD6E5:62613873"
+    }
+  },
+  "uuid": "e0b9766d-ff6d-4e8e-a3bb-d645297d18be",
+  "persistent": true,
+  "scenarioName": "scenario-1-organizations-7544739-team-3451996-members",
+  "requiredScenarioState": "scenario-1-organizations-7544739-team-3451996-members-2",
+  "newScenarioState": "scenario-1-organizations-7544739-team-3451996-members-3",
+  "insertionIndex": 6
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-7.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-7.json
new file mode 100644
index 000000000..69c75821b
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-7.json
@@ -0,0 +1,46 @@
+{
+  "id": "43361fed-9632-4319-a7a7-3abeecf3790f",
+  "name": "organizations_7544739_team_3451996_members",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/members?role=maintainer",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "organizations_7544739_team_3451996_members-7.json",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:51 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/\"da8fb970de728aff6154c2f2a9083e384ea024b402424bc8456f0c4117a6deaf\"",
+      "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": "4976",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "24",
+      "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": "C18C:7057:121D070:12649B9:62613873"
+    }
+  },
+  "uuid": "43361fed-9632-4319-a7a7-3abeecf3790f",
+  "persistent": true,
+  "insertionIndex": 7
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-8.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-8.json
new file mode 100644
index 000000000..d3efb30f7
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_members-8.json
@@ -0,0 +1,46 @@
+{
+  "id": "8c628b1f-bb2f-4a3f-b714-c5a49fe0e9fb",
+  "name": "organizations_7544739_team_3451996_members",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/members?role=member",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "body": "[]",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:52 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": "\"e33d671b99cfd3b69cbea6599065ce3f5431730434d2452958e0865316fdb5be\"",
+      "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": "4975",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "25",
+      "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": "C18E:8011:C859B4:CC5ACE:62613874"
+    }
+  },
+  "uuid": "8c628b1f-bb2f-4a3f-b714-c5a49fe0e9fb",
+  "persistent": true,
+  "insertionIndex": 8
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-11.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-11.json
new file mode 100644
index 000000000..0c423f552
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-11.json
@@ -0,0 +1,41 @@
+{
+  "id": "54b46c29-3b21-41ff-8dbe-bc90f4e2834f",
+  "name": "organizations_7544739_team_3451996_memberships_gsmet",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/memberships/gsmet",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 404,
+    "body": "{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest/reference/teams#get-team-membership-for-a-user\"}",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:53 GMT",
+      "Content-Type": "application/json; charset=utf-8",
+      "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, write:org",
+      "X-GitHub-Media-Type": "github.v3; format=json",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4972",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "28",
+      "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'",
+      "Vary": "Accept-Encoding, Accept, X-Requested-With",
+      "X-GitHub-Request-Id": "C194:B3FD:C25197:C63FCC:62613875"
+    }
+  },
+  "uuid": "54b46c29-3b21-41ff-8dbe-bc90f4e2834f",
+  "persistent": true,
+  "insertionIndex": 11
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-5.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-5.json
new file mode 100644
index 000000000..fd01acdb9
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-5.json
@@ -0,0 +1,53 @@
+{
+  "id": "5ae8bc2b-2b7d-4e1a-bce3-84b91d3a4e41",
+  "name": "organizations_7544739_team_3451996_memberships_gsmet",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/memberships/gsmet",
+    "method": "PUT",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    },
+    "bodyPatterns": [
+      {
+        "equalToJson": "{\"role\":\"maintainer\"}",
+        "ignoreArrayOrder": true,
+        "ignoreExtraElements": false
+      }
+    ]
+  },
+  "response": {
+    "status": 200,
+    "body": "{\"state\":\"active\",\"role\":\"maintainer\",\"url\":\"https://api.github.com/organizations/7544739/team/3451996/memberships/gsmet\"}",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:51 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/\"6e79bcc9d1fb97f3ea11c87805d3dafea4016657495845ba0b3c74b9492cb67d\"",
+      "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, repo",
+      "X-GitHub-Media-Type": "github.v3; format=json",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4978",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "22",
+      "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": "C188:495D:1E8F50:2038E7:62613873"
+    }
+  },
+  "uuid": "5ae8bc2b-2b7d-4e1a-bce3-84b91d3a4e41",
+  "persistent": true,
+  "insertionIndex": 5
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-9.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-9.json
new file mode 100644
index 000000000..e2cda5d4d
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/organizations_7544739_team_3451996_memberships_gsmet-9.json
@@ -0,0 +1,39 @@
+{
+  "id": "1b440ab0-a70b-43a3-8295-b69f335f3e0b",
+  "name": "organizations_7544739_team_3451996_memberships_gsmet",
+  "request": {
+    "url": "/organizations/7544739/team/3451996/memberships/gsmet",
+    "method": "DELETE",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 204,
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:53 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, repo",
+      "X-GitHub-Media-Type": "github.v3; format=json",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4974",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "26",
+      "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'",
+      "Vary": "Accept-Encoding, Accept, X-Requested-With",
+      "X-GitHub-Request-Id": "C190:B3FE:1268AB0:12B21EB:62613874"
+    }
+  },
+  "uuid": "1b440ab0-a70b-43a3-8295-b69f335f3e0b",
+  "persistent": true,
+  "insertionIndex": 9
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/orgs_hub4j-test-org-1.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/orgs_hub4j-test-org-1.json
new file mode 100644
index 000000000..a6e0aadc6
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/orgs_hub4j-test-org-1.json
@@ -0,0 +1,47 @@
+{
+  "id": "07e23af6-158e-4ae7-8733-c0cd44af55d9",
+  "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": "orgs_hub4j-test-org-1.json",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:49 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/\"c02031d2ea85f3634e9f8fe9240f1d2790a675e0cc9c2884fad5cd632a52ce94\"",
+      "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": "4982",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "18",
+      "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": "C17E:4960:8D54D8:8FD3FA:62613871"
+    }
+  },
+  "uuid": "07e23af6-158e-4ae7-8733-c0cd44af55d9",
+  "persistent": true,
+  "insertionIndex": 1
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/orgs_hub4j-test-org_teams_dummy-team-2.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/orgs_hub4j-test-org_teams_dummy-team-2.json
new file mode 100644
index 000000000..9e1f0ba38
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/orgs_hub4j-test-org_teams_dummy-team-2.json
@@ -0,0 +1,47 @@
+{
+  "id": "66add0d9-eb3e-4c1f-bea2-6e0f32941e92",
+  "name": "orgs_hub4j-test-org_teams_dummy-team",
+  "request": {
+    "url": "/orgs/hub4j-test-org/teams/dummy-team",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "orgs_hub4j-test-org_teams_dummy-team-2.json",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:50 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": "4981",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "19",
+      "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": "C180:E7CD:1147E92:118D151:62613872"
+    }
+  },
+  "uuid": "66add0d9-eb3e-4c1f-bea2-6e0f32941e92",
+  "persistent": true,
+  "insertionIndex": 2
+}
\ No newline at end of file
diff --git a/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/users_gsmet-4.json b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/users_gsmet-4.json
new file mode 100644
index 000000000..709ab6ec3
--- /dev/null
+++ b/src/test/resources/org/kohsuke/github/GHTeamTest/wiremock/addRemoveMember/mappings/users_gsmet-4.json
@@ -0,0 +1,47 @@
+{
+  "id": "dc528185-62a6-431c-b570-3a1c768fe91c",
+  "name": "users_gsmet",
+  "request": {
+    "url": "/users/gsmet",
+    "method": "GET",
+    "headers": {
+      "Accept": {
+        "equalTo": "application/vnd.github.v3+json"
+      }
+    }
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "users_gsmet-4.json",
+    "headers": {
+      "Server": "GitHub.com",
+      "Date": "Thu, 21 Apr 2022 10:56:50 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/\"93ed71936dd0a92c3d1561cfdfbe7ea961c27ab15c76ec2608bcccba0b3c3284\"",
+      "Last-Modified": "Thu, 14 Apr 2022 20:01:34 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": "",
+      "X-GitHub-Media-Type": "github.v3; format=json",
+      "X-RateLimit-Limit": "5000",
+      "X-RateLimit-Remaining": "4979",
+      "X-RateLimit-Reset": "1650541694",
+      "X-RateLimit-Used": "21",
+      "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": "C184:1227B:12AEABF:12F6177:62613872"
+    }
+  },
+  "uuid": "dc528185-62a6-431c-b570-3a1c768fe91c",
+  "persistent": true,
+  "insertionIndex": 4
+}
\ No newline at end of file