* api4: fix TestGetUsersNotInTeam assertions

This test was relying on data from a previous test run. With the data cleared before each test, the assertions much match reality.

* *testlib: always InitSystemAdmin

Some tests implicitly relied on the basic user having system
administrator privileges because it was the first user created as such.
Eliminate `InitSystemAdmin` and explicitly create the system admin user
instead to avoid this ambiguity going forward.

* *testlib: drop all tables before each test

* api4: split up TestChannelDelete to avoid duplicate InitBasic

* api4: teardown in TestResetPassword, for when this test comes back

* invalidate cache on DropAllTables

This is necessary since the test store persists across tests.

* disable parallel tests

While tests within a package must be explicitly parallelized using `t.Parallel()`, tests across packages are run in parallel by default.  This causes problems given that the tests all currently share the same database instance.

Unfortunately, this also means that running the tests is much slower, but we can return to this later.
Этот коммит содержится в:
Jesse Hallam
2018-11-20 20:16:25 -05:00
коммит произвёл Joram Wilander
родитель 2555a5d45d
Коммит a78913178c
35 изменённых файлов: 271 добавлений и 327 удалений

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

@@ -15,7 +15,6 @@ import (
"reflect"
"strconv"
"strings"
"sync"
"testing"
"time"
@@ -77,6 +76,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)
@@ -179,61 +182,6 @@ func SetupConfig(updateConfig func(cfg *model.Config)) *TestHelper {
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()
os.Remove(me.tempConfigPath)
@@ -248,6 +196,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()
@@ -276,16 +228,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))

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

@@ -9,7 +9,7 @@ import (
)
func TestGetBrandImage(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -25,7 +25,7 @@ func TestGetBrandImage(t *testing.T) {
}
func TestUploadBrandImage(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -54,7 +54,7 @@ func TestUploadBrandImage(t *testing.T) {
}
func TestDeleteBrandImage(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
data, err := 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

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

@@ -15,7 +15,7 @@ import (
)
func TestUploadFileAsMultipart(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -128,7 +128,7 @@ func TestUploadFileAsMultipart(t *testing.T) {
}
func TestUploadFileAsRequestBody(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -251,7 +251,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
@@ -366,7 +366,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
@@ -418,7 +418,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
@@ -494,7 +494,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
@@ -546,7 +546,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
@@ -613,7 +613,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

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

@@ -23,7 +23,7 @@ import (
)
func TestCreatePost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -120,7 +120,7 @@ func TestCreatePost(t *testing.T) {
}
func TestCreatePostEphemeral(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.SystemAdminClient
@@ -167,7 +167,7 @@ func testCreatePostWithOutgoingHook(
triggerWhen int,
commentPostType bool,
) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
user := th.SystemAdminUser
team := th.BasicTeam
@@ -356,7 +356,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
@@ -401,7 +401,7 @@ func TestCreatePostPublic(t *testing.T) {
}
func TestCreatePostAll(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -456,7 +456,7 @@ func TestCreatePostAll(t *testing.T) {
}
func TestCreatePostSendOutOfChannelMentions(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -523,7 +523,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
@@ -603,7 +603,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)
@@ -625,7 +625,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
@@ -713,7 +713,7 @@ func TestPatchPost(t *testing.T) {
}
func TestPinPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -748,7 +748,7 @@ func TestPinPost(t *testing.T) {
}
func TestUnpinPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -783,7 +783,7 @@ func TestUnpinPost(t *testing.T) {
}
func TestGetPostsForChannel(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -895,7 +895,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
@@ -1160,7 +1160,7 @@ func TestGetPostsAfterAndBefore(t *testing.T) {
}
func TestGetPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1209,7 +1209,7 @@ func TestGetPost(t *testing.T) {
}
func TestDeletePost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1247,7 +1247,7 @@ func TestDeletePost(t *testing.T) {
}
func TestGetPostThread(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1676,7 +1676,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

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

@@ -86,7 +86,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
@@ -125,7 +125,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
@@ -172,7 +172,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{
@@ -215,7 +215,7 @@ func TestGetTeamSanitization(t *testing.T) {
}
func TestGetTeamUnread(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -249,7 +249,7 @@ func TestGetTeamUnread(t *testing.T) {
}
func TestUpdateTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -344,7 +344,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{
@@ -376,7 +376,7 @@ func TestUpdateTeamSanitization(t *testing.T) {
}
func TestPatchTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -439,7 +439,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{
@@ -471,7 +471,7 @@ func TestPatchTeamSanitization(t *testing.T) {
}
func TestSoftDeleteTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -513,7 +513,7 @@ func TestSoftDeleteTeam(t *testing.T) {
}
func TestPermanentDeleteTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -554,7 +554,7 @@ func TestPermanentDeleteTeam(t *testing.T) {
}
func TestGetAllTeams(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -627,7 +627,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{
@@ -692,7 +692,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
@@ -739,7 +739,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{
@@ -782,7 +782,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
@@ -864,7 +864,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{
@@ -940,7 +940,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) {
}
func TestGetTeamsForUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -982,7 +982,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{
@@ -1052,7 +1052,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
@@ -1089,7 +1089,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
@@ -1154,7 +1154,7 @@ func TestGetTeamMembers(t *testing.T) {
}
func TestGetTeamMembersForUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1230,7 +1230,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
@@ -1411,7 +1411,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
@@ -1512,7 +1512,7 @@ func TestAddTeamMembers(t *testing.T) {
}
func TestRemoveTeamMember(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1543,7 +1543,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
@@ -1598,7 +1598,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
@@ -1676,7 +1676,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()
@@ -1751,7 +1751,7 @@ func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
}
func TestGetMyTeamsUnread(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1782,7 +1782,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
@@ -1807,7 +1807,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) {
@@ -1886,7 +1886,7 @@ func TestImportTeam(t *testing.T) {
}
func TestInviteUsersToTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
user1 := th.GenerateTestEmail()
@@ -1996,7 +1996,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
@@ -2024,7 +2024,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
@@ -2087,7 +2087,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
@@ -2103,7 +2103,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
@@ -2140,7 +2140,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

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

@@ -17,7 +17,7 @@ import (
)
func TestCreateUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
AdminClient := th.SystemAdminClient
@@ -93,7 +93,7 @@ func TestCreateUser(t *testing.T) {
}
func TestCreateUserWithToken(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -232,7 +232,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
@@ -353,7 +353,7 @@ func TestGetMe(t *testing.T) {
}
func TestGetUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -424,7 +424,7 @@ func TestGetUser(t *testing.T) {
}
func TestGetUserByUsername(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -492,7 +492,7 @@ func TestGetUserByUsername(t *testing.T) {
}
func TestGetUserByEmail(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -557,7 +557,7 @@ func TestGetUserByEmail(t *testing.T) {
}
func TestSearchUsers(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -747,7 +747,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
@@ -880,7 +880,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
@@ -984,7 +984,7 @@ func TestGetUsersByUsernames(t *testing.T) {
}
func TestGetTotalUsersStat(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -999,7 +999,7 @@ func TestGetTotalUsersStat(t *testing.T) {
}
func TestUpdateUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1064,7 +1064,7 @@ func TestUpdateUser(t *testing.T) {
}
func TestPatchUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1160,7 +1160,7 @@ func TestPatchUser(t *testing.T) {
}
func TestUpdateUserAuth(t *testing.T) {
th := Setup().InitSystemAdmin().InitBasic()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.SystemAdminClient
@@ -1222,7 +1222,7 @@ func TestUpdateUserAuth(t *testing.T) {
}
func TestDeleteUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1254,7 +1254,7 @@ func TestDeleteUser(t *testing.T) {
}
func TestUpdateUserRoles(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1309,7 +1309,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
@@ -1376,7 +1376,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
@@ -1535,7 +1535,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
@@ -1585,7 +1585,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
@@ -1631,7 +1631,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
@@ -1641,27 +1641,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, "")
@@ -1677,7 +1672,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
@@ -1720,7 +1715,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
@@ -1761,7 +1756,7 @@ func TestGetUsersNotInChannel(t *testing.T) {
}
func TestUpdateUserMfa(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1777,7 +1772,7 @@ func TestUpdateUserMfa(t *testing.T) {
}
func TestCheckUserMfa(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1823,7 +1818,7 @@ func TestCheckUserMfa(t *testing.T) {
}
func TestGenerateMfaSecret(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1856,7 +1851,7 @@ func TestGenerateMfaSecret(t *testing.T) {
}
func TestUpdateUserPassword(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1925,6 +1920,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
@@ -2009,7 +2005,7 @@ func TestUpdateUserPassword(t *testing.T) {
}*/
func TestGetSessions(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -2049,7 +2045,7 @@ func TestGetSessions(t *testing.T) {
}
func TestRevokeSessions(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -2122,8 +2118,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)
@@ -2187,7 +2181,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
@@ -2260,7 +2254,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
@@ -2311,7 +2305,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
@@ -2407,7 +2401,7 @@ func TestCBALogin(t *testing.T) {
}
func TestSwitchAccount(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -2535,7 +2529,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
@@ -2616,7 +2610,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
@@ -2700,7 +2694,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
@@ -2746,7 +2740,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
@@ -2790,7 +2784,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
@@ -2834,7 +2828,7 @@ func TestDisableUserAccessToken(t *testing.T) {
}
func TestEnableUserAccessToken(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -2876,7 +2870,7 @@ func TestEnableUserAccessToken(t *testing.T) {
}
func TestUserAccessTokenInactiveUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -2899,7 +2893,7 @@ func TestUserAccessTokenInactiveUser(t *testing.T) {
}
func TestUserAccessTokenDisableConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -3092,7 +3086,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