Fix errcheck issues in server/channels/app/login_test (#29119)

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
Alenoda
2024-11-13 20:08:23 +01:00
коммит произвёл GitHub
родитель a19ec14967
Коммит 891b2144df
2 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@@ -101,7 +101,6 @@ issues:
channels/app/integration_action.go|\ channels/app/integration_action.go|\
channels/app/integration_action_test.go|\ channels/app/integration_action_test.go|\
channels/app/job_test.go|\ channels/app/job_test.go|\
channels/app/login_test.go|\
channels/app/migrations.go|\ channels/app/migrations.go|\
channels/app/permissions.go|\ channels/app/permissions.go|\
channels/app/permissions_test.go|\ channels/app/permissions_test.go|\

Просмотреть файл

@@ -48,22 +48,31 @@ func TestCWSLogin(t *testing.T) {
t.Run("Should authenticate user when CWS login is enabled and tokens are equal", func(t *testing.T) { t.Run("Should authenticate user when CWS login is enabled and tokens are equal", func(t *testing.T) {
token := model.NewToken(TokenTypeCWSAccess, "") token := model.NewToken(TokenTypeCWSAccess, "")
defer th.App.DeleteToken(token) defer func() {
appErr := th.App.DeleteToken(token)
require.Nil(t, appErr)
}()
os.Setenv("CWS_CLOUD_TOKEN", token.Token) os.Setenv("CWS_CLOUD_TOKEN", token.Token)
user, err := th.App.AuthenticateUserForLogin(th.Context, "", th.BasicUser.Username, "", "", token.Token, false) user, appErr := th.App.AuthenticateUserForLogin(th.Context, "", th.BasicUser.Username, "", "", token.Token, false)
require.Nil(t, err) require.Nil(t, appErr)
require.NotNil(t, user) require.NotNil(t, user)
require.Equal(t, th.BasicUser.Username, user.Username) require.Equal(t, th.BasicUser.Username, user.Username)
_, apperr := th.App.Srv().Store().Token().GetByToken(token.Token) _, err := th.App.Srv().Store().Token().GetByToken(token.Token)
require.NoError(t, apperr) require.NoError(t, err)
th.App.DeleteToken(token) appErr = th.App.DeleteToken(token)
require.Nil(t, appErr)
}) })
t.Run("Should not authenticate the user when CWS token was used", func(t *testing.T) { t.Run("Should not authenticate the user when CWS token was used", func(t *testing.T) {
token := model.NewToken(TokenTypeCWSAccess, "") token := model.NewToken(TokenTypeCWSAccess, "")
os.Setenv("CWS_CLOUD_TOKEN", token.Token) os.Setenv("CWS_CLOUD_TOKEN", token.Token)
require.NoError(t, th.App.Srv().Store().Token().Save(token)) require.NoError(t, th.App.Srv().Store().Token().Save(token))
defer th.App.DeleteToken(token) defer func() {
appErr := th.App.DeleteToken(token)
require.Nil(t, appErr)
}()
user, err := th.App.AuthenticateUserForLogin(th.Context, "", th.BasicUser.Username, "", "", token.Token, false) user, err := th.App.AuthenticateUserForLogin(th.Context, "", th.BasicUser.Username, "", "", token.Token, false)
require.NotNil(t, err) require.NotNil(t, err)
require.Nil(t, user) require.Nil(t, user)