Mm 49611 (#22054)
* remove limits we do not listen to anymore * add back boards property for focalboard project compatibility * remove boards cards as paid feature * remove lingering unlimited integrations paid feature
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5d0fdb9dff
Коммит
305fbb17cf
@@ -7,7 +7,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -19,11 +18,9 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/mock"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
"github.com/mattermost/mattermost-server/v6/app/request"
|
||||||
"github.com/mattermost/mattermost-server/v6/einterfaces/mocks"
|
|
||||||
"github.com/mattermost/mattermost-server/v6/model"
|
"github.com/mattermost/mattermost-server/v6/model"
|
||||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||||
@@ -1007,65 +1004,6 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnablePluginWithCloudLimits(t *testing.T) {
|
|
||||||
th := Setup(t)
|
|
||||||
defer th.TearDown()
|
|
||||||
|
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
|
||||||
*cfg.PluginSettings.Enable = true
|
|
||||||
*cfg.PluginSettings.RequirePluginSignature = false
|
|
||||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: false}
|
|
||||||
cfg.PluginSettings.PluginStates["testplugin2"] = &model.PluginState{Enable: false}
|
|
||||||
})
|
|
||||||
|
|
||||||
cloud := &mocks.CloudInterface{}
|
|
||||||
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
|
|
||||||
Integrations: &model.IntegrationsLimits{
|
|
||||||
Enabled: model.NewInt(1),
|
|
||||||
},
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
cloudImpl := th.App.Srv().Cloud
|
|
||||||
defer func() {
|
|
||||||
th.App.Srv().Cloud = cloudImpl
|
|
||||||
}()
|
|
||||||
th.App.Srv().Cloud = cloud
|
|
||||||
|
|
||||||
env := th.App.GetPluginsEnvironment()
|
|
||||||
require.NotNil(t, env)
|
|
||||||
|
|
||||||
path, _ := fileutils.FindDir("tests")
|
|
||||||
fileReader, err := os.Open(filepath.Join(path, "testplugin.tar.gz"))
|
|
||||||
require.NoError(t, err)
|
|
||||||
defer fileReader.Close()
|
|
||||||
|
|
||||||
_, appErr := th.App.WriteFile(fileReader, getBundleStorePath("testplugin"))
|
|
||||||
checkNoError(t, appErr)
|
|
||||||
|
|
||||||
fileReader, err = os.Open(filepath.Join(path, "testplugin2.tar.gz"))
|
|
||||||
require.NoError(t, err)
|
|
||||||
defer fileReader.Close()
|
|
||||||
|
|
||||||
_, appErr = th.App.WriteFile(fileReader, getBundleStorePath("testplugin2"))
|
|
||||||
checkNoError(t, appErr)
|
|
||||||
|
|
||||||
appErr = th.App.SyncPlugins()
|
|
||||||
checkNoError(t, appErr)
|
|
||||||
|
|
||||||
appErr = th.App.EnablePlugin("testplugin")
|
|
||||||
checkNoError(t, appErr)
|
|
||||||
|
|
||||||
// Let enable succeed if a CWS error occurs
|
|
||||||
cloud = &mocks.CloudInterface{}
|
|
||||||
th.App.Srv().Cloud = cloud
|
|
||||||
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(nil, errors.New("error getting limits"))
|
|
||||||
|
|
||||||
appErr = th.App.EnablePlugin("testplugin2")
|
|
||||||
checkNoError(t, appErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetPluginStateOverride(t *testing.T) {
|
func TestGetPluginStateOverride(t *testing.T) {
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|||||||
@@ -268,6 +268,11 @@ type SubscriptionChange struct {
|
|||||||
DowngradeFeedback *DowngradeFeedback `json:"downgrade_feedback"`
|
DowngradeFeedback *DowngradeFeedback `json:"downgrade_feedback"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO remove BoardsLimits.
|
||||||
|
// It is not used for real.
|
||||||
|
// Focalboard has some lingering code using this struct
|
||||||
|
// https://github.com/mattermost/focalboard/blob/fd4cf95f8ac9ba616864b25bf91bb1e4ec21335a/server/app/cloud.go#L86
|
||||||
|
// we should remove this struct once that code is removed.
|
||||||
type BoardsLimits struct {
|
type BoardsLimits struct {
|
||||||
Cards *int `json:"cards"`
|
Cards *int `json:"cards"`
|
||||||
Views *int `json:"views"`
|
Views *int `json:"views"`
|
||||||
@@ -277,10 +282,6 @@ type FilesLimits struct {
|
|||||||
TotalStorage *int64 `json:"total_storage"`
|
TotalStorage *int64 `json:"total_storage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type IntegrationsLimits struct {
|
|
||||||
Enabled *int `json:"enabled"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MessagesLimits struct {
|
type MessagesLimits struct {
|
||||||
History *int `json:"history"`
|
History *int `json:"history"`
|
||||||
}
|
}
|
||||||
@@ -290,11 +291,15 @@ type TeamsLimits struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ProductLimits struct {
|
type ProductLimits struct {
|
||||||
Boards *BoardsLimits `json:"boards,omitempty"`
|
// TODO remove Boards property.
|
||||||
Files *FilesLimits `json:"files,omitempty"`
|
// It is not used for real.
|
||||||
Integrations *IntegrationsLimits `json:"integrations,omitempty"`
|
// Focalboard has some lingering code using this property
|
||||||
Messages *MessagesLimits `json:"messages,omitempty"`
|
// https://github.com/mattermost/focalboard/blob/fd4cf95f8ac9ba616864b25bf91bb1e4ec21335a/server/app/cloud.go#L86
|
||||||
Teams *TeamsLimits `json:"teams,omitempty"`
|
// we should remove this property once that code is removed.
|
||||||
|
Boards *BoardsLimits `json:"boards,omitempty"`
|
||||||
|
Files *FilesLimits `json:"files,omitempty"`
|
||||||
|
Messages *MessagesLimits `json:"messages,omitempty"`
|
||||||
|
Teams *TeamsLimits `json:"teams,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSubscriptionRequest is the parameters for the API request to create a subscription.
|
// CreateSubscriptionRequest is the parameters for the API request to create a subscription.
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ const (
|
|||||||
PaidFeaturePlaybooksRetrospective = MattermostPaidFeature("mattermost.feature.playbooks_retro")
|
PaidFeaturePlaybooksRetrospective = MattermostPaidFeature("mattermost.feature.playbooks_retro")
|
||||||
PaidFeatureUnlimitedMessages = MattermostPaidFeature("mattermost.feature.unlimited_messages")
|
PaidFeatureUnlimitedMessages = MattermostPaidFeature("mattermost.feature.unlimited_messages")
|
||||||
PaidFeatureUnlimitedFileStorage = MattermostPaidFeature("mattermost.feature.unlimited_file_storage")
|
PaidFeatureUnlimitedFileStorage = MattermostPaidFeature("mattermost.feature.unlimited_file_storage")
|
||||||
PaidFeatureUnlimitedIntegrations = MattermostPaidFeature("mattermost.feature.unlimited_integrations")
|
|
||||||
PaidFeatureUnlimitedBoardcards = MattermostPaidFeature("mattermost.feature.unlimited_board_cards")
|
|
||||||
PaidFeatureAllProfessionalfeatures = MattermostPaidFeature("mattermost.feature.all_professional")
|
PaidFeatureAllProfessionalfeatures = MattermostPaidFeature("mattermost.feature.all_professional")
|
||||||
PaidFeatureAllEnterprisefeatures = MattermostPaidFeature("mattermost.feature.all_enterprise")
|
PaidFeatureAllEnterprisefeatures = MattermostPaidFeature("mattermost.feature.all_enterprise")
|
||||||
UpgradeDowngradedWorkspace = MattermostPaidFeature("mattermost.feature.upgrade_downgraded_workspace")
|
UpgradeDowngradedWorkspace = MattermostPaidFeature("mattermost.feature.upgrade_downgraded_workspace")
|
||||||
@@ -39,8 +37,6 @@ var paidFeatures map[MattermostPaidFeature]struct{} = map[MattermostPaidFeature]
|
|||||||
PaidFeaturePlaybooksRetrospective: {},
|
PaidFeaturePlaybooksRetrospective: {},
|
||||||
PaidFeatureUnlimitedMessages: {},
|
PaidFeatureUnlimitedMessages: {},
|
||||||
PaidFeatureUnlimitedFileStorage: {},
|
PaidFeatureUnlimitedFileStorage: {},
|
||||||
PaidFeatureUnlimitedIntegrations: {},
|
|
||||||
PaidFeatureUnlimitedBoardcards: {},
|
|
||||||
PaidFeatureAllProfessionalfeatures: {},
|
PaidFeatureAllProfessionalfeatures: {},
|
||||||
PaidFeatureAllEnterprisefeatures: {},
|
PaidFeatureAllEnterprisefeatures: {},
|
||||||
UpgradeDowngradedWorkspace: {},
|
UpgradeDowngradedWorkspace: {},
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user