diff --git a/server/.golangci.yml b/server/.golangci.yml index 1c7fe228b6..c8c9ed52c8 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -101,7 +101,6 @@ issues: channels/app/integration_action.go|\ channels/app/integration_action_test.go|\ channels/app/job_test.go|\ - channels/app/login_test.go|\ channels/app/migrations.go|\ channels/app/permissions.go|\ channels/app/permissions_test.go|\ diff --git a/server/channels/app/login_test.go b/server/channels/app/login_test.go index 53dbce604f..17649e2fc7 100644 --- a/server/channels/app/login_test.go +++ b/server/channels/app/login_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) { 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) - user, err := th.App.AuthenticateUserForLogin(th.Context, "", th.BasicUser.Username, "", "", token.Token, false) - require.Nil(t, err) + user, appErr := th.App.AuthenticateUserForLogin(th.Context, "", th.BasicUser.Username, "", "", token.Token, false) + require.Nil(t, appErr) require.NotNil(t, user) require.Equal(t, th.BasicUser.Username, user.Username) - _, apperr := th.App.Srv().Store().Token().GetByToken(token.Token) - require.NoError(t, apperr) - th.App.DeleteToken(token) + _, err := th.App.Srv().Store().Token().GetByToken(token.Token) + require.NoError(t, err) + 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) { token := model.NewToken(TokenTypeCWSAccess, "") os.Setenv("CWS_CLOUD_TOKEN", token.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) require.NotNil(t, err) require.Nil(t, user)