diff options
author | Corey Hulen <corey@hulen.com> | 2016-08-25 04:32:44 -0800 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-08-25 08:32:44 -0400 |
commit | 839f1ad444849db1dd18c9da0c3b7380b355a047 (patch) | |
tree | 5344f29c42a5db0af983402fa8bd47483992ead2 /utils | |
parent | c3ae3f20f58b25aa6aba480ddc2239fd09e610cb (diff) | |
download | chat-839f1ad444849db1dd18c9da0c3b7380b355a047.tar.gz chat-839f1ad444849db1dd18c9da0c3b7380b355a047.tar.bz2 chat-839f1ad444849db1dd18c9da0c3b7380b355a047.zip |
Fixing license (#3878)
* Fixing sanitize license
* Fixing license
* Fixing unit tests
Diffstat (limited to 'utils')
-rw-r--r-- | utils/license.go | 12 | ||||
-rw-r--r-- | utils/license_test.go | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/utils/license.go b/utils/license.go index f0a91665e..4d6387788 100644 --- a/utils/license.go +++ b/utils/license.go @@ -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 { diff --git a/utils/license_test.go b/utils/license_test.go index d85d59dcf..6508172d5 100644 --- a/utils/license_test.go +++ b/utils/license_test.go @@ -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") } |