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