Invalidate cloud caches when a new license is loaded (#21579)

Automatic Merge
Этот коммит содержится в:
Nick Misasi
2022-11-02 16:40:26 -04:00
коммит произвёл GitHub
родитель 1ae97fc381
Коммит a541cda9d0
19 изменённых файлов: 69 добавлений и 43 удалений

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

@@ -289,6 +289,10 @@ func (l *License) IsStarted() bool {
return l.StartsAt < GetMillis()
}
func (l *License) IsCloud() bool {
return l != nil && l.Features != nil && l.Features.Cloud != nil && *l.Features.Cloud
}
func (l *License) IsTrialLicense() bool {
return l.IsTrial || (l.ExpiresAt-l.StartsAt) == trialDuration.Milliseconds() || (l.ExpiresAt-l.StartsAt) == adminTrialDuration.Milliseconds()
}

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

@@ -143,6 +143,23 @@ func TestLicenseIsStarted(t *testing.T) {
assert.False(t, l1.IsStarted())
}
func TestIsCloud(t *testing.T) {
l1 := License{}
l1.Features = &Features{}
l1.Features.SetDefaults()
assert.False(t, l1.IsCloud())
boolTrue := true
l1.Features.Cloud = &boolTrue
assert.True(t, l1.IsCloud())
var license *License
assert.False(t, license.IsCloud())
l1.Features = nil
assert.False(t, l1.IsCloud())
}
func TestLicenseRecordIsValid(t *testing.T) {
lr := LicenseRecord{
CreateAt: GetMillis(),