Update client license etag to handle new features (#2716)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
9243b8761a
Коммит
c6c3f1e478
@@ -153,20 +153,13 @@ func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func getClientLicenceConfig(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
config := utils.ClientLicense
|
||||
|
||||
var etag string
|
||||
if config["IsLicensed"] == "false" {
|
||||
etag = model.Etag(config["IsLicensed"])
|
||||
} else {
|
||||
etag = model.Etag(config["IsLicensed"], config["IssuedAt"])
|
||||
}
|
||||
|
||||
etag := utils.GetClientLicenseEtag()
|
||||
if HandleEtag(etag, w, r) {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
||||
clientLicense := utils.ClientLicense
|
||||
|
||||
w.Write([]byte(model.MapToJson(config)))
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
||||
w.Write([]byte(model.MapToJson(clientLicense)))
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/mattermost/platform/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetLicenceConfig(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
if result, err := Client.GetClientLicenceConfig(); err != nil {
|
||||
if result, err := Client.GetClientLicenceConfig(""); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
cfg := result.Data.(map[string]string)
|
||||
@@ -18,5 +19,31 @@ func TestGetLicenceConfig(t *testing.T) {
|
||||
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.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"}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user