Merge branch 'master' into post-metadata

Этот коммит содержится в:
Harrison Healey
2018-11-22 13:11:55 -05:00
родитель 5f65356a3f d263353e85
Коммит c9f3d03b6d
60 изменённых файлов: 2195 добавлений и 1822 удалений

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

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