Fixes errcheck issues in server/channels/api4/team_test.go (#29151)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9b15c50418
Коммит
ee1d6eb887
@@ -79,7 +79,6 @@ issues:
|
|||||||
channels/api4/system.go|\
|
channels/api4/system.go|\
|
||||||
channels/api4/system_local.go|\
|
channels/api4/system_local.go|\
|
||||||
channels/api4/team_local.go|\
|
channels/api4/team_local.go|\
|
||||||
channels/api4/team_test.go|\
|
|
||||||
channels/api4/user_test.go|\
|
channels/api4/user_test.go|\
|
||||||
channels/api4/websocket_test.go|\
|
channels/api4/websocket_test.go|\
|
||||||
channels/app/bot_test.go|\
|
channels/app/bot_test.go|\
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ func TestCreateTeam(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("unauthenticated receives 403", func(t *testing.T) {
|
t.Run("unauthenticated receives 403", func(t *testing.T) {
|
||||||
th.Client.Logout(context.Background())
|
_, err := th.Client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen}
|
team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TeamOpen}
|
||||||
_, resp, err := th.Client.CreateTeam(context.Background(), team)
|
_, resp, err := th.Client.CreateTeam(context.Background(), team)
|
||||||
@@ -96,7 +97,8 @@ func TestCreateTeam(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("should verify user permissions during team creation", func(t *testing.T) {
|
t.Run("should verify user permissions during team creation", func(t *testing.T) {
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
err := th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
sc := th.SystemAdminClient
|
sc := th.SystemAdminClient
|
||||||
scheme, _, err := sc.CreateScheme(context.Background(), &model.Scheme{
|
scheme, _, err := sc.CreateScheme(context.Background(), &model.Scheme{
|
||||||
@@ -275,7 +277,8 @@ func TestGetTeam(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeam(context.Background(), team.Id, "")
|
_, resp, err = client.GetTeam(context.Background(), team.Id, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -380,7 +383,8 @@ func TestGetTeamUnread(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamUnread(context.Background(), th.BasicTeam.Id, th.BasicUser.Id)
|
_, resp, err = client.GetTeamUnread(context.Background(), th.BasicTeam.Id, th.BasicUser.Id)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -473,7 +477,8 @@ func TestUpdateTeam(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
th.Client.Logout(context.Background()) // for non-local clients
|
_, err = th.Client.Logout(context.Background())
|
||||||
|
require.NoError(t, err) // for non-local clients
|
||||||
_, resp, err = th.Client.UpdateTeam(context.Background(), team)
|
_, resp, err = th.Client.UpdateTeam(context.Background(), team)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -540,7 +545,8 @@ func TestPatchTeam(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
th.Client.Logout(context.Background())
|
_, err = th.Client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = th.Client.PatchTeam(context.Background(), team.Id, patch)
|
_, resp, err = th.Client.PatchTeam(context.Background(), team.Id, patch)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -676,7 +682,8 @@ func TestRestoreTeam(t *testing.T) {
|
|||||||
}, "restore active public team")
|
}, "restore active public team")
|
||||||
|
|
||||||
t.Run("not logged in", func(t *testing.T) {
|
t.Run("not logged in", func(t *testing.T) {
|
||||||
client.Logout(context.Background())
|
_, err := client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err := client.RestoreTeam(context.Background(), teamPublic.Id)
|
_, resp, err := client.RestoreTeam(context.Background(), teamPublic.Id)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -849,7 +856,8 @@ func TestUpdateTeamPrivacy(t *testing.T) {
|
|||||||
}, "non-existent team for admins")
|
}, "non-existent team for admins")
|
||||||
|
|
||||||
t.Run("not logged in", func(t *testing.T) {
|
t.Run("not logged in", func(t *testing.T) {
|
||||||
client.Logout(context.Background())
|
_, err := client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err := client.UpdateTeamPrivacy(context.Background(), teamPublic.Id, model.TeamInvite)
|
_, resp, err := client.UpdateTeamPrivacy(context.Background(), teamPublic.Id, model.TeamInvite)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -971,7 +979,8 @@ func TestSoftDeleteTeam(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
th.Client.Logout(context.Background())
|
_, err = th.Client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
resp, err = th.Client.SoftDeleteTeam(context.Background(), th.BasicTeam.Id)
|
resp, err = th.Client.SoftDeleteTeam(context.Background(), th.BasicTeam.Id)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -1294,7 +1303,8 @@ func TestGetAllTeams(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Unauthorized", func(t *testing.T) {
|
t.Run("Unauthorized", func(t *testing.T) {
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetAllTeams(context.Background(), "", 1, 10)
|
_, resp, err = client.GetAllTeams(context.Background(), "", 1, 10)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -1302,7 +1312,8 @@ func TestGetAllTeams(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("Sanitize the teams in the response with total count", func(t *testing.T) {
|
t.Run("Sanitize the teams in the response with total count", func(t *testing.T) {
|
||||||
otherUser := th.CreateUser()
|
otherUser := th.CreateUser()
|
||||||
client.Login(context.Background(), otherUser.Email, otherUser.Password)
|
_, _, err = client.Login(context.Background(), otherUser.Email, otherUser.Password)
|
||||||
|
require.NoError(t, err)
|
||||||
teams, _, _, err := client.GetAllTeamsWithTotalCount(context.Background(), "", 0, 10)
|
teams, _, _, err := client.GetAllTeamsWithTotalCount(context.Background(), "", 0, 10)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
for _, team := range teams {
|
for _, team := range teams {
|
||||||
@@ -1400,7 +1411,8 @@ func TestGetTeamByName(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
th.Client.Logout(context.Background())
|
_, err := th.Client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err := th.Client.GetTeamByName(context.Background(), team.Name, "")
|
_, resp, err := th.Client.GetTeamByName(context.Background(), team.Name, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -1511,7 +1523,8 @@ func TestSearchAllTeams(t *testing.T) {
|
|||||||
oTeam.UpdateAt = updatedTeam.UpdateAt
|
oTeam.UpdateAt = updatedTeam.UpdateAt
|
||||||
|
|
||||||
pTeam := &model.Team{DisplayName: "PName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TeamInvite}
|
pTeam := &model.Team{DisplayName: "PName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TeamInvite}
|
||||||
th.Client.CreateTeam(context.Background(), pTeam)
|
_, _, err := th.Client.CreateTeam(context.Background(), pTeam)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
rteams, _, err := th.Client.SearchTeams(context.Background(), &model.TeamSearch{Term: pTeam.Name})
|
rteams, _, err := th.Client.SearchTeams(context.Background(), &model.TeamSearch{Term: pTeam.Name})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1521,7 +1534,8 @@ func TestSearchAllTeams(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Empty(t, rteams, "should have not returned team")
|
require.Empty(t, rteams, "should have not returned team")
|
||||||
|
|
||||||
th.Client.Logout(context.Background())
|
_, err = th.Client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, resp, err := th.Client.SearchTeams(context.Background(), &model.TeamSearch{Term: pTeam.Name})
|
_, resp, err := th.Client.SearchTeams(context.Background(), &model.TeamSearch{Term: pTeam.Name})
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
@@ -2032,7 +2046,8 @@ func TestGetTeamMembers(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamMembers(context.Background(), team.Id, 0, 1, "")
|
_, resp, err = client.GetTeamMembers(context.Background(), team.Id, 0, 1, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -2078,13 +2093,15 @@ func TestGetTeamMembersForUser(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamMembersForUser(context.Background(), th.BasicUser.Id, "")
|
_, resp, err = client.GetTeamMembersForUser(context.Background(), th.BasicUser.Id, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
|
|
||||||
user := th.CreateUser()
|
user := th.CreateUser()
|
||||||
client.Login(context.Background(), user.Email, user.Password)
|
_, _, err = client.Login(context.Background(), user.Email, user.Password)
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamMembersForUser(context.Background(), th.BasicUser.Id, "")
|
_, resp, err = client.GetTeamMembersForUser(context.Background(), th.BasicUser.Id, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
@@ -2123,7 +2140,8 @@ func TestGetTeamMembersByIds(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamMembersByIds(context.Background(), th.BasicTeam.Id, []string{th.BasicUser.Id})
|
_, resp, err = client.GetTeamMembersByIds(context.Background(), th.BasicTeam.Id, []string{th.BasicUser.Id})
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -2157,7 +2175,8 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
_, resp, err := client.AddTeamMember(context.Background(), team.Id, otherUser.Id)
|
_, resp, err := client.AddTeamMember(context.Background(), team.Id, otherUser.Id)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
require.Error(t, err, "Error is nil")
|
require.Error(t, err, "Error is nil")
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
// SystemAdmin and mode can add member to a team
|
// SystemAdmin and mode can add member to a team
|
||||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||||
@@ -2201,7 +2220,8 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Check the appropriate permissions are enforced.
|
// Check the appropriate permissions are enforced.
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
@@ -2224,7 +2244,8 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
|
|
||||||
// Update user to team admin
|
// Update user to team admin
|
||||||
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||||
th.App.Srv().InvalidateAllCaches()
|
appErr = th.App.Srv().InvalidateAllCaches()
|
||||||
|
require.Nil(t, appErr)
|
||||||
th.LoginBasic()
|
th.LoginBasic()
|
||||||
|
|
||||||
// Should work as a team admin.
|
// Should work as a team admin.
|
||||||
@@ -2238,7 +2259,8 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
th.RemovePermissionFromRole(model.PermissionAddUserToTeam.Id, model.TeamAdminRoleId)
|
th.RemovePermissionFromRole(model.PermissionAddUserToTeam.Id, model.TeamAdminRoleId)
|
||||||
|
|
||||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||||
th.App.Srv().InvalidateAllCaches()
|
appErr = th.App.Srv().InvalidateAllCaches()
|
||||||
|
require.Nil(t, appErr)
|
||||||
th.LoginBasic()
|
th.LoginBasic()
|
||||||
|
|
||||||
// Should work as a regular user.
|
// Should work as a regular user.
|
||||||
@@ -2251,7 +2273,8 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
CheckErrorID(t, err, "api.team.add_team_member.invalid_body.app_error")
|
CheckErrorID(t, err, "api.team.add_team_member.invalid_body.app_error")
|
||||||
|
|
||||||
// by token
|
// by token
|
||||||
client.Login(context.Background(), otherUser.Email, otherUser.Password)
|
_, _, err = client.Login(context.Background(), otherUser.Email, otherUser.Password)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
token := model.NewToken(
|
token := model.NewToken(
|
||||||
app.TokenTypeTeamInvitation,
|
app.TokenTypeTeamInvitation,
|
||||||
@@ -2285,7 +2308,8 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
_, resp, err = client.AddTeamMemberFromInvite(context.Background(), token.Token, "")
|
_, resp, err = client.AddTeamMemberFromInvite(context.Background(), token.Token, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
th.App.DeleteToken(token)
|
appErr = th.App.DeleteToken(token)
|
||||||
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
// invalid team id
|
// invalid team id
|
||||||
testId := GenerateTestID()
|
testId := GenerateTestID()
|
||||||
@@ -2298,9 +2322,10 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
_, resp, err = client.AddTeamMemberFromInvite(context.Background(), token.Token, "")
|
_, resp, err = client.AddTeamMemberFromInvite(context.Background(), token.Token, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
th.App.DeleteToken(token)
|
appErr = th.App.DeleteToken(token)
|
||||||
|
require.Nil(t, appErr)
|
||||||
// by invite_id
|
// by invite_id
|
||||||
|
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||||
defer th.App.Srv().SetLicense(nil)
|
defer th.App.Srv().SetLicense(nil)
|
||||||
_, _, err = client.Login(context.Background(), guest.Email, guest.Password)
|
_, _, err = client.Login(context.Background(), guest.Email, guest.Password)
|
||||||
@@ -2311,7 +2336,8 @@ func TestAddTeamMember(t *testing.T) {
|
|||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
// by invite_id
|
// by invite_id
|
||||||
client.Login(context.Background(), otherUser.Email, otherUser.Password)
|
_, _, err = client.Login(context.Background(), otherUser.Email, otherUser.Password)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
tm, _, err = client.AddTeamMemberFromInvite(context.Background(), "", team.InviteId)
|
tm, _, err = client.AddTeamMemberFromInvite(context.Background(), "", team.InviteId)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -2438,7 +2464,8 @@ func TestAddTeamMemberMyself(t *testing.T) {
|
|||||||
t.Run(tc.Name, func(t *testing.T) {
|
t.Run(tc.Name, func(t *testing.T) {
|
||||||
team := th.CreateTeam()
|
team := th.CreateTeam()
|
||||||
team.AllowOpenInvite = tc.Public
|
team.AllowOpenInvite = tc.Public
|
||||||
th.App.UpdateTeam(team)
|
_, appErr := th.App.UpdateTeam(team)
|
||||||
|
require.Nil(t, appErr)
|
||||||
if tc.PublicPermission {
|
if tc.PublicPermission {
|
||||||
th.AddPermissionToRole(model.PermissionJoinPublicTeams.Id, model.SystemUserRoleId)
|
th.AddPermissionToRole(model.PermissionJoinPublicTeams.Id, model.SystemUserRoleId)
|
||||||
} else {
|
} else {
|
||||||
@@ -2530,7 +2557,8 @@ func TestAddTeamMembers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
guestUser := th.CreateUser()
|
guestUser := th.CreateUser()
|
||||||
th.App.UpdateUserRoles(th.Context, guestUser.Id, model.SystemGuestRoleId, false)
|
_, appErr := th.App.UpdateUserRoles(th.Context, guestUser.Id, model.SystemGuestRoleId, false)
|
||||||
|
require.Nil(t, appErr)
|
||||||
guestList := []string{
|
guestList := []string{
|
||||||
guestUser.Id,
|
guestUser.Id,
|
||||||
}
|
}
|
||||||
@@ -2540,7 +2568,7 @@ func TestAddTeamMembers(t *testing.T) {
|
|||||||
})
|
})
|
||||||
bot := th.CreateBotWithSystemAdminClient()
|
bot := th.CreateBotWithSystemAdminClient()
|
||||||
|
|
||||||
appErr := th.App.RemoveUserFromTeam(th.Context, th.BasicTeam.Id, th.BasicUser2.Id, "")
|
appErr = th.App.RemoveUserFromTeam(th.Context, th.BasicTeam.Id, th.BasicUser2.Id, "")
|
||||||
require.Nil(t, appErr)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
// Regular user can't add a member to a team they don't belong to.
|
// Regular user can't add a member to a team they don't belong to.
|
||||||
@@ -2548,7 +2576,8 @@ func TestAddTeamMembers(t *testing.T) {
|
|||||||
_, resp, err := client.AddTeamMembers(context.Background(), team.Id, userList)
|
_, resp, err := client.AddTeamMembers(context.Background(), team.Id, userList)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Regular user can add a member to a team they belong to.
|
// Regular user can add a member to a team they belong to.
|
||||||
th.LoginBasic()
|
th.LoginBasic()
|
||||||
@@ -2602,7 +2631,8 @@ func TestAddTeamMembers(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Set the config so that only team admins can add a user to a team.
|
// Set the config so that only team admins can add a user to a team.
|
||||||
th.AddPermissionToRole(model.PermissionInviteUser.Id, model.TeamAdminRoleId)
|
th.AddPermissionToRole(model.PermissionInviteUser.Id, model.TeamAdminRoleId)
|
||||||
@@ -2619,7 +2649,8 @@ func TestAddTeamMembers(t *testing.T) {
|
|||||||
|
|
||||||
// Update user to team admin
|
// Update user to team admin
|
||||||
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||||
th.App.Srv().InvalidateAllCaches()
|
appErr = th.App.Srv().InvalidateAllCaches()
|
||||||
|
require.Nil(t, appErr)
|
||||||
th.LoginBasic()
|
th.LoginBasic()
|
||||||
|
|
||||||
// Should work as a team admin.
|
// Should work as a team admin.
|
||||||
@@ -2633,7 +2664,8 @@ func TestAddTeamMembers(t *testing.T) {
|
|||||||
th.RemovePermissionFromRole(model.PermissionAddUserToTeam.Id, model.TeamAdminRoleId)
|
th.RemovePermissionFromRole(model.PermissionAddUserToTeam.Id, model.TeamAdminRoleId)
|
||||||
|
|
||||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||||
th.App.Srv().InvalidateAllCaches()
|
appErr = th.App.Srv().InvalidateAllCaches()
|
||||||
|
require.Nil(t, appErr)
|
||||||
th.LoginBasic()
|
th.LoginBasic()
|
||||||
|
|
||||||
// Should work as a regular user.
|
// Should work as a regular user.
|
||||||
@@ -2825,12 +2857,14 @@ func TestGetTeamStats(t *testing.T) {
|
|||||||
|
|
||||||
// login with different user and test if forbidden
|
// login with different user and test if forbidden
|
||||||
user := th.CreateUser()
|
user := th.CreateUser()
|
||||||
client.Login(context.Background(), user.Email, user.Password)
|
_, _, err = client.Login(context.Background(), user.Email, user.Password)
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamStats(context.Background(), th.BasicTeam.Id, "")
|
_, resp, err = client.GetTeamStats(context.Background(), th.BasicTeam.Id, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamStats(context.Background(), th.BasicTeam.Id, "")
|
_, resp, err = client.GetTeamStats(context.Background(), th.BasicTeam.Id, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -2921,7 +2955,8 @@ func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
|
|||||||
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
||||||
defer func() {
|
defer func() {
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = enableGuestAccounts })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = enableGuestAccounts })
|
||||||
th.App.Srv().RemoveLicense()
|
appErr := th.App.Srv().RemoveLicense()
|
||||||
|
require.Nil(t, appErr)
|
||||||
}()
|
}()
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||||
@@ -3049,7 +3084,8 @@ func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
SystemAdminClient.Logout(context.Background())
|
_, err = SystemAdminClient.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
resp, err = SystemAdminClient.UpdateTeamMemberSchemeRoles(context.Background(), th.BasicTeam.Id, th.SystemAdminUser.Id, s4)
|
resp, err = SystemAdminClient.UpdateTeamMemberSchemeRoles(context.Background(), th.BasicTeam.Id, th.SystemAdminUser.Id, s4)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -3061,7 +3097,8 @@ func TestGetMyTeamsUnread(t *testing.T) {
|
|||||||
client := th.Client
|
client := th.Client
|
||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
client.Login(context.Background(), user.Email, user.Password)
|
_, _, err := client.Login(context.Background(), user.Email, user.Password)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
teams, _, err := client.GetTeamsUnreadForUser(context.Background(), user.Id, "", true)
|
teams, _, err := client.GetTeamsUnreadForUser(context.Background(), user.Id, "", true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -3079,7 +3116,8 @@ func TestGetMyTeamsUnread(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err = client.GetTeamsUnreadForUser(context.Background(), user.Id, "", true)
|
_, resp, err = client.GetTeamsUnreadForUser(context.Background(), user.Id, "", true)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -3137,7 +3175,8 @@ func TestTeamExists(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Logged out user", func(t *testing.T) {
|
t.Run("Logged out user", func(t *testing.T) {
|
||||||
client.Logout(context.Background())
|
_, err := client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
_, resp, err := client.TeamExists(context.Background(), public_not_member_team.Name, "")
|
_, resp, err := client.TeamExists(context.Background(), public_not_member_team.Name, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
@@ -3310,8 +3349,10 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
emailList := memberInvite.Emails
|
emailList := memberInvite.Emails
|
||||||
|
|
||||||
//Delete all the messages before check the sample email
|
//Delete all the messages before check the sample email
|
||||||
mail.DeleteMailBox(user1)
|
err := mail.DeleteMailBox(user1)
|
||||||
mail.DeleteMailBox(user2)
|
require.NoError(t, err)
|
||||||
|
err = mail.DeleteMailBox(user2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
enableEmailInvitations := *th.App.Config().ServiceSettings.EnableEmailInvitations
|
enableEmailInvitations := *th.App.Config().ServiceSettings.EnableEmailInvitations
|
||||||
restrictCreationToDomains := th.App.Config().TeamSettings.RestrictCreationToDomains
|
restrictCreationToDomains := th.App.Config().TeamSettings.RestrictCreationToDomains
|
||||||
@@ -3322,7 +3363,7 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = false })
|
||||||
th.TestForAllClients(t, func(t *testing.T, client *model.Client4) {
|
th.TestForAllClients(t, func(t *testing.T, client *model.Client4) {
|
||||||
_, err := client.InviteUsersToTeam(context.Background(), th.BasicTeam.Id, emailList)
|
_, err = client.InviteUsersToTeam(context.Background(), th.BasicTeam.Id, emailList)
|
||||||
require.Error(t, err, "Should be disabled")
|
require.Error(t, err, "Should be disabled")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -3330,10 +3371,10 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
//Check if the email was sent to the right email address
|
//Check if the email was sent to the right email address
|
||||||
for _, email := range emailList {
|
for _, email := range emailList {
|
||||||
var resultsMailbox mail.JSONMessageHeaderInbucket
|
var resultsMailbox mail.JSONMessageHeaderInbucket
|
||||||
err := mail.RetryInbucket(5, func() error {
|
err = mail.RetryInbucket(5, func() error {
|
||||||
var err error
|
var innerErr error
|
||||||
resultsMailbox, err = mail.GetMailBox(email)
|
resultsMailbox, innerErr = mail.GetMailBox(email)
|
||||||
return err
|
return innerErr
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
@@ -3341,8 +3382,8 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if err == nil && len(resultsMailbox) > 0 {
|
if err == nil && len(resultsMailbox) > 0 {
|
||||||
require.True(t, strings.ContainsAny(resultsMailbox[len(resultsMailbox)-1].To[0], email), "Wrong To recipient")
|
require.True(t, strings.ContainsAny(resultsMailbox[len(resultsMailbox)-1].To[0], email), "Wrong To recipient")
|
||||||
resultsEmail, err := mail.GetMessageFromMailbox(email, resultsMailbox[len(resultsMailbox)-1].ID)
|
resultsEmail, mailErr := mail.GetMessageFromMailbox(email, resultsMailbox[len(resultsMailbox)-1].ID)
|
||||||
if err == nil {
|
if mailErr == nil {
|
||||||
require.Equalf(t, resultsEmail.Subject, expectedSubject, "Wrong Subject, \nactual: %s, \nexpected: %s", resultsEmail.Subject, expectedSubject)
|
require.Equalf(t, resultsEmail.Subject, expectedSubject, "Wrong Subject, \nactual: %s, \nexpected: %s", resultsEmail.Subject, expectedSubject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3350,7 +3391,7 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = true })
|
||||||
_, err := th.SystemAdminClient.InviteUsersToTeam(context.Background(), th.BasicTeam.Id, emailList)
|
_, err = th.SystemAdminClient.InviteUsersToTeam(context.Background(), th.BasicTeam.Id, emailList)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
nameFormat := *th.App.Config().TeamSettings.TeammateNameDisplay
|
nameFormat := *th.App.Config().TeamSettings.TeammateNameDisplay
|
||||||
expectedSubject := i18n.T("api.templates.invite_subject",
|
expectedSubject := i18n.T("api.templates.invite_subject",
|
||||||
@@ -3360,8 +3401,10 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
checkEmail(t, expectedSubject)
|
checkEmail(t, expectedSubject)
|
||||||
|
|
||||||
// Test the invite to team and channel
|
// Test the invite to team and channel
|
||||||
mail.DeleteMailBox(user1)
|
err = mail.DeleteMailBox(user1)
|
||||||
mail.DeleteMailBox(user2)
|
require.NoError(t, err)
|
||||||
|
err = mail.DeleteMailBox(user2)
|
||||||
|
require.NoError(t, err)
|
||||||
_, _, err = th.SystemAdminClient.InviteUsersToTeamAndChannelsGracefully(context.Background(), th.BasicTeam.Id, []string{user1, user2}, []string{th.BasicChannel.Id}, "")
|
_, _, err = th.SystemAdminClient.InviteUsersToTeamAndChannelsGracefully(context.Background(), th.BasicTeam.Id, []string{user1, user2}, []string{th.BasicChannel.Id}, "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expectedSubject = i18n.T("api.templates.invite_team_and_channel_subject",
|
expectedSubject = i18n.T("api.templates.invite_team_and_channel_subject",
|
||||||
@@ -3371,8 +3414,10 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
"SiteName": th.App.ClientConfig()["SiteName"]})
|
"SiteName": th.App.ClientConfig()["SiteName"]})
|
||||||
checkEmail(t, expectedSubject)
|
checkEmail(t, expectedSubject)
|
||||||
|
|
||||||
mail.DeleteMailBox(user1)
|
err = mail.DeleteMailBox(user1)
|
||||||
mail.DeleteMailBox(user2)
|
require.NoError(t, err)
|
||||||
|
err = mail.DeleteMailBox(user2)
|
||||||
|
require.NoError(t, err)
|
||||||
_, err = th.LocalClient.InviteUsersToTeam(context.Background(), th.BasicTeam.Id, emailList)
|
_, err = th.LocalClient.InviteUsersToTeam(context.Background(), th.BasicTeam.Id, emailList)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expectedSubject = i18n.T("api.templates.invite_subject",
|
expectedSubject = i18n.T("api.templates.invite_subject",
|
||||||
@@ -3382,8 +3427,10 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
checkEmail(t, expectedSubject)
|
checkEmail(t, expectedSubject)
|
||||||
|
|
||||||
// Test the invite local to team and channel
|
// Test the invite local to team and channel
|
||||||
mail.DeleteMailBox(user1)
|
err = mail.DeleteMailBox(user1)
|
||||||
mail.DeleteMailBox(user2)
|
require.NoError(t, err)
|
||||||
|
err = mail.DeleteMailBox(user2)
|
||||||
|
require.NoError(t, err)
|
||||||
_, _, err = th.LocalClient.InviteUsersToTeamAndChannelsGracefully(context.Background(), th.BasicTeam.Id, []string{user1, user2}, []string{th.BasicChannel.Id}, "")
|
_, _, err = th.LocalClient.InviteUsersToTeamAndChannelsGracefully(context.Background(), th.BasicTeam.Id, []string{user1, user2}, []string{th.BasicChannel.Id}, "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expectedSubject = i18n.T("api.templates.invite_team_and_channel_subject",
|
expectedSubject = i18n.T("api.templates.invite_team_and_channel_subject",
|
||||||
@@ -3462,8 +3509,10 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
|||||||
emailList := []string{guest1, guest2}
|
emailList := []string{guest1, guest2}
|
||||||
|
|
||||||
//Delete all the messages before check the sample email
|
//Delete all the messages before check the sample email
|
||||||
mail.DeleteMailBox(guest1)
|
err := mail.DeleteMailBox(guest1)
|
||||||
mail.DeleteMailBox(guest2)
|
require.NoError(t, err)
|
||||||
|
err = mail.DeleteMailBox(guest2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
enableEmailInvitations := *th.App.Config().ServiceSettings.EnableEmailInvitations
|
enableEmailInvitations := *th.App.Config().ServiceSettings.EnableEmailInvitations
|
||||||
restrictCreationToDomains := th.App.Config().TeamSettings.RestrictCreationToDomains
|
restrictCreationToDomains := th.App.Config().TeamSettings.RestrictCreationToDomains
|
||||||
@@ -3481,7 +3530,7 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
|||||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = false })
|
||||||
_, err := th.SystemAdminClient.InviteGuestsToTeam(context.Background(), th.BasicTeam.Id, emailList, []string{th.BasicChannel.Id}, "test-message")
|
_, err = th.SystemAdminClient.InviteGuestsToTeam(context.Background(), th.BasicTeam.Id, emailList, []string{th.BasicChannel.Id}, "test-message")
|
||||||
assert.Error(t, err, "Should be disabled")
|
assert.Error(t, err, "Should be disabled")
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||||
@@ -3694,7 +3743,8 @@ func TestSetTeamIcon(t *testing.T) {
|
|||||||
require.Fail(t, "Should have failed either forbidden or unauthorized")
|
require.Fail(t, "Should have failed either forbidden or unauthorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
resp, err = client.SetTeamIcon(context.Background(), team.Id, data)
|
resp, err = client.SetTeamIcon(context.Background(), team.Id, data)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
@@ -3732,7 +3782,8 @@ func TestGetTeamIcon(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckNotFoundStatus(t, resp)
|
CheckNotFoundStatus(t, resp)
|
||||||
|
|
||||||
client.Logout(context.Background())
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, resp, err = client.GetTeamIcon(context.Background(), team.Id, "")
|
_, resp, err = client.GetTeamIcon(context.Background(), team.Id, "")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
@@ -3747,22 +3798,26 @@ func TestRemoveTeamIcon(t *testing.T) {
|
|||||||
|
|
||||||
th.LoginTeamAdmin()
|
th.LoginTeamAdmin()
|
||||||
data, _ := testutils.ReadTestFile("test.png")
|
data, _ := testutils.ReadTestFile("test.png")
|
||||||
client.SetTeamIcon(context.Background(), team.Id, data)
|
_, err := client.SetTeamIcon(context.Background(), team.Id, data)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err := client.RemoveTeamIcon(context.Background(), team.Id)
|
_, err = client.RemoveTeamIcon(context.Background(), team.Id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
teamAfter, _ := th.App.GetTeam(team.Id)
|
teamAfter, _ := th.App.GetTeam(team.Id)
|
||||||
require.Equal(t, teamAfter.LastTeamIconUpdate, int64(0), "should update LastTeamIconUpdate to 0")
|
require.Equal(t, teamAfter.LastTeamIconUpdate, int64(0), "should update LastTeamIconUpdate to 0")
|
||||||
|
|
||||||
client.SetTeamIcon(context.Background(), team.Id, data)
|
_, err = client.SetTeamIcon(context.Background(), team.Id, data)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = th.SystemAdminClient.RemoveTeamIcon(context.Background(), team.Id)
|
_, err = th.SystemAdminClient.RemoveTeamIcon(context.Background(), team.Id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
teamAfter, _ = th.App.GetTeam(team.Id)
|
teamAfter, _ = th.App.GetTeam(team.Id)
|
||||||
require.Equal(t, teamAfter.LastTeamIconUpdate, int64(0), "should update LastTeamIconUpdate to 0")
|
require.Equal(t, teamAfter.LastTeamIconUpdate, int64(0), "should update LastTeamIconUpdate to 0")
|
||||||
|
|
||||||
client.SetTeamIcon(context.Background(), team.Id, data)
|
_, err = client.SetTeamIcon(context.Background(), team.Id, data)
|
||||||
client.Logout(context.Background())
|
require.NoError(t, err)
|
||||||
|
_, err = client.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
resp, err := client.RemoveTeamIcon(context.Background(), team.Id)
|
resp, err := client.RemoveTeamIcon(context.Background(), team.Id)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
@@ -3780,7 +3835,8 @@ func TestUpdateTeamScheme(t *testing.T) {
|
|||||||
|
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||||
|
|
||||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
err := th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
team := &model.Team{
|
team := &model.Team{
|
||||||
DisplayName: "Name",
|
DisplayName: "Name",
|
||||||
@@ -3810,7 +3866,7 @@ func TestUpdateTeamScheme(t *testing.T) {
|
|||||||
channelScheme, _, _ = th.SystemAdminClient.CreateScheme(context.Background(), channelScheme)
|
channelScheme, _, _ = th.SystemAdminClient.CreateScheme(context.Background(), channelScheme)
|
||||||
|
|
||||||
// Test the setup/base case.
|
// Test the setup/base case.
|
||||||
_, err := th.SystemAdminClient.UpdateTeamScheme(context.Background(), team.Id, teamScheme.Id)
|
_, err = th.SystemAdminClient.UpdateTeamScheme(context.Background(), team.Id, teamScheme.Id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Test the return to default scheme
|
// Test the return to default scheme
|
||||||
@@ -3846,7 +3902,8 @@ func TestUpdateTeamScheme(t *testing.T) {
|
|||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
// Test that an unauthenticated user gets rejected.
|
// Test that an unauthenticated user gets rejected.
|
||||||
th.SystemAdminClient.Logout(context.Background())
|
_, err = th.SystemAdminClient.Logout(context.Background())
|
||||||
|
require.NoError(t, err)
|
||||||
resp, err = th.SystemAdminClient.UpdateTeamScheme(context.Background(), team.Id, teamScheme.Id)
|
resp, err = th.SystemAdminClient.UpdateTeamScheme(context.Background(), team.Id, teamScheme.Id)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user