Merge branch 'master' into mark-as-unread

Этот коммит содержится в:
Harrison Healey
2019-11-04 15:04:28 -05:00
родитель fa34be4aa0 501da809f3
Коммит 47409aaa4b
50 изменённых файлов: 788 добавлений и 420 удалений

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

@@ -8,6 +8,7 @@ import (
"testing"
"github.com/mattermost/mattermost-server/utils/testutils"
"github.com/stretchr/testify/require"
)
func TestGetBrandImage(t *testing.T) {
@@ -32,9 +33,7 @@ func TestUploadBrandImage(t *testing.T) {
Client := th.Client
data, err := testutils.ReadTestFile("test.png")
if err != nil {
t.Fatal(err)
}
require.Nil(t, err)
_, resp := Client.UploadBrandImage(data)
CheckForbiddenStatus(t, resp)
@@ -48,7 +47,7 @@ func TestUploadBrandImage(t *testing.T) {
} else if resp.StatusCode == http.StatusUnauthorized {
CheckUnauthorizedStatus(t, resp)
} else {
t.Fatal("Should have failed either forbidden or unauthorized")
require.Fail(t, "Should have failed either forbidden or unauthorized")
}
_, resp = th.SystemAdminClient.UploadBrandImage(data)
@@ -60,9 +59,7 @@ func TestDeleteBrandImage(t *testing.T) {
defer th.TearDown()
data, err := testutils.ReadTestFile("test.png")
if err != nil {
t.Fatal(err)
}
require.Nil(t, err)
_, resp := th.SystemAdminClient.UploadBrandImage(data)
CheckCreatedStatus(t, resp)

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

@@ -7,6 +7,7 @@ import (
"testing"
"github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/require"
)
func TestGetClusterStatus(t *testing.T) {
@@ -22,9 +23,7 @@ func TestGetClusterStatus(t *testing.T) {
infos, resp := th.SystemAdminClient.GetClusterStatus()
CheckNoError(t, resp)
if infos == nil {
t.Fatal("should not be nil")
}
require.NotNil(t, infos, "cluster status should not be nil")
})
t.Run("as restricted system admin", func(t *testing.T) {

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

@@ -108,7 +108,7 @@ func TestGetJobs(t *testing.T) {
received, resp = th.SystemAdminClient.GetJobs(1, 2)
require.Nil(t, resp.Error)
require.Equal(t,jobs[1].Id, received[0].Id, "should've received oldest job last")
require.Equal(t, jobs[1].Id, received[0].Id, "should've received oldest job last")
_, resp = th.Client.GetJobs(0, 60)
CheckForbiddenStatus(t, resp)

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

@@ -262,14 +262,16 @@ func postLog(c *Context, w http.ResponseWriter, r *http.Request) {
msg = msg[0:399]
}
msg = "Client Logs API Endpoint Message: " + msg
fields := []mlog.Field{
mlog.String("type", "client_message"),
mlog.String("user_agent", c.App.UserAgent),
}
if !forceToDebug && lvl == "ERROR" {
err := &model.AppError{}
err.Message = msg
err.Id = msg
err.Where = "client"
c.LogError(err)
mlog.Error(msg, fields...)
} else {
mlog.Debug("message", mlog.String("message", msg))
mlog.Debug(msg, fields...)
}
m["message"] = msg

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

@@ -283,6 +283,13 @@ func TestPostLog(t *testing.T) {
_, resp := Client.PostLog(message)
CheckNoError(t, resp)
*th.App.Config().ServiceSettings.EnableDeveloper = false
_, resp = Client.PostLog(message)
CheckNoError(t, resp)
*th.App.Config().ServiceSettings.EnableDeveloper = true
Client.Logout()
_, resp = Client.PostLog(message)

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

@@ -925,11 +925,6 @@ func patchUser(c *Context, w http.ResponseWriter, r *http.Request) {
}
if c.App.Session.IsOAuth && patch.Email != nil {
if err != nil {
c.Err = err
return
}
if ouser.Email != *patch.Email {
c.SetPermissionError(model.PERMISSION_EDIT_OTHER_USERS)
c.Err.DetailedError += ", attempted email update by oauth app"