MM-12881 Add license sku fields (#9883)
* Add license sku fields * Add diagnostics * Gofmt fixes
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2e4373f91c
Коммит
3904c01f46
@@ -8,10 +8,9 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/segmentio/analytics-go"
|
||||
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
analytics "github.com/segmentio/analytics-go"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -569,6 +568,7 @@ func (a *App) trackLicense() {
|
||||
"start": license.StartsAt,
|
||||
"expire": license.ExpiresAt,
|
||||
"users": *license.Features.Users,
|
||||
"edition": license.SkuShortName,
|
||||
}
|
||||
|
||||
features := license.Features.ToMap()
|
||||
|
||||
@@ -212,6 +212,8 @@ func (a *App) GetSanitizedClientLicense() map[string]string {
|
||||
delete(sanitizedLicense, "IssuedAt")
|
||||
delete(sanitizedLicense, "StartsAt")
|
||||
delete(sanitizedLicense, "ExpiresAt")
|
||||
delete(sanitizedLicense, "SkuName")
|
||||
delete(sanitizedLicense, "SkuShortName")
|
||||
|
||||
return sanitizedLicense
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestLoadLicense(t *testing.T) {
|
||||
@@ -100,13 +101,18 @@ func TestGetSanitizedClientLicense(t *testing.T) {
|
||||
l1.Features = &model.Features{}
|
||||
l1.Customer = &model.Customer{}
|
||||
l1.Customer.Name = "TestName"
|
||||
l1.SkuName = "SKU NAME"
|
||||
l1.SkuShortName = "SKU SHORT NAME"
|
||||
l1.StartsAt = model.GetMillis() - 1000
|
||||
l1.ExpiresAt = model.GetMillis() + 100000
|
||||
th.App.SetLicense(l1)
|
||||
|
||||
m := th.App.GetSanitizedClientLicense()
|
||||
|
||||
if _, ok := m["Name"]; ok {
|
||||
t.Fatal("should have been sanatized")
|
||||
}
|
||||
_, ok := m["Name"]
|
||||
assert.False(t, ok)
|
||||
_, ok = m["SkuName"]
|
||||
assert.False(t, ok)
|
||||
_, ok = m["SkuShortName"]
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user