Removing all FakeApp usages (#14174)
* Removing some other fake apps * More FakeApp removed * Removing entirely FakeApp * Fixing some tests * Fixing get Cluster id from get plugin status * Fixing failing tests * Fixing tests * Fixing test initialization for web * Fixing InitServer for server tests * Fixing InitServer for server tests * Reverting go.sum and go.mod * Removing unneded HTMLTemplates function in App layer * Moving back some functions to its old place to easy the review * Moving back some functions to its old place to easy the review * Using the last struct2interface version * Generating store layers * Fixing merge problems * Addressing PR comments * Small fix * Fixing app tests build * Fixing tests * fixing tests * Fix tests * Fixing tests * Fixing tests * Fixing tests * Moving license to server struct * Adding some fixes to the test compilation * Fixing cluster and some jobs initialization * Fixing some license tests compilation problems * Fixing recursive cache invalidation * Regenerating app layers * Fix test compilation Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f3ac33e6dc
Коммит
f5eab1271b
@@ -102,7 +102,7 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
|
||||
}
|
||||
|
||||
th := &TestHelper{
|
||||
App: s.FakeApp(),
|
||||
App: app.New(app.ServerConnector(s)),
|
||||
Server: s,
|
||||
ConfigStore: memoryStore,
|
||||
IncludeCacheLayer: includeCache,
|
||||
@@ -131,7 +131,7 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
|
||||
Init(th.Server, th.Server.AppOptions, th.App.Srv().Router)
|
||||
InitLocal(th.Server, th.Server.AppOptions, th.App.Srv().LocalRouter)
|
||||
web.New(th.Server, th.Server.AppOptions, th.App.Srv().Router)
|
||||
wsapi.Init(th.App, th.App.Srv().WebSocketRouter)
|
||||
wsapi.Init(th.App.Srv())
|
||||
th.App.DoAppMigrations()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = true })
|
||||
@@ -146,9 +146,9 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
|
||||
})
|
||||
|
||||
if enterprise {
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
} else {
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
}
|
||||
|
||||
th.Client = th.CreateClient()
|
||||
@@ -170,6 +170,8 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
|
||||
th.tempWorkspace = tempWorkspace
|
||||
}
|
||||
|
||||
th.App.InitServer()
|
||||
|
||||
return th
|
||||
}
|
||||
|
||||
@@ -265,7 +267,7 @@ func (me *TestHelper) TearDown() {
|
||||
utils.DisableDebugLogForTest()
|
||||
if me.IncludeCacheLayer {
|
||||
// Clean all the caches
|
||||
me.App.InvalidateAllCaches()
|
||||
me.App.Srv().InvalidateAllCaches()
|
||||
}
|
||||
|
||||
me.ShutdownApp()
|
||||
|
||||
@@ -1546,7 +1546,7 @@ func updateChannelScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
defer c.LogAuditRec(auditRec)
|
||||
auditRec.AddMeta("new_scheme_id", schemeID)
|
||||
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.UpdateChannelScheme", "api.channel.update_channel_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -1640,7 +1640,7 @@ func channelMembersMinusGroupMembers(c *Context, w http.ResponseWriter, r *http.
|
||||
}
|
||||
|
||||
func channelMemberCountsByGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.channelMemberCountsByGroup", "api.channel.channel_member_counts_by_group.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -1673,7 +1673,7 @@ func channelMemberCountsByGroup(c *Context, w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
|
||||
func getChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.GetChannelModerations", "api.channel.get_channel_moderations.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -1710,7 +1710,7 @@ func getChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func patchChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.patchChannelModerations", "api.channel.patch_channel_moderations.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -430,10 +430,10 @@ func TestCreateDirectChannelAsGuest(t *testing.T) {
|
||||
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
||||
defer func() {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = enableGuestAccounts })
|
||||
th.App.RemoveLicense()
|
||||
th.App.Srv().RemoveLicense()
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
id := model.NewId()
|
||||
guest := &model.User{
|
||||
@@ -557,10 +557,10 @@ func TestCreateGroupChannelAsGuest(t *testing.T) {
|
||||
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
||||
defer func() {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = enableGuestAccounts })
|
||||
th.App.RemoveLicense()
|
||||
th.App.Srv().RemoveLicense()
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
id := model.NewId()
|
||||
guest := &model.User{
|
||||
@@ -2373,7 +2373,7 @@ func TestAddChannelMember(t *testing.T) {
|
||||
Client.Logout()
|
||||
|
||||
th.MakeUserChannelAdmin(user, privateChannel)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
Client.Login(user.Username, user.Password)
|
||||
_, resp = Client.AddChannelMember(privateChannel.Id, user3.Id)
|
||||
@@ -2622,7 +2622,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
||||
|
||||
th.LoginBasic()
|
||||
th.UpdateUserToNonTeamAdmin(user1, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
// Check the appropriate permissions are enforced.
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
@@ -2660,7 +2660,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.MakeUserChannelAdmin(user1, privateChannel)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, user2.Id)
|
||||
CheckNoError(t, resp)
|
||||
@@ -2902,10 +2902,10 @@ func TestAutocompleteChannelsForSearchGuestUsers(t *testing.T) {
|
||||
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
||||
defer func() {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = enableGuestAccounts })
|
||||
th.App.RemoveLicense()
|
||||
th.App.Srv().RemoveLicense()
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
id := model.NewId()
|
||||
guest := &model.User{
|
||||
@@ -3028,7 +3028,7 @@ func TestUpdateChannelScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -3085,10 +3085,10 @@ func TestUpdateChannelScheme(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// Test that a license is required.
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
_, resp = th.SystemAdminClient.UpdateChannelScheme(channel.Id, channelScheme.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
// Test an invalid scheme scope.
|
||||
_, resp = th.SystemAdminClient.UpdateChannelScheme(channel.Id, teamScheme.Id)
|
||||
@@ -3251,14 +3251,14 @@ func TestGetChannelModerations(t *testing.T) {
|
||||
require.Equal(t, "api.channel.get_channel_moderations.license.error", res.Error.Id)
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
t.Run("Errors as a non sysadmin", func(t *testing.T) {
|
||||
_, res := th.Client.GetChannelModerations(channel.Id, "")
|
||||
require.Equal(t, "api.context.permissions.app_error", res.Error.Id)
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
t.Run("Returns default moderations with default roles", func(t *testing.T) {
|
||||
moderations, res := th.SystemAdminClient.GetChannelModerations(channel.Id, "")
|
||||
@@ -3420,14 +3420,14 @@ func TestPatchChannelModerations(t *testing.T) {
|
||||
require.Equal(t, "api.channel.patch_channel_moderations.license.error", res.Error.Id)
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
t.Run("Errors as a non sysadmin", func(t *testing.T) {
|
||||
_, res := th.Client.PatchChannelModerations(channel.Id, emptyPatch)
|
||||
require.Equal(t, "api.context.permissions.app_error", res.Error.Id)
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
t.Run("Returns default moderations with empty patch", func(t *testing.T) {
|
||||
moderations, res := th.SystemAdminClient.PatchChannelModerations(channel.Id, emptyPatch)
|
||||
@@ -3592,7 +3592,7 @@ func TestGetChannelMemberCountsByGroup(t *testing.T) {
|
||||
require.Equal(t, "api.channel.channel_member_counts_by_group.license.error", res.Error.Id)
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
t.Run("Errors without read permission to the channel", func(t *testing.T) {
|
||||
_, res := th.Client.GetChannelMemberCountsByGroup(model.NewId(), false, "")
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store/storetest/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -125,6 +126,12 @@ func TestCORSRequestHandling(t *testing.T) {
|
||||
*cfg.ServiceSettings.CorsAllowCredentials = testcase.CorsAllowCredentials
|
||||
})
|
||||
defer th.TearDown()
|
||||
systemStore := mocks.SystemStore{}
|
||||
systemStore.On("Get").Return(make(model.StringMap), nil)
|
||||
licenseStore := mocks.LicenseStore{}
|
||||
licenseStore.On("Get", "").Return(&model.LicenseRecord{}, nil)
|
||||
th.App.Srv().Store.(*mocks.Store).On("System").Return(&systemStore)
|
||||
th.App.Srv().Store.(*mocks.Store).On("License").Return(&licenseStore)
|
||||
|
||||
port := th.App.Srv().ListenAddr.Port
|
||||
host := fmt.Sprintf("http://localhost:%v", port)
|
||||
|
||||
@@ -79,7 +79,7 @@ func getGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func patchGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("patchGroup", audit.Fail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.patchGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func linkGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.createGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -275,7 +275,7 @@ func getGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
syncableType := c.Params.SyncableType
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -312,7 +312,7 @@ func getGroupSyncables(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
syncableType := c.Params.SyncableType
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroupSyncables", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -374,7 +374,7 @@ func patchGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.patchGroupSyncable", "api.ldap_groups.license_error", nil, "",
|
||||
http.StatusNotImplemented)
|
||||
return
|
||||
@@ -440,7 +440,7 @@ func unlinkGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddMeta("syncable_id", syncableID)
|
||||
auditRec.AddMeta("syncable_type", syncableType)
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.unlinkGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -499,7 +499,7 @@ func getGroupMembers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroupMembers", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -541,7 +541,7 @@ func getGroupsByUserId(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroupsByUserId", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -567,7 +567,7 @@ func getGroupsByChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroupsByChannel", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -625,7 +625,7 @@ func getGroupsByTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroupsByTeam", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -667,7 +667,7 @@ func getGroupsAssociatedToChannelsByTeam(c *Context, w http.ResponseWriter, r *h
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroupsAssociatedToChannelsByTeam", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -702,7 +702,7 @@ func getGroupsAssociatedToChannelsByTeam(c *Context, w http.ResponseWriter, r *h
|
||||
}
|
||||
|
||||
func getGroups(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getGroups", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestGetGroup(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.GetGroup(g.Id, "")
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
group, response := th.SystemAdminClient.GetGroup(g.Id, "")
|
||||
CheckNoError(t, response)
|
||||
@@ -91,7 +91,7 @@ func TestPatchGroup(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.PatchGroup(g.Id, gp)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
group2, response := th.SystemAdminClient.PatchGroup(g.Id, gp)
|
||||
CheckOKStatus(t, response)
|
||||
@@ -149,7 +149,7 @@ func TestLinkGroupTeam(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
_, response = th.Client.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||
assert.NotNil(t, response.Error)
|
||||
@@ -187,7 +187,7 @@ func TestLinkGroupChannel(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
groupTeam, response := th.Client.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||
assert.Equal(t, http.StatusCreated, response.StatusCode)
|
||||
@@ -220,12 +220,12 @@ func TestUnlinkGroupTeam(t *testing.T) {
|
||||
AutoAdd: model.NewBool(true),
|
||||
}
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
_, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||
assert.Equal(t, http.StatusCreated, response.StatusCode)
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
response = th.Client.UnlinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
@@ -233,7 +233,7 @@ func TestUnlinkGroupTeam(t *testing.T) {
|
||||
response = th.SystemAdminClient.UnlinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
response = th.Client.UnlinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam)
|
||||
assert.NotNil(t, response.Error)
|
||||
@@ -267,12 +267,12 @@ func TestUnlinkGroupChannel(t *testing.T) {
|
||||
AutoAdd: model.NewBool(true),
|
||||
}
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
_, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||
assert.Equal(t, http.StatusCreated, response.StatusCode)
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
response = th.Client.UnlinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
@@ -280,7 +280,7 @@ func TestUnlinkGroupChannel(t *testing.T) {
|
||||
response = th.SystemAdminClient.UnlinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
_, response = th.SystemAdminClient.UpdateChannelRoles(th.BasicChannel.Id, th.BasicUser.Id, "")
|
||||
require.Nil(t, response.Error)
|
||||
@@ -319,7 +319,7 @@ func TestGetGroupTeam(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, "")
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
patch := &model.GroupSyncablePatch{
|
||||
AutoAdd: model.NewBool(true),
|
||||
@@ -373,7 +373,7 @@ func TestGetGroupChannel(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, "")
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
patch := &model.GroupSyncablePatch{
|
||||
AutoAdd: model.NewBool(true),
|
||||
@@ -421,7 +421,7 @@ func TestGetGroupTeams(t *testing.T) {
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
patch := &model.GroupSyncablePatch{
|
||||
AutoAdd: model.NewBool(true),
|
||||
@@ -433,7 +433,7 @@ func TestGetGroupTeams(t *testing.T) {
|
||||
assert.Equal(t, http.StatusCreated, response.StatusCode)
|
||||
}
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
_, response := th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "")
|
||||
CheckNotImplementedStatus(t, response)
|
||||
@@ -441,7 +441,7 @@ func TestGetGroupTeams(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "")
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
_, response = th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "")
|
||||
assert.Equal(t, http.StatusForbidden, response.StatusCode)
|
||||
@@ -470,7 +470,7 @@ func TestGetGroupChannels(t *testing.T) {
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
patch := &model.GroupSyncablePatch{
|
||||
AutoAdd: model.NewBool(true),
|
||||
@@ -482,7 +482,7 @@ func TestGetGroupChannels(t *testing.T) {
|
||||
assert.Equal(t, http.StatusCreated, response.StatusCode)
|
||||
}
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
_, response := th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "")
|
||||
CheckNotImplementedStatus(t, response)
|
||||
@@ -490,7 +490,7 @@ func TestGetGroupChannels(t *testing.T) {
|
||||
_, response = th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "")
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
_, response = th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "")
|
||||
assert.Equal(t, http.StatusForbidden, response.StatusCode)
|
||||
@@ -523,7 +523,7 @@ func TestPatchGroupTeam(t *testing.T) {
|
||||
AutoAdd: model.NewBool(true),
|
||||
}
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
groupSyncable, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||
assert.Equal(t, http.StatusCreated, response.StatusCode)
|
||||
@@ -533,12 +533,12 @@ func TestPatchGroupTeam(t *testing.T) {
|
||||
_, response = th.Client.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||
assert.Equal(t, http.StatusForbidden, response.StatusCode)
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
_, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
patch.AutoAdd = model.NewBool(false)
|
||||
groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch)
|
||||
@@ -588,7 +588,7 @@ func TestPatchGroupChannel(t *testing.T) {
|
||||
AutoAdd: model.NewBool(true),
|
||||
}
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
groupSyncable, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||
assert.Equal(t, http.StatusCreated, response.StatusCode)
|
||||
@@ -607,12 +607,12 @@ func TestPatchGroupChannel(t *testing.T) {
|
||||
_, err = th.App.PatchRole(role, &model.RolePatch{Permissions: &originalPermissions})
|
||||
require.Nil(t, err)
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
_, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
patch.AutoAdd = model.NewBool(false)
|
||||
groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch)
|
||||
@@ -678,14 +678,14 @@ func TestGetGroupsByChannel(t *testing.T) {
|
||||
CheckBadRequestStatus(t, response)
|
||||
})
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
_, _, response := client.GetGroupsByChannel(th.BasicChannel.Id, opts)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
privateChannel := th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
|
||||
|
||||
@@ -751,12 +751,12 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
|
||||
_, response := th.SystemAdminClient.GetGroupsAssociatedToChannelsByTeam("asdfasdf", opts)
|
||||
CheckBadRequestStatus(t, response)
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
_, response = th.SystemAdminClient.GetGroupsAssociatedToChannelsByTeam(th.BasicTeam.Id, opts)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
groups, response := th.SystemAdminClient.GetGroupsAssociatedToChannelsByTeam(th.BasicTeam.Id, opts)
|
||||
assert.Nil(t, response.Error)
|
||||
@@ -827,14 +827,14 @@ func TestGetGroupsByTeam(t *testing.T) {
|
||||
CheckBadRequestStatus(t, response)
|
||||
})
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
_, _, response := client.GetGroupsByTeam(th.BasicTeam.Id, opts)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
groups, _, response := client.GetGroupsByTeam(th.BasicTeam.Id, opts)
|
||||
@@ -887,12 +887,12 @@ func TestGetGroups(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
_, response := th.SystemAdminClient.GetGroups(opts)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
_, response = th.SystemAdminClient.GetGroups(opts)
|
||||
require.Nil(t, response.Error)
|
||||
@@ -995,11 +995,11 @@ func TestGetGroupsByUserId(t *testing.T) {
|
||||
_, err = th.App.UpsertGroupMember(group2.Id, user1.Id)
|
||||
assert.Nil(t, err)
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
_, response := th.SystemAdminClient.GetGroupsByUserId(user1.Id)
|
||||
CheckNotImplementedStatus(t, response)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
_, response = th.SystemAdminClient.GetGroupsByUserId("")
|
||||
CheckBadRequestStatus(t, response)
|
||||
|
||||
@@ -1028,7 +1028,7 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
var groups []*model.Group
|
||||
for i := 0; i < 4; i++ {
|
||||
|
||||
10
api4/ldap.go
10
api4/ldap.go
@@ -34,7 +34,7 @@ func (api *API) InitLdap() {
|
||||
}
|
||||
|
||||
func syncLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAP {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAP {
|
||||
c.Err = model.NewAppError("Api4.syncLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func syncLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func testLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAP {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAP {
|
||||
c.Err = model.NewAppError("Api4.testLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func getLdapGroups(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.getLdapGroups", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func linkLdapGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
defer c.LogAuditRec(auditRec)
|
||||
auditRec.AddMeta("remote_id", c.Params.RemoteId)
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.linkLdapGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func unlinkLdapGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.LDAPGroups {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
||||
c.Err = model.NewAppError("Api4.unlinkLdapGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestTestLdap(t *testing.T) {
|
||||
require.NotNil(t, resp.Error)
|
||||
require.Equal(t, "api.ldap_groups.license_error", resp.Error.Id)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap_groups"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap_groups"))
|
||||
|
||||
_, resp = th.Client.TestLdap()
|
||||
CheckForbiddenStatus(t, resp)
|
||||
@@ -42,7 +42,7 @@ func TestSyncLdap(t *testing.T) {
|
||||
require.NotNil(t, resp.Error)
|
||||
require.Equal(t, "api.ldap_groups.license_error", resp.Error.Id)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("ldap_groups"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap_groups"))
|
||||
|
||||
_, resp = th.SystemAdminClient.SyncLdap()
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -37,9 +37,9 @@ func getClientLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
var clientLicense map[string]string
|
||||
|
||||
if c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) {
|
||||
clientLicense = c.App.ClientLicense()
|
||||
clientLicense = c.App.Srv().ClientLicense()
|
||||
} else {
|
||||
clientLicense = c.App.GetSanitizedClientLicense()
|
||||
clientLicense = c.App.Srv().GetSanitizedClientLicense()
|
||||
}
|
||||
|
||||
w.Write([]byte(model.MapToJson(clientLicense)))
|
||||
@@ -92,7 +92,7 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
io.Copy(buf, file)
|
||||
|
||||
license, appErr := c.App.SaveLicense(buf.Bytes())
|
||||
license, appErr := c.App.Srv().SaveLicense(buf.Bytes())
|
||||
if appErr != nil {
|
||||
if appErr.Id == model.EXPIRED_LICENSE_ERROR {
|
||||
c.LogAudit("failed - expired or non-started license")
|
||||
@@ -131,7 +131,7 @@ func removeLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.App.RemoveLicense(); err != nil {
|
||||
if err := c.App.Srv().RemoveLicense(); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -187,7 +187,7 @@ func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
Users: usersNumber.Users,
|
||||
}
|
||||
|
||||
if err := c.App.RequestTrialLicense(trialLicenseRequest); err != nil {
|
||||
if err := c.App.Srv().RequestTrialLicense(trialLicenseRequest); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func localAddLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
io.Copy(buf, file)
|
||||
|
||||
license, appErr := c.App.SaveLicense(buf.Bytes())
|
||||
license, appErr := c.App.Srv().SaveLicense(buf.Bytes())
|
||||
if appErr != nil {
|
||||
if appErr.Id == model.EXPIRED_LICENSE_ERROR {
|
||||
c.LogAudit("failed - expired or non-started license")
|
||||
@@ -83,7 +83,7 @@ func localRemoveLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
defer c.LogAuditRec(auditRec)
|
||||
c.LogAudit("attempt")
|
||||
|
||||
if err := c.App.RemoveLicense(); err != nil {
|
||||
if err := c.App.Srv().RemoveLicense(); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ func TestGetMarketplacePlugins(t *testing.T) {
|
||||
l := model.NewTestLicense()
|
||||
// model.NewTestLicense generates a E20 license
|
||||
*l.Features.EnterprisePlugins = false
|
||||
th.App.SetLicense(l)
|
||||
th.App.Srv().SetLicense(l)
|
||||
|
||||
plugins, resp := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
|
||||
CheckNoError(t, resp)
|
||||
@@ -628,7 +628,7 @@ func TestGetMarketplacePlugins(t *testing.T) {
|
||||
*cfg.PluginSettings.MarketplaceUrl = testServer.URL
|
||||
})
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("enterprise_plugins"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("enterprise_plugins"))
|
||||
|
||||
plugins, resp := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -682,7 +682,7 @@ func saveIsPinnedPost(c *Context, w http.ResponseWriter, r *http.Request, isPinn
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() != nil &&
|
||||
if c.App.Srv().License() != nil &&
|
||||
*c.App.Config().TeamSettings.ExperimentalTownSquareIsReadOnly &&
|
||||
channel.Name == model.DEFAULT_CHANNEL &&
|
||||
!c.App.RolesGrantPermission(user.GetRoles(), model.PERMISSION_MANAGE_SYSTEM.Id) {
|
||||
|
||||
@@ -444,7 +444,7 @@ func TestCreatePostPublic(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_POST_ALL_PUBLIC_ROLE_ID, false)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
@@ -458,7 +458,7 @@ func TestCreatePostPublic(t *testing.T) {
|
||||
th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID, false)
|
||||
th.App.JoinUserToTeam(th.BasicTeam, ruser, "")
|
||||
th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.TEAM_USER_ROLE_ID+" "+model.TEAM_POST_ALL_PUBLIC_ROLE_ID)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
@@ -491,7 +491,7 @@ func TestCreatePostAll(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_POST_ALL_ROLE_ID, false)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
@@ -509,7 +509,7 @@ func TestCreatePostAll(t *testing.T) {
|
||||
th.App.UpdateUserRoles(ruser.Id, model.SYSTEM_USER_ROLE_ID, false)
|
||||
th.App.JoinUserToTeam(th.BasicTeam, ruser, "")
|
||||
th.App.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.TEAM_USER_ROLE_ID+" "+model.TEAM_POST_ALL_ROLE_ID)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
@@ -667,7 +667,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
fileIds := make([]string, 3)
|
||||
data, err := testutils.ReadTestFile("test.png")
|
||||
@@ -850,7 +850,7 @@ func TestPatchPost(t *testing.T) {
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
fileIds := make([]string, 3)
|
||||
data, err := testutils.ReadTestFile("test.png")
|
||||
@@ -976,10 +976,10 @@ func TestPinPost(t *testing.T) {
|
||||
|
||||
t.Run("unable-to-pin-post-in-read-only-town-square", func(t *testing.T) {
|
||||
townSquareIsReadOnly := *th.App.Config().TeamSettings.ExperimentalTownSquareIsReadOnly
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
|
||||
|
||||
defer th.App.RemoveLicense()
|
||||
defer th.App.Srv().RemoveLicense()
|
||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = townSquareIsReadOnly })
|
||||
|
||||
channel, err := th.App.GetChannelByName("town-square", th.BasicTeam.Id, true)
|
||||
|
||||
@@ -161,7 +161,7 @@ func TestSaveReaction(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
post := th.CreatePostWithClient(th.Client, channel)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true })
|
||||
|
||||
reaction := &model.Reaction{
|
||||
@@ -177,7 +177,7 @@ func TestSaveReaction(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, 0, len(reactions), "should have not created a reaction")
|
||||
|
||||
th.App.RemoveLicense()
|
||||
th.App.Srv().RemoveLicense()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
|
||||
})
|
||||
|
||||
@@ -486,7 +486,7 @@ func TestDeleteReaction(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
post := th.CreatePostWithClient(th.Client, channel)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
reaction := &model.Reaction{
|
||||
UserId: userId,
|
||||
@@ -510,7 +510,7 @@ func TestDeleteReaction(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, 1, len(reactions), "should have not deleted a reaction")
|
||||
|
||||
th.App.RemoveLicense()
|
||||
th.App.Srv().RemoveLicense()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = false })
|
||||
})
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ func patchRole(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
auditRec.AddMeta("role", oldRole)
|
||||
|
||||
if c.App.License() == nil && patch.Permissions != nil {
|
||||
if c.App.Srv().License() == nil && patch.Permissions != nil {
|
||||
if oldRole.Name == "system_guest" || oldRole.Name == "team_guest" || oldRole.Name == "channel_guest" {
|
||||
c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
@@ -134,7 +134,7 @@ func patchRole(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if c.App.License() != nil && (oldRole.Name == "system_guest" || oldRole.Name == "team_guest" || oldRole.Name == "channel_guest") && !*c.App.License().Features.GuestAccountsPermissions {
|
||||
if c.App.Srv().License() != nil && (oldRole.Name == "system_guest" || oldRole.Name == "team_guest" || oldRole.Name == "channel_guest") && !*c.App.Srv().License().Features.GuestAccountsPermissions {
|
||||
c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func TestPatchRole(t *testing.T) {
|
||||
// Add a license.
|
||||
license := model.NewTestLicense()
|
||||
license.Features.GuestAccountsPermissions = model.NewBool(false)
|
||||
th.App.SetLicense(license)
|
||||
th.App.Srv().SetLicense(license)
|
||||
|
||||
// Try again, should succeed
|
||||
received, resp = th.SystemAdminClient.PatchRole(role.Id, patch)
|
||||
@@ -212,7 +212,7 @@ func TestPatchRole(t *testing.T) {
|
||||
t.Run("Check guest permissions editing without E20 license", func(t *testing.T) {
|
||||
license := model.NewTestLicense()
|
||||
license.Features.GuestAccountsPermissions = model.NewBool(false)
|
||||
th.App.SetLicense(license)
|
||||
th.App.Srv().SetLicense(license)
|
||||
|
||||
guestRole, err := th.App.Srv().Store.Role().GetByName("system_guest")
|
||||
require.Nil(t, err)
|
||||
@@ -223,7 +223,7 @@ func TestPatchRole(t *testing.T) {
|
||||
t.Run("Check guest permissions editing with E20 license", func(t *testing.T) {
|
||||
license := model.NewTestLicense()
|
||||
license.Features.GuestAccountsPermissions = model.NewBool(true)
|
||||
th.App.SetLicense(license)
|
||||
th.App.Srv().SetLicense(license)
|
||||
guestRole, err := th.App.Srv().Store.Role().GetByName("system_guest")
|
||||
require.Nil(t, err)
|
||||
_, resp = th.SystemAdminClient.PatchRole(guestRole.Id, patch)
|
||||
|
||||
@@ -31,7 +31,7 @@ func createScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
defer c.LogAuditRec(auditRec)
|
||||
auditRec.AddMeta("scheme", scheme)
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.CustomPermissionsSchemes {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.CustomPermissionsSchemes {
|
||||
c.Err = model.NewAppError("Api4.CreateScheme", "api.scheme.create_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func patchScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("patchScheme", audit.Fail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.CustomPermissionsSchemes {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.CustomPermissionsSchemes {
|
||||
c.Err = model.NewAppError("Api4.PatchScheme", "api.scheme.patch_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -211,7 +211,7 @@ func deleteScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("deleteScheme", audit.Fail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
if c.App.License() == nil || !*c.App.License().Features.CustomPermissionsSchemes {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.CustomPermissionsSchemes {
|
||||
c.Err = model.NewAppError("Api4.DeleteScheme", "api.scheme.delete_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestCreateScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -135,7 +135,7 @@ func TestCreateScheme(t *testing.T) {
|
||||
CheckForbiddenStatus(t, r5)
|
||||
|
||||
// Try and create a scheme without a license.
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
scheme6 := &model.Scheme{
|
||||
DisplayName: model.NewId(),
|
||||
Name: model.NewId(),
|
||||
@@ -148,7 +148,7 @@ func TestCreateScheme(t *testing.T) {
|
||||
th.App.SetPhase2PermissionsMigrationStatus(false)
|
||||
|
||||
th.LoginSystemAdmin()
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
scheme7 := &model.Scheme{
|
||||
DisplayName: model.NewId(),
|
||||
@@ -164,7 +164,7 @@ func TestGetScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
// Basic test of creating a team scheme.
|
||||
scheme1 := &model.Scheme{
|
||||
@@ -209,7 +209,7 @@ func TestGetScheme(t *testing.T) {
|
||||
CheckUnauthorizedStatus(t, r5)
|
||||
|
||||
th.SystemAdminClient.Login(th.SystemAdminUser.Username, th.SystemAdminUser.Password)
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
_, r6 := th.SystemAdminClient.GetScheme(s1.Id)
|
||||
CheckNoError(t, r6)
|
||||
|
||||
@@ -226,7 +226,7 @@ func TestGetSchemes(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
scheme1 := &model.Scheme{
|
||||
DisplayName: model.NewId(),
|
||||
@@ -289,7 +289,7 @@ func TestGetTeamsForScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -381,7 +381,7 @@ func TestGetChannelsForScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -475,7 +475,7 @@ func TestPatchScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -565,14 +565,14 @@ func TestPatchScheme(t *testing.T) {
|
||||
CheckForbiddenStatus(t, r10)
|
||||
|
||||
// Test without license.
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
_, r11 := th.SystemAdminClient.PatchScheme(s6.Id, schemePatch)
|
||||
CheckNotImplementedStatus(t, r11)
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(false)
|
||||
|
||||
th.LoginSystemAdmin()
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
_, r12 := th.SystemAdminClient.PatchScheme(s6.Id, schemePatch)
|
||||
CheckNotImplementedStatus(t, r12)
|
||||
@@ -583,7 +583,7 @@ func TestDeleteScheme(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("ValidTeamScheme", func(t *testing.T) {
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -661,7 +661,7 @@ func TestDeleteScheme(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ValidChannelScheme", func(t *testing.T) {
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -721,7 +721,7 @@ func TestDeleteScheme(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("FailureCases", func(t *testing.T) {
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -748,13 +748,13 @@ func TestDeleteScheme(t *testing.T) {
|
||||
CheckForbiddenStatus(t, r4)
|
||||
|
||||
// Test without license.
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
_, r5 := th.SystemAdminClient.DeleteScheme(s1.Id)
|
||||
CheckNotImplementedStatus(t, r5)
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(false)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
_, r6 := th.SystemAdminClient.DeleteScheme(s1.Id)
|
||||
CheckNotImplementedStatus(t, r6)
|
||||
|
||||
@@ -108,7 +108,7 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
filestoreStatusKey := "filestore_status"
|
||||
s[filestoreStatusKey] = model.STATUS_OK
|
||||
license := c.App.License()
|
||||
license := c.App.Srv().License()
|
||||
backend, appErr := filesstore.NewFileBackend(&c.App.Config().FileSettings, license != nil && *license.Features.Compliance)
|
||||
if appErr == nil {
|
||||
appErr = backend.TestConnection()
|
||||
@@ -240,7 +240,7 @@ func invalidateCaches(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
err := c.App.InvalidateAllCaches()
|
||||
err := c.App.Srv().InvalidateAllCaches()
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -379,7 +379,7 @@ func testS3(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
cfg.FileSettings.AmazonS3SecretAccessKey = c.App.Config().FileSettings.AmazonS3SecretAccessKey
|
||||
}
|
||||
|
||||
license := c.App.License()
|
||||
license := c.App.Srv().License()
|
||||
backend, appErr := filesstore.NewFileBackend(&cfg.FileSettings, license != nil && *license.Features.Compliance)
|
||||
if appErr == nil {
|
||||
appErr = backend.TestConnection()
|
||||
|
||||
@@ -1220,7 +1220,7 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
graceful := r.URL.Query().Get("graceful") != ""
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invate_guests_to_channels.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -1455,7 +1455,7 @@ func updateTeamScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("updateTeamScheme", audit.Fail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.UpdateTeamScheme", "api.team.update_team_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1647,8 +1647,8 @@ func TestAddTeamMember(t *testing.T) {
|
||||
team := th.BasicTeam
|
||||
otherUser := th.CreateUser()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
defer th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
defer th.App.Srv().SetLicense(nil)
|
||||
|
||||
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
||||
defer func() {
|
||||
@@ -1731,7 +1731,7 @@ func TestAddTeamMember(t *testing.T) {
|
||||
|
||||
// Update user to team admin
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
th.LoginBasic()
|
||||
|
||||
// Should work as a team admin.
|
||||
@@ -1745,7 +1745,7 @@ func TestAddTeamMember(t *testing.T) {
|
||||
th.RemovePermissionFromRole(model.PERMISSION_ADD_USER_TO_TEAM.Id, model.TEAM_ADMIN_ROLE_ID)
|
||||
|
||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
th.LoginBasic()
|
||||
|
||||
// Should work as a regular user.
|
||||
@@ -1800,8 +1800,8 @@ func TestAddTeamMember(t *testing.T) {
|
||||
th.App.DeleteToken(token)
|
||||
|
||||
// by invite_id
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
defer th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
defer th.App.Srv().SetLicense(nil)
|
||||
_, resp = Client.Login(guest.Email, guest.Password)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -2094,7 +2094,7 @@ func TestAddTeamMembers(t *testing.T) {
|
||||
|
||||
// Update user to team admin
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
th.LoginBasic()
|
||||
|
||||
// Should work as a team admin.
|
||||
@@ -2108,7 +2108,7 @@ func TestAddTeamMembers(t *testing.T) {
|
||||
th.RemovePermissionFromRole(model.PERMISSION_ADD_USER_TO_TEAM.Id, model.TEAM_ADMIN_ROLE_ID)
|
||||
|
||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
th.LoginBasic()
|
||||
|
||||
// Should work as a regular user.
|
||||
@@ -2755,7 +2755,7 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GuestAccountsSettings.Enable = &enableGuestAccounts })
|
||||
}()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = false })
|
||||
_, resp := th.SystemAdminClient.InviteGuestsToTeam(th.BasicTeam.Id, emailList, []string{th.BasicChannel.Id}, "test-message")
|
||||
@@ -2768,13 +2768,13 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = true })
|
||||
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
|
||||
_, resp = th.SystemAdminClient.InviteGuestsToTeam(th.BasicTeam.Id, emailList, []string{th.BasicChannel.Id}, "test-message")
|
||||
require.NotNil(t, resp.Error, "Should be disabled")
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
defer th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
defer th.App.Srv().SetLicense(nil)
|
||||
|
||||
okMsg, resp := th.SystemAdminClient.InviteGuestsToTeam(th.BasicTeam.Id, emailList, []string{th.BasicChannel.Id}, "test-message")
|
||||
CheckNoError(t, resp)
|
||||
@@ -2973,7 +2973,7 @@ func TestUpdateTeamScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(true)
|
||||
|
||||
@@ -3025,10 +3025,10 @@ func TestUpdateTeamScheme(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// Test that a license is required.
|
||||
th.App.SetLicense(nil)
|
||||
th.App.Srv().SetLicense(nil)
|
||||
_, resp = th.SystemAdminClient.UpdateTeamScheme(team.Id, teamScheme.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
// Test an invalid scheme scope.
|
||||
_, resp = th.SystemAdminClient.UpdateTeamScheme(team.Id, channelScheme.Id)
|
||||
|
||||
@@ -32,7 +32,7 @@ func createTermsOfService(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if license := c.App.License(); license == nil || !*license.Features.CustomTermsOfService {
|
||||
if license := c.App.Srv().License(); license == nil || !*license.Features.CustomTermsOfService {
|
||||
c.Err = model.NewAppError("createTermsOfService", "api.create_terms_of_service.custom_terms_of_service_disabled.app_error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestCreateTermsOfServiceAdminUser(t *testing.T) {
|
||||
termsOfService, resp := Client.CreateTermsOfService("terms of service new", th.SystemAdminUser.Id)
|
||||
CheckErrorMessage(t, resp, "api.create_terms_of_service.custom_terms_of_service_disabled.app_error")
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("EnableCustomTermsOfService"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("EnableCustomTermsOfService"))
|
||||
|
||||
termsOfService, resp = Client.CreateTermsOfService("terms of service new_2", th.SystemAdminUser.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -113,7 +113,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddMeta("token_type", token.Type)
|
||||
|
||||
if token.Type == app.TOKEN_TYPE_GUEST_INVITATION {
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("CreateUserWithToken", "api.user.create_user.guest_accounts.license.app_error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -1469,7 +1469,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
ldapOnly := props["ldap_only"] == "true"
|
||||
|
||||
if *c.App.Config().ExperimentalSettings.ClientSideCertEnable {
|
||||
if license := c.App.License(); license == nil || !*license.Features.SAML {
|
||||
if license := c.App.Srv().License(); license == nil || !*license.Features.SAML {
|
||||
c.Err = model.NewAppError("ClientSideCertNotAllowed", "api.user.login.client_side_cert.license.app_error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -1503,7 +1503,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddMeta("user", user)
|
||||
|
||||
if user.IsGuest() {
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("login", "api.user.login.guest_accounts.license.error", nil, "", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
@@ -2232,7 +2232,7 @@ func demoteUserToGuest(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.License() == nil {
|
||||
if c.App.Srv().License() == nil {
|
||||
c.Err = model.NewAppError("Api4.demoteUserToGuest", "api.team.demote_user_to_guest.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ func TestCreateUserWebSocketEvent(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("guest should not received new_user event but user should", func(t *testing.T) {
|
||||
th.App.SetLicense(model.NewTestLicense("guests"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("guests"))
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.AllowEmailAccounts = true })
|
||||
|
||||
@@ -2332,7 +2332,7 @@ func TestUpdateUserMfa(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("mfa"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("mfa"))
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableMultifactorAuthentication = true })
|
||||
|
||||
session, _ := th.App.GetSession(th.Client.AuthToken)
|
||||
@@ -2372,7 +2372,7 @@ func TestCheckUserMfa(t *testing.T) {
|
||||
|
||||
require.False(t, required, "mfa not active")
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("mfa"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("mfa"))
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableMultifactorAuthentication = true })
|
||||
|
||||
th.LoginBasic()
|
||||
@@ -2478,7 +2478,7 @@ func TestGenerateMfaSecret(t *testing.T) {
|
||||
_, resp = th.Client.GenerateMfaSecret("junk")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("mfa"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("mfa"))
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableMultifactorAuthentication = true })
|
||||
|
||||
_, resp = th.Client.GenerateMfaSecret(model.NewId())
|
||||
@@ -3130,7 +3130,7 @@ func TestCBALogin(t *testing.T) {
|
||||
t.Run("primary", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.App.SetLicense(model.NewTestLicense("saml"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("saml"))
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.EnableBotAccountCreation = true
|
||||
@@ -3188,7 +3188,7 @@ func TestCBALogin(t *testing.T) {
|
||||
t.Run("secondary", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.App.SetLicense(model.NewTestLicense("saml"))
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("saml"))
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.EnableBotAccountCreation = true
|
||||
@@ -3256,7 +3256,7 @@ func TestSwitchAccount(t *testing.T) {
|
||||
|
||||
require.NotEmpty(t, link, "bad link")
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer = false })
|
||||
|
||||
sr = &model.SwitchRequest{
|
||||
@@ -4607,10 +4607,10 @@ func TestDemoteUserToGuest(t *testing.T) {
|
||||
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
||||
defer func() {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = enableGuestAccounts })
|
||||
th.App.RemoveLicense()
|
||||
th.App.Srv().RemoveLicense()
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
_, respErr := th.SystemAdminClient.GetUser(user.Id, "")
|
||||
CheckNoError(t, respErr)
|
||||
_, respErr = th.SystemAdminClient.DemoteUserToGuest(user.Id)
|
||||
@@ -4660,10 +4660,10 @@ func TestPromoteGuestToUser(t *testing.T) {
|
||||
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
|
||||
defer func() {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = enableGuestAccounts })
|
||||
th.App.RemoveLicense()
|
||||
th.App.Srv().RemoveLicense()
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||
th.App.SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
_, respErr := th.SystemAdminClient.GetUser(user.Id, "")
|
||||
CheckNoError(t, respErr)
|
||||
_, respErr = th.SystemAdminClient.PromoteGuestToUser(user.Id)
|
||||
|
||||
Ссылка в новой задаче
Block a user