Remove license globals entirely (#8229)

* remove license globals entirely

* fix infinite recursion

* test fix
Этот коммит содержится в:
Chris
2018-02-09 10:04:48 -06:00
коммит произвёл GitHub
родитель 7e8106b95c
Коммит a6309aaf48
29 изменённых файлов: 256 добавлений и 429 удалений

Просмотреть файл

@@ -118,9 +118,10 @@ func setupTestHelper(enterprise bool) *TestHelper {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = true })
utils.SetIsLicensed(enterprise)
if enterprise {
utils.License().Features.SetDefaults()
th.App.SetLicense(model.NewTestLicense())
} else {
th.App.SetLicense(nil)
}
return th

Просмотреть файл

@@ -9,7 +9,6 @@ import (
"net/http"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitLicense() {
@@ -83,7 +82,7 @@ func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) {
func getClientLicenceConfig(c *Context, w http.ResponseWriter, r *http.Request) {
useSanitizedLicense := !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM)
etag := utils.GetClientLicenseEtag(useSanitizedLicense)
etag := c.App.GetClientLicenseEtag(useSanitizedLicense)
if c.HandleEtag(etag, "Get Client License Config", w, r) {
return
}
@@ -91,9 +90,9 @@ func getClientLicenceConfig(c *Context, w http.ResponseWriter, r *http.Request)
var clientLicense map[string]string
if useSanitizedLicense {
clientLicense = utils.ClientLicense()
clientLicense = c.App.ClientLicense()
} else {
clientLicense = utils.GetSanitizedClientLicense()
clientLicense = c.App.GetSanitizedClientLicense()
}
w.Header().Set(model.HEADER_ETAG_SERVER, etag)

Просмотреть файл

@@ -5,8 +5,6 @@ package api
import (
"testing"
"github.com/mattermost/mattermost-server/utils"
)
func TestGetLicenceConfig(t *testing.T) {
@@ -32,7 +30,7 @@ func TestGetLicenceConfig(t *testing.T) {
t.Fatal("cache should be empty")
}
utils.SetClientLicense(map[string]string{"IsLicensed": "true"})
th.App.SetClientLicense(map[string]string{"IsLicensed": "true"})
if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil {
t.Fatal(err)
@@ -40,7 +38,7 @@ func TestGetLicenceConfig(t *testing.T) {
t.Fatal("result should not be empty")
}
utils.SetClientLicense(map[string]string{"SomeFeature": "true", "IsLicensed": "true"})
th.App.SetClientLicense(map[string]string{"SomeFeature": "true", "IsLicensed": "true"})
if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil {
t.Fatal(err)
@@ -48,6 +46,6 @@ func TestGetLicenceConfig(t *testing.T) {
t.Fatal("result should not be empty")
}
utils.SetClientLicense(map[string]string{"IsLicensed": "false"})
th.App.SetClientLicense(map[string]string{"IsLicensed": "false"})
}
}

Просмотреть файл

@@ -299,9 +299,9 @@ func getInitialLoad(c *Context, w http.ResponseWriter, r *http.Request) {
il.ClientCfg = c.App.ClientConfig()
if c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
il.LicenseCfg = utils.ClientLicense()
il.LicenseCfg = c.App.ClientLicense()
} else {
il.LicenseCfg = utils.GetSanitizedClientLicense()
il.LicenseCfg = c.App.GetSanitizedClientLicense()
}
w.Write([]byte(il.ToJson()))