2016-02-08 07:26:10 -05:00
|
|
|
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
2016-04-15 08:48:14 -04:00
|
|
|
"github.com/mattermost/platform/utils"
|
2016-02-08 07:26:10 -05:00
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGetLicenceConfig(t *testing.T) {
|
2016-04-21 22:37:01 -07:00
|
|
|
th := Setup().InitBasic()
|
|
|
|
|
Client := th.BasicClient
|
2016-02-08 07:26:10 -05:00
|
|
|
|
2016-04-15 08:48:14 -04:00
|
|
|
if result, err := Client.GetClientLicenceConfig(""); err != nil {
|
2016-02-08 07:26:10 -05:00
|
|
|
t.Fatal(err)
|
|
|
|
|
} else {
|
|
|
|
|
cfg := result.Data.(map[string]string)
|
|
|
|
|
|
|
|
|
|
if _, ok := cfg["IsLicensed"]; !ok {
|
|
|
|
|
t.Fatal(cfg)
|
|
|
|
|
}
|
2016-04-15 08:48:14 -04:00
|
|
|
|
|
|
|
|
// test etag caching
|
|
|
|
|
if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
} else if len(cache_result.Data.(map[string]string)) != 0 {
|
|
|
|
|
t.Log(cache_result.Data)
|
|
|
|
|
t.Fatal("cache should be empty")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
utils.ClientLicense["IsLicensed"] = "true"
|
|
|
|
|
|
|
|
|
|
if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
} else if len(cache_result.Data.(map[string]string)) == 0 {
|
|
|
|
|
t.Fatal("result should not be empty")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
utils.ClientLicense["SomeFeature"] = "true"
|
|
|
|
|
|
|
|
|
|
if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
} else if len(cache_result.Data.(map[string]string)) == 0 {
|
|
|
|
|
t.Fatal("result should not be empty")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
utils.ClientLicense = map[string]string{"IsLicensed": "false"}
|
2016-02-08 07:26:10 -05:00
|
|
|
}
|
|
|
|
|
}
|