summaryrefslogtreecommitdiffstats
path: root/api/team_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-08-22 20:08:09 -0400
committerenahum <nahumhbl@gmail.com>2016-08-22 21:08:09 -0300
commitf0c672e3ad64f0daf023d9ef70de940b3354e133 (patch)
tree6cdbb84c914589bb229b02b1ccb0cefdc741cda1 /api/team_test.go
parent3c50442d04238eedd0e867a19674d4e01c5a1bb7 (diff)
downloadchat-f0c672e3ad64f0daf023d9ef70de940b3354e133.tar.gz
chat-f0c672e3ad64f0daf023d9ef70de940b3354e133.tar.bz2
chat-f0c672e3ad64f0daf023d9ef70de940b3354e133.zip
Changed /teams/all api to only return teams the current user is a member of if they're not an admin (#3853)
Diffstat (limited to 'api/team_test.go')
-rw-r--r--api/team_test.go36
1 files changed, 10 insertions, 26 deletions
diff --git a/api/team_test.go b/api/team_test.go
index 0d82e4e64..ade65edcd 100644
--- a/api/team_test.go
+++ b/api/team_test.go
@@ -255,7 +255,7 @@ func TestAddUserToTeamFromInvite(t *testing.T) {
}
func TestGetAllTeams(t *testing.T) {
- th := Setup().InitBasic()
+ th := Setup().InitBasic().InitSystemAdmin()
th.BasicClient.Logout()
Client := th.BasicClient
@@ -272,34 +272,18 @@ func TestGetAllTeams(t *testing.T) {
if r1, err := Client.GetAllTeams(); err != nil {
t.Fatal(err)
- } else {
- teams := r1.Data.(map[string]*model.Team)
- if teams[team.Id].Name != team.Name {
- t.Fatal()
- }
- if teams[team.Id].Email != "" {
- t.Fatal("Non admin users shoudn't get full listings")
- }
+ } else if teams := r1.Data.(map[string]*model.Team); len(teams) != 1 {
+ t.Fatal("non admin users only get the teams that they're a member of")
+ } else if receivedTeam, ok := teams[team.Id]; !ok || receivedTeam.Id != team.Id {
+ t.Fatal("should've received team that the user is a member of")
}
- c := &Context{}
- c.RequestId = model.NewId()
- c.IpAddress = "cmd_line"
- UpdateUserRoles(c, user, model.ROLE_SYSTEM_ADMIN)
-
- Client.Login(user.Email, "passwd1")
- Client.SetTeamId(team.Id)
-
- if r1, err := Client.GetAllTeams(); err != nil {
+ if r1, err := th.SystemAdminClient.GetAllTeams(); err != nil {
t.Fatal(err)
- } else {
- teams := r1.Data.(map[string]*model.Team)
- if teams[team.Id].Name != team.Name {
- t.Fatal()
- }
- if teams[team.Id].Email != team.Email {
- t.Fatal()
- }
+ } else if teams := r1.Data.(map[string]*model.Team); len(teams) == 1 {
+ t.Fatal("admin users should receive all teams")
+ } else if receivedTeam, ok := teams[team.Id]; !ok || receivedTeam.Id != team.Id {
+ t.Fatal("admin should've received team that they aren't a member of")
}
}