MM-14626: Make license expiry checks behave how they are meant to. (#10495)

This commit is contained in:
George Goldberg
2019-03-26 10:32:59 +00:00
committed by GitHub
parent eaeede66b2
commit c3c8b28eb7
2 changed files with 7 additions and 14 deletions

View File

@@ -62,6 +62,10 @@ func (a *App) SaveLicense(licenseBytes []byte) (*model.License, *model.AppError)
return nil, model.NewAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "", http.StatusBadRequest)
}
if license != nil && license.IsExpired() {
return nil, model.NewAppError("addLicense", model.EXPIRED_LICENSE_ERROR, nil, "", http.StatusBadRequest)
}
if ok := a.SetLicense(license); !ok {
return nil, model.NewAppError("addLicense", model.EXPIRED_LICENSE_ERROR, nil, "", http.StatusBadRequest)
}
@@ -117,11 +121,9 @@ func (a *App) SetLicense(license *model.License) bool {
if license != nil {
license.Features.SetDefaults()
if !license.IsExpired() {
a.Srv.licenseValue.Store(license)
a.Srv.clientLicenseValue.Store(utils.GetClientLicense(license))
return true
}
a.Srv.licenseValue.Store(license)
a.Srv.clientLicenseValue.Store(utils.GetClientLicense(license))
return true
}
a.Srv.licenseValue.Store((*model.License)(nil))

View File

@@ -53,15 +53,6 @@ func TestSetLicense(t *testing.T) {
t.Fatal("license should have worked")
}
l2 := &model.License{}
l2.Features = &model.Features{}
l2.Customer = &model.Customer{}
l2.StartsAt = model.GetMillis() - 1000
l2.ExpiresAt = model.GetMillis() - 100
if ok := th.App.SetLicense(l2); ok {
t.Fatal("license should have failed")
}
l3 := &model.License{}
l3.Features = &model.Features{}
l3.Customer = &model.Customer{}