blob: 39f7233556ec0d517af0922b5dd9246fead9f61e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package api
import (
"testing"
"github.com/mattermost/mattermost-server/utils"
)
func TestGetLicenceConfig(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient
if result, err := Client.GetClientLicenceConfig(""); err != nil {
t.Fatal(err)
} else {
cfg := result.Data.(map[string]string)
if _, ok := cfg["IsLicensed"]; !ok {
t.Fatal(cfg)
}
// 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.SetClientLicense(map[string]string{"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.SetClientLicense(map[string]string{"SomeFeature": "true", "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.SetClientLicense(map[string]string{"IsLicensed": "false"})
}
}
|