PLT-7718 Patch for files (#7564)
* Patch for files * Fix merge * Fix tests * Fix another test
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fa80cb10a8
Коммит
fadd9514f6
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUploadFile(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
@@ -38,7 +38,9 @@ func TestUploadFile(t *testing.T) {
|
||||
channel := th.BasicChannel
|
||||
|
||||
var uploadInfo *model.FileInfo
|
||||
if data, err := readTestFile("test.png"); err != nil {
|
||||
var data []byte
|
||||
var err error
|
||||
if data, err = readTestFile("test.png"); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if resp, err := Client.UploadPostAttachment(data, channel.Id, "test.png"); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -103,6 +105,22 @@ func TestUploadFile(t *testing.T) {
|
||||
t.Fatalf("file preview should've been saved in %v", expectedPreviewPath)
|
||||
}
|
||||
|
||||
if _, err := Client.UploadPostAttachment(data, model.NewId(), "test.png"); err == nil || err.StatusCode != http.StatusForbidden {
|
||||
t.Fatal("should have failed - bad channel id")
|
||||
}
|
||||
|
||||
if _, err := Client.UploadPostAttachment(data, "../../junk", "test.png"); err == nil || err.StatusCode != http.StatusForbidden {
|
||||
t.Fatal("should have failed - bad channel id")
|
||||
}
|
||||
|
||||
if _, err := th.SystemAdminClient.UploadPostAttachment(data, model.NewId(), "test.png"); err == nil || err.StatusCode != http.StatusForbidden {
|
||||
t.Fatal("should have failed - bad channel id")
|
||||
}
|
||||
|
||||
if _, err := th.SystemAdminClient.UploadPostAttachment(data, "../../junk", "test.png"); err == nil || err.StatusCode != http.StatusForbidden {
|
||||
t.Fatal("should have failed - bad channel id")
|
||||
}
|
||||
|
||||
enableFileAttachments := *utils.Cfg.FileSettings.EnableFileAttachments
|
||||
defer func() {
|
||||
*utils.Cfg.FileSettings.EnableFileAttachments = enableFileAttachments
|
||||
|
||||
Ссылка в новой задаче
Block a user