MM-57013 Added download button for downloading logs from server logs page in system console (#26389)
* added download system logs * download all logs * download all logs check-lint fix * check lint fix * download logs api * download logs api working * download logs working with error log * linting issues and code cleanup * CI check fix * documented the api and logs from file with error handling * test and final changes done * final changes done * Fix order of server-side translations * Fix incorrect indentation of logs.yaml --------- Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
71c25fb316
Коммит
a8b18ac807
@@ -402,6 +402,46 @@ func TestGetLogs(t *testing.T) {
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestDownloadLogs(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
th.TestLogger.Info(strconv.Itoa(i))
|
||||
}
|
||||
err := th.TestLogger.Flush()
|
||||
require.NoError(t, err, "failed to flush log")
|
||||
|
||||
t.Run("Download Logs as system admin", func(t *testing.T) {
|
||||
resData, resp, err2 := th.SystemAdminClient.DownloadLogs(context.Background())
|
||||
require.NoError(t, err2)
|
||||
|
||||
require.Equal(t, "text/plain", resp.Header.Get("Content-Type"))
|
||||
require.Contains(t, resp.Header.Get("Content-Disposition"), "attachment;filename=\"mattermost.log\"")
|
||||
|
||||
bodyString := string(resData)
|
||||
for i := 0; i < 20; i++ {
|
||||
assert.Contains(t, bodyString, fmt.Sprintf(`"msg":"%d"`, i))
|
||||
}
|
||||
})
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ExperimentalSettings.RestrictSystemAdmin = true })
|
||||
_, resp, err2 := th.Client.DownloadLogs(context.Background())
|
||||
require.Error(t, err2)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
_, resp, err := th.Client.DownloadLogs(context.Background())
|
||||
require.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.Client.Logout(context.Background())
|
||||
_, resp, err = th.Client.DownloadLogs(context.Background())
|
||||
require.Error(t, err)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestPostLog(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user