Update client license etag to handle new features (#2716)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
9243b8761a
Коммит
c6c3f1e478
@@ -5,11 +5,13 @@ package utils
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/md5"
|
||||
"crypto/rsa"
|
||||
"crypto/sha512"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -129,3 +131,13 @@ func getClientLicense(l *model.License) map[string]string {
|
||||
|
||||
return props
|
||||
}
|
||||
|
||||
func GetClientLicenseEtag() string {
|
||||
value := ""
|
||||
|
||||
for k, v := range ClientLicense {
|
||||
value += fmt.Sprintf("%s:%s;", k, v)
|
||||
}
|
||||
|
||||
return model.Etag(fmt.Sprintf("%x", md5.Sum([]byte(value))))
|
||||
}
|
||||
|
||||
@@ -48,3 +48,21 @@ func TestValidateLicense(t *testing.T) {
|
||||
t.Fatal("should have failed - bad license")
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientLicenseEtag(t *testing.T) {
|
||||
etag1 := GetClientLicenseEtag()
|
||||
|
||||
ClientLicense["SomeFeature"] = "true"
|
||||
|
||||
etag2 := GetClientLicenseEtag()
|
||||
if etag1 == etag2 {
|
||||
t.Fatal("etags should not match")
|
||||
}
|
||||
|
||||
ClientLicense["SomeFeature"] = "false"
|
||||
|
||||
etag3 := GetClientLicenseEtag()
|
||||
if etag2 == etag3 {
|
||||
t.Fatal("etags should not match")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user