mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
Merge branch 'master' into post-metadata
This commit is contained in:
commit
c9f3d03b6d
60 changed files with 2195 additions and 1822 deletions
2
Makefile
2
Makefile
|
|
@ -351,7 +351,7 @@ test-te: do-cover-file ## Runs tests in the team edition.
|
|||
@echo Testing TE
|
||||
@echo "Packages to test: "$(TE_PACKAGES)
|
||||
find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \;
|
||||
$(GO) test $(GOFLAGS) -run=$(TESTS) $(TESTFLAGS) -v -timeout=2000s -covermode=count -coverpkg=$(ALL_PACKAGES_COMMA) -exec $(ROOT)/scripts/test-xprog.sh $(TE_PACKAGES)
|
||||
$(GO) test $(GOFLAGS) -run=$(TESTS) $(TESTFLAGS) -p 1 -v -timeout=2000s -covermode=count -coverpkg=$(ALL_PACKAGES_COMMA) -exec $(ROOT)/scripts/test-xprog.sh $(TE_PACKAGES)
|
||||
find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 {} >> cover.out ; rm "{}"' \;
|
||||
|
||||
test-ee: do-cover-file ## Runs tests in the enterprise edition.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import (
|
|||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -76,6 +75,10 @@ func StopTestStore() {
|
|||
}
|
||||
|
||||
func setupTestHelper(enterprise bool, updateConfig func(*model.Config)) *TestHelper {
|
||||
if testStore != nil {
|
||||
testStore.DropAllTables()
|
||||
}
|
||||
|
||||
permConfig, err := os.Open(utils.FindConfigFile("config.json"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -175,65 +178,26 @@ func SetupConfig(updateConfig func(cfg *model.Config)) *TestHelper {
|
|||
return setupTestHelper(false, updateConfig)
|
||||
}
|
||||
|
||||
func (me *TestHelper) ShutdownApp() {
|
||||
done := make(chan bool)
|
||||
go func() {
|
||||
me.App.Shutdown()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(30 * time.Second):
|
||||
// panic instead of t.Fatal to terminate all tests in this package, otherwise the
|
||||
// still running App could spuriously fail subsequent tests.
|
||||
panic("failed to shutdown App within 30 seconds")
|
||||
}
|
||||
}
|
||||
|
||||
func (me *TestHelper) TearDown() {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(3)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
options := &model.UserSearchOptions{
|
||||
AllowEmails: false,
|
||||
AllowFullNames: false,
|
||||
Limit: model.USER_SEARCH_MAX_LIMIT,
|
||||
}
|
||||
if result := <-me.App.Srv.Store.User().Search("", "fakeuser", options); result.Err != nil {
|
||||
mlog.Error("Error tearing down test users")
|
||||
} else {
|
||||
users := result.Data.([]*model.User)
|
||||
|
||||
for _, u := range users {
|
||||
if err := me.App.PermanentDeleteUser(u); err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if result := <-me.App.Srv.Store.Team().SearchByName("faketeam"); result.Err != nil {
|
||||
mlog.Error("Error tearing down test teams")
|
||||
} else {
|
||||
teams := result.Data.([]*model.Team)
|
||||
|
||||
for _, t := range teams {
|
||||
if err := me.App.PermanentDeleteTeam(t); err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if result := <-me.App.Srv.Store.OAuth().GetApps(0, 1000); result.Err != nil {
|
||||
mlog.Error("Error tearing down test oauth apps")
|
||||
} else {
|
||||
apps := result.Data.([]*model.OAuthApp)
|
||||
|
||||
for _, a := range apps {
|
||||
if strings.HasPrefix(a.Name, "fakeoauthapp") {
|
||||
<-me.App.Srv.Store.OAuth().DeleteApp(a.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
|
||||
me.App.Shutdown()
|
||||
me.ShutdownApp()
|
||||
os.Remove(me.tempConfigPath)
|
||||
|
||||
utils.EnableDebugLogForTest()
|
||||
|
|
@ -247,6 +211,10 @@ func (me *TestHelper) TearDown() {
|
|||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.waitForConnectivity()
|
||||
|
||||
me.SystemAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_ADMIN_ROLE_ID, false)
|
||||
me.LoginSystemAdmin()
|
||||
|
||||
me.TeamAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.TeamAdminUser.Id, model.SYSTEM_USER_ROLE_ID, false)
|
||||
me.LoginTeamAdmin()
|
||||
|
|
@ -275,16 +243,6 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
|||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitSystemAdmin() *TestHelper {
|
||||
me.waitForConnectivity()
|
||||
|
||||
me.SystemAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_ADMIN_ROLE_ID, false)
|
||||
me.LoginSystemAdmin()
|
||||
|
||||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) waitForConnectivity() {
|
||||
for i := 0; i < 1000; i++ {
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%v", me.App.Srv.ListenAddr.Port))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetBrandImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ func TestGetBrandImage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUploadBrandImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ func TestUploadBrandImage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteBrandImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
data, err := testutils.ReadTestFile("test.png")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -142,7 +142,7 @@ func TestCreateChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -240,7 +240,7 @@ func TestUpdateChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPatchChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ func TestPatchChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateDirectChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user1 := th.BasicUser
|
||||
|
|
@ -378,7 +378,7 @@ func TestCreateDirectChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteDirectChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -395,7 +395,7 @@ func TestDeleteDirectChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateGroupChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -467,7 +467,7 @@ func TestCreateGroupChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteGroupChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -487,7 +487,7 @@ func TestDeleteGroupChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -536,7 +536,7 @@ func TestGetChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetDeletedChannelsForTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -583,7 +583,7 @@ func TestGetDeletedChannelsForTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPublicChannelsForTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -663,7 +663,7 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
|
@ -725,7 +725,7 @@ func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelsForTeamForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -773,7 +773,7 @@ func TestGetChannelsForTeamForUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSearchChannels(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -828,7 +828,7 @@ func TestSearchChannels(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -915,8 +915,13 @@ func TestDeleteChannel(t *testing.T) {
|
|||
|
||||
_, resp = th.SystemAdminClient.DeleteChannel(publicChannel5.Id)
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
th.InitBasic().InitSystemAdmin()
|
||||
func TestDeleteChannel2(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
||||
// Check the appropriate permissions are enforced.
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
|
|
@ -927,9 +932,6 @@ func TestDeleteChannel(t *testing.T) {
|
|||
th.AddPermissionToRole(model.PERMISSION_DELETE_PUBLIC_CHANNEL.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_DELETE_PRIVATE_CHANNEL.Id, model.TEAM_USER_ROLE_ID)
|
||||
|
||||
Client = th.Client
|
||||
user = th.BasicUser
|
||||
|
||||
// channels created by SystemAdmin
|
||||
publicChannel6 := th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_OPEN)
|
||||
privateChannel7 := th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
|
||||
|
|
@ -938,7 +940,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
th.App.AddUserToChannel(user, privateChannel7)
|
||||
|
||||
// successful delete by user
|
||||
_, resp = Client.DeleteChannel(publicChannel6.Id)
|
||||
_, resp := Client.DeleteChannel(publicChannel6.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
_, resp = Client.DeleteChannel(privateChannel7.Id)
|
||||
|
|
@ -991,7 +993,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConvertChannelToPrivate(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1065,7 +1067,7 @@ func TestConvertChannelToPrivate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRestoreChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1091,7 +1093,7 @@ func TestRestoreChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelByName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1150,7 +1152,7 @@ func TestGetChannelByName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelByNameForTeamName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1191,7 +1193,7 @@ func TestGetChannelByNameForTeamName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelMembers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1246,7 +1248,7 @@ func TestGetChannelMembers(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelMembersByIds(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1293,7 +1295,7 @@ func TestGetChannelMembersByIds(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1340,7 +1342,7 @@ func TestGetChannelMember(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelMembersForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1383,7 +1385,7 @@ func TestGetChannelMembersForUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestViewChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1454,7 +1456,7 @@ func TestViewChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelUnread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -1498,7 +1500,7 @@ func TestGetChannelUnread(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelStats(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.CreatePrivateChannel()
|
||||
|
|
@ -1532,7 +1534,7 @@ func TestGetChannelStats(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPinnedPosts(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -1571,7 +1573,7 @@ func TestGetPinnedPosts(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateChannelRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1650,7 +1652,7 @@ func TestUpdateChannelRoles(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateChannelMemberSchemeRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
th.LoginBasic()
|
||||
|
|
@ -1725,7 +1727,7 @@ func TestUpdateChannelMemberSchemeRoles(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateChannelNotifyProps(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1775,7 +1777,7 @@ func TestUpdateChannelNotifyProps(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAddChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -1934,7 +1936,7 @@ func TestAddChannelMember(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
team := th.BasicTeam
|
||||
|
|
@ -2138,7 +2140,7 @@ func TestAutocompleteChannels(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAutocompleteChannelsForSearch(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.LoginSystemAdminWithClient(th.SystemAdminClient)
|
||||
|
|
@ -2261,7 +2263,7 @@ func TestAutocompleteChannelsForSearch(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateChannelScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
|
|
@ -2337,7 +2339,7 @@ func TestUpdateChannelScheme(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelMembersTimezones(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetClusterStatus(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.GetClusterStatus()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ func TestCreateCommand(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
|
|
@ -151,7 +151,7 @@ func TestUpdateCommand(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
|
|
@ -214,7 +214,7 @@ func TestDeleteCommand(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestListCommands(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ func TestListCommands(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestListAutocompleteCommands(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ func TestListAutocompleteCommands(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRegenToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -392,7 +392,7 @@ func TestRegenToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExecuteInvalidCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -455,7 +455,7 @@ func TestExecuteInvalidCommand(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExecuteGetCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -517,7 +517,7 @@ func TestExecuteGetCommand(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExecutePostCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func TestElasticsearchTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.TestElasticsearch()
|
||||
|
|
@ -19,7 +19,7 @@ func TestElasticsearchTest(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestElasticsearchPurgeIndexes(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.PurgeElasticsearchIndexes()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ func TestGetEmojiList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
)
|
||||
|
||||
func TestUploadFileAsMultipart(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ func TestUploadFileAsMultipart(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUploadFileAsRequestBody(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ func TestUploadFileAsRequestBody(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -367,7 +367,7 @@ func TestGetFileHeaders(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFileThumbnail(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -419,7 +419,7 @@ func TestGetFileThumbnail(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFileLink(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -495,7 +495,7 @@ func TestGetFileLink(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFilePreview(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -547,7 +547,7 @@ func TestGetFilePreview(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFileInfo(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -614,7 +614,7 @@ func TestGetFileInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPublicFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateJob(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
job := &model.Job{
|
||||
|
|
@ -39,7 +39,7 @@ func TestCreateJob(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetJob(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
job := &model.Job{
|
||||
|
|
@ -70,7 +70,7 @@ func TestGetJob(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetJobs(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
jobType := model.NewId()
|
||||
|
|
@ -122,7 +122,7 @@ func TestGetJobs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetJobsByType(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
jobType := model.NewId()
|
||||
|
|
@ -186,7 +186,7 @@ func TestGetJobsByType(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCancelJob(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
jobs := []*model.Job{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func TestLdapTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.TestLdap()
|
||||
|
|
@ -19,7 +19,7 @@ func TestLdapTest(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLdapSync(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.SystemAdminClient.SyncLdap()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -96,7 +96,7 @@ func TestCreateOAuthApp(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -213,7 +213,7 @@ func TestUpdateOAuthApp(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOAuthApps(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -287,7 +287,7 @@ func TestGetOAuthApps(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -363,7 +363,7 @@ func TestGetOAuthApp(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOAuthAppInfo(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -439,7 +439,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -509,7 +509,7 @@ func TestDeleteOAuthApp(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRegenerateOAuthAppSecret(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -583,7 +583,7 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAuthorizedOAuthAppsForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -643,7 +643,7 @@ func TestGetAuthorizedOAuthAppsForUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAuthorizeOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -732,7 +732,7 @@ func TestAuthorizeOAuthApp(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeauthorizeOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
)
|
||||
|
||||
func TestPlugin(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
enablePlugins := *th.App.Config().PluginSettings.Enable
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreatePost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ func TestCreatePost(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreatePostEphemeral(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ func testCreatePostWithOutgoingHook(
|
|||
triggerWhen int,
|
||||
commentPostType bool,
|
||||
) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
user := th.SystemAdminUser
|
||||
team := th.BasicTeam
|
||||
|
|
@ -357,7 +357,7 @@ func TestCreatePostWithOutgoingHook_no_content_type(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreatePostPublic(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -402,7 +402,7 @@ func TestCreatePostPublic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreatePostAll(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ func TestCreatePostAll(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreatePostSendOutOfChannelMentions(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ func TestCreatePostSendOutOfChannelMentions(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdatePost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -604,7 +604,7 @@ func TestUpdateOthersPostInDirectMessageChannel(t *testing.T) {
|
|||
// This test checks that a sysadmin with the "EDIT_OTHERS_POSTS" permission can edit someone else's post in a
|
||||
// channel without a team (DM/GM). This indirectly checks for the proper cascading all the way to system-wide roles
|
||||
// on the user object of permissions based on a post in a channel with no team ID.
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
dmChannel := th.CreateDmChannel(th.SystemAdminUser)
|
||||
|
|
@ -626,7 +626,7 @@ func TestUpdateOthersPostInDirectMessageChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPatchPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -714,7 +714,7 @@ func TestPatchPost(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPinPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -749,7 +749,7 @@ func TestPinPost(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnpinPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -784,7 +784,7 @@ func TestUnpinPost(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPostsForChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -896,7 +896,7 @@ func TestGetPostsForChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFlaggedPostsForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -1161,7 +1161,7 @@ func TestGetPostsAfterAndBefore(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1210,7 +1210,7 @@ func TestGetPost(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeletePost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1248,7 +1248,7 @@ func TestDeletePost(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPostThread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1677,7 +1677,7 @@ func TestSearchPostsWithDateFlags(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetFileInfosForPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestSaveReaction(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
userId := th.BasicUser.Id
|
||||
|
|
@ -225,7 +225,7 @@ func TestSaveReaction(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetReactions(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
userId := th.BasicUser.Id
|
||||
|
|
@ -306,7 +306,7 @@ func TestGetReactions(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteReaction(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
userId := th.BasicUser.Id
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetRole(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
role := &model.Role{
|
||||
|
|
@ -47,7 +47,7 @@ func TestGetRole(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetRoleByName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
role := &model.Role{
|
||||
|
|
@ -81,7 +81,7 @@ func TestGetRoleByName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetRolesByNames(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
role1 := &model.Role{
|
||||
|
|
@ -147,7 +147,7 @@ func TestGetRolesByNames(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPatchRole(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
role := &model.Role{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetSamlMetadata(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
|
@ -150,7 +150,7 @@ func TestCreateScheme(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
|
@ -210,7 +210,7 @@ func TestGetScheme(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetSchemes(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
|
@ -273,7 +273,7 @@ func TestGetSchemes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamsForScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
|
@ -368,7 +368,7 @@ func TestGetTeamsForScheme(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelsForScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
|
@ -465,7 +465,7 @@ func TestGetChannelsForScheme(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPatchScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
|
@ -570,7 +570,7 @@ func TestPatchScheme(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("ValidTeamScheme", func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func TestGetUsersStatusesByIds(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateUserStatus(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetPing(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ func TestGetPing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ func TestGetConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReloadConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ func TestReloadConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ func TestGetEnvironmentConfig(t *testing.T) {
|
|||
os.Setenv("MM_SERVICESETTINGS_ENABLECUSTOMEMOJI", "true")
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_SITEURL")
|
||||
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("as system admin", func(t *testing.T) {
|
||||
|
|
@ -212,7 +212,7 @@ func TestGetEnvironmentConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOldClientConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
testKey := "supersecretkey"
|
||||
|
|
@ -274,7 +274,7 @@ func TestGetOldClientConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOldClientLicense(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ func TestGetOldClientLicense(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAudits(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ func TestGetAudits(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEmailTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -379,7 +379,7 @@ func TestEmailTest(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDatabaseRecycle(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -391,7 +391,7 @@ func TestDatabaseRecycle(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInvalidateCaches(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -409,7 +409,7 @@ func TestInvalidateCaches(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetLogs(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -449,7 +449,7 @@ func TestGetLogs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPostLog(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -484,7 +484,7 @@ func TestPostLog(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUploadLicenseFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -502,7 +502,7 @@ func TestUploadLicenseFile(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveLicenseFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -520,7 +520,7 @@ func TestRemoveLicenseFile(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAnalyticsOld(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -593,7 +593,7 @@ func TestGetAnalyticsOld(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestS3TestConnection(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -672,7 +672,7 @@ func TestRedirectLocation(t *testing.T) {
|
|||
|
||||
mockBitlyLink := testServer.URL
|
||||
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
enableLinkPreviews := *th.App.Config().ServiceSettings.EnableLinkPreviews
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func TestCreateTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateTeamSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
// Non-admin users can create a team, but they become a team admin by doing so
|
||||
|
|
@ -126,7 +126,7 @@ func TestCreateTeamSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -173,7 +173,7 @@ func TestGetTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
|
|
@ -216,7 +216,7 @@ func TestGetTeamSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamUnread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ func TestGetTeamUnread(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ func TestUpdateTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateTeamSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
|
|
@ -377,7 +377,7 @@ func TestUpdateTeamSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPatchTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ func TestPatchTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPatchTeamSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
|
|
@ -472,7 +472,7 @@ func TestPatchTeamSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSoftDeleteTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ func TestSoftDeleteTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPermanentDeleteTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ func TestPermanentDeleteTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAllTeams(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -628,7 +628,7 @@ func TestGetAllTeams(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAllTeamsSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
|
|
@ -693,7 +693,7 @@ func TestGetAllTeamsSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamByName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -740,7 +740,7 @@ func TestGetTeamByName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamByNameSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
|
|
@ -783,7 +783,7 @@ func TestGetTeamByNameSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSearchAllTeams(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
oTeam := th.BasicTeam
|
||||
|
|
@ -865,7 +865,7 @@ func TestSearchAllTeams(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSearchAllTeamsSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
|
|
@ -941,7 +941,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamsForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -983,7 +983,7 @@ func TestGetTeamsForUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamsForUserSanitization(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
|
|
@ -1053,7 +1053,7 @@ func TestGetTeamsForUserSanitization(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -1090,7 +1090,7 @@ func TestGetTeamMember(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamMembers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -1155,7 +1155,7 @@ func TestGetTeamMembers(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamMembersForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1231,7 +1231,7 @@ func TestGetTeamMembersByIds(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAddTeamMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -1412,7 +1412,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAddTeamMembers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -1513,7 +1513,7 @@ func TestAddTeamMembers(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveTeamMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1544,7 +1544,7 @@ func TestRemoveTeamMember(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamStats(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -1599,7 +1599,7 @@ func TestGetTeamStats(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateTeamMemberRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
|
@ -1677,7 +1677,7 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
th.LoginBasic()
|
||||
|
|
@ -1752,7 +1752,7 @@ func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetMyTeamsUnread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1783,7 +1783,7 @@ func TestGetMyTeamsUnread(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTeamExists(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -1808,7 +1808,7 @@ func TestTeamExists(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestImportTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("ImportTeam", func(t *testing.T) {
|
||||
|
|
@ -1887,7 +1887,7 @@ func TestImportTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInviteUsersToTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
user1 := th.GenerateTestEmail()
|
||||
|
|
@ -1997,7 +1997,7 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamInviteInfo(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -2025,7 +2025,7 @@ func TestGetTeamInviteInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetTeamIcon(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -2088,7 +2088,7 @@ func TestSetTeamIcon(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTeamIcon(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -2104,7 +2104,7 @@ func TestGetTeamIcon(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveTeamIcon(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
|
@ -2141,7 +2141,7 @@ func TestRemoveTeamIcon(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateTeamScheme(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense(""))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func TestCreateTermsOfService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateTermsOfServiceAdminUser(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -94,7 +94,7 @@ func TestCreateUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateUserWithToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ func TestCreateUserWithToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateUserWithInviteId(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -354,7 +354,7 @@ func TestGetMe(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ func TestGetUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUserByUsername(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -493,7 +493,7 @@ func TestGetUserByUsername(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUserByEmail(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ func TestGetUserByEmail(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSearchUsers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -748,7 +748,7 @@ func findUserInList(id string, users []*model.User) bool {
|
|||
}
|
||||
|
||||
func TestAutocompleteUsers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
|
@ -881,7 +881,7 @@ func TestAutocompleteUsers(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetProfileImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -985,7 +985,7 @@ func TestGetUsersByUsernames(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetTotalUsersStat(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1000,7 +1000,7 @@ func TestGetTotalUsersStat(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1065,7 +1065,7 @@ func TestUpdateUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPatchUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1161,7 +1161,7 @@ func TestPatchUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateUserAuth(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
|
|
@ -1223,7 +1223,7 @@ func TestUpdateUserAuth(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
|
|
@ -1255,7 +1255,7 @@ func TestDeleteUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateUserRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
|
|
@ -1310,7 +1310,7 @@ func assertWebsocketEventUserUpdatedWithEmail(t *testing.T, client *model.WebSoc
|
|||
|
||||
func TestUpdateUserActive(t *testing.T) {
|
||||
t.Run("basic tests", func(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
|
|
@ -1377,7 +1377,7 @@ func TestUpdateUserActive(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("websocket events", func(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
|
@ -1536,7 +1536,7 @@ func TestGetRecentlyActiveUsersInTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUsersWithoutTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
|
@ -1586,7 +1586,7 @@ func TestGetUsersWithoutTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUsersInTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
|
@ -1632,7 +1632,7 @@ func TestGetUsersInTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUsersNotInTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
|
@ -1642,27 +1642,22 @@ func TestGetUsersNotInTeam(t *testing.T) {
|
|||
for _, u := range rusers {
|
||||
CheckUserSanitization(t, u)
|
||||
}
|
||||
require.Len(t, rusers, 1, "should be 1 user in total")
|
||||
|
||||
rusers, resp = Client.GetUsersNotInTeam(teamId, 0, 60, resp.Etag)
|
||||
CheckEtag(t, rusers, resp)
|
||||
|
||||
rusers, resp = Client.GetUsersNotInTeam(teamId, 0, 1, "")
|
||||
CheckNoError(t, resp)
|
||||
if len(rusers) != 1 {
|
||||
t.Fatal("should be 1 per page")
|
||||
}
|
||||
require.Len(t, rusers, 1, "should be 1 per page")
|
||||
|
||||
rusers, resp = Client.GetUsersNotInTeam(teamId, 1, 1, "")
|
||||
CheckNoError(t, resp)
|
||||
if len(rusers) != 1 {
|
||||
t.Fatal("should be 1 per page")
|
||||
}
|
||||
require.Len(t, rusers, 0, "should be no users")
|
||||
|
||||
rusers, resp = Client.GetUsersNotInTeam(teamId, 10000, 100, "")
|
||||
CheckNoError(t, resp)
|
||||
if len(rusers) != 0 {
|
||||
t.Fatal("should be no users")
|
||||
}
|
||||
require.Len(t, rusers, 0, "should be no users")
|
||||
|
||||
Client.Logout()
|
||||
_, resp = Client.GetUsersNotInTeam(teamId, 0, 60, "")
|
||||
|
|
@ -1678,7 +1673,7 @@ func TestGetUsersNotInTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUsersInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channelId := th.BasicChannel.Id
|
||||
|
|
@ -1721,7 +1716,7 @@ func TestGetUsersInChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUsersNotInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
|
@ -1762,7 +1757,7 @@ func TestGetUsersNotInChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateUserMfa(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1778,7 +1773,7 @@ func TestUpdateUserMfa(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckUserMfa(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1824,7 +1819,7 @@ func TestCheckUserMfa(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGenerateMfaSecret(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1857,7 +1852,7 @@ func TestGenerateMfaSecret(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateUserPassword(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1926,6 +1921,7 @@ func TestUpdateUserPassword(t *testing.T) {
|
|||
|
||||
/*func TestResetPassword(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
Client.Logout()
|
||||
user := th.BasicUser
|
||||
|
|
@ -2010,7 +2006,7 @@ func TestUpdateUserPassword(t *testing.T) {
|
|||
}*/
|
||||
|
||||
func TestGetSessions(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -2050,7 +2046,7 @@ func TestGetSessions(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRevokeSessions(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -2123,8 +2119,6 @@ func TestRevokeAllSessions(t *testing.T) {
|
|||
_, resp := Client.RevokeAllSessions(th.BasicUser2.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.InitSystemAdmin()
|
||||
|
||||
_, resp = Client.RevokeAllSessions("junk" + user.Id)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
|
|
@ -2188,7 +2182,7 @@ func TestAttachDeviceId(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUserAudits(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -2261,7 +2255,7 @@ func TestSendVerificationEmail(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetProfileImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -2312,7 +2306,7 @@ func TestSetProfileImage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetDefaultProfileImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
|
@ -2408,7 +2402,7 @@ func TestCBALogin(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSwitchAccount(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -2536,7 +2530,7 @@ func TestSwitchAccount(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -2617,7 +2611,7 @@ func TestCreateUserAccessToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -2701,7 +2695,7 @@ func TestGetUserAccessToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSearchUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -2747,7 +2741,7 @@ func TestSearchUserAccessToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRevokeUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -2791,7 +2785,7 @@ func TestRevokeUserAccessToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDisableUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
|
@ -2835,7 +2829,7 @@ func TestDisableUserAccessToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEnableUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -2877,7 +2871,7 @@ func TestEnableUserAccessToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUserAccessTokenInactiveUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -2900,7 +2894,7 @@ func TestUserAccessTokenInactiveUser(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUserAccessTokenDisableConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -3093,7 +3087,6 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func TestGetUserTermsOfService(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateIncomingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ func TestCreateIncomingWebhook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetIncomingWebhooks(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ func TestGetIncomingWebhooks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetIncomingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ func TestGetIncomingWebhook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteIncomingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ func TestDeleteIncomingWebhook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateOutgoingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -293,7 +293,7 @@ func TestCreateOutgoingWebhook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOutgoingWebhooks(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -394,7 +394,7 @@ func TestGetOutgoingWebhooks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOutgoingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -424,7 +424,7 @@ func TestGetOutgoingWebhook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateIncomingHook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -644,7 +644,7 @@ func TestUpdateIncomingHook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateOutgoingHook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -839,7 +839,7 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeleteOutgoingHook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ func StopTestStore() {
|
|||
}
|
||||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
if testStore != nil {
|
||||
testStore.DropAllTables()
|
||||
}
|
||||
|
||||
permConfig, err := os.Open(utils.FindConfigFile("config.json"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -148,8 +152,13 @@ func Setup() *TestHelper {
|
|||
}
|
||||
|
||||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.SystemAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_ADMIN_ROLE_ID, false)
|
||||
me.SystemAdminUser, _ = me.App.GetUser(me.SystemAdminUser.Id)
|
||||
|
||||
me.BasicTeam = me.CreateTeam()
|
||||
me.BasicUser = me.CreateUser()
|
||||
|
||||
me.LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
me.BasicUser2 = me.CreateUser()
|
||||
me.LinkUserToTeam(me.BasicUser2, me.BasicTeam)
|
||||
|
|
@ -159,14 +168,6 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
|||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitSystemAdmin() *TestHelper {
|
||||
me.SystemAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_ADMIN_ROLE_ID, false)
|
||||
me.SystemAdminUser, _ = me.App.GetUser(me.SystemAdminUser.Id)
|
||||
|
||||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) MockHTTPService(handler http.Handler) *TestHelper {
|
||||
me.MockedHTTPService = testutils.MakeMockedHTTPService(handler)
|
||||
me.App.HTTPService = me.MockedHTTPService
|
||||
|
|
@ -423,8 +424,25 @@ func (me *TestHelper) AddReactionToPost(post *model.Post, user *model.User, emoj
|
|||
return reaction
|
||||
}
|
||||
|
||||
func (me *TestHelper) ShutdownApp() {
|
||||
done := make(chan bool)
|
||||
go func() {
|
||||
me.App.Shutdown()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(30 * time.Second):
|
||||
// panic instead of t.Fatal to terminate all tests in this package, otherwise the
|
||||
// still running App could spuriously fail subsequent tests.
|
||||
panic("failed to shutdown App within 30 seconds")
|
||||
}
|
||||
}
|
||||
|
||||
func (me *TestHelper) TearDown() {
|
||||
me.App.Shutdown()
|
||||
me.ShutdownApp()
|
||||
|
||||
os.Remove(me.tempConfigPath)
|
||||
if err := recover(); err != nil {
|
||||
StopTestStore()
|
||||
|
|
|
|||
|
|
@ -211,10 +211,10 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
|
|||
a.InvalidateCacheForUser(channel.CreatorId)
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.ChannelHasBeenCreated(pluginContext, sc)
|
||||
return true
|
||||
}, plugin.ChannelHasBeenCreatedId)
|
||||
|
|
@ -238,10 +238,10 @@ func (a *App) CreateDirectChannel(userId string, otherUserId string) (*model.Cha
|
|||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(otherUserId)
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.ChannelHasBeenCreated(pluginContext, channel)
|
||||
return true
|
||||
}, plugin.ChannelHasBeenCreatedId)
|
||||
|
|
@ -857,10 +857,10 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.UserHasJoinedChannel(pluginContext, cm, userRequestor)
|
||||
return true
|
||||
}, plugin.UserHasJoinedChannelId)
|
||||
|
|
@ -1247,10 +1247,10 @@ func (a *App) JoinChannel(channel *model.Channel, userId string) *model.AppError
|
|||
return err
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.UserHasJoinedChannel(pluginContext, cm, nil)
|
||||
return true
|
||||
}, plugin.UserHasJoinedChannelId)
|
||||
|
|
@ -1448,8 +1448,7 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
|||
a.InvalidateCacheForUser(userIdToRemove)
|
||||
a.InvalidateCacheForChannelMembers(channel.Id)
|
||||
|
||||
if a.PluginsReady() {
|
||||
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var actorUser *model.User
|
||||
if removerUserId != "" {
|
||||
actorUser, _ = a.GetUser(removerUserId)
|
||||
|
|
@ -1457,7 +1456,7 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
|||
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.UserHasLeftChannel(pluginContext, cm, actorUser)
|
||||
return true
|
||||
}, plugin.UserHasLeftChannelId)
|
||||
|
|
@ -1710,13 +1709,15 @@ func (a *App) MoveChannel(team *model.Team, channel *model.Channel, user *model.
|
|||
channelMemberIds = append(channelMemberIds, channelMember.UserId)
|
||||
}
|
||||
|
||||
teamMembers, err2 := a.GetTeamMembersByIds(team.Id, channelMemberIds)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
if len(channelMemberIds) > 0 {
|
||||
teamMembers, err2 := a.GetTeamMembersByIds(team.Id, channelMemberIds)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
|
||||
if len(teamMembers) != len(*channelMembers) {
|
||||
return model.NewAppError("MoveChannel", "app.channel.move_channel.members_do_not_match.error", nil, "", http.StatusInternalServerError)
|
||||
if len(teamMembers) != len(*channelMembers) {
|
||||
return model.NewAppError("MoveChannel", "app.channel.move_channel.members_do_not_match.error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
// keep instance of the previous team
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/store"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/store"
|
||||
)
|
||||
|
||||
func TestPermanentDeleteChannel(t *testing.T) {
|
||||
|
|
@ -138,6 +139,22 @@ func TestMoveChannel(t *testing.T) {
|
|||
if err := th.App.MoveChannel(targetTeam, channel2, th.BasicUser, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Test moving a channel with no members.
|
||||
channel3 := &model.Channel{
|
||||
DisplayName: "dn_" + model.NewId(),
|
||||
Name: "name_" + model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
TeamId: sourceTeam.Id,
|
||||
CreatorId: th.BasicUser.Id,
|
||||
}
|
||||
|
||||
var err *model.AppError
|
||||
channel3, err = th.App.CreateChannel(channel3, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.MoveChannel(targetTeam, channel3, th.BasicUser, false)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testing.T) {
|
||||
|
|
@ -713,7 +730,7 @@ func TestRenameChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChannelMembersTimezones(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
userRequestorId := ""
|
||||
|
|
|
|||
|
|
@ -580,62 +580,65 @@ func (a *App) trackLicense() {
|
|||
}
|
||||
|
||||
func (a *App) trackPlugins() {
|
||||
if a.PluginsReady() {
|
||||
totalEnabledCount := 0
|
||||
webappEnabledCount := 0
|
||||
backendEnabledCount := 0
|
||||
totalDisabledCount := 0
|
||||
webappDisabledCount := 0
|
||||
backendDisabledCount := 0
|
||||
brokenManifestCount := 0
|
||||
settingsCount := 0
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return
|
||||
}
|
||||
|
||||
pluginStates := a.Config().PluginSettings.PluginStates
|
||||
plugins, _ := a.Srv.Plugins.Available()
|
||||
totalEnabledCount := 0
|
||||
webappEnabledCount := 0
|
||||
backendEnabledCount := 0
|
||||
totalDisabledCount := 0
|
||||
webappDisabledCount := 0
|
||||
backendDisabledCount := 0
|
||||
brokenManifestCount := 0
|
||||
settingsCount := 0
|
||||
|
||||
if pluginStates != nil && plugins != nil {
|
||||
for _, plugin := range plugins {
|
||||
if plugin.Manifest == nil {
|
||||
brokenManifestCount += 1
|
||||
continue
|
||||
pluginStates := a.Config().PluginSettings.PluginStates
|
||||
plugins, _ := pluginsEnvironment.Available()
|
||||
|
||||
if pluginStates != nil && plugins != nil {
|
||||
for _, plugin := range plugins {
|
||||
if plugin.Manifest == nil {
|
||||
brokenManifestCount += 1
|
||||
continue
|
||||
}
|
||||
if state, ok := pluginStates[plugin.Manifest.Id]; ok && state.Enable {
|
||||
totalEnabledCount += 1
|
||||
if plugin.Manifest.HasServer() {
|
||||
backendEnabledCount += 1
|
||||
}
|
||||
if state, ok := pluginStates[plugin.Manifest.Id]; ok && state.Enable {
|
||||
totalEnabledCount += 1
|
||||
if plugin.Manifest.HasServer() {
|
||||
backendEnabledCount += 1
|
||||
}
|
||||
if plugin.Manifest.HasWebapp() {
|
||||
webappEnabledCount += 1
|
||||
}
|
||||
} else {
|
||||
totalDisabledCount += 1
|
||||
if plugin.Manifest.HasServer() {
|
||||
backendDisabledCount += 1
|
||||
}
|
||||
if plugin.Manifest.HasWebapp() {
|
||||
webappDisabledCount += 1
|
||||
}
|
||||
if plugin.Manifest.HasWebapp() {
|
||||
webappEnabledCount += 1
|
||||
}
|
||||
if plugin.Manifest.SettingsSchema != nil {
|
||||
settingsCount += 1
|
||||
} else {
|
||||
totalDisabledCount += 1
|
||||
if plugin.Manifest.HasServer() {
|
||||
backendDisabledCount += 1
|
||||
}
|
||||
if plugin.Manifest.HasWebapp() {
|
||||
webappDisabledCount += 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
totalEnabledCount = -1 // -1 to indicate disabled or error
|
||||
totalDisabledCount = -1 // -1 to indicate disabled or error
|
||||
if plugin.Manifest.SettingsSchema != nil {
|
||||
settingsCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
a.SendDiagnostic(TRACK_PLUGINS, map[string]interface{}{
|
||||
"enabled_plugins": totalEnabledCount,
|
||||
"enabled_webapp_plugins": webappEnabledCount,
|
||||
"enabled_backend_plugins": backendEnabledCount,
|
||||
"disabled_plugins": totalDisabledCount,
|
||||
"disabled_webapp_plugins": webappDisabledCount,
|
||||
"disabled_backend_plugins": backendDisabledCount,
|
||||
"plugins_with_settings": settingsCount,
|
||||
"plugins_with_broken_manifests": brokenManifestCount,
|
||||
})
|
||||
} else {
|
||||
totalEnabledCount = -1 // -1 to indicate disabled or error
|
||||
totalDisabledCount = -1 // -1 to indicate disabled or error
|
||||
}
|
||||
|
||||
a.SendDiagnostic(TRACK_PLUGINS, map[string]interface{}{
|
||||
"enabled_plugins": totalEnabledCount,
|
||||
"enabled_webapp_plugins": webappEnabledCount,
|
||||
"enabled_backend_plugins": backendEnabledCount,
|
||||
"disabled_plugins": totalDisabledCount,
|
||||
"disabled_webapp_plugins": webappDisabledCount,
|
||||
"disabled_backend_plugins": backendDisabledCount,
|
||||
"plugins_with_settings": settingsCount,
|
||||
"plugins_with_broken_manifests": brokenManifestCount,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) trackServer() {
|
||||
|
|
|
|||
|
|
@ -460,10 +460,10 @@ func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamId string, ra
|
|||
info.ThumbnailPath = pathPrefix + nameWithoutExtension + "_thumb.jpg"
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var rejectionError *model.AppError
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
var newBytes bytes.Buffer
|
||||
replacementInfo, rejectionReason := hooks.FileWillBeUploaded(pluginContext, info, bytes.NewReader(data), &newBytes)
|
||||
if rejectionReason != "" {
|
||||
|
|
|
|||
|
|
@ -66,10 +66,10 @@ func (a *App) AuthenticateUserForLogin(id, loginId, password, mfaToken string, l
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var rejectionReason string
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
rejectionReason = hooks.UserWillLogIn(pluginContext, user)
|
||||
return rejectionReason == ""
|
||||
}, plugin.UserWillLogInId)
|
||||
|
|
@ -80,7 +80,7 @@ func (a *App) AuthenticateUserForLogin(id, loginId, password, mfaToken string, l
|
|||
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.UserHasLoggedIn(pluginContext, user)
|
||||
return true
|
||||
}, plugin.UserHasLoggedInId)
|
||||
|
|
|
|||
|
|
@ -15,22 +15,49 @@ import (
|
|||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
// GetPluginsEnvironment returns the plugin environment for use if plugins are enabled and
|
||||
// initialized.
|
||||
//
|
||||
// To get the plugins environment when the plugins are disabled, manually acquire the plugins
|
||||
// lock instead.
|
||||
func (a *App) GetPluginsEnvironment() *plugin.Environment {
|
||||
if !*a.Config().PluginSettings.Enable {
|
||||
return nil
|
||||
}
|
||||
|
||||
a.Srv.PluginsLock.RLock()
|
||||
defer a.Srv.PluginsLock.RUnlock()
|
||||
|
||||
return a.Srv.PluginsEnvironment
|
||||
}
|
||||
|
||||
func (a *App) SetPluginsEnvironment(pluginsEnvironment *plugin.Environment) {
|
||||
a.Srv.PluginsLock.Lock()
|
||||
defer a.Srv.PluginsLock.Unlock()
|
||||
|
||||
a.Srv.PluginsEnvironment = pluginsEnvironment
|
||||
}
|
||||
|
||||
func (a *App) SyncPluginsActiveState() {
|
||||
if a.Srv.Plugins == nil {
|
||||
a.Srv.PluginsLock.RLock()
|
||||
pluginsEnvironment := a.Srv.PluginsEnvironment
|
||||
a.Srv.PluginsLock.RUnlock()
|
||||
|
||||
if pluginsEnvironment == nil {
|
||||
return
|
||||
}
|
||||
|
||||
config := a.Config().PluginSettings
|
||||
|
||||
if *config.Enable {
|
||||
availablePlugins, err := a.Srv.Plugins.Available()
|
||||
availablePlugins, err := pluginsEnvironment.Available()
|
||||
if err != nil {
|
||||
a.Log.Error("Unable to get available plugins", mlog.Err(err))
|
||||
return
|
||||
}
|
||||
|
||||
// Deactivate any plugins that have been disabled.
|
||||
for _, plugin := range a.Srv.Plugins.Active() {
|
||||
for _, plugin := range pluginsEnvironment.Active() {
|
||||
// Determine if plugin is enabled
|
||||
pluginId := plugin.Manifest.Id
|
||||
pluginEnabled := false
|
||||
|
|
@ -40,7 +67,7 @@ func (a *App) SyncPluginsActiveState() {
|
|||
|
||||
// If it's not enabled we need to deactivate it
|
||||
if !pluginEnabled {
|
||||
deactivated := a.Srv.Plugins.Deactivate(pluginId)
|
||||
deactivated := pluginsEnvironment.Deactivate(pluginId)
|
||||
if deactivated && plugin.Manifest.HasClient() {
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_DISABLED, "", "", "", nil)
|
||||
message.Add("manifest", plugin.Manifest.ClientManifest())
|
||||
|
|
@ -65,7 +92,7 @@ func (a *App) SyncPluginsActiveState() {
|
|||
|
||||
// Activate plugin if enabled
|
||||
if pluginEnabled {
|
||||
updatedManifest, activated, err := a.Srv.Plugins.Activate(pluginId)
|
||||
updatedManifest, activated, err := pluginsEnvironment.Activate(pluginId)
|
||||
if err != nil {
|
||||
plugin.WrapLogger(a.Log).Error("Unable to activate plugin", mlog.Err(err))
|
||||
continue
|
||||
|
|
@ -79,7 +106,7 @@ func (a *App) SyncPluginsActiveState() {
|
|||
}
|
||||
}
|
||||
} else { // If plugins are disabled, shutdown plugins.
|
||||
a.Srv.Plugins.Shutdown()
|
||||
pluginsEnvironment.Shutdown()
|
||||
}
|
||||
|
||||
if err := a.notifyPluginStatusesChanged(); err != nil {
|
||||
|
|
@ -92,7 +119,10 @@ func (a *App) NewPluginAPI(manifest *model.Manifest) plugin.API {
|
|||
}
|
||||
|
||||
func (a *App) InitPlugins(pluginDir, webappPluginDir string) {
|
||||
if a.Srv.Plugins != nil || !*a.Config().PluginSettings.Enable {
|
||||
a.Srv.PluginsLock.RLock()
|
||||
pluginsEnvironment := a.Srv.PluginsEnvironment
|
||||
a.Srv.PluginsLock.RUnlock()
|
||||
if pluginsEnvironment != nil || !*a.Config().PluginSettings.Enable {
|
||||
a.SyncPluginsActiveState()
|
||||
return
|
||||
}
|
||||
|
|
@ -109,12 +139,12 @@ func (a *App) InitPlugins(pluginDir, webappPluginDir string) {
|
|||
return
|
||||
}
|
||||
|
||||
if env, err := plugin.NewEnvironment(a.NewPluginAPI, pluginDir, webappPluginDir, a.Log); err != nil {
|
||||
env, err := plugin.NewEnvironment(a.NewPluginAPI, pluginDir, webappPluginDir, a.Log)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to start up plugins", mlog.Err(err))
|
||||
return
|
||||
} else {
|
||||
a.Srv.Plugins = env
|
||||
}
|
||||
a.SetPluginsEnvironment(env)
|
||||
|
||||
prepackagedPluginsDir, found := utils.FindDir("prepackaged_plugins")
|
||||
if found {
|
||||
|
|
@ -136,39 +166,46 @@ func (a *App) InitPlugins(pluginDir, webappPluginDir string) {
|
|||
}
|
||||
|
||||
// Sync plugin active state when config changes. Also notify plugins.
|
||||
a.Srv.PluginsLock.Lock()
|
||||
a.RemoveConfigListener(a.Srv.PluginConfigListenerId)
|
||||
a.Srv.PluginConfigListenerId = a.AddConfigListener(func(*model.Config, *model.Config) {
|
||||
a.SyncPluginsActiveState()
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.OnConfigurationChange()
|
||||
return true
|
||||
}, plugin.OnConfigurationChangeId)
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.OnConfigurationChange()
|
||||
return true
|
||||
}, plugin.OnConfigurationChangeId)
|
||||
}
|
||||
})
|
||||
a.Srv.PluginsLock.Unlock()
|
||||
|
||||
a.SyncPluginsActiveState()
|
||||
|
||||
}
|
||||
|
||||
func (a *App) ShutDownPlugins() {
|
||||
if a.Srv.Plugins == nil {
|
||||
a.Srv.PluginsLock.Lock()
|
||||
pluginsEnvironment := a.Srv.PluginsEnvironment
|
||||
defer a.Srv.PluginsLock.Unlock()
|
||||
if pluginsEnvironment == nil {
|
||||
return
|
||||
}
|
||||
|
||||
mlog.Info("Shutting down plugins")
|
||||
|
||||
a.Srv.Plugins.Shutdown()
|
||||
pluginsEnvironment.Shutdown()
|
||||
|
||||
a.RemoveConfigListener(a.Srv.PluginConfigListenerId)
|
||||
a.Srv.PluginConfigListenerId = ""
|
||||
a.Srv.Plugins = nil
|
||||
a.Srv.PluginsEnvironment = nil
|
||||
}
|
||||
|
||||
func (a *App) GetActivePluginManifests() ([]*model.Manifest, *model.AppError) {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return nil, model.NewAppError("GetActivePluginManifests", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
plugins := a.Srv.Plugins.Active()
|
||||
plugins := pluginsEnvironment.Active()
|
||||
|
||||
manifests := make([]*model.Manifest, len(plugins))
|
||||
for i, plugin := range plugins {
|
||||
|
|
@ -181,11 +218,12 @@ func (a *App) GetActivePluginManifests() ([]*model.Manifest, *model.AppError) {
|
|||
// EnablePlugin will set the config for an installed plugin to enabled, triggering asynchronous
|
||||
// activation if inactive anywhere in the cluster.
|
||||
func (a *App) EnablePlugin(id string) *model.AppError {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return model.NewAppError("EnablePlugin", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
plugins, err := a.Srv.Plugins.Available()
|
||||
plugins, err := pluginsEnvironment.Available()
|
||||
if err != nil {
|
||||
return model.NewAppError("EnablePlugin", "app.plugin.config.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
@ -221,11 +259,12 @@ func (a *App) EnablePlugin(id string) *model.AppError {
|
|||
|
||||
// DisablePlugin will set the config for an installed plugin to disabled, triggering deactivation if active.
|
||||
func (a *App) DisablePlugin(id string) *model.AppError {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return model.NewAppError("DisablePlugin", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
plugins, err := a.Srv.Plugins.Available()
|
||||
plugins, err := pluginsEnvironment.Available()
|
||||
if err != nil {
|
||||
return model.NewAppError("DisablePlugin", "app.plugin.config.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
@ -255,16 +294,13 @@ func (a *App) DisablePlugin(id string) *model.AppError {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *App) PluginsReady() bool {
|
||||
return a.Srv.Plugins != nil && *a.Config().PluginSettings.Enable
|
||||
}
|
||||
|
||||
func (a *App) GetPlugins() (*model.PluginsResponse, *model.AppError) {
|
||||
if !a.PluginsReady() {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return nil, model.NewAppError("GetPlugins", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
availablePlugins, err := a.Srv.Plugins.Available()
|
||||
availablePlugins, err := pluginsEnvironment.Available()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPlugins", "app.plugin.get_plugins.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
@ -278,7 +314,7 @@ func (a *App) GetPlugins() (*model.PluginsResponse, *model.AppError) {
|
|||
Manifest: *plugin.Manifest,
|
||||
}
|
||||
|
||||
if a.Srv.Plugins.IsActive(plugin.Manifest.Id) {
|
||||
if pluginsEnvironment.IsActive(plugin.Manifest.Id) {
|
||||
resp.Active = append(resp.Active, info)
|
||||
} else {
|
||||
resp.Inactive = append(resp.Inactive, info)
|
||||
|
|
|
|||
|
|
@ -262,6 +262,9 @@ func (api *PluginAPI) DeleteChannel(channelId string) *model.AppError {
|
|||
|
||||
func (api *PluginAPI) GetPublicChannelsForTeam(teamId string, page, perPage int) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.GetPublicChannelsForTeam(teamId, page*perPage, perPage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return *channels, err
|
||||
}
|
||||
|
||||
|
|
@ -277,8 +280,12 @@ func (api *PluginAPI) GetChannelByNameForTeamName(teamName, channelName string,
|
|||
return api.app.GetChannelByNameForTeamName(channelName, teamName, includeDeleted)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
|
||||
return api.app.GetChannelsForUser(teamId, userId, includeDeleted)
|
||||
func (api *PluginAPI) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.GetChannelsForUser(teamId, userId, includeDeleted)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return *channels, err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelStats(channelId string) (*model.ChannelStats, *model.AppError) {
|
||||
|
|
@ -301,8 +308,12 @@ func (api *PluginAPI) UpdateChannel(channel *model.Channel) (*model.Channel, *mo
|
|||
return api.app.UpdateChannel(channel)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
return api.app.SearchChannels(teamId, term)
|
||||
func (api *PluginAPI) SearchChannels(teamId string, term string) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.SearchChannels(teamId, term)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return *channels, err
|
||||
}
|
||||
|
||||
func (api *PluginAPI) AddChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError) {
|
||||
|
|
@ -499,6 +510,38 @@ func (api *PluginAPI) OpenInteractiveDialog(dialog model.OpenDialogRequest) *mod
|
|||
return api.app.OpenInteractiveDialog(dialog)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
_, err := api.app.GetTeam(teamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = api.app.RemoveTeamIcon(teamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
|
||||
_, err := api.app.GetUser(userId1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = api.app.GetUser(userId2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dm, err := api.app.CreateDirectChannel(userId1, userId2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dm, nil
|
||||
}
|
||||
|
||||
// Plugin Section
|
||||
|
||||
func (api *PluginAPI) GetPlugins() ([]*model.Manifest, *model.AppError) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func setupPluginApiTest(t *testing.T, pluginCode string, pluginManifest string,
|
|||
require.NotNil(t, manifest)
|
||||
require.True(t, activated)
|
||||
|
||||
app.Srv.Plugins = env
|
||||
app.SetPluginsEnvironment(env)
|
||||
}
|
||||
|
||||
func TestPluginAPIUpdateUserStatus(t *testing.T) {
|
||||
|
|
@ -87,18 +87,18 @@ func TestPluginAPISavePluginConfig(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := api.SavePluginConfig(pluginConfig); err != nil{
|
||||
if err := api.SavePluginConfig(pluginConfig); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
MyStringSetting string
|
||||
MyIntSetting int
|
||||
MyBoolSetting bool
|
||||
MyIntSetting int
|
||||
MyBoolSetting bool
|
||||
}
|
||||
|
||||
savedConfiguration := new(Configuration)
|
||||
if err := api.LoadPluginConfiguration(savedConfiguration); err != nil{
|
||||
if err := api.LoadPluginConfiguration(savedConfiguration); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
|||
}
|
||||
]
|
||||
}}`, "testloadpluginconfig", th.App)
|
||||
hooks, err := th.App.Srv.Plugins.HooksForPlugin("testloadpluginconfig")
|
||||
hooks, err := th.App.GetPluginsEnvironment().HooksForPlugin("testloadpluginconfig")
|
||||
assert.NoError(t, err)
|
||||
_, ret := hooks.MessageWillBePosted(nil, nil)
|
||||
assert.Equal(t, "str32true", ret)
|
||||
|
|
@ -280,7 +280,7 @@ func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
|||
}
|
||||
]
|
||||
}}`, "testloadpluginconfig", th.App)
|
||||
hooks, err := th.App.Srv.Plugins.HooksForPlugin("testloadpluginconfig")
|
||||
hooks, err := th.App.GetPluginsEnvironment().HooksForPlugin("testloadpluginconfig")
|
||||
assert.NoError(t, err)
|
||||
_, ret := hooks.MessageWillBePosted(nil, nil)
|
||||
assert.Equal(t, "override35true", ret)
|
||||
|
|
@ -377,9 +377,9 @@ func TestPluginAPIGetPlugins(t *testing.T) {
|
|||
require.True(t, activated)
|
||||
pluginManifests = append(pluginManifests, manifest)
|
||||
}
|
||||
th.App.Srv.Plugins = env
|
||||
th.App.SetPluginsEnvironment(env)
|
||||
|
||||
// Decative the last one for testing
|
||||
// Decativate the last one for testing
|
||||
sucess := env.Deactivate(pluginIDs[len(pluginIDs)-1])
|
||||
require.True(t, sucess)
|
||||
|
||||
|
|
@ -450,3 +450,80 @@ func TestPluginAPISetTeamIcon(t *testing.T) {
|
|||
require.Nil(t, err2)
|
||||
require.Equal(t, img2.At(2, 3), colorful)
|
||||
}
|
||||
|
||||
func TestPluginAPISearchChannels(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
t.Run("all fine", func(t *testing.T) {
|
||||
channels, err := api.SearchChannels(th.BasicTeam.Id, th.BasicChannel.Name)
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, channels, 1)
|
||||
})
|
||||
|
||||
t.Run("invalid team id", func(t *testing.T) {
|
||||
channels, err := api.SearchChannels("invalidid", th.BasicChannel.Name)
|
||||
assert.Nil(t, err)
|
||||
assert.Empty(t, channels)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPluginAPIGetChannelsForTeamForUser(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
t.Run("all fine", func(t *testing.T) {
|
||||
channels, err := api.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, false)
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, channels, 3)
|
||||
})
|
||||
|
||||
t.Run("invalid team id", func(t *testing.T) {
|
||||
channels, err := api.GetChannelsForTeamForUser("invalidid", th.BasicUser.Id, false)
|
||||
assert.NotNil(t, err)
|
||||
assert.Empty(t, channels)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPluginAPIRemoveTeamIcon(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
// Create an 128 x 128 image
|
||||
img := image.NewRGBA(image.Rect(0, 0, 128, 128))
|
||||
|
||||
// Draw a red dot at (2, 3)
|
||||
img.Set(2, 3, color.RGBA{255, 0, 0, 255})
|
||||
buf := new(bytes.Buffer)
|
||||
err1 := png.Encode(buf, img)
|
||||
require.Nil(t, err1)
|
||||
dataBytes := buf.Bytes()
|
||||
fileReader := bytes.NewReader(dataBytes)
|
||||
|
||||
// Set the Team Icon
|
||||
err := th.App.SetTeamIconFromFile(th.BasicTeam, fileReader)
|
||||
require.Nil(t, err)
|
||||
err = api.RemoveTeamIcon(th.BasicTeam.Id)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestPluginAPICreateDirectChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
dm1, err := api.CreateDirectChannel(th.BasicUser.Id, th.BasicUser2.Id)
|
||||
require.Nil(t, err)
|
||||
require.NotEmpty(t, dm1)
|
||||
|
||||
dm2, err := api.CreateDirectChannel(th.BasicUser.Id, th.BasicUser.Id)
|
||||
require.Nil(t, err)
|
||||
require.NotEmpty(t, dm2)
|
||||
|
||||
dm3, err := api.CreateDirectChannel(th.BasicUser.Id, model.NewId())
|
||||
require.NotNil(t, err)
|
||||
require.Empty(t, dm3)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,12 +101,14 @@ func (a *App) ExecutePluginCommand(args *model.CommandArgs) (*model.Command, *mo
|
|||
|
||||
for _, pc := range a.Srv.pluginCommands {
|
||||
if (pc.Command.TeamId == "" || pc.Command.TeamId == args.TeamId) && pc.Command.Trigger == trigger {
|
||||
pluginHooks, err := a.Srv.Plugins.HooksForPlugin(pc.PluginId)
|
||||
if err != nil {
|
||||
return pc.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command.error.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
pluginHooks, err := pluginsEnvironment.HooksForPlugin(pc.PluginId)
|
||||
if err != nil {
|
||||
return pc.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command.error.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
response, appErr := pluginHooks.ExecuteCommand(&plugin.Context{}, args)
|
||||
return pc.Command, response, appErr
|
||||
}
|
||||
response, appErr := pluginHooks.ExecuteCommand(&plugin.Context{}, args)
|
||||
return pc.Command, response, appErr
|
||||
}
|
||||
}
|
||||
return nil, nil, nil
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func SetAppEnvironmentWithPlugins(t *testing.T, pluginCode []string, app *App, a
|
|||
env, err := plugin.NewEnvironment(apiFunc, pluginDir, webappPluginDir, app.Log)
|
||||
require.NoError(t, err)
|
||||
|
||||
app.Srv.Plugins = env
|
||||
app.SetPluginsEnvironment(env)
|
||||
pluginIds := []string{}
|
||||
activationErrors := []error{}
|
||||
for _, code := range pluginCode {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ func (a *App) InstallPlugin(pluginFile io.Reader, replace bool) (*model.Manifest
|
|||
}
|
||||
|
||||
func (a *App) installPlugin(pluginFile io.Reader, replace bool) (*model.Manifest, *model.AppError) {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return nil, model.NewAppError("installPlugin", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ func (a *App) installPlugin(pluginFile io.Reader, replace bool) (*model.Manifest
|
|||
return nil, model.NewAppError("installPlugin", "app.plugin.invalid_id.app_error", map[string]interface{}{"Min": plugin.MinIdLength, "Max": plugin.MaxIdLength, "Regex": plugin.ValidIdRegex}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
bundles, err := a.Srv.Plugins.Available()
|
||||
bundles, err := pluginsEnvironment.Available()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("installPlugin", "app.plugin.install.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
@ -91,11 +92,12 @@ func (a *App) RemovePlugin(id string) *model.AppError {
|
|||
}
|
||||
|
||||
func (a *App) removePlugin(id string) *model.AppError {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return model.NewAppError("removePlugin", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
plugins, err := a.Srv.Plugins.Available()
|
||||
plugins, err := pluginsEnvironment.Available()
|
||||
if err != nil {
|
||||
return model.NewAppError("removePlugin", "app.plugin.deactivate.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
|
@ -114,13 +116,13 @@ func (a *App) removePlugin(id string) *model.AppError {
|
|||
return model.NewAppError("removePlugin", "app.plugin.not_installed.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if a.Srv.Plugins.IsActive(id) && manifest.HasClient() {
|
||||
if pluginsEnvironment.IsActive(id) && manifest.HasClient() {
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_DISABLED, "", "", "", nil)
|
||||
message.Add("manifest", manifest.ClientManifest())
|
||||
a.Publish(message)
|
||||
}
|
||||
|
||||
a.Srv.Plugins.Deactivate(id)
|
||||
pluginsEnvironment.Deactivate(id)
|
||||
a.UnregisterPluginCommands(id)
|
||||
|
||||
err = os.RemoveAll(pluginPath)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ import (
|
|||
)
|
||||
|
||||
func (a *App) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
err := model.NewAppError("ServePluginRequest", "app.plugin.disabled.app_error", nil, "Enable plugins to serve plugin requests", http.StatusNotImplemented)
|
||||
a.Log.Error(err.Error())
|
||||
w.WriteHeader(err.StatusCode)
|
||||
|
|
@ -29,7 +30,7 @@ func (a *App) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
params := mux.Vars(r)
|
||||
hooks, err := a.Srv.Plugins.HooksForPlugin(params["plugin_id"])
|
||||
hooks, err := pluginsEnvironment.HooksForPlugin(params["plugin_id"])
|
||||
if err != nil {
|
||||
a.Log.Error("Access to route for non-existent plugin", mlog.String("missing_plugin_id", params["plugin_id"]), mlog.Err(err))
|
||||
http.NotFound(w, r)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,12 @@ import (
|
|||
|
||||
// GetPluginStatus returns the status for a plugin installed on this server.
|
||||
func (a *App) GetPluginStatus(id string) (*model.PluginStatus, *model.AppError) {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return nil, model.NewAppError("GetPluginStatus", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
pluginStatuses, err := a.Srv.Plugins.Statuses()
|
||||
pluginStatuses, err := pluginsEnvironment.Statuses()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPluginStatus", "app.plugin.get_statuses.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
@ -32,11 +33,12 @@ func (a *App) GetPluginStatus(id string) (*model.PluginStatus, *model.AppError)
|
|||
|
||||
// GetPluginStatuses returns the status for plugins installed on this server.
|
||||
func (a *App) GetPluginStatuses() (model.PluginStatuses, *model.AppError) {
|
||||
if a.Srv.Plugins == nil || !*a.Config().PluginSettings.Enable {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
return nil, model.NewAppError("GetPluginStatuses", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
pluginStatuses, err := a.Srv.Plugins.Statuses()
|
||||
pluginStatuses, err := pluginsEnvironment.Statuses()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPluginStatuses", "app.plugin.get_statuses.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ func TestGetPluginStatusesDisabled(t *testing.T) {
|
|||
})
|
||||
|
||||
_, err := th.App.GetPluginStatuses()
|
||||
require.NotNil(t, err)
|
||||
require.EqualError(t, err, "GetPluginStatuses: Plugins have been disabled. Please check your logs for details., ")
|
||||
}
|
||||
|
||||
|
|
|
|||
16
app/post.go
16
app/post.go
|
|
@ -139,10 +139,10 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var rejectionError *model.AppError
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
replacementPost, rejectionReason := hooks.MessageWillBePosted(pluginContext, post)
|
||||
if rejectionReason != "" {
|
||||
rejectionError = model.NewAppError("createPost", "Post rejected by plugin. "+rejectionReason, nil, "", http.StatusBadRequest)
|
||||
|
|
@ -165,10 +165,10 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
|||
}
|
||||
rpost := result.Data.(*model.Post)
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.MessageHasBeenPosted(pluginContext, rpost)
|
||||
return true
|
||||
}, plugin.MessageHasBeenPostedId)
|
||||
|
|
@ -351,10 +351,10 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var rejectionReason string
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
newPost, rejectionReason = hooks.MessageWillBeUpdated(pluginContext, newPost, oldPost)
|
||||
return post != nil
|
||||
}, plugin.MessageWillBeUpdatedId)
|
||||
|
|
@ -369,10 +369,10 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model
|
|||
}
|
||||
rpost := result.Data.(*model.Post)
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.MessageHasBeenUpdated(pluginContext, newPost, oldPost)
|
||||
return true
|
||||
}, plugin.MessageHasBeenUpdatedId)
|
||||
|
|
|
|||
|
|
@ -54,8 +54,9 @@ type Server struct {
|
|||
goroutineCount int32
|
||||
goroutineExitSignal chan struct{}
|
||||
|
||||
Plugins *plugin.Environment
|
||||
PluginsEnvironment *plugin.Environment
|
||||
PluginConfigListenerId string
|
||||
PluginsLock sync.RWMutex
|
||||
|
||||
EmailBatching *EmailBatchingJob
|
||||
EmailRateLimiter *throttled.GCRARateLimiter
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId
|
|||
return nil
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var actor *model.User
|
||||
if userRequestorId != "" {
|
||||
actor, _ = a.GetUser(userRequestorId)
|
||||
|
|
@ -469,7 +469,7 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId
|
|||
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.UserHasJoinedTeam(pluginContext, tm, actor)
|
||||
return true
|
||||
}, plugin.UserHasJoinedTeamId)
|
||||
|
|
@ -784,7 +784,7 @@ func (a *App) LeaveTeam(team *model.Team, user *model.User, requestorId string)
|
|||
return result.Err
|
||||
}
|
||||
|
||||
if a.PluginsReady() {
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var actor *model.User
|
||||
if requestorId != "" {
|
||||
actor, _ = a.GetUser(requestorId)
|
||||
|
|
@ -792,7 +792,7 @@ func (a *App) LeaveTeam(team *model.Team, user *model.User, requestorId string)
|
|||
|
||||
a.Srv.Go(func() {
|
||||
pluginContext := &plugin.Context{}
|
||||
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.UserHasLeftTeam(pluginContext, teamMember, actor)
|
||||
return true
|
||||
}, plugin.UserHasLeftTeamId)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package app
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ type WebConn struct {
|
|||
AllChannelMembers map[string]string
|
||||
LastAllChannelMembersTime int64
|
||||
Sequence int64
|
||||
closeOnce sync.Once
|
||||
endWritePump chan struct{}
|
||||
pumpFinished chan struct{}
|
||||
}
|
||||
|
|
@ -59,8 +61,8 @@ func (a *App) NewWebConn(ws *websocket.Conn, session model.Session, t goi18n.Tra
|
|||
UserId: session.UserId,
|
||||
T: t,
|
||||
Locale: locale,
|
||||
endWritePump: make(chan struct{}, 2),
|
||||
pumpFinished: make(chan struct{}, 1),
|
||||
endWritePump: make(chan struct{}),
|
||||
pumpFinished: make(chan struct{}),
|
||||
}
|
||||
|
||||
wc.SetSession(&session)
|
||||
|
|
@ -72,7 +74,9 @@ func (a *App) NewWebConn(ws *websocket.Conn, session model.Session, t goi18n.Tra
|
|||
|
||||
func (wc *WebConn) Close() {
|
||||
wc.WebSocket.Close()
|
||||
wc.endWritePump <- struct{}{}
|
||||
wc.closeOnce.Do(func() {
|
||||
close(wc.endWritePump)
|
||||
})
|
||||
<-wc.pumpFinished
|
||||
}
|
||||
|
||||
|
|
@ -105,16 +109,18 @@ func (c *WebConn) SetSession(v *model.Session) {
|
|||
}
|
||||
|
||||
func (c *WebConn) Pump() {
|
||||
ch := make(chan struct{}, 1)
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
c.writePump()
|
||||
ch <- struct{}{}
|
||||
close(ch)
|
||||
}()
|
||||
c.readPump()
|
||||
c.endWritePump <- struct{}{}
|
||||
c.closeOnce.Do(func() {
|
||||
close(c.endWritePump)
|
||||
})
|
||||
<-ch
|
||||
c.App.HubUnregister(c)
|
||||
c.pumpFinished <- struct{}{}
|
||||
close(c.pumpFinished)
|
||||
}
|
||||
|
||||
func (c *WebConn) readPump() {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
func TestWebConnShouldSendEvent(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
session, err := th.App.CreateSession(&model.Session{UserId: th.BasicUser.Id, Roles: th.BasicUser.GetRawRoles()})
|
||||
|
|
|
|||
|
|
@ -346,7 +346,10 @@ func (a *App) UpdateWebConnUserActivity(session model.Session, activityAt int64)
|
|||
}
|
||||
|
||||
func (h *Hub) Register(webConn *WebConn) {
|
||||
h.register <- webConn
|
||||
select {
|
||||
case h.register <- webConn:
|
||||
case <-h.didStop:
|
||||
}
|
||||
|
||||
if webConn.IsAuthenticated() {
|
||||
webConn.SendHello()
|
||||
|
|
@ -356,22 +359,31 @@ func (h *Hub) Register(webConn *WebConn) {
|
|||
func (h *Hub) Unregister(webConn *WebConn) {
|
||||
select {
|
||||
case h.unregister <- webConn:
|
||||
case <-h.stop:
|
||||
case <-h.didStop:
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hub) Broadcast(message *model.WebSocketEvent) {
|
||||
if h != nil && h.broadcast != nil && message != nil {
|
||||
h.broadcast <- message
|
||||
select {
|
||||
case h.broadcast <- message:
|
||||
case <-h.didStop:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hub) InvalidateUser(userId string) {
|
||||
h.invalidateUser <- userId
|
||||
select {
|
||||
case h.invalidateUser <- userId:
|
||||
case <-h.didStop:
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hub) UpdateActivity(userId, sessionToken string, activityAt int64) {
|
||||
h.activity <- &WebConnActivityMessage{UserId: userId, SessionToken: sessionToken, ActivityAt: activityAt}
|
||||
select {
|
||||
case h.activity <- &WebConnActivityMessage{UserId: userId, SessionToken: sessionToken, ActivityAt: activityAt}:
|
||||
case <-h.didStop:
|
||||
}
|
||||
}
|
||||
|
||||
func getGoroutineId() int {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
|
|
@ -60,3 +61,45 @@ func TestHubStopWithMultipleConnections(t *testing.T) {
|
|||
defer wc2.Close()
|
||||
defer wc3.Close()
|
||||
}
|
||||
|
||||
// TestHubStopRaceCondition verifies that attempts to use the hub after it has shutdown does not
|
||||
// block the caller indefinitely.
|
||||
func TestHubStopRaceCondition(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
s := httptest.NewServer(http.HandlerFunc(dummyWebsocketHandler(t)))
|
||||
|
||||
th.App.HubStart()
|
||||
wc1 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
defer wc1.Close()
|
||||
|
||||
hub := th.App.Srv.Hubs[0]
|
||||
th.App.HubStop()
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
done := make(chan bool)
|
||||
go func() {
|
||||
wc4 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
wc5 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
hub.Register(wc4)
|
||||
hub.Register(wc5)
|
||||
|
||||
hub.UpdateActivity("userId", "sessionToken", 0)
|
||||
|
||||
for i := 0; i <= BROADCAST_QUEUE_SIZE; i++ {
|
||||
hub.Broadcast(&model.WebSocketEvent{})
|
||||
}
|
||||
|
||||
hub.InvalidateUser("userId")
|
||||
hub.Unregister(wc4)
|
||||
hub.Unregister(wc5)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(15 * time.Second):
|
||||
t.Fatalf("hub call did not return within 15 seconds after stop")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import (
|
|||
|
||||
func TestCreateCommand(t *testing.T) {
|
||||
th := api4.Setup().InitBasic()
|
||||
th.InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
team := th.BasicTeam
|
||||
adminUser := th.TeamAdminUser
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func TestPlugin(t *testing.T) {
|
|||
os.MkdirAll("./test-plugins", os.ModePerm)
|
||||
os.MkdirAll("./test-client-plugins", os.ModePerm)
|
||||
|
||||
th := api4.Setup().InitBasic().InitSystemAdmin()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
path, _ := utils.FindDir("tests")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateTeam(t *testing.T) {
|
||||
th := api4.Setup().InitSystemAdmin()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
|
|
@ -29,7 +29,7 @@ func TestCreateTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJoinTeam(t *testing.T) {
|
||||
th := api4.Setup().InitSystemAdmin().InitBasic()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
CheckCommand(t, "team", "add", th.BasicTeam.Name, th.BasicUser.Email)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateUserWithTeam(t *testing.T) {
|
||||
th := api4.Setup().InitBasic().InitSystemAdmin()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func TestListWebhooks(t *testing.T) {
|
||||
th := api4.Setup().InitBasic().InitSystemAdmin()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
adminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ func TestListWebhooks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateIncomingWebhook(t *testing.T) {
|
||||
th := api4.Setup().InitBasic().InitSystemAdmin()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
|
@ -98,7 +98,7 @@ func TestCreateIncomingWebhook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestModifyIncomingWebhook(t *testing.T) {
|
||||
th := api4.Setup().InitBasic().InitSystemAdmin()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
|
@ -153,7 +153,7 @@ func TestModifyIncomingWebhook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateOutgoingWebhook(t *testing.T) {
|
||||
th := api4.Setup().InitBasic().InitSystemAdmin()
|
||||
th := api4.Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
},
|
||||
{
|
||||
"id": "interactive_message.generate_trigger_id.signing_failed",
|
||||
"translation": "Failed to sign generatedd trigger ID for interactive dialog."
|
||||
"translation": "Failed to sign generated trigger ID for interactive dialog."
|
||||
},
|
||||
{
|
||||
"id": "interactive_message.decode_trigger_id.base64_decode_failed",
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ func StopTestStore() {
|
|||
}
|
||||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
if testStore != nil {
|
||||
testStore.DropAllTables()
|
||||
}
|
||||
|
||||
permConfig, err := os.Open(utils.FindConfigFile("config.json"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -129,6 +133,10 @@ func Setup() *TestHelper {
|
|||
}
|
||||
|
||||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.SystemAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_ADMIN_ROLE_ID, false)
|
||||
me.SystemAdminUser, _ = me.App.GetUser(me.SystemAdminUser.Id)
|
||||
|
||||
me.BasicTeam = me.CreateTeam()
|
||||
me.BasicUser = me.CreateUser()
|
||||
me.LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
|
|
@ -140,14 +148,6 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
|||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitSystemAdmin() *TestHelper {
|
||||
me.SystemAdminUser = me.CreateUser()
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_ADMIN_ROLE_ID, false)
|
||||
me.SystemAdminUser, _ = me.App.GetUser(me.SystemAdminUser.Id)
|
||||
|
||||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) MakeEmail() string {
|
||||
return "success_" + model.NewId() + "@simulator.amazonses.com"
|
||||
}
|
||||
|
|
|
|||
2666
model/client4.go
2666
model/client4.go
File diff suppressed because it is too large
Load diff
|
|
@ -64,7 +64,9 @@ func StringifySlackFieldValue(a []*SlackAttachment) []*SlackAttachment {
|
|||
// This method only parses and processes the attachments,
|
||||
// all else should be set in the post which is passed
|
||||
func ParseSlackAttachment(post *Post, attachments []*SlackAttachment) {
|
||||
post.Type = POST_SLACK_ATTACHMENT
|
||||
if post.Type == "" {
|
||||
post.Type = POST_SLACK_ATTACHMENT
|
||||
}
|
||||
|
||||
for _, attachment := range attachments {
|
||||
attachment.Text = ParseSlackLinksToMarkdown(attachment.Text)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ type API interface {
|
|||
// CreateUser creates a user.
|
||||
CreateUser(user *model.User) (*model.User, *model.AppError)
|
||||
|
||||
// CreateDirectChannel creates a Direct channel.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError)
|
||||
|
||||
// DeleteUser deletes a user.
|
||||
DeleteUser(userId string) *model.AppError
|
||||
|
||||
|
|
@ -74,16 +79,21 @@ type API interface {
|
|||
// Minimum server version: 5.6
|
||||
GetUsersInTeam(teamId string, page int, perPage int) ([]*model.User, *model.AppError)
|
||||
|
||||
// GetTeamIcon gets the Team Icon.
|
||||
// GetTeamIcon gets the team icon.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
GetTeamIcon(teamId string) ([]byte, *model.AppError)
|
||||
|
||||
// SetTeamIcon sets the Team Icon.
|
||||
// SetTeamIcon sets the team icon.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
SetTeamIcon(teamId string, data []byte) *model.AppError
|
||||
|
||||
// RemoveTeamIcon removes the team icon.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
RemoveTeamIcon(teamId string) *model.AppError
|
||||
|
||||
// UpdateUser updates a user.
|
||||
UpdateUser(user *model.User) (*model.User, *model.AppError)
|
||||
|
||||
|
|
@ -178,7 +188,7 @@ type API interface {
|
|||
// GetChannelsForTeamForUser gets a list of channels for given user ID in given team ID.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError)
|
||||
|
||||
// GetChannelStats gets statistics for a channel.
|
||||
//
|
||||
|
|
@ -197,7 +207,7 @@ type API interface {
|
|||
// SearchChannels returns the channels on a team matching the provided search term.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannels(teamId string, term string) ([]*model.Channel, *model.AppError)
|
||||
|
||||
// AddChannelMember creates a channel membership for a user.
|
||||
AddChannelMember(channelId, userId string) (*model.ChannelMember, *model.AppError)
|
||||
|
|
|
|||
|
|
@ -767,6 +767,36 @@ func (s *apiRPCServer) CreateUser(args *Z_CreateUserArgs, returns *Z_CreateUserR
|
|||
return nil
|
||||
}
|
||||
|
||||
type Z_CreateDirectChannelArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_CreateDirectChannelReturns struct {
|
||||
A *model.Channel
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
|
||||
_args := &Z_CreateDirectChannelArgs{userId1, userId2}
|
||||
_returns := &Z_CreateDirectChannelReturns{}
|
||||
if err := g.client.Call("Plugin.CreateDirectChannel", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to CreateDirectChannel API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) CreateDirectChannel(args *Z_CreateDirectChannelArgs, returns *Z_CreateDirectChannelReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.CreateDirectChannel(args.A, args.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API CreateDirectChannel called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_DeleteUserArgs struct {
|
||||
A string
|
||||
}
|
||||
|
|
@ -1000,6 +1030,34 @@ func (s *apiRPCServer) SetTeamIcon(args *Z_SetTeamIconArgs, returns *Z_SetTeamIc
|
|||
return nil
|
||||
}
|
||||
|
||||
type Z_RemoveTeamIconArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
type Z_RemoveTeamIconReturns struct {
|
||||
A *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
_args := &Z_RemoveTeamIconArgs{teamId}
|
||||
_returns := &Z_RemoveTeamIconReturns{}
|
||||
if err := g.client.Call("Plugin.RemoveTeamIcon", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to RemoveTeamIcon API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) RemoveTeamIcon(args *Z_RemoveTeamIconArgs, returns *Z_RemoveTeamIconReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
RemoveTeamIcon(teamId string) *model.AppError
|
||||
}); ok {
|
||||
returns.A = hook.RemoveTeamIcon(args.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API RemoveTeamIcon called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpdateUserArgs struct {
|
||||
A *model.User
|
||||
}
|
||||
|
|
@ -1778,11 +1836,11 @@ type Z_GetChannelsForTeamForUserArgs struct {
|
|||
}
|
||||
|
||||
type Z_GetChannelsForTeamForUserReturns struct {
|
||||
A *model.ChannelList
|
||||
A []*model.Channel
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
|
||||
func (g *apiRPCClient) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError) {
|
||||
_args := &Z_GetChannelsForTeamForUserArgs{teamId, userId, includeDeleted}
|
||||
_returns := &Z_GetChannelsForTeamForUserReturns{}
|
||||
if err := g.client.Call("Plugin.GetChannelsForTeamForUser", _args, _returns); err != nil {
|
||||
|
|
@ -1793,7 +1851,7 @@ func (g *apiRPCClient) GetChannelsForTeamForUser(teamId, userId string, includeD
|
|||
|
||||
func (s *apiRPCServer) GetChannelsForTeamForUser(args *Z_GetChannelsForTeamForUserArgs, returns *Z_GetChannelsForTeamForUserReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetChannelsForTeamForUser(args.A, args.B, args.C)
|
||||
} else {
|
||||
|
|
@ -1925,11 +1983,11 @@ type Z_SearchChannelsArgs struct {
|
|||
}
|
||||
|
||||
type Z_SearchChannelsReturns struct {
|
||||
A *model.ChannelList
|
||||
A []*model.Channel
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (g *apiRPCClient) SearchChannels(teamId string, term string) ([]*model.Channel, *model.AppError) {
|
||||
_args := &Z_SearchChannelsArgs{teamId, term}
|
||||
_returns := &Z_SearchChannelsReturns{}
|
||||
if err := g.client.Call("Plugin.SearchChannels", _args, _returns); err != nil {
|
||||
|
|
@ -1940,7 +1998,7 @@ func (g *apiRPCClient) SearchChannels(teamId string, term string) (*model.Channe
|
|||
|
||||
func (s *apiRPCServer) SearchChannels(args *Z_SearchChannelsArgs, returns *Z_SearchChannelsReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError)
|
||||
SearchChannels(teamId string, term string) ([]*model.Channel, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.SearchChannels(args.A, args.B)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -112,6 +112,31 @@ func (_m *API) CreateChannel(channel *model.Channel) (*model.Channel, *model.App
|
|||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateDirectChannel provides a mock function with given fields: userId1, userId2
|
||||
func (_m *API) CreateDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
|
||||
ret := _m.Called(userId1, userId2)
|
||||
|
||||
var r0 *model.Channel
|
||||
if rf, ok := ret.Get(0).(func(string, string) *model.Channel); ok {
|
||||
r0 = rf(userId1, userId2)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.Channel)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
|
||||
r1 = rf(userId1, userId2)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreatePost provides a mock function with given fields: post
|
||||
func (_m *API) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
|
||||
ret := _m.Called(post)
|
||||
|
|
@ -541,15 +566,15 @@ func (_m *API) GetChannelStats(channelId string) (*model.ChannelStats, *model.Ap
|
|||
}
|
||||
|
||||
// GetChannelsForTeamForUser provides a mock function with given fields: teamId, userId, includeDeleted
|
||||
func (_m *API) GetChannelsForTeamForUser(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
|
||||
func (_m *API) GetChannelsForTeamForUser(teamId string, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError) {
|
||||
ret := _m.Called(teamId, userId, includeDeleted)
|
||||
|
||||
var r0 *model.ChannelList
|
||||
if rf, ok := ret.Get(0).(func(string, string, bool) *model.ChannelList); ok {
|
||||
var r0 []*model.Channel
|
||||
if rf, ok := ret.Get(0).(func(string, string, bool) []*model.Channel); ok {
|
||||
r0 = rf(teamId, userId, includeDeleted)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.ChannelList)
|
||||
r0 = ret.Get(0).([]*model.Channel)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1833,6 +1858,22 @@ func (_m *API) RemoveReaction(reaction *model.Reaction) *model.AppError {
|
|||
return r0
|
||||
}
|
||||
|
||||
// RemoveTeamIcon provides a mock function with given fields: teamId
|
||||
func (_m *API) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
ret := _m.Called(teamId)
|
||||
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||
r0 = rf(teamId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// SaveConfig provides a mock function with given fields: config
|
||||
func (_m *API) SaveConfig(config *model.Config) *model.AppError {
|
||||
ret := _m.Called(config)
|
||||
|
|
@ -1866,15 +1907,15 @@ func (_m *API) SavePluginConfig(pluginConfig map[string]interface{}) *model.AppE
|
|||
}
|
||||
|
||||
// SearchChannels provides a mock function with given fields: teamId, term
|
||||
func (_m *API) SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
func (_m *API) SearchChannels(teamId string, term string) ([]*model.Channel, *model.AppError) {
|
||||
ret := _m.Called(teamId, term)
|
||||
|
||||
var r0 *model.ChannelList
|
||||
if rf, ok := ret.Get(0).(func(string, string) *model.ChannelList); ok {
|
||||
var r0 []*model.Channel
|
||||
if rf, ok := ret.Get(0).(func(string, string) []*model.Channel); ok {
|
||||
r0 = rf(teamId, term)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.ChannelList)
|
||||
r0 = ret.Get(0).([]*model.Channel)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ func (s *LayeredStore) UnlockFromMaster() {
|
|||
}
|
||||
|
||||
func (s *LayeredStore) DropAllTables() {
|
||||
defer s.LocalCacheLayer.Invalidate()
|
||||
s.DatabaseLayer.DropAllTables()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,3 +111,9 @@ func (s *LocalCacheSupplier) doClearCacheCluster(cache utils.ObjectCache) {
|
|||
s.cluster.SendClusterMessage(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *LocalCacheSupplier) Invalidate() {
|
||||
s.doClearCacheCluster(s.reactionCache)
|
||||
s.doClearCacheCluster(s.roleCache)
|
||||
s.doClearCacheCluster(s.schemeCache)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue