* Fixing sanitize license

* Fixing license

* Fixing unit tests
Этот коммит содержится в:
Corey Hulen
2016-08-25 04:32:44 -08:00
коммит произвёл Harrison Healey
родитель c3ae3f20f5
Коммит 839f1ad444
4 изменённых файлов: 21 добавлений и 9 удалений

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

@@ -141,17 +141,23 @@ func getClientLicense(l *model.License) map[string]string {
return props
}
func GetClientLicenseEtag() string {
func GetClientLicenseEtag(useSanitized bool) string {
value := ""
for k, v := range ClientLicense {
lic := ClientLicense
if useSanitized {
lic = GetSanitizedClientLicense()
}
for k, v := range lic {
value += fmt.Sprintf("%s:%s;", k, v)
}
return model.Etag(fmt.Sprintf("%x", md5.Sum([]byte(value))))
}
func GetSantizedClientLicense() map[string]string {
func GetSanitizedClientLicense() map[string]string {
sanitizedLicense := make(map[string]string)
for k, v := range ClientLicense {

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

@@ -50,18 +50,18 @@ func TestValidateLicense(t *testing.T) {
}
func TestClientLicenseEtag(t *testing.T) {
etag1 := GetClientLicenseEtag()
etag1 := GetClientLicenseEtag(false)
ClientLicense["SomeFeature"] = "true"
etag2 := GetClientLicenseEtag()
etag2 := GetClientLicenseEtag(false)
if etag1 == etag2 {
t.Fatal("etags should not match")
}
ClientLicense["SomeFeature"] = "false"
etag3 := GetClientLicenseEtag()
etag3 := GetClientLicenseEtag(false)
if etag2 == etag3 {
t.Fatal("etags should not match")
}