* 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>
Этот коммит содержится в:
Jesús Espino
2020-06-12 13:43:50 +02:00
коммит произвёл GitHub
родитель f3ac33e6dc
Коммит f5eab1271b
88 изменённых файлов: 973 добавлений и 1177 удалений

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

@@ -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, "")