PLT-6090 adding ability to read license file from disk (#5895)

* PLT-6090 adding ability to read license file from disk

* Fixing unit test that fails only sometimes

* Fixing test that fails randomly
Этот коммит содержится в:
Corey Hulen
2017-03-31 06:54:30 -07:00
коммит произвёл Christopher Speller
родитель fa40bfb9e6
Коммит 00bb479989
7 изменённых файлов: 97 добавлений и 11 удалений

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

@@ -12,6 +12,8 @@ import (
"encoding/base64"
"encoding/pem"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
@@ -112,6 +114,31 @@ func ValidateLicense(signed []byte) (bool, string) {
return true, string(plaintext)
}
func GetLicenseFileFromDisk(fileName string) []byte {
file, err := os.Open(fileName)
if err != nil {
l4g.Error("Failed to open license key from disk at %v err=%v", fileName, err.Error())
return nil
}
defer file.Close()
licenseBytes, err := ioutil.ReadAll(file)
if err != nil {
l4g.Error("Failed to read license key from disk at %v err=%v", fileName, err.Error())
return nil
}
return licenseBytes
}
func GetLicenseFileLocation(fileLocation string) string {
if fileLocation == "" {
return FindDir("config") + "mattermost.mattermost-license"
} else {
return fileLocation
}
}
func getClientLicense(l *model.License) map[string]string {
props := make(map[string]string)