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)
|
||||
}
|
||||
|
||||
@@ -21,12 +21,14 @@ type LicenseRecord struct {
|
||||
}
|
||||
|
||||
type License struct {
|
||||
Id string `json:"id"`
|
||||
IssuedAt int64 `json:"issued_at"`
|
||||
StartsAt int64 `json:"starts_at"`
|
||||
ExpiresAt int64 `json:"expires_at"`
|
||||
Customer *Customer `json:"customer"`
|
||||
Features *Features `json:"features"`
|
||||
Id string `json:"id"`
|
||||
IssuedAt int64 `json:"issued_at"`
|
||||
StartsAt int64 `json:"starts_at"`
|
||||
ExpiresAt int64 `json:"expires_at"`
|
||||
Customer *Customer `json:"customer"`
|
||||
Features *Features `json:"features"`
|
||||
SkuName string `json:"sku_name"`
|
||||
SkuShortName string `json:"sku_short_name"`
|
||||
}
|
||||
|
||||
type Customer struct {
|
||||
|
||||
@@ -128,6 +128,8 @@ func GetClientLicense(l *model.License) map[string]string {
|
||||
|
||||
if l != nil {
|
||||
props["Id"] = l.Id
|
||||
props["SkuName"] = l.SkuName
|
||||
props["SkuShortName"] = l.SkuShortName
|
||||
props["Users"] = strconv.Itoa(*l.Features.Users)
|
||||
props["LDAP"] = strconv.FormatBool(*l.Features.LDAP)
|
||||
props["MFA"] = strconv.FormatBool(*l.Features.MFA)
|
||||
|
||||
Ссылка в новой задаче
Block a user