mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Move system console to use v4 endpoints and redux * Rename logs dir to get past gitignore * Fix test email * Update brand unit test * Updates per feedback
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package api4
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetBrandImage(t *testing.T) {
|
|
th := Setup().InitBasic().InitSystemAdmin()
|
|
defer TearDown()
|
|
Client := th.Client
|
|
|
|
_, resp := Client.GetBrandImage()
|
|
CheckNotFoundStatus(t, resp)
|
|
|
|
Client.Logout()
|
|
_, resp = Client.GetBrandImage()
|
|
CheckNotFoundStatus(t, resp)
|
|
|
|
_, resp = th.SystemAdminClient.GetBrandImage()
|
|
CheckNotFoundStatus(t, resp)
|
|
}
|
|
|
|
func TestUploadBrandImage(t *testing.T) {
|
|
th := Setup().InitBasic().InitSystemAdmin()
|
|
defer TearDown()
|
|
Client := th.Client
|
|
|
|
data, err := readTestFile("test.png")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
ok, resp := Client.UploadBrandImage(data)
|
|
CheckForbiddenStatus(t, resp)
|
|
if ok {
|
|
t.Fatal("Should return false, set brand image not allowed")
|
|
}
|
|
|
|
// status code returns either forbidden or unauthorized
|
|
// note: forbidden is set as default at Client4.SetProfileImage when request is terminated early by server
|
|
Client.Logout()
|
|
_, resp = Client.UploadBrandImage(data)
|
|
if resp.StatusCode == http.StatusForbidden {
|
|
CheckForbiddenStatus(t, resp)
|
|
} else if resp.StatusCode == http.StatusUnauthorized {
|
|
CheckUnauthorizedStatus(t, resp)
|
|
} else {
|
|
t.Fatal("Should have failed either forbidden or unauthorized")
|
|
}
|
|
|
|
_, resp = th.SystemAdminClient.UploadBrandImage(data)
|
|
CheckNotImplementedStatus(t, resp)
|
|
}
|