Update client license etag to handle new features (#2716)

Этот коммит содержится в:
Joram Wilander
2016-04-15 08:48:14 -04:00
коммит произвёл Harrison Healey
родитель 9243b8761a
Коммит c6c3f1e478
6 изменённых файлов: 68 добавлений и 15 удалений

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

@@ -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")
}
}