From d5f243dad694d6746ec2b6560a81212a78d8c975 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Wed, 6 Jul 2016 13:40:59 -0800 Subject: PLT-2863 adding remove user from team (#3429) * PLT-2863 adding remove user from team * PLT-2863 adding the client side UI * Fixing trailing space * Fixing reported issues * Adding documentatino * Switching to final javascript driver --- api/team_test.go | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'api/team_test.go') diff --git a/api/team_test.go b/api/team_test.go index a62ffcdb5..9fc3e8105 100644 --- a/api/team_test.go +++ b/api/team_test.go @@ -158,7 +158,7 @@ func TestAddUserToTeam(t *testing.T) { } user2 := th.CreateUser(th.BasicClient) - if result, err := th.BasicClient.AddUserToTeam(user2.Id); err != nil { + if result, err := th.BasicClient.AddUserToTeam("", user2.Id); err != nil { t.Fatal(err) } else { rm := result.Data.(map[string]string) @@ -168,6 +168,39 @@ func TestAddUserToTeam(t *testing.T) { } } +func TestRemoveUserFromTeam(t *testing.T) { + th := Setup().InitSystemAdmin().InitBasic() + + if _, err := th.BasicClient.RemoveUserFromTeam(th.SystemAdminTeam.Id, th.SystemAdminUser.Id); err == nil { + t.Fatal("should fail not enough permissions") + } else { + if err.Id != "api.context.permissions.app_error" { + t.Fatal("wrong error") + } + } + + if _, err := th.BasicClient.RemoveUserFromTeam("", th.SystemAdminUser.Id); err == nil { + t.Fatal("should fail not enough permissions") + } else { + if err.Id != "api.team.update_team.permissions.app_error" { + t.Fatal("wrong error") + } + } + + if _, err := th.BasicClient.RemoveUserFromTeam("", th.BasicUser.Id); err != nil { + t.Fatal("should have removed the user from the team") + } + + th.BasicClient.Logout() + th.LoginSystemAdmin() + + th.SystemAdminClient.Must(th.SystemAdminClient.AddUserToTeam(th.BasicTeam.Id, th.BasicUser.Id)) + + if _, err := th.SystemAdminClient.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser.Id); err != nil { + t.Fatal("should have removed the user from the team") + } +} + func TestAddUserToTeamFromInvite(t *testing.T) { th := Setup().InitBasic() th.BasicClient.Logout() -- cgit v1.2.3-1-g7c22