mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
Fix: authorization-test errcheck issue (#28788)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
This commit is contained in:
parent
b276fbc809
commit
19865329ca
2 changed files with 26 additions and 11 deletions
|
|
@ -86,7 +86,6 @@ issues:
|
|||
channels/api4/user_test.go|\
|
||||
channels/api4/websocket_test.go|\
|
||||
channels/app/app_test.go|\
|
||||
channels/app/authorization_test.go|\
|
||||
channels/app/auto_responder_test.go|\
|
||||
channels/app/bot_test.go|\
|
||||
channels/app/brand.go|\
|
||||
|
|
|
|||
|
|
@ -178,8 +178,10 @@ func TestSessionHasPermissionToChannels(t *testing.T) {
|
|||
|
||||
ch1 := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
ch2 := th.CreatePrivateChannel(th.Context, th.BasicTeam)
|
||||
th.App.AddUserToChannel(th.Context, th.BasicUser, ch1, false)
|
||||
th.App.AddUserToChannel(th.Context, th.BasicUser, ch2, false)
|
||||
_, appErr := th.App.AddUserToChannel(th.Context, th.BasicUser, ch1, false)
|
||||
assert.Nil(t, appErr)
|
||||
_, appErr = th.App.AddUserToChannel(th.Context, th.BasicUser, ch2, false)
|
||||
assert.Nil(t, appErr)
|
||||
|
||||
allChannels := []string{th.BasicChannel.Id, ch1.Id, ch2.Id}
|
||||
|
||||
|
|
@ -196,7 +198,8 @@ func TestSessionHasPermissionToChannels(t *testing.T) {
|
|||
UserId: th.BasicUser.Id,
|
||||
}
|
||||
|
||||
th.App.removeUserFromChannel(th.Context, th.BasicUser.Id, th.SystemAdminUser.Id, ch1)
|
||||
appErr := th.App.removeUserFromChannel(th.Context, th.BasicUser.Id, th.SystemAdminUser.Id, ch1)
|
||||
assert.Nil(t, appErr)
|
||||
assert.False(t, th.App.SessionHasPermissionToChannels(th.Context, session, allChannels, model.PermissionReadChannel))
|
||||
})
|
||||
|
||||
|
|
@ -256,7 +259,10 @@ func TestSessionHasPermissionToManageBot(t *testing.T) {
|
|||
OwnerId: th.BasicUser.Id,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteBot(th.Context, bot.UserId)
|
||||
defer func() {
|
||||
appErr := th.App.PermanentDeleteBot(th.Context, bot.UserId)
|
||||
assert.Nil(t, appErr)
|
||||
}()
|
||||
assert.NotNil(t, bot)
|
||||
|
||||
t.Run("test my bot", func(t *testing.T) {
|
||||
|
|
@ -385,7 +391,10 @@ func TestSessionHasPermissionToUser(t *testing.T) {
|
|||
})
|
||||
require.Nil(t, err)
|
||||
assert.NotNil(t, bot)
|
||||
defer th.App.PermanentDeleteBot(th.Context, bot.UserId)
|
||||
defer func() {
|
||||
appErr := th.App.PermanentDeleteBot(th.Context, bot.UserId)
|
||||
assert.Nil(t, appErr)
|
||||
}()
|
||||
|
||||
assert.False(t, th.App.SessionHasPermissionToUser(session, bot.UserId))
|
||||
})
|
||||
|
|
@ -410,7 +419,10 @@ func TestSessionHasPermissionToManageUserOrBot(t *testing.T) {
|
|||
OwnerId: th.BasicUser.Id,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteBot(th.Context, bot.UserId)
|
||||
defer func() {
|
||||
appErr := th.App.PermanentDeleteBot(th.Context, bot.UserId)
|
||||
assert.Nil(t, appErr)
|
||||
}()
|
||||
|
||||
t.Run("test basic user access", func(t *testing.T) {
|
||||
session := model.Session{
|
||||
|
|
@ -685,12 +697,14 @@ func TestSessionHasPermissionToChannelByPost(t *testing.T) {
|
|||
require.Nil(t, err)
|
||||
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.App.AddUserToChannel(th.Context, th.BasicUser, channel, false)
|
||||
_, appErr := th.App.AddUserToChannel(th.Context, th.BasicUser, channel, false)
|
||||
assert.Nil(t, appErr)
|
||||
post := th.CreatePost(channel)
|
||||
|
||||
archivedChannel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
archivedPost := th.CreatePost(archivedChannel)
|
||||
th.App.DeleteChannel(th.Context, archivedChannel, th.SystemAdminUser.Id)
|
||||
appErr = th.App.DeleteChannel(th.Context, archivedChannel, th.SystemAdminUser.Id)
|
||||
assert.Nil(t, appErr)
|
||||
|
||||
t.Run("read channel", func(t *testing.T) {
|
||||
require.Equal(t, true, th.App.SessionHasPermissionToChannelByPost(*session, post.Id, model.PermissionReadChannel))
|
||||
|
|
@ -734,12 +748,14 @@ func TestHasPermissionToChannelByPost(t *testing.T) {
|
|||
defer th.TearDown()
|
||||
|
||||
channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
th.App.AddUserToChannel(th.Context, th.BasicUser, channel, false)
|
||||
_, appErr := th.App.AddUserToChannel(th.Context, th.BasicUser, channel, false)
|
||||
assert.Nil(t, appErr)
|
||||
post := th.CreatePost(channel)
|
||||
|
||||
archivedChannel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
archivedPost := th.CreatePost(archivedChannel)
|
||||
th.App.DeleteChannel(th.Context, archivedChannel, th.SystemAdminUser.Id)
|
||||
appErr = th.App.DeleteChannel(th.Context, archivedChannel, th.SystemAdminUser.Id)
|
||||
assert.Nil(t, appErr)
|
||||
|
||||
t.Run("read channel", func(t *testing.T) {
|
||||
require.Equal(t, true, th.App.HasPermissionToChannelByPost(th.Context, th.BasicUser.Id, post.Id, model.PermissionReadChannel))
|
||||
|
|
|
|||
Loading…
Reference in a new issue