add megacheck as makefile target (#9288)
Fix code issues in channel_test.go Fix Channel Test Issues detected by Megacheck Fix API Emoji Test Issues detected by Megacheck Fixed API Issues Reported by Megacheck Fixed App issues reported by megacheck Remaining fixes removed test added by mistake from old HEAD gofmt Store Fixes simplified returns Fix test for multi member channel delete revert to delete unused function
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
68fdaaa995
Коммит
531897b1f0
@@ -150,8 +150,8 @@ func TestUpdateChannel(t *testing.T) {
|
||||
channel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.CHANNEL_OPEN, TeamId: team.Id}
|
||||
private := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.CHANNEL_PRIVATE, TeamId: team.Id}
|
||||
|
||||
channel, resp := Client.CreateChannel(channel)
|
||||
private, resp = Client.CreateChannel(private)
|
||||
channel, _ = Client.CreateChannel(channel)
|
||||
private, _ = Client.CreateChannel(private)
|
||||
|
||||
//Update a open channel
|
||||
channel.DisplayName = "My new display name"
|
||||
@@ -434,7 +434,7 @@ func TestCreateGroupChannel(t *testing.T) {
|
||||
t.Fatal("should be equal")
|
||||
}
|
||||
|
||||
rgc, resp = Client.CreateGroupChannel([]string{user2.Id})
|
||||
_, resp = Client.CreateGroupChannel([]string{user2.Id})
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
user4 := th.CreateUser()
|
||||
@@ -541,12 +541,12 @@ func TestGetDeletedChannelsForTeam(t *testing.T) {
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
channels, resp := Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
|
||||
_, resp := Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.LoginTeamAdmin()
|
||||
|
||||
channels, resp = Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
|
||||
channels, resp := Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
|
||||
CheckNoError(t, resp)
|
||||
numInitialChannelsForTeam := len(channels)
|
||||
|
||||
@@ -860,6 +860,7 @@ func TestDeleteChannel(t *testing.T) {
|
||||
|
||||
// successful delete of channel with multiple members
|
||||
publicChannel3 := th.CreatePublicChannel()
|
||||
th.App.AddUserToChannel(user, publicChannel3)
|
||||
th.App.AddUserToChannel(user2, publicChannel3)
|
||||
_, resp = Client.DeleteChannel(publicChannel3.Id)
|
||||
CheckNoError(t, resp)
|
||||
@@ -901,7 +902,7 @@ func TestDeleteChannel(t *testing.T) {
|
||||
publicChannel5 := th.CreatePublicChannel()
|
||||
Client.Logout()
|
||||
|
||||
Client.Login(user2.Id, user2.Password)
|
||||
Client.Login(user.Id, user.Password)
|
||||
_, resp = Client.DeleteChannel(publicChannel5.Id)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
@@ -927,16 +928,14 @@ func TestDeleteChannel(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_DELETE_PRIVATE_CHANNEL.Id, model.TEAM_USER_ROLE_ID)
|
||||
|
||||
Client = th.Client
|
||||
team = th.BasicTeam
|
||||
user = th.BasicUser
|
||||
user2 = th.BasicUser2
|
||||
|
||||
// channels created by SystemAdmin
|
||||
publicChannel6 := th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_OPEN)
|
||||
privateChannel7 := th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
|
||||
th.App.AddUserToChannel(user, publicChannel6)
|
||||
th.App.AddUserToChannel(user, privateChannel7)
|
||||
th.App.AddUserToChannel(user2, privateChannel7)
|
||||
th.App.AddUserToChannel(user, privateChannel7)
|
||||
|
||||
// successful delete by user
|
||||
_, resp = Client.DeleteChannel(publicChannel6.Id)
|
||||
@@ -956,7 +955,7 @@ func TestDeleteChannel(t *testing.T) {
|
||||
privateChannel7 = th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
|
||||
th.App.AddUserToChannel(user, publicChannel6)
|
||||
th.App.AddUserToChannel(user, privateChannel7)
|
||||
th.App.AddUserToChannel(user2, privateChannel7)
|
||||
th.App.AddUserToChannel(user, privateChannel7)
|
||||
|
||||
// cannot delete by user
|
||||
_, resp = Client.DeleteChannel(publicChannel6.Id)
|
||||
@@ -1629,7 +1628,7 @@ func TestUpdateChannelRoles(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
|
||||
// System Admin promotes User 1
|
||||
pass, resp = th.SystemAdminClient.UpdateChannelRoles(channel.Id, th.BasicUser.Id, CHANNEL_ADMIN)
|
||||
_, resp = th.SystemAdminClient.UpdateChannelRoles(channel.Id, th.BasicUser.Id, CHANNEL_ADMIN)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.LoginBasic()
|
||||
|
||||
@@ -329,12 +329,16 @@ func TestDeleteEmoji(t *testing.T) {
|
||||
|
||||
th.RemovePermissionFromRole(model.PERMISSION_MANAGE_EMOJIS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OTHERS_EMOJIS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
|
||||
Client.Logout()
|
||||
th.LoginBasic2()
|
||||
ok, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
|
||||
_, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.RemovePermissionFromRole(model.PERMISSION_MANAGE_OTHERS_EMOJIS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_EMOJIS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
|
||||
Client.Logout()
|
||||
th.LoginBasic()
|
||||
|
||||
@@ -349,8 +353,10 @@ func TestDeleteEmoji(t *testing.T) {
|
||||
|
||||
Client.Logout()
|
||||
th.LoginBasic2()
|
||||
ok, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
|
||||
_, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
th.LoginBasic()
|
||||
|
||||
@@ -365,9 +371,11 @@ func TestDeleteEmoji(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_EMOJIS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OTHERS_EMOJIS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
|
||||
Client.Logout()
|
||||
th.LoginBasic2()
|
||||
ok, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
|
||||
_, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
@@ -401,7 +409,8 @@ func TestDeleteEmoji(t *testing.T) {
|
||||
|
||||
Client.Logout()
|
||||
th.LoginBasic2()
|
||||
ok, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
|
||||
_, resp = Client.DeleteEmoji(newEmoji.Id)
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@ func TestGetFileLink(t *testing.T) {
|
||||
fileId = fileResp.FileInfos[0].Id
|
||||
}
|
||||
|
||||
link, resp := Client.GetFileLink(fileId)
|
||||
_, resp := Client.GetFileLink(fileId)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
// Hacky way to assign file to a post (usually would be done by CreatePost call)
|
||||
@@ -460,8 +460,9 @@ func TestGetFileLink(t *testing.T) {
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = true })
|
||||
link, resp = Client.GetFileLink(fileId)
|
||||
link, resp := Client.GetFileLink(fileId)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
if link == "" {
|
||||
t.Fatal("should've received public link")
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestCreatePost(t *testing.T) {
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
post2 := &model.Post{ChannelId: th.BasicChannel2.Id, Message: "zz" + model.NewId() + "a", CreateAt: 123}
|
||||
rpost2, resp := Client.CreatePost(post2)
|
||||
rpost2, _ := Client.CreatePost(post2)
|
||||
|
||||
if rpost2.CreateAt == post2.CreateAt {
|
||||
t.Fatal("create at should not match")
|
||||
@@ -154,7 +154,7 @@ func TestCreatePostEphemeral(t *testing.T) {
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
Client = th.Client
|
||||
rpost, resp = Client.CreatePostEphemeral(ephemeralPost)
|
||||
_, resp = Client.CreatePostEphemeral(ephemeralPost)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
}
|
||||
|
||||
@@ -1023,22 +1023,22 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
|
||||
|
||||
Client.Logout()
|
||||
|
||||
rpl, resp = Client.GetFlaggedPostsForUserInChannel(user.Id, channel1.Id, 0, 10)
|
||||
_, resp = Client.GetFlaggedPostsForUserInChannel(user.Id, channel1.Id, 0, 10)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
rpl, resp = Client.GetFlaggedPostsForUserInTeam(user.Id, team1.Id, 0, 10)
|
||||
_, resp = Client.GetFlaggedPostsForUserInTeam(user.Id, team1.Id, 0, 10)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
rpl, resp = Client.GetFlaggedPostsForUser(user.Id, 0, 10)
|
||||
_, resp = Client.GetFlaggedPostsForUser(user.Id, 0, 10)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
rpl, resp = th.SystemAdminClient.GetFlaggedPostsForUserInChannel(user.Id, channel1.Id, 0, 10)
|
||||
_, resp = th.SystemAdminClient.GetFlaggedPostsForUserInChannel(user.Id, channel1.Id, 0, 10)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
rpl, resp = th.SystemAdminClient.GetFlaggedPostsForUserInTeam(user.Id, team1.Id, 0, 10)
|
||||
_, resp = th.SystemAdminClient.GetFlaggedPostsForUserInTeam(user.Id, team1.Id, 0, 10)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
rpl, resp = th.SystemAdminClient.GetFlaggedPostsForUser(user.Id, 0, 10)
|
||||
_, resp = th.SystemAdminClient.GetFlaggedPostsForUser(user.Id, 0, 10)
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
@@ -1153,25 +1153,25 @@ func TestGetPost(t *testing.T) {
|
||||
Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id)
|
||||
|
||||
// Channel is public, should be able to read post
|
||||
post, resp = Client.GetPost(th.BasicPost.Id, "")
|
||||
_, resp = Client.GetPost(th.BasicPost.Id, "")
|
||||
CheckNoError(t, resp)
|
||||
|
||||
privatePost := th.CreatePostWithClient(Client, th.BasicPrivateChannel)
|
||||
|
||||
post, resp = Client.GetPost(privatePost.Id, "")
|
||||
_, resp = Client.GetPost(privatePost.Id, "")
|
||||
CheckNoError(t, resp)
|
||||
|
||||
Client.RemoveUserFromChannel(th.BasicPrivateChannel.Id, th.BasicUser.Id)
|
||||
|
||||
// Channel is private, should not be able to read post
|
||||
post, resp = Client.GetPost(privatePost.Id, "")
|
||||
_, resp = Client.GetPost(privatePost.Id, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
_, resp = Client.GetPost(model.NewId(), "")
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
post, resp = th.SystemAdminClient.GetPost(th.BasicPost.Id, "")
|
||||
_, resp = th.SystemAdminClient.GetPost(th.BasicPost.Id, "")
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
@@ -1267,7 +1267,7 @@ func TestGetPostThread(t *testing.T) {
|
||||
_, resp = Client.GetPostThread(model.NewId(), "")
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
list, resp = th.SystemAdminClient.GetPostThread(th.BasicPost.Id, "")
|
||||
_, resp = th.SystemAdminClient.GetPostThread(th.BasicPost.Id, "")
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
@@ -1351,12 +1351,13 @@ func TestSearchPosts(t *testing.T) {
|
||||
t.Fatal("wrong search")
|
||||
}
|
||||
|
||||
if posts, resp = Client.SearchPosts(th.BasicTeam.Id, "*", false); len(posts.Order) != 0 {
|
||||
if posts, _ = Client.SearchPosts(th.BasicTeam.Id, "*", false); len(posts.Order) != 0 {
|
||||
t.Fatal("searching for just * shouldn't return any results")
|
||||
}
|
||||
|
||||
posts, resp = Client.SearchPosts(th.BasicTeam.Id, "post1 post2", true)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
if len(posts.Order) != 2 {
|
||||
t.Fatal("wrong search results")
|
||||
}
|
||||
|
||||
@@ -105,15 +105,15 @@ func TestGetPreferencesByCategory(t *testing.T) {
|
||||
t.Fatalf("received the wrong number of preferences %v:%v", len(prefs), 2)
|
||||
}
|
||||
|
||||
prefs, resp = Client.GetPreferencesByCategory(user1.Id, "junk")
|
||||
_, resp = Client.GetPreferencesByCategory(user1.Id, "junk")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
th.LoginBasic2()
|
||||
|
||||
prefs, resp = Client.GetPreferencesByCategory(th.BasicUser2.Id, category)
|
||||
_, resp = Client.GetPreferencesByCategory(th.BasicUser2.Id, category)
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
prefs, resp = Client.GetPreferencesByCategory(user1.Id, category)
|
||||
_, resp = Client.GetPreferencesByCategory(user1.Id, category)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
prefs, resp = Client.GetPreferencesByCategory(th.BasicUser2.Id, "junk")
|
||||
@@ -309,7 +309,7 @@ func TestDeletePreferences(t *testing.T) {
|
||||
|
||||
th.LoginBasic()
|
||||
|
||||
prefs, resp := Client.GetPreferences(th.BasicUser.Id)
|
||||
prefs, _ := Client.GetPreferences(th.BasicUser.Id)
|
||||
originalCount := len(prefs)
|
||||
|
||||
// save 10 preferences
|
||||
@@ -328,7 +328,7 @@ func TestDeletePreferences(t *testing.T) {
|
||||
// delete 10 preferences
|
||||
th.LoginBasic2()
|
||||
|
||||
_, resp = Client.DeletePreferences(th.BasicUser2.Id, &preferences)
|
||||
_, resp := Client.DeletePreferences(th.BasicUser2.Id, &preferences)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.LoginBasic()
|
||||
@@ -339,7 +339,7 @@ func TestDeletePreferences(t *testing.T) {
|
||||
_, resp = Client.DeletePreferences(th.BasicUser2.Id, &preferences)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
prefs, resp = Client.GetPreferences(th.BasicUser.Id)
|
||||
prefs, _ = Client.GetPreferences(th.BasicUser.Id)
|
||||
if len(prefs) != originalCount {
|
||||
t.Fatal("should've deleted preferences")
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func TestGetRolesByNames(t *testing.T) {
|
||||
assert.Contains(t, received, role3)
|
||||
|
||||
// Check a list of non-existent roles.
|
||||
received, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId()})
|
||||
_, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId()})
|
||||
CheckNoError(t, resp)
|
||||
|
||||
// Empty list should error.
|
||||
@@ -138,11 +138,11 @@ func TestGetRolesByNames(t *testing.T) {
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
// Invalid role name should error.
|
||||
received, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId(), "!!!!!!"})
|
||||
_, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId(), "!!!!!!"})
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
// Empty/whitespace rolenames should be ignored.
|
||||
received, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId(), "", " "})
|
||||
_, resp = th.Client.GetRolesByNames([]string{model.NewId(), model.NewId(), "", " "})
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
@@ -178,16 +178,16 @@ func TestPatchRole(t *testing.T) {
|
||||
assert.Equal(t, received.SchemeManaged, role.SchemeManaged)
|
||||
|
||||
// Check a no-op patch succeeds.
|
||||
received, resp = th.SystemAdminClient.PatchRole(role.Id, patch)
|
||||
_, resp = th.SystemAdminClient.PatchRole(role.Id, patch)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
received, resp = th.SystemAdminClient.PatchRole("junk", patch)
|
||||
_, resp = th.SystemAdminClient.PatchRole("junk", patch)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
received, resp = th.Client.PatchRole(model.NewId(), patch)
|
||||
_, resp = th.Client.PatchRole(model.NewId(), patch)
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
received, resp = th.Client.PatchRole(role.Id, patch)
|
||||
_, resp = th.Client.PatchRole(role.Id, patch)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// Check a change that the license would not allow.
|
||||
@@ -195,7 +195,7 @@ func TestPatchRole(t *testing.T) {
|
||||
Permissions: &[]string{"manage_system", "manage_webhooks"},
|
||||
}
|
||||
|
||||
received, resp = th.SystemAdminClient.PatchRole(role.Id, patch)
|
||||
_, resp = th.SystemAdminClient.PatchRole(role.Id, patch)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
|
||||
// Add a license.
|
||||
|
||||
@@ -150,11 +150,11 @@ func TestUpdateUserStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
toUpdateUserStatus.Status = "online"
|
||||
updateUserStatus, resp = Client.UpdateUserStatus(th.BasicUser2.Id, toUpdateUserStatus)
|
||||
_, resp = Client.UpdateUserStatus(th.BasicUser2.Id, toUpdateUserStatus)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
toUpdateUserStatus.Status = "online"
|
||||
updateUserStatus, resp = th.SystemAdminClient.UpdateUserStatus(th.BasicUser2.Id, toUpdateUserStatus)
|
||||
updateUserStatus, _ = th.SystemAdminClient.UpdateUserStatus(th.BasicUser2.Id, toUpdateUserStatus)
|
||||
if updateUserStatus.Status != "online" {
|
||||
t.Fatal("Should return online status")
|
||||
}
|
||||
|
||||
@@ -858,10 +858,10 @@ func TestSearchAllTeams(t *testing.T) {
|
||||
|
||||
Client.Logout()
|
||||
|
||||
rteams, resp = Client.SearchTeams(&model.TeamSearch{Term: pTeam.Name})
|
||||
_, resp = Client.SearchTeams(&model.TeamSearch{Term: pTeam.Name})
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
rteams, resp = Client.SearchTeams(&model.TeamSearch{Term: pTeam.DisplayName})
|
||||
_, resp = Client.SearchTeams(&model.TeamSearch{Term: pTeam.DisplayName})
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
|
||||
@@ -1148,10 +1148,10 @@ func TestGetTeamMembers(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
rmembers, resp = Client.GetTeamMembers(team.Id, 0, 1, "")
|
||||
_, resp = Client.GetTeamMembers(team.Id, 0, 1, "")
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
rmembers, resp = th.SystemAdminClient.GetTeamMembers(team.Id, 0, 100, "")
|
||||
_, resp = th.SystemAdminClient.GetTeamMembers(team.Id, 0, 100, "")
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
@@ -1220,10 +1220,10 @@ func TestGetTeamMembersByIds(t *testing.T) {
|
||||
t.Fatal("1 user should be returned")
|
||||
}
|
||||
|
||||
tm1, resp = Client.GetTeamMembersByIds("junk", []string{th.BasicUser.Id})
|
||||
_, resp = Client.GetTeamMembersByIds("junk", []string{th.BasicUser.Id})
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
tm1, resp = Client.GetTeamMembersByIds(model.NewId(), []string{th.BasicUser.Id})
|
||||
_, resp = Client.GetTeamMembersByIds(model.NewId(), []string{th.BasicUser.Id})
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
@@ -1244,7 +1244,7 @@ func TestAddTeamMember(t *testing.T) {
|
||||
|
||||
// Regular user can't add a member to a team they don't belong to.
|
||||
th.LoginBasic2()
|
||||
tm, resp := Client.AddTeamMember(team.Id, otherUser.Id)
|
||||
_, resp := Client.AddTeamMember(team.Id, otherUser.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
if resp.Error == nil {
|
||||
t.Fatalf("Error is nil")
|
||||
@@ -1253,7 +1253,7 @@ func TestAddTeamMember(t *testing.T) {
|
||||
|
||||
// Regular user can add a member to a team they belong to.
|
||||
th.LoginBasic()
|
||||
tm, resp = Client.AddTeamMember(team.Id, otherUser.Id)
|
||||
tm, resp := Client.AddTeamMember(team.Id, otherUser.Id)
|
||||
CheckNoError(t, resp)
|
||||
CheckCreatedStatus(t, resp)
|
||||
|
||||
@@ -1370,7 +1370,7 @@ func TestAddTeamMember(t *testing.T) {
|
||||
token.CreateAt = model.GetMillis() - 1000*60*60*50
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
|
||||
tm, resp = Client.AddTeamMemberFromInvite(token.Token, "")
|
||||
_, resp = Client.AddTeamMemberFromInvite(token.Token, "")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
th.App.DeleteToken(token)
|
||||
|
||||
@@ -1382,7 +1382,7 @@ func TestAddTeamMember(t *testing.T) {
|
||||
)
|
||||
<-th.App.Srv.Store.Token().Save(token)
|
||||
|
||||
tm, resp = Client.AddTeamMemberFromInvite(token.Token, "")
|
||||
_, resp = Client.AddTeamMemberFromInvite(token.Token, "")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
th.App.DeleteToken(token)
|
||||
|
||||
@@ -1428,13 +1428,13 @@ func TestAddTeamMembers(t *testing.T) {
|
||||
|
||||
// Regular user can't add a member to a team they don't belong to.
|
||||
th.LoginBasic2()
|
||||
tm, resp := Client.AddTeamMembers(team.Id, userList)
|
||||
_, resp := Client.AddTeamMembers(team.Id, userList)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
Client.Logout()
|
||||
|
||||
// Regular user can add a member to a team they belong to.
|
||||
th.LoginBasic()
|
||||
tm, resp = Client.AddTeamMembers(team.Id, userList)
|
||||
tm, resp := Client.AddTeamMembers(team.Id, userList)
|
||||
CheckNoError(t, resp)
|
||||
CheckCreatedStatus(t, resp)
|
||||
|
||||
@@ -2018,7 +2018,7 @@ func TestGetTeamInviteInfo(t *testing.T) {
|
||||
team, resp = th.SystemAdminClient.UpdateTeam(team)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
team, resp = Client.GetTeamInviteInfo(team.InviteId)
|
||||
_, resp = Client.GetTeamInviteInfo(team.InviteId)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
_, resp = Client.GetTeamInviteInfo("junk")
|
||||
|
||||
@@ -406,7 +406,7 @@ func TestGetUser(t *testing.T) {
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
// System admins should ignore privacy settings
|
||||
ruser, resp = th.SystemAdminClient.GetUser(user.Id, resp.Etag)
|
||||
ruser, _ = th.SystemAdminClient.GetUser(user.Id, resp.Etag)
|
||||
if ruser.Email == "" {
|
||||
t.Fatal("email should not be blank")
|
||||
}
|
||||
@@ -474,7 +474,7 @@ func TestGetUserByUsername(t *testing.T) {
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
// System admins should ignore privacy settings
|
||||
ruser, resp = th.SystemAdminClient.GetUserByUsername(user.Username, resp.Etag)
|
||||
ruser, _ = th.SystemAdminClient.GetUserByUsername(user.Username, resp.Etag)
|
||||
if ruser.Email == "" {
|
||||
t.Fatal("email should not be blank")
|
||||
}
|
||||
@@ -539,7 +539,7 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
// System admins should ignore privacy settings
|
||||
ruser, resp = th.SystemAdminClient.GetUserByEmail(user.Email, resp.Etag)
|
||||
ruser, _ = th.SystemAdminClient.GetUserByEmail(user.Email, resp.Etag)
|
||||
if ruser.Email == "" {
|
||||
t.Fatal("email should not be blank")
|
||||
}
|
||||
@@ -2208,14 +2208,14 @@ func TestVerifyUserEmail(t *testing.T) {
|
||||
|
||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||
|
||||
ruser, resp := Client.CreateUser(&user)
|
||||
ruser, _ := Client.CreateUser(&user)
|
||||
|
||||
token, err := th.App.CreateVerifyEmailToken(ruser.Id)
|
||||
if err != nil {
|
||||
t.Fatal("Unable to create email verify token")
|
||||
}
|
||||
|
||||
_, resp = Client.VerifyUserEmail(token.Token)
|
||||
_, resp := Client.VerifyUserEmail(token.Token)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
_, resp = Client.VerifyUserEmail(GenerateTestId())
|
||||
@@ -2329,7 +2329,7 @@ func TestCBALogin(t *testing.T) {
|
||||
}
|
||||
|
||||
Client.HttpHeader["X-SSL-Client-Cert-Subject-DN"] = "C=US, ST=Maryland, L=Pasadena, O=Brent Baccala, OU=FreeSoft, CN=www.freesoft.org/emailAddress=" + th.BasicUser.Email
|
||||
user, resp = Client.Login(th.BasicUser.Email, "")
|
||||
user, _ = Client.Login(th.BasicUser.Email, "")
|
||||
if !(user != nil && user.Email == th.BasicUser.Email) {
|
||||
t.Fatal("Should have been able to login")
|
||||
}
|
||||
@@ -2340,13 +2340,13 @@ func TestCBALogin(t *testing.T) {
|
||||
})
|
||||
|
||||
Client.HttpHeader["X-SSL-Client-Cert-Subject-DN"] = "C=US, ST=Maryland, L=Pasadena, O=Brent Baccala, OU=FreeSoft, CN=www.freesoft.org/emailAddress=" + th.BasicUser.Email
|
||||
user, resp = Client.Login(th.BasicUser.Email, "")
|
||||
user, _ = Client.Login(th.BasicUser.Email, "")
|
||||
if resp.Error.StatusCode != 400 && user == nil {
|
||||
t.Fatal("Should have failed because password is required")
|
||||
}
|
||||
|
||||
Client.HttpHeader["X-SSL-Client-Cert-Subject-DN"] = "C=US, ST=Maryland, L=Pasadena, O=Brent Baccala, OU=FreeSoft, CN=www.freesoft.org/emailAddress=" + th.BasicUser.Email
|
||||
user, resp = Client.Login(th.BasicUser.Email, th.BasicUser.Password)
|
||||
user, _ = Client.Login(th.BasicUser.Email, th.BasicUser.Password)
|
||||
if !(user != nil && user.Email == th.BasicUser.Email) {
|
||||
t.Fatal("Should have been able to login")
|
||||
}
|
||||
@@ -2597,7 +2597,7 @@ func TestGetUserAccessToken(t *testing.T) {
|
||||
_, resp = AdminClient.GetUserAccessToken(token.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
token, resp = Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
_, resp = Client.CreateUserAccessToken(th.BasicUser.Id, testDescription)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
rtokens, resp := Client.GetUserAccessTokensForUser(th.BasicUser.Id, 0, 100)
|
||||
|
||||
@@ -365,7 +365,7 @@ func TestGetOutgoingWebhooks(t *testing.T) {
|
||||
t.Fatal("missing hook")
|
||||
}
|
||||
|
||||
hooks, resp = th.SystemAdminClient.GetOutgoingWebhooksForChannel(model.NewId(), 0, 1000, "")
|
||||
_, resp = th.SystemAdminClient.GetOutgoingWebhooksForChannel(model.NewId(), 0, 1000, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
_, resp = Client.GetOutgoingWebhooks(0, 1000, "")
|
||||
|
||||
Ссылка в новой задаче
Block a user