PLT-8314: Test Message Export Against S3 Bucket (#7957)
* Removed export directory config setting, in favour of hard-coding it to an 'export' directory under the local file directory. Improved the local file backend copy implementation to implicitly create the destination directory if it's missing * Fixed the tests
Этот коммит содержится в:
@@ -8,7 +8,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -25,6 +24,10 @@ const (
|
||||
DATABASE_DRIVER_MYSQL = "mysql"
|
||||
DATABASE_DRIVER_POSTGRES = "postgres"
|
||||
|
||||
MINIO_ACCESS_KEY = "minioaccesskey"
|
||||
MINIO_SECRET_KEY = "miniosecretkey"
|
||||
MINIO_BUCKET = "mattermost-test"
|
||||
|
||||
PASSWORD_MAXIMUM_LENGTH = 64
|
||||
PASSWORD_MINIMUM_LENGTH = 5
|
||||
|
||||
@@ -1523,7 +1526,6 @@ type MessageExportSettings struct {
|
||||
EnableExport *bool
|
||||
DailyRunTime *string
|
||||
ExportFromTimestamp *int64
|
||||
FileLocation *string
|
||||
BatchSize *int
|
||||
}
|
||||
|
||||
@@ -1532,10 +1534,6 @@ func (s *MessageExportSettings) SetDefaults() {
|
||||
s.EnableExport = NewBool(false)
|
||||
}
|
||||
|
||||
if s.FileLocation == nil {
|
||||
s.FileLocation = NewString("export")
|
||||
}
|
||||
|
||||
if s.DailyRunTime == nil {
|
||||
s.DailyRunTime = NewString("01:00")
|
||||
}
|
||||
@@ -2064,19 +2062,8 @@ func (mes *MessageExportSettings) isValid(fs FileSettings) *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.daily_runtime.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if _, err := time.Parse("15:04", *mes.DailyRunTime); err != nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.daily_runtime.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
} else if mes.FileLocation == nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.file_location.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if mes.BatchSize == nil || *mes.BatchSize < 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.batch_size.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if *fs.DriverName != IMAGE_DRIVER_LOCAL {
|
||||
if absFileDir, err := filepath.Abs(fs.Directory); err != nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.file_location.relative", nil, err.Error(), http.StatusBadRequest)
|
||||
} else if absMessageExportDir, err := filepath.Abs(*mes.FileLocation); err != nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.file_location.relative", nil, err.Error(), http.StatusBadRequest)
|
||||
} else if !strings.HasPrefix(absMessageExportDir, absFileDir) {
|
||||
// configured export directory must be relative to data directory
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.file_location.relative", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Ссылка в новой задаче
Block a user