2017-04-12 08:27:57 -04:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
2016-05-24 14:31:30 -07:00
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
2017-09-06 16:24:34 -04:00
|
|
|
|
2017-09-06 23:05:10 -07:00
|
|
|
"github.com/mattermost/mattermost-server/utils"
|
2016-05-24 14:31:30 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGetClientProperties(t *testing.T) {
|
|
|
|
|
th := Setup().InitBasic()
|
2017-10-02 03:50:56 -05:00
|
|
|
defer th.TearDown()
|
2016-05-24 14:31:30 -07:00
|
|
|
|
|
|
|
|
if props, err := th.BasicClient.GetClientProperties(); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
} else {
|
|
|
|
|
if len(props["Version"]) == 0 {
|
|
|
|
|
t.Fatal()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestLogClient(t *testing.T) {
|
|
|
|
|
th := Setup().InitBasic()
|
2017-10-02 03:50:56 -05:00
|
|
|
defer th.TearDown()
|
2016-05-24 14:31:30 -07:00
|
|
|
|
|
|
|
|
if ret, _ := th.BasicClient.LogClient("this is a test"); !ret {
|
|
|
|
|
t.Fatal("failed to log")
|
|
|
|
|
}
|
2017-09-06 16:24:34 -04:00
|
|
|
|
|
|
|
|
enableDeveloper := *utils.Cfg.ServiceSettings.EnableDeveloper
|
|
|
|
|
defer func() {
|
|
|
|
|
*utils.Cfg.ServiceSettings.EnableDeveloper = enableDeveloper
|
|
|
|
|
}()
|
|
|
|
|
*utils.Cfg.ServiceSettings.EnableDeveloper = false
|
|
|
|
|
|
|
|
|
|
th.BasicClient.Logout()
|
|
|
|
|
|
|
|
|
|
if _, err := th.BasicClient.LogClient("this is a test"); err == nil {
|
|
|
|
|
t.Fatal("should have failed")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*utils.Cfg.ServiceSettings.EnableDeveloper = true
|
|
|
|
|
|
|
|
|
|
if ret, _ := th.BasicClient.LogClient("this is a test"); !ret {
|
|
|
|
|
t.Fatal("failed to log")
|
|
|
|
|
}
|
2016-05-24 14:31:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGetPing(t *testing.T) {
|
|
|
|
|
th := Setup().InitBasic()
|
2017-10-02 03:50:56 -05:00
|
|
|
defer th.TearDown()
|
2016-05-24 14:31:30 -07:00
|
|
|
|
|
|
|
|
if m, err := th.BasicClient.GetPing(); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
} else {
|
|
|
|
|
if len(m["version"]) == 0 {
|
|
|
|
|
t.Fatal()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|