* 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 удалений

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

@@ -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++ {