mirror of
https://github.com/mattermost/mattermost.git
synced 2026-04-26 00:33:23 -04:00
Don't use global app for api / api4 tests (#7528)
* don't use global app for api / api4 tests * put sleep back. we're gonna have to do some goroutine wrangling * fix oauth test config assumptions * jobs package, i'm comin' for you next * app test fix * try increasing sleep a little
This commit is contained in:
parent
b84736e9b6
commit
9bc7af0c57
66 changed files with 879 additions and 461 deletions
|
|
@ -8,13 +8,19 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/store"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
app.UseGlobalApp = false
|
||||
}
|
||||
|
||||
func TestGetLogs(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.GetLogs(); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -32,6 +38,7 @@ func TestGetClusterInfos(t *testing.T) {
|
|||
t.SkipNow()
|
||||
}
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.GetClusterStatus(); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -44,6 +51,7 @@ func TestGetClusterInfos(t *testing.T) {
|
|||
|
||||
func TestGetAllAudits(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.GetAllAudits(); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -58,6 +66,7 @@ func TestGetAllAudits(t *testing.T) {
|
|||
|
||||
func TestGetConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.GetConfig(); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -104,6 +113,7 @@ func TestGetConfig(t *testing.T) {
|
|||
|
||||
func TestReloadConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.ReloadConfig(); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -119,6 +129,7 @@ func TestReloadConfig(t *testing.T) {
|
|||
|
||||
func TestInvalidateAllCache(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.InvalidateAllCaches(); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -131,6 +142,7 @@ func TestInvalidateAllCache(t *testing.T) {
|
|||
|
||||
func TestSaveConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.SaveConfig(utils.Cfg); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -147,6 +159,7 @@ func TestSaveConfig(t *testing.T) {
|
|||
|
||||
func TestRecycleDatabaseConnection(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.RecycleDatabaseConnection(); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -159,6 +172,7 @@ func TestRecycleDatabaseConnection(t *testing.T) {
|
|||
|
||||
func TestEmailTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
SendEmailNotifications := utils.Cfg.EmailSettings.SendEmailNotifications
|
||||
SMTPServer := utils.Cfg.EmailSettings.SMTPServer
|
||||
|
|
@ -191,6 +205,7 @@ func TestEmailTest(t *testing.T) {
|
|||
|
||||
func TestLdapTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.TestLdap(utils.Cfg); err == nil {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
|
|
@ -203,6 +218,8 @@ func TestLdapTest(t *testing.T) {
|
|||
|
||||
func TestGetTeamAnalyticsStandard(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
th.CreatePrivateChannel(th.BasicClient, th.BasicTeam)
|
||||
|
||||
if _, err := th.BasicClient.GetTeamAnalytics(th.BasicTeam.Id, "standard"); err == nil {
|
||||
|
|
@ -432,6 +449,7 @@ func TestUserCountsWithPostsByDay(t *testing.T) {
|
|||
|
||||
func TestGetTeamAnalyticsExtra(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
th.CreatePost(th.BasicClient, th.BasicChannel)
|
||||
|
||||
|
|
@ -568,6 +586,7 @@ func TestGetTeamAnalyticsExtra(t *testing.T) {
|
|||
|
||||
func TestAdminResetMfa(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.AdminResetMfa("12345678901234567890123456"); err == nil {
|
||||
t.Fatal("should have failed - not an admin")
|
||||
|
|
@ -590,12 +609,14 @@ func TestAdminResetMfa(t *testing.T) {
|
|||
|
||||
func TestAdminResetPassword(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if _, err := Client.AdminResetPassword("", "newpwd1"); err == nil {
|
||||
|
|
@ -617,7 +638,7 @@ func TestAdminResetPassword(t *testing.T) {
|
|||
authData := model.NewId()
|
||||
user2 := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", AuthData: &authData, AuthService: "random"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
if _, err := Client.AdminResetPassword(user.Id, "newpwd1"); err != nil {
|
||||
|
|
@ -635,6 +656,8 @@ func TestAdminResetPassword(t *testing.T) {
|
|||
|
||||
func TestAdminLdapSyncNow(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
if _, err := Client.LdapSyncNow(); err != nil {
|
||||
|
|
@ -645,6 +668,7 @@ func TestAdminLdapSyncNow(t *testing.T) {
|
|||
// Needs more work
|
||||
func TestGetRecentlyActiveUsers(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if userMap, err := th.BasicClient.GetRecentlyActiveUsers(th.BasicTeam.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -655,6 +679,8 @@ func TestGetRecentlyActiveUsers(t *testing.T) {
|
|||
|
||||
func TestDisableAPIv3(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
enableAPIv3 := *utils.Cfg.ServiceSettings.EnableAPIv3
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ type TestHelper struct {
|
|||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
th := &TestHelper{
|
||||
App: app.Global(),
|
||||
App: app.New(),
|
||||
}
|
||||
|
||||
if th.App.Srv == nil {
|
||||
|
|
@ -90,10 +90,10 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
|||
me.BasicUser = me.CreateUser(me.BasicClient)
|
||||
me.LoginBasic()
|
||||
me.BasicTeam = me.CreateTeam(me.BasicClient)
|
||||
LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
UpdateUserToNonTeamAdmin(me.BasicUser, me.BasicTeam)
|
||||
me.LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
me.UpdateUserToNonTeamAdmin(me.BasicUser, me.BasicTeam)
|
||||
me.BasicUser2 = me.CreateUser(me.BasicClient)
|
||||
LinkUserToTeam(me.BasicUser2, me.BasicTeam)
|
||||
me.LinkUserToTeam(me.BasicUser2, me.BasicTeam)
|
||||
me.BasicClient.SetTeamId(me.BasicTeam.Id)
|
||||
me.BasicChannel = me.CreateChannel(me.BasicClient, me.BasicTeam)
|
||||
me.BasicPost = me.CreatePost(me.BasicClient, me.BasicChannel)
|
||||
|
|
@ -110,7 +110,7 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
|
|||
me.SystemAdminUser.Password = "Password1"
|
||||
me.LoginSystemAdmin()
|
||||
me.SystemAdminTeam = me.CreateTeam(me.SystemAdminClient)
|
||||
LinkUserToTeam(me.SystemAdminUser, me.SystemAdminTeam)
|
||||
me.LinkUserToTeam(me.SystemAdminUser, me.SystemAdminTeam)
|
||||
me.SystemAdminClient.SetTeamId(me.SystemAdminTeam.Id)
|
||||
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id)
|
||||
me.SystemAdminChannel = me.CreateChannel(me.SystemAdminClient, me.SystemAdminTeam)
|
||||
|
|
@ -159,10 +159,10 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User {
|
|||
return ruser
|
||||
}
|
||||
|
||||
func LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
err := app.Global().JoinUserToTeam(team, user, "")
|
||||
err := me.App.JoinUserToTeam(team, user, "")
|
||||
if err != nil {
|
||||
l4g.Error(err.Error())
|
||||
l4g.Close()
|
||||
|
|
@ -173,11 +173,11 @@ func LinkUserToTeam(user *model.User, team *model.Team) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
|
||||
func (me *TestHelper) UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id + " " + model.ROLE_TEAM_ADMIN.Id}
|
||||
if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
utils.EnableDebugLogForTest()
|
||||
l4g.Error(tmr.Err.Error())
|
||||
l4g.Close()
|
||||
|
|
@ -187,11 +187,11 @@ func UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
|
||||
func (me *TestHelper) UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id}
|
||||
if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
utils.EnableDebugLogForTest()
|
||||
l4g.Error(tmr.Err.Error())
|
||||
l4g.Close()
|
||||
|
|
@ -201,13 +201,13 @@ func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
|
||||
func (me *TestHelper) MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
if cmr := <-app.Global().Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
|
||||
if cmr := <-me.App.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
|
||||
cm := cmr.Data.(*model.ChannelMember)
|
||||
cm.Roles = "channel_admin channel_user"
|
||||
if sr := <-app.Global().Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
|
||||
if sr := <-me.App.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
|
||||
utils.EnableDebugLogForTest()
|
||||
panic(sr.Err)
|
||||
}
|
||||
|
|
@ -219,13 +219,13 @@ func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func MakeUserChannelUser(user *model.User, channel *model.Channel) {
|
||||
func (me *TestHelper) MakeUserChannelUser(user *model.User, channel *model.Channel) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
if cmr := <-app.Global().Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
|
||||
if cmr := <-me.App.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
|
||||
cm := cmr.Data.(*model.ChannelMember)
|
||||
cm.Roles = "channel_user"
|
||||
if sr := <-app.Global().Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
|
||||
if sr := <-me.App.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
|
||||
utils.EnableDebugLogForTest()
|
||||
panic(sr.Err)
|
||||
}
|
||||
|
|
@ -308,8 +308,6 @@ func (me *TestHelper) LoginSystemAdmin() {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func TearDown() {
|
||||
if app.Global().Srv != nil {
|
||||
app.Global().StopServer()
|
||||
}
|
||||
func (me *TestHelper) TearDown() {
|
||||
me.App.Shutdown()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import (
|
|||
|
||||
func TestCreateChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
team := th.BasicTeam
|
||||
|
|
@ -136,7 +138,7 @@ func TestCreateChannel(t *testing.T) {
|
|||
t.Fatal("should have errored not team admin")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
Client.Logout()
|
||||
th.LoginBasic()
|
||||
Client.SetTeamId(team.Id)
|
||||
|
|
@ -161,7 +163,7 @@ func TestCreateChannel(t *testing.T) {
|
|||
t.Fatal("should have errored not system admin")
|
||||
}
|
||||
|
||||
LinkUserToTeam(th.SystemAdminUser, team)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, team)
|
||||
|
||||
if _, err := SystemAdminClient.CreateChannel(channel2); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -191,6 +193,8 @@ func TestCreateChannel(t *testing.T) {
|
|||
|
||||
func TestCreateDirectChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
|
@ -235,6 +239,8 @@ func TestCreateDirectChannel(t *testing.T) {
|
|||
|
||||
func TestCreateGroupChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
|
@ -275,13 +281,15 @@ func TestCreateGroupChannel(t *testing.T) {
|
|||
|
||||
func TestUpdateChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
sysAdminUser := th.SystemAdminUser
|
||||
user := th.CreateUser(Client)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
|
|
@ -327,7 +335,7 @@ func TestUpdateChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
Client.Must(Client.JoinChannel(channel1.Id))
|
||||
UpdateUserToTeamAdmin(user2, team)
|
||||
th.UpdateUserToTeamAdmin(user2, team)
|
||||
|
||||
Client.Logout()
|
||||
Client.Login(user2.Email, user2.Password)
|
||||
|
|
@ -338,7 +346,7 @@ func TestUpdateChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
Client.Login(sysAdminUser.Email, sysAdminUser.Password)
|
||||
LinkUserToTeam(sysAdminUser, team)
|
||||
th.LinkUserToTeam(sysAdminUser, team)
|
||||
Client.Must(Client.JoinChannel(channel1.Id))
|
||||
|
||||
if _, err := Client.UpdateChannel(upChannel1); err != nil {
|
||||
|
|
@ -372,7 +380,7 @@ func TestUpdateChannel(t *testing.T) {
|
|||
channel2 := th.CreateChannel(Client, team)
|
||||
channel3 := th.CreatePrivateChannel(Client, team)
|
||||
|
||||
LinkUserToTeam(th.BasicUser, team)
|
||||
th.LinkUserToTeam(th.BasicUser, team)
|
||||
|
||||
Client.Must(Client.AddChannelMember(channel2.Id, th.BasicUser.Id))
|
||||
Client.Must(Client.AddChannelMember(channel3.Id, th.BasicUser.Id))
|
||||
|
|
@ -392,8 +400,8 @@ func TestUpdateChannel(t *testing.T) {
|
|||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
utils.License().Features.SetDefaults()
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
MakeUserChannelUser(th.BasicUser, channel2)
|
||||
MakeUserChannelUser(th.BasicUser, channel3)
|
||||
th.MakeUserChannelUser(th.BasicUser, channel2)
|
||||
th.MakeUserChannelUser(th.BasicUser, channel3)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
if _, err := Client.UpdateChannel(channel2); err == nil {
|
||||
|
|
@ -403,7 +411,7 @@ func TestUpdateChannel(t *testing.T) {
|
|||
t.Fatal("should have errored not channel admin")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
if _, err := Client.UpdateChannel(channel2); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -411,11 +419,11 @@ func TestUpdateChannel(t *testing.T) {
|
|||
if _, err := Client.UpdateChannel(channel3); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
UpdateUserToNonTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
|
||||
MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
if _, err := Client.UpdateChannel(channel2); err != nil {
|
||||
|
|
@ -439,7 +447,7 @@ func TestUpdateChannel(t *testing.T) {
|
|||
t.Fatal("should have errored not team admin")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
Client.Logout()
|
||||
Client.Login(th.BasicUser.Email, th.BasicUser.Password)
|
||||
Client.SetTeamId(team.Id)
|
||||
|
|
@ -489,10 +497,12 @@ func TestUpdateChannel(t *testing.T) {
|
|||
|
||||
func TestUpdateChannelDisplayName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
user := th.CreateUser(Client)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
|
|
@ -515,6 +525,8 @@ func TestUpdateChannelDisplayName(t *testing.T) {
|
|||
|
||||
func TestUpdateChannelHeader(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
team := th.BasicTeam
|
||||
|
|
@ -628,8 +640,8 @@ func TestUpdateChannelHeader(t *testing.T) {
|
|||
*utils.Cfg.TeamSettings.RestrictPublicChannelManagement = model.PERMISSIONS_CHANNEL_ADMIN
|
||||
*utils.Cfg.TeamSettings.RestrictPrivateChannelManagement = model.PERMISSIONS_CHANNEL_ADMIN
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
MakeUserChannelUser(th.BasicUser, channel2)
|
||||
MakeUserChannelUser(th.BasicUser, channel3)
|
||||
th.MakeUserChannelUser(th.BasicUser, channel2)
|
||||
th.MakeUserChannelUser(th.BasicUser, channel3)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
if _, err := Client.UpdateChannelHeader(data2); err == nil {
|
||||
|
|
@ -639,8 +651,8 @@ func TestUpdateChannelHeader(t *testing.T) {
|
|||
t.Fatal("should have errored not channel admin")
|
||||
}
|
||||
|
||||
MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
if _, err := Client.UpdateChannelHeader(data2); err != nil {
|
||||
|
|
@ -661,7 +673,7 @@ func TestUpdateChannelHeader(t *testing.T) {
|
|||
t.Fatal("should have errored not team admin")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
Client.Logout()
|
||||
th.LoginBasic()
|
||||
Client.SetTeamId(team.Id)
|
||||
|
|
@ -684,7 +696,7 @@ func TestUpdateChannelHeader(t *testing.T) {
|
|||
t.Fatal("should have errored not system admin")
|
||||
}
|
||||
|
||||
LinkUserToTeam(th.SystemAdminUser, team)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, team)
|
||||
Client.Must(Client.AddChannelMember(channel2.Id, th.SystemAdminUser.Id))
|
||||
Client.Must(Client.AddChannelMember(channel3.Id, th.SystemAdminUser.Id))
|
||||
th.LoginSystemAdmin()
|
||||
|
|
@ -711,6 +723,8 @@ func TestUpdateChannelHeader(t *testing.T) {
|
|||
|
||||
func TestUpdateChannelPurpose(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
team := th.BasicTeam
|
||||
|
|
@ -810,8 +824,8 @@ func TestUpdateChannelPurpose(t *testing.T) {
|
|||
*utils.Cfg.TeamSettings.RestrictPublicChannelManagement = model.PERMISSIONS_CHANNEL_ADMIN
|
||||
*utils.Cfg.TeamSettings.RestrictPrivateChannelManagement = model.PERMISSIONS_CHANNEL_ADMIN
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
MakeUserChannelUser(th.BasicUser, channel2)
|
||||
MakeUserChannelUser(th.BasicUser, channel3)
|
||||
th.MakeUserChannelUser(th.BasicUser, channel2)
|
||||
th.MakeUserChannelUser(th.BasicUser, channel3)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
if _, err := Client.UpdateChannelPurpose(data2); err == nil {
|
||||
|
|
@ -821,8 +835,8 @@ func TestUpdateChannelPurpose(t *testing.T) {
|
|||
t.Fatal("should have errored not channel admin")
|
||||
}
|
||||
|
||||
MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
if _, err := Client.UpdateChannelPurpose(data2); err != nil {
|
||||
|
|
@ -843,7 +857,7 @@ func TestUpdateChannelPurpose(t *testing.T) {
|
|||
t.Fatal("should have errored not team admin")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
Client.Logout()
|
||||
th.LoginBasic()
|
||||
Client.SetTeamId(team.Id)
|
||||
|
|
@ -866,7 +880,7 @@ func TestUpdateChannelPurpose(t *testing.T) {
|
|||
t.Fatal("should have errored not system admin")
|
||||
}
|
||||
|
||||
LinkUserToTeam(th.SystemAdminUser, team)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, team)
|
||||
Client.Must(Client.AddChannelMember(channel2.Id, th.SystemAdminUser.Id))
|
||||
Client.Must(Client.AddChannelMember(channel3.Id, th.SystemAdminUser.Id))
|
||||
th.LoginSystemAdmin()
|
||||
|
|
@ -892,6 +906,8 @@ func TestUpdateChannelPurpose(t *testing.T) {
|
|||
|
||||
func TestGetChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
team2 := th.CreateTeam(Client)
|
||||
|
|
@ -965,6 +981,8 @@ func TestGetChannel(t *testing.T) {
|
|||
|
||||
func TestGetMoreChannelsPage(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1034,6 +1052,8 @@ func TestGetMoreChannelsPage(t *testing.T) {
|
|||
|
||||
func TestGetChannelCounts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1068,6 +1088,8 @@ func TestGetChannelCounts(t *testing.T) {
|
|||
|
||||
func TestGetMyChannelMembers(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1092,6 +1114,8 @@ func TestGetMyChannelMembers(t *testing.T) {
|
|||
|
||||
func TestJoinChannelById(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1112,7 +1136,7 @@ func TestJoinChannelById(t *testing.T) {
|
|||
rchannel := Client.Must(Client.CreateDirectChannel(th.BasicUser.Id)).Data.(*model.Channel)
|
||||
|
||||
user3 := th.CreateUser(th.BasicClient)
|
||||
LinkUserToTeam(user3, team)
|
||||
th.LinkUserToTeam(user3, team)
|
||||
Client.Must(Client.Login(user3.Email, "Password1"))
|
||||
|
||||
if _, err := Client.JoinChannel(rchannel.Id); err == nil {
|
||||
|
|
@ -1136,6 +1160,8 @@ func TestJoinChannelById(t *testing.T) {
|
|||
|
||||
func TestJoinChannelByName(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1156,7 +1182,7 @@ func TestJoinChannelByName(t *testing.T) {
|
|||
rchannel := Client.Must(Client.CreateDirectChannel(th.BasicUser.Id)).Data.(*model.Channel)
|
||||
|
||||
user3 := th.CreateUser(th.BasicClient)
|
||||
LinkUserToTeam(user3, team)
|
||||
th.LinkUserToTeam(user3, team)
|
||||
Client.Must(Client.Login(user3.Email, "Password1"))
|
||||
|
||||
if _, err := Client.JoinChannelByName(rchannel.Name); err == nil {
|
||||
|
|
@ -1180,6 +1206,8 @@ func TestJoinChannelByName(t *testing.T) {
|
|||
|
||||
func TestJoinChannelByNameDisabledUser(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1199,6 +1227,8 @@ func TestJoinChannelByNameDisabledUser(t *testing.T) {
|
|||
|
||||
func TestLeaveChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1237,13 +1267,15 @@ func TestLeaveChannel(t *testing.T) {
|
|||
|
||||
func TestDeleteChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
userSystemAdmin := th.SystemAdminUser
|
||||
userTeamAdmin := th.CreateUser(Client)
|
||||
LinkUserToTeam(userTeamAdmin, team)
|
||||
th.LinkUserToTeam(userTeamAdmin, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
Client.Login(user2.Email, user2.Password)
|
||||
|
||||
|
|
@ -1274,7 +1306,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
userStd := th.CreateUser(Client)
|
||||
LinkUserToTeam(userStd, team)
|
||||
th.LinkUserToTeam(userStd, team)
|
||||
Client.Login(userStd.Email, userStd.Password)
|
||||
|
||||
if _, err := Client.JoinChannel(channel1.Id); err == nil {
|
||||
|
|
@ -1298,7 +1330,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(userStd, team)
|
||||
th.UpdateUserToTeamAdmin(userStd, team)
|
||||
|
||||
Client.Logout()
|
||||
Client.Login(userStd.Email, userStd.Password)
|
||||
|
|
@ -1343,7 +1375,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
th.LoginSystemAdmin()
|
||||
LinkUserToTeam(th.BasicUser, team)
|
||||
th.LinkUserToTeam(th.BasicUser, team)
|
||||
|
||||
channel2 = th.CreateChannel(Client, team)
|
||||
channel3 = th.CreatePrivateChannel(Client, team)
|
||||
|
|
@ -1385,8 +1417,8 @@ func TestDeleteChannel(t *testing.T) {
|
|||
t.Fatal("should have errored not channel admin")
|
||||
}
|
||||
|
||||
MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel2)
|
||||
th.MakeUserChannelAdmin(th.BasicUser, channel3)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
if _, err := Client.DeleteChannel(channel2.Id); err != nil {
|
||||
|
|
@ -1403,7 +1435,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
|
||||
Client.Must(Client.AddChannelMember(channel2.Id, th.BasicUser.Id))
|
||||
Client.Must(Client.AddChannelMember(channel3.Id, th.BasicUser.Id))
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
|
||||
Client.Login(th.BasicUser.Email, th.BasicUser.Password)
|
||||
th.App.InvalidateAllCaches()
|
||||
|
|
@ -1415,7 +1447,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
UpdateUserToNonTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
|
||||
utils.SetIsLicensed(true)
|
||||
|
|
@ -1441,7 +1473,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
t.Fatal("should have errored not team admin")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
Client.Logout()
|
||||
Client.Login(th.BasicUser.Email, th.BasicUser.Password)
|
||||
Client.SetTeamId(team.Id)
|
||||
|
|
@ -1515,6 +1547,8 @@ func TestDeleteChannel(t *testing.T) {
|
|||
|
||||
func TestGetChannelStats(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1532,6 +1566,8 @@ func TestGetChannelStats(t *testing.T) {
|
|||
|
||||
func TestAddChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
user1 := th.BasicUser
|
||||
|
|
@ -1633,7 +1669,7 @@ func TestAddChannelMember(t *testing.T) {
|
|||
t.Fatal("Should have failed due to permissions")
|
||||
}
|
||||
|
||||
MakeUserChannelAdmin(user1, channel5)
|
||||
th.MakeUserChannelAdmin(user1, channel5)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1658,7 +1694,7 @@ func TestAddChannelMember(t *testing.T) {
|
|||
t.Fatal("Should have failed due to permissions")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(user1, team)
|
||||
th.UpdateUserToTeamAdmin(user1, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1690,11 +1726,13 @@ func TestAddChannelMember(t *testing.T) {
|
|||
|
||||
func TestRemoveChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
UpdateUserToTeamAdmin(user2, team)
|
||||
th.UpdateUserToTeamAdmin(user2, team)
|
||||
|
||||
channelMadeByCA := &model.Channel{DisplayName: "A Test API Name", Name: "zz" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
|
||||
channelMadeByCA = Client.Must(Client.CreateChannel(channelMadeByCA)).Data.(*model.Channel)
|
||||
|
|
@ -1707,7 +1745,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
|
||||
|
||||
userStd := th.CreateUser(th.BasicClient)
|
||||
LinkUserToTeam(userStd, team)
|
||||
th.LinkUserToTeam(userStd, team)
|
||||
|
||||
Client.Must(Client.AddChannelMember(channel1.Id, userStd.Id))
|
||||
|
||||
|
|
@ -1809,7 +1847,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
t.Fatal("Should have failed due to permissions")
|
||||
}
|
||||
|
||||
MakeUserChannelAdmin(user1, channel5)
|
||||
th.MakeUserChannelAdmin(user1, channel5)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1834,7 +1872,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
t.Fatal("Should have failed due to permissions")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(user1, team)
|
||||
th.UpdateUserToTeamAdmin(user1, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1867,6 +1905,8 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
|
||||
func TestUpdateNotifyProps(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
user := th.BasicUser
|
||||
|
|
@ -2006,6 +2046,8 @@ func TestUpdateNotifyProps(t *testing.T) {
|
|||
|
||||
func TestFuzzyChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -2051,6 +2093,8 @@ func TestFuzzyChannel(t *testing.T) {
|
|||
|
||||
func TestGetChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -2089,6 +2133,8 @@ func TestGetChannelMember(t *testing.T) {
|
|||
|
||||
func TestSearchMoreChannels(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -2166,6 +2212,8 @@ func TestSearchMoreChannels(t *testing.T) {
|
|||
|
||||
func TestAutocompleteChannels(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -2236,6 +2284,8 @@ func TestAutocompleteChannels(t *testing.T) {
|
|||
|
||||
func TestGetChannelByName(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if result, err := Client.GetChannelByName(th.BasicChannel.Name); err != nil {
|
||||
|
|
@ -2268,6 +2318,8 @@ func TestGetChannelByName(t *testing.T) {
|
|||
|
||||
func TestViewChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
view := model.ChannelView{
|
||||
|
|
@ -2313,6 +2365,7 @@ func TestViewChannel(t *testing.T) {
|
|||
|
||||
func TestGetChannelMembersByIds(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.App.AddUserToChannel(th.BasicUser2, th.BasicChannel); err != nil {
|
||||
t.Fatal("Could not add second user to channel")
|
||||
|
|
@ -2350,8 +2403,10 @@ func TestGetChannelMembersByIds(t *testing.T) {
|
|||
|
||||
func TestUpdateChannelRoles(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.SystemAdminClient.SetTeamId(th.BasicTeam.Id)
|
||||
LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
|
||||
const CHANNEL_ADMIN = "channel_admin channel_user"
|
||||
const CHANNEL_MEMBER = "channel_user"
|
||||
|
|
@ -2423,6 +2478,8 @@ func TestUpdateChannelRoles(t *testing.T) {
|
|||
|
||||
func TestGetPinnedPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
post1 := th.BasicPost
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ func TestCliCreateTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
name := "name" + id
|
||||
|
|
@ -55,6 +56,7 @@ func TestCliCreateUserWithTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
email := "success+" + id + "@simulator.amazonses.com"
|
||||
|
|
@ -96,6 +98,8 @@ func TestCliCreateUserWithoutTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup()
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
email := "success+" + id + "@simulator.amazonses.com"
|
||||
username := "name" + id
|
||||
|
|
@ -123,6 +127,7 @@ func TestCliAssignRole(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
cmd := exec.Command("bash", "-c", "go run ../cmd/platform/*.go roles system_admin "+th.BasicUser.Email)
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
|
@ -147,6 +152,8 @@ func TestCliJoinChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
|
||||
|
||||
cmd := exec.Command("bash", "-c", "go run ../cmd/platform/*.go channel add "+th.BasicTeam.Name+":"+channel.Name+" "+th.BasicUser2.Email)
|
||||
|
|
@ -179,6 +186,8 @@ func TestCliRemoveChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
|
||||
|
||||
cmd := exec.Command("bash", "-c", "go run ../cmd/platform/*.go channel add "+th.BasicTeam.Name+":"+channel.Name+" "+th.BasicUser2.Email)
|
||||
|
|
@ -218,6 +227,8 @@ func TestCliListChannels(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
|
||||
th.BasicClient.Must(th.BasicClient.DeleteChannel(channel.Id))
|
||||
|
||||
|
|
@ -243,6 +254,8 @@ func TestCliRestoreChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
|
||||
th.BasicClient.Must(th.BasicClient.DeleteChannel(channel.Id))
|
||||
|
||||
|
|
@ -268,6 +281,7 @@ func TestCliJoinTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
cmd := exec.Command("bash", "-c", "go run ../cmd/platform/*.go team add "+th.SystemAdminTeam.Name+" "+th.BasicUser.Email)
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
|
@ -298,6 +312,7 @@ func TestCliLeaveTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
cmd := exec.Command("bash", "-c", "go run ../cmd/platform/*.go team remove "+th.BasicTeam.Name+" "+th.BasicUser.Email)
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
|
@ -335,6 +350,7 @@ func TestCliResetPassword(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
cmd := exec.Command("bash", "-c", "go run ../cmd/platform/*.go user password "+th.BasicUser.Email+" password2")
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
|
@ -354,6 +370,7 @@ func TestCliCreateChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
name := "name" + id
|
||||
|
|
@ -380,6 +397,7 @@ func TestCliMakeUserActiveAndInactive(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
// first inactivate the user
|
||||
cmd := exec.Command("bash", "-c", "go run ../cmd/platform/*.go user deactivate "+th.BasicUser.Email)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestEchoCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestExpandCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -30,6 +32,8 @@ func TestExpandCommand(t *testing.T) {
|
|||
|
||||
func TestCollapseCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestHelpCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import (
|
|||
|
||||
func TestInvitePeopleCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import (
|
|||
// also used to test /open (see command_open_test.go)
|
||||
func testJoinCommands(t *testing.T, alias string) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
user2 := th.BasicUser2
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestLeaveCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
user2 := th.BasicUser2
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import (
|
|||
|
||||
func TestLoadTestHelpCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -35,6 +37,8 @@ func TestLoadTestHelpCommands(t *testing.T) {
|
|||
|
||||
func TestLoadTestSetupCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -56,6 +60,8 @@ func TestLoadTestSetupCommands(t *testing.T) {
|
|||
|
||||
func TestLoadTestUsersCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -77,6 +83,8 @@ func TestLoadTestUsersCommands(t *testing.T) {
|
|||
|
||||
func TestLoadTestChannelsCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -98,6 +106,8 @@ func TestLoadTestChannelsCommands(t *testing.T) {
|
|||
|
||||
func TestLoadTestPostsCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
func TestLogoutTestCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/logout"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestMeCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@ import (
|
|||
|
||||
func TestMsgCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
user3 := th.CreateUser(th.BasicClient)
|
||||
LinkUserToTeam(user3, team)
|
||||
th.LinkUserToTeam(user3, team)
|
||||
|
||||
Client.Must(Client.CreateDirectChannel(user2.Id))
|
||||
Client.Must(Client.CreateDirectChannel(user3.Id))
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ import (
|
|||
|
||||
func TestSearchCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/search"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ import (
|
|||
|
||||
func TestSettingsCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/settings"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ import (
|
|||
|
||||
func TestShortcutsCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/shortcuts"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestShrugCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestStatusCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
commandAndTest(t, th, "away")
|
||||
commandAndTest(t, th, "offline")
|
||||
commandAndTest(t, th, "online")
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import (
|
|||
|
||||
func TestListCommands(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if results, err := Client.ListCommands(); err != nil {
|
||||
|
|
@ -36,6 +38,8 @@ func TestListCommands(t *testing.T) {
|
|||
|
||||
func TestCreateCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user := th.SystemAdminUser
|
||||
team := th.SystemAdminTeam
|
||||
|
|
@ -99,6 +103,8 @@ func TestCreateCommand(t *testing.T) {
|
|||
|
||||
func TestListTeamCommands(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
|
||||
|
|
@ -123,6 +129,8 @@ func TestListTeamCommands(t *testing.T) {
|
|||
|
||||
func TestUpdateCommand(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
team := th.SystemAdminTeam
|
||||
|
|
@ -162,6 +170,8 @@ func TestUpdateCommand(t *testing.T) {
|
|||
|
||||
func TestRegenToken(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
|
||||
|
|
@ -187,6 +197,8 @@ func TestRegenToken(t *testing.T) {
|
|||
|
||||
func TestDeleteCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
|
||||
|
|
@ -230,6 +242,8 @@ func TestDeleteCommand(t *testing.T) {
|
|||
|
||||
func TestTestCommand(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
channel1 := th.SystemAdminChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import (
|
|||
|
||||
func TestGetEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
@ -96,6 +98,8 @@ func TestGetEmoji(t *testing.T) {
|
|||
|
||||
func TestCreateEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
@ -218,6 +222,8 @@ func TestCreateEmoji(t *testing.T) {
|
|||
|
||||
func TestDeleteEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
@ -276,6 +282,8 @@ func createTestEmoji(t *testing.T, a *app.App, emoji *model.Emoji, imageData []b
|
|||
|
||||
func TestGetEmojiImage(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
func TestUploadFile(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Logf("skipping because no file driver is enabled")
|
||||
|
|
@ -124,6 +125,7 @@ func TestUploadFile(t *testing.T) {
|
|||
|
||||
func TestGetFileInfo(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -193,6 +195,7 @@ func TestGetFileInfo(t *testing.T) {
|
|||
|
||||
func TestGetFile(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -275,6 +278,7 @@ func TestGetFile(t *testing.T) {
|
|||
|
||||
func TestGetFileThumbnail(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -331,6 +335,7 @@ func TestGetFileThumbnail(t *testing.T) {
|
|||
|
||||
func TestGetFilePreview(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -387,6 +392,7 @@ func TestGetFilePreview(t *testing.T) {
|
|||
|
||||
func TestGetPublicFile(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -454,6 +460,7 @@ func TestGetPublicFile(t *testing.T) {
|
|||
|
||||
func TestGetPublicFileOld(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -538,6 +545,7 @@ func generatePublicLinkOld(siteURL, teamId, channelId, userId, filename string)
|
|||
|
||||
func TestGetPublicLink(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -607,6 +615,7 @@ func TestGetPublicLink(t *testing.T) {
|
|||
|
||||
func TestMigrateFilenamesToFileInfos(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -719,6 +728,7 @@ func uploadFileOld(t *testing.T, data []byte, dest string, filename string) {
|
|||
|
||||
func TestFindTeamIdForFilename(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
@ -785,6 +795,7 @@ func TestFindTeamIdForFilename(t *testing.T) {
|
|||
|
||||
func TestGetInfoForFilename(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName == "" {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
func TestGetClientProperties(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if props, err := th.BasicClient.GetClientProperties(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -23,6 +24,7 @@ func TestGetClientProperties(t *testing.T) {
|
|||
|
||||
func TestLogClient(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if ret, _ := th.BasicClient.LogClient("this is a test"); !ret {
|
||||
t.Fatal("failed to log")
|
||||
|
|
@ -49,6 +51,7 @@ func TestLogClient(t *testing.T) {
|
|||
|
||||
func TestGetPing(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if m, err := th.BasicClient.GetPing(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import (
|
|||
|
||||
func TestGetLicenceConfig(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if result, err := Client.GetClientLicenceConfig(""); err != nil {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import (
|
|||
|
||||
func TestOAuthRegisterApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
oauthApp := &model.OAuthApp{Name: "TestApp" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}, IsTrusted: true}
|
||||
|
|
@ -108,6 +110,8 @@ func TestOAuthRegisterApp(t *testing.T) {
|
|||
|
||||
func TestOAuthAllow(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -193,6 +197,8 @@ func TestOAuthAllow(t *testing.T) {
|
|||
|
||||
func TestOAuthGetAppsByUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -263,6 +269,8 @@ func TestOAuthGetAppsByUser(t *testing.T) {
|
|||
|
||||
func TestOAuthGetAppInfo(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -291,6 +299,8 @@ func TestOAuthGetAppInfo(t *testing.T) {
|
|||
|
||||
func TestOAuthGetAuthorizedApps(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -324,6 +334,8 @@ func TestOAuthGetAuthorizedApps(t *testing.T) {
|
|||
|
||||
func TestOAuthDeauthorizeApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -375,6 +387,8 @@ func TestOAuthDeauthorizeApp(t *testing.T) {
|
|||
|
||||
func TestOAuthRegenerateAppSecret(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -416,6 +430,8 @@ func TestOAuthRegenerateAppSecret(t *testing.T) {
|
|||
|
||||
func TestOAuthDeleteApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -547,6 +563,8 @@ func TestOAuthAccessToken(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
enableOAuth := utils.Cfg.ServiceSettings.EnableOAuthServiceProvider
|
||||
|
|
@ -764,6 +782,8 @@ func TestOAuthComplete(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if r, err := HttpGet(Client.Url+"/login/gitlab/complete", Client.HttpClient, "", true); err == nil {
|
||||
|
|
@ -806,6 +826,14 @@ func TestOAuthComplete(t *testing.T) {
|
|||
// We are going to use mattermost as the provider emulating gitlab
|
||||
utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
|
||||
|
||||
adminOnly := *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
defer func() {
|
||||
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = adminOnly
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
}()
|
||||
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oauthApp := &model.OAuthApp{
|
||||
Name: "TestApp5" + model.NewId(),
|
||||
Homepage: "https://nowhere.com",
|
||||
|
|
|
|||
|
|
@ -22,21 +22,23 @@ import (
|
|||
)
|
||||
|
||||
func TestCreatePost(t *testing.T) {
|
||||
adm := Setup().InitSystemAdmin()
|
||||
AdminClient := adm.SystemAdminClient
|
||||
adminTeam := adm.SystemAdminTeam
|
||||
adminUser := adm.CreateUser(adm.SystemAdminClient)
|
||||
LinkUserToTeam(adminUser, adminTeam)
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
team2 := th.CreateTeam(th.BasicClient)
|
||||
user3 := th.CreateUser(th.BasicClient)
|
||||
LinkUserToTeam(user3, team2)
|
||||
th.LinkUserToTeam(user3, team2)
|
||||
channel1 := th.BasicChannel
|
||||
channel2 := th.CreateChannel(Client, team)
|
||||
|
||||
th.InitSystemAdmin()
|
||||
AdminClient := th.SystemAdminClient
|
||||
adminTeam := th.SystemAdminTeam
|
||||
adminUser := th.CreateUser(th.SystemAdminClient)
|
||||
th.LinkUserToTeam(adminUser, adminTeam)
|
||||
|
||||
post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"}
|
||||
rpost1, err := Client.CreatePost(post1)
|
||||
if err != nil {
|
||||
|
|
@ -142,7 +144,7 @@ func TestCreatePost(t *testing.T) {
|
|||
} else if rpost9 := resp.Data.(*model.Post); len(rpost9.FileIds) != 3 {
|
||||
t.Fatal("post should have 3 files")
|
||||
} else {
|
||||
infos := store.Must(adm.App.Srv.Store.FileInfo().GetForPost(rpost9.Id, true, true)).([]*model.FileInfo)
|
||||
infos := store.Must(th.App.Srv.Store.FileInfo().GetForPost(rpost9.Id, true, true)).([]*model.FileInfo)
|
||||
|
||||
if len(infos) != 3 {
|
||||
t.Fatal("should've attached all 3 files to post")
|
||||
|
|
@ -164,7 +166,7 @@ func TestCreatePost(t *testing.T) {
|
|||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
utils.License().Features.SetDefaults()
|
||||
|
||||
defaultChannel := store.Must(adm.App.Srv.Store.Channel().GetByName(team.Id, model.DEFAULT_CHANNEL, true)).(*model.Channel)
|
||||
defaultChannel := store.Must(th.App.Srv.Store.Channel().GetByName(team.Id, model.DEFAULT_CHANNEL, true)).(*model.Channel)
|
||||
defaultPost := &model.Post{
|
||||
ChannelId: defaultChannel.Id,
|
||||
Message: "Default Channel Post",
|
||||
|
|
@ -173,7 +175,7 @@ func TestCreatePost(t *testing.T) {
|
|||
t.Fatal("should have failed -- ExperimentalTownSquareIsReadOnly is true and it's a read only channel")
|
||||
}
|
||||
|
||||
adminDefaultChannel := store.Must(adm.App.Srv.Store.Channel().GetByName(adminTeam.Id, model.DEFAULT_CHANNEL, true)).(*model.Channel)
|
||||
adminDefaultChannel := store.Must(th.App.Srv.Store.Channel().GetByName(adminTeam.Id, model.DEFAULT_CHANNEL, true)).(*model.Channel)
|
||||
adminDefaultPost := &model.Post{
|
||||
ChannelId: adminDefaultChannel.Id,
|
||||
Message: "Admin Default Channel Post",
|
||||
|
|
@ -188,6 +190,8 @@ func TestCreatePostWithCreateAt(t *testing.T) {
|
|||
// An ordinary user cannot use CreateAt
|
||||
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -204,8 +208,8 @@ func TestCreatePostWithCreateAt(t *testing.T) {
|
|||
|
||||
// But a System Admin user can
|
||||
|
||||
th2 := Setup().InitSystemAdmin()
|
||||
SysClient := th2.SystemAdminClient
|
||||
th.InitSystemAdmin()
|
||||
SysClient := th.SystemAdminClient
|
||||
|
||||
if resp, err := SysClient.CreatePost(post); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -221,6 +225,8 @@ func testCreatePostWithOutgoingHook(
|
|||
triggerWhen int,
|
||||
) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
user := th.SystemAdminUser
|
||||
|
|
@ -382,6 +388,8 @@ func TestCreatePostWithOutgoingHook_no_content_type(t *testing.T) {
|
|||
|
||||
func TestUpdatePost(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -510,6 +518,8 @@ func TestUpdatePost(t *testing.T) {
|
|||
|
||||
func TestGetPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -565,6 +575,8 @@ func TestGetPosts(t *testing.T) {
|
|||
|
||||
func TestGetPostsSince(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -625,6 +637,8 @@ func TestGetPostsSince(t *testing.T) {
|
|||
|
||||
func TestGetPostsBeforeAfter(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -693,6 +707,8 @@ func TestGetPostsBeforeAfter(t *testing.T) {
|
|||
|
||||
func TestSearchPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -739,6 +755,8 @@ func TestSearchPosts(t *testing.T) {
|
|||
|
||||
func TestSearchHashtagPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -760,6 +778,8 @@ func TestSearchHashtagPosts(t *testing.T) {
|
|||
|
||||
func TestSearchPostsInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
team := th.BasicTeam
|
||||
|
|
@ -829,6 +849,8 @@ func TestSearchPostsInChannel(t *testing.T) {
|
|||
|
||||
func TestSearchPostsFromUser(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
team := th.BasicTeam
|
||||
|
|
@ -838,7 +860,7 @@ func TestSearchPostsFromUser(t *testing.T) {
|
|||
Client.Must(Client.AddChannelMember(channel1.Id, th.BasicUser2.Id))
|
||||
Client.Must(Client.AddChannelMember(channel2.Id, th.BasicUser2.Id))
|
||||
user3 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user3, team)
|
||||
th.LinkUserToTeam(user3, team)
|
||||
Client.Must(Client.AddChannelMember(channel1.Id, user3.Id))
|
||||
Client.Must(Client.AddChannelMember(channel2.Id, user3.Id))
|
||||
|
||||
|
|
@ -896,6 +918,8 @@ func TestSearchPostsFromUser(t *testing.T) {
|
|||
|
||||
func TestGetPostsCache(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -935,6 +959,8 @@ func TestGetPostsCache(t *testing.T) {
|
|||
|
||||
func TestDeletePosts(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
team1 := th.BasicTeam
|
||||
|
|
@ -989,7 +1015,7 @@ func TestDeletePosts(t *testing.T) {
|
|||
post4b = Client.Must(Client.CreatePost(post4b)).Data.(*model.Post)
|
||||
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
SystemAdminClient.Must(SystemAdminClient.JoinChannel(channel1.Id))
|
||||
|
||||
th.LoginBasic2()
|
||||
|
|
@ -1010,7 +1036,7 @@ func TestDeletePosts(t *testing.T) {
|
|||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
utils.License().Features.SetDefaults()
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser2, th.BasicTeam)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser2, th.BasicTeam)
|
||||
|
||||
Client.Logout()
|
||||
th.LoginBasic2()
|
||||
|
|
@ -1081,6 +1107,8 @@ func TestDeletePosts(t *testing.T) {
|
|||
|
||||
func TestEmailMention(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
Client.Must(Client.AddChannelMember(channel1.Id, th.BasicUser2.Id))
|
||||
|
|
@ -1143,6 +1171,8 @@ func TestEmailMention(t *testing.T) {
|
|||
|
||||
func TestFuzzyPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -1158,6 +1188,8 @@ func TestFuzzyPosts(t *testing.T) {
|
|||
|
||||
func TestGetFlaggedPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user1 := th.BasicUser
|
||||
post1 := th.BasicPost
|
||||
|
|
@ -1198,6 +1230,7 @@ func TestGetFlaggedPosts(t *testing.T) {
|
|||
|
||||
func TestGetMessageForNotification(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
testPng := store.Must(th.App.Srv.Store.FileInfo().Save(&model.FileInfo{
|
||||
CreatorId: model.NewId(),
|
||||
|
|
@ -1273,6 +1306,8 @@ func TestGetMessageForNotification(t *testing.T) {
|
|||
|
||||
func TestGetFileInfosForPost(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -1311,6 +1346,8 @@ func TestGetFileInfosForPost(t *testing.T) {
|
|||
|
||||
func TestGetPostById(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
|
||||
|
|
@ -1341,6 +1378,8 @@ func TestGetPostById(t *testing.T) {
|
|||
|
||||
func TestGetPermalinkTmp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
channel1 := th.BasicChannel
|
||||
team := th.BasicTeam
|
||||
|
|
@ -1408,6 +1447,8 @@ func TestGetPermalinkTmp(t *testing.T) {
|
|||
|
||||
func TestGetOpenGraphMetadata(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
enableLinkPreviews := *utils.Cfg.ServiceSettings.EnableLinkPreviews
|
||||
|
|
@ -1476,6 +1517,8 @@ func TestGetOpenGraphMetadata(t *testing.T) {
|
|||
|
||||
func TestPinPost(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
post := th.BasicPost
|
||||
|
|
@ -1499,6 +1542,8 @@ func TestPinPost(t *testing.T) {
|
|||
|
||||
func TestUnpinPost(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
pinnedPost := th.PinnedPost
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import (
|
|||
|
||||
func TestGetAllPreferences(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user1 := th.BasicUser
|
||||
|
||||
|
|
@ -53,6 +55,8 @@ func TestGetAllPreferences(t *testing.T) {
|
|||
|
||||
func TestSetPreferences(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user1 := th.BasicUser
|
||||
|
||||
|
|
@ -89,6 +93,8 @@ func TestSetPreferences(t *testing.T) {
|
|||
|
||||
func TestGetPreferenceCategory(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user1 := th.BasicUser
|
||||
|
||||
|
|
@ -133,6 +139,8 @@ func TestGetPreferenceCategory(t *testing.T) {
|
|||
|
||||
func TestGetPreference(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user := th.BasicUser
|
||||
|
||||
|
|
@ -165,6 +173,8 @@ func TestGetPreference(t *testing.T) {
|
|||
|
||||
func TestDeletePreferences(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user1 := th.BasicUser
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
func TestSaveReaction(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
|
|
@ -142,6 +143,7 @@ func TestSaveReaction(t *testing.T) {
|
|||
|
||||
func TestDeleteReaction(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
|
|
@ -231,6 +233,7 @@ func TestDeleteReaction(t *testing.T) {
|
|||
|
||||
func TestListReactions(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServer(t *testing.T) {
|
||||
}
|
||||
|
|
@ -15,6 +15,8 @@ import (
|
|||
|
||||
func TestStatuses(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
WebSocketClient, err := th.CreateWebSocketClient()
|
||||
if err != nil {
|
||||
|
|
@ -33,12 +35,12 @@ func TestStatuses(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser2 := Client.Must(Client.CreateUser(&user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(ruser2, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser2, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser2.Id))
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
|
@ -206,6 +208,8 @@ func TestStatuses(t *testing.T) {
|
|||
func TestGetStatusesByIds(t *testing.T) {
|
||||
ReloadConfigForSetup()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if result, err := Client.GetStatusesByIds([]string{th.BasicUser.Id}); err != nil {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import (
|
|||
|
||||
func TestCreateTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -23,7 +25,7 @@ func TestCreateTeam(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(user, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
|
|
@ -56,6 +58,8 @@ func TestCreateTeam(t *testing.T) {
|
|||
|
||||
func TestAddUserToTeam(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.BasicClient.Logout()
|
||||
|
||||
// Test adding a user to a team you are not a member of.
|
||||
|
|
@ -126,7 +130,7 @@ func TestAddUserToTeam(t *testing.T) {
|
|||
}
|
||||
|
||||
// Should work as team admin.
|
||||
UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN
|
||||
utils.SetIsLicensed(true)
|
||||
|
|
@ -158,6 +162,7 @@ func TestAddUserToTeam(t *testing.T) {
|
|||
|
||||
func TestRemoveUserFromTeam(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if _, err := th.BasicClient.RemoveUserFromTeam(th.SystemAdminTeam.Id, th.SystemAdminUser.Id); err == nil {
|
||||
t.Fatal("should fail not enough permissions")
|
||||
|
|
@ -191,6 +196,7 @@ func TestRemoveUserFromTeam(t *testing.T) {
|
|||
|
||||
func TestAddUserToTeamFromInvite(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
user2 := th.CreateUser(th.BasicClient)
|
||||
th.BasicClient.Must(th.BasicClient.Logout())
|
||||
|
|
@ -208,6 +214,8 @@ func TestAddUserToTeamFromInvite(t *testing.T) {
|
|||
|
||||
func TestGetAllTeams(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -217,7 +225,7 @@ func TestGetAllTeams(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
|
|
@ -247,6 +255,8 @@ func TestGetAllTeams(t *testing.T) {
|
|||
|
||||
func TestGetAllTeamListings(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN, AllowOpenInvite: true}
|
||||
|
|
@ -256,7 +266,7 @@ func TestGetAllTeamListings(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
|
|
@ -294,6 +304,8 @@ func TestGetAllTeamListings(t *testing.T) {
|
|||
|
||||
func TestTeamPermDelete(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -303,7 +315,7 @@ func TestTeamPermDelete(t *testing.T) {
|
|||
|
||||
user1 := &model.User{Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user1, team)
|
||||
th.LinkUserToTeam(user1, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.Login(user1.Email, "passwd1")
|
||||
|
|
@ -338,6 +350,8 @@ func TestTeamPermDelete(t *testing.T) {
|
|||
|
||||
func TestInviteMembers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -348,7 +362,7 @@ func TestInviteMembers(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
|
|
@ -379,7 +393,7 @@ func TestInviteMembers(t *testing.T) {
|
|||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
th.LoginBasic2()
|
||||
LinkUserToTeam(th.BasicUser2, team)
|
||||
th.LinkUserToTeam(th.BasicUser2, team)
|
||||
|
||||
if _, err := Client.InviteMembers(invites); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -401,7 +415,7 @@ func TestInviteMembers(t *testing.T) {
|
|||
t.Fatal("should have errored not team admin and licensed")
|
||||
}
|
||||
|
||||
UpdateUserToTeamAdmin(th.BasicUser2, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser2, team)
|
||||
Client.Logout()
|
||||
th.LoginBasic2()
|
||||
Client.SetTeamId(team.Id)
|
||||
|
|
@ -417,7 +431,7 @@ func TestInviteMembers(t *testing.T) {
|
|||
t.Fatal("should have errored not system admin and licensed")
|
||||
}
|
||||
|
||||
LinkUserToTeam(th.SystemAdminUser, team)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, team)
|
||||
|
||||
if _, err := SystemAdminClient.InviteMembers(invites); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -426,6 +440,8 @@ func TestInviteMembers(t *testing.T) {
|
|||
|
||||
func TestUpdateTeamDisplayName(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -435,7 +451,7 @@ func TestUpdateTeamDisplayName(t *testing.T) {
|
|||
|
||||
user2 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.Login(user2.Email, "passwd1")
|
||||
|
|
@ -462,6 +478,8 @@ func TestUpdateTeamDisplayName(t *testing.T) {
|
|||
|
||||
func TestFuzzyTeamCreate(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
for i := 0; i < len(utils.FUZZY_STRINGS_NAMES) || i < len(utils.FUZZY_STRINGS_EMAILS); i++ {
|
||||
|
|
@ -486,6 +504,8 @@ func TestFuzzyTeamCreate(t *testing.T) {
|
|||
|
||||
func TestGetMyTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -496,7 +516,7 @@ func TestGetMyTeam(t *testing.T) {
|
|||
|
||||
user := model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
|
@ -519,6 +539,7 @@ func TestGetMyTeam(t *testing.T) {
|
|||
|
||||
func TestGetTeamMembers(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if result, err := th.BasicClient.GetTeamMembers(th.BasicTeam.Id, 0, 100); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -536,6 +557,7 @@ func TestGetTeamMembers(t *testing.T) {
|
|||
|
||||
func TestGetMyTeamMembers(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if result, err := th.BasicClient.GetMyTeamMembers(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -549,6 +571,7 @@ func TestGetMyTeamMembers(t *testing.T) {
|
|||
|
||||
func TestGetMyTeamsUnread(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if result, err := th.BasicClient.GetMyTeamsUnread(""); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -571,6 +594,7 @@ func TestGetMyTeamsUnread(t *testing.T) {
|
|||
|
||||
func TestGetTeamMember(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if result, err := th.BasicClient.GetTeamMember(th.BasicTeam.Id, th.BasicUser.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -600,6 +624,7 @@ func TestGetTeamMember(t *testing.T) {
|
|||
|
||||
func TestGetTeamMembersByIds(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if result, err := th.BasicClient.GetTeamMembersByIds(th.BasicTeam.Id, []string{th.BasicUser.Id}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -633,8 +658,10 @@ func TestGetTeamMembersByIds(t *testing.T) {
|
|||
|
||||
func TestUpdateTeamMemberRoles(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.SystemAdminClient.SetTeamId(th.BasicTeam.Id)
|
||||
LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
|
||||
const BASIC_MEMBER = "team_user"
|
||||
const TEAM_ADMIN = "team_user team_admin"
|
||||
|
|
@ -696,6 +723,8 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
|
|||
|
||||
func TestGetTeamStats(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if result, err := th.SystemAdminClient.GetTeamStats(th.BasicTeam.Id); err != nil {
|
||||
|
|
@ -753,6 +782,8 @@ func TestGetTeamStats(t *testing.T) {
|
|||
|
||||
func TestUpdateTeamDescription(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -762,7 +793,7 @@ func TestUpdateTeamDescription(t *testing.T) {
|
|||
|
||||
user2 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Jabba the Hutt", Password: "passwd1"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.Login(user2.Email, "passwd1")
|
||||
|
|
@ -789,6 +820,8 @@ func TestUpdateTeamDescription(t *testing.T) {
|
|||
|
||||
func TestGetTeamByName(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN, AllowOpenInvite: false}
|
||||
|
|
@ -867,6 +900,8 @@ func TestGetTeamByName(t *testing.T) {
|
|||
|
||||
func TestFindTeamByName(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
Client.Logout()
|
||||
|
||||
|
|
|
|||
153
api/user_test.go
153
api/user_test.go
|
|
@ -24,6 +24,8 @@ import (
|
|||
|
||||
func TestCreateUser(t *testing.T) {
|
||||
th := Setup()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.CreateClient()
|
||||
|
||||
user := model.User{Email: strings.ToLower("success+"+model.NewId()) + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "hello1", Username: "n" + model.NewId()}
|
||||
|
|
@ -38,7 +40,7 @@ func TestCreateUser(t *testing.T) {
|
|||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
rteam, _ := Client.CreateTeam(&team)
|
||||
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
|
||||
if ruser.Data.(*model.User).Nickname != user.Nickname {
|
||||
t.Fatal("nickname didn't match")
|
||||
|
|
@ -83,6 +85,8 @@ func TestCreateUser(t *testing.T) {
|
|||
|
||||
func TestLogin(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
enableSignInWithEmail := *utils.Cfg.EmailSettings.EnableSignInWithEmail
|
||||
|
|
@ -108,7 +112,7 @@ func TestLogin(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Username: "corey" + model.NewId(), Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
if result, err := Client.LoginById(ruser.Data.(*model.User).Id, user.Password); err != nil {
|
||||
|
|
@ -212,6 +216,8 @@ func TestLogin(t *testing.T) {
|
|||
|
||||
func TestLoginByLdap(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -221,7 +227,7 @@ func TestLoginByLdap(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Username: "corey" + model.NewId(), Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
if _, err := Client.LoginByLdap(ruser.Data.(*model.User).Id, user.Password); err == nil {
|
||||
|
|
@ -231,6 +237,8 @@ func TestLoginByLdap(t *testing.T) {
|
|||
|
||||
func TestLoginWithDeviceId(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user := th.BasicUser
|
||||
Client.Must(Client.Logout())
|
||||
|
|
@ -258,6 +266,8 @@ func TestLoginWithDeviceId(t *testing.T) {
|
|||
|
||||
func TestPasswordGuessLockout(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user := th.BasicUser
|
||||
Client.Must(Client.Logout())
|
||||
|
|
@ -294,6 +304,8 @@ func TestPasswordGuessLockout(t *testing.T) {
|
|||
|
||||
func TestSessions(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user := th.BasicUser
|
||||
Client.Must(Client.Logout())
|
||||
|
|
@ -342,6 +354,8 @@ func TestSessions(t *testing.T) {
|
|||
|
||||
func TestGetUser(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -354,17 +368,17 @@ func TestGetUser(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1", FirstName: "Corey", LastName: "Hulen"}
|
||||
ruser2, _ := Client.CreateUser(&user2, "")
|
||||
LinkUserToTeam(ruser2.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser2.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser2.Data.(*model.User).Id))
|
||||
|
||||
user3 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser3, _ := Client.CreateUser(&user3, "")
|
||||
LinkUserToTeam(ruser3.Data.(*model.User), rteam2.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser3.Data.(*model.User), rteam2.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser3.Data.(*model.User).Id))
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
|
@ -499,6 +513,7 @@ func TestGetUser(t *testing.T) {
|
|||
|
||||
func TestGetProfiles(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.BasicClient.Must(th.BasicClient.CreateDirectChannel(th.BasicUser2.Id))
|
||||
|
||||
|
|
@ -555,6 +570,7 @@ func TestGetProfiles(t *testing.T) {
|
|||
|
||||
func TestGetProfilesByIds(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
prevShowEmail := utils.Cfg.PrivacySettings.ShowEmailAddress
|
||||
defer func() {
|
||||
|
|
@ -610,6 +626,8 @@ func TestGetProfilesByIds(t *testing.T) {
|
|||
|
||||
func TestGetAudits(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -619,7 +637,7 @@ func TestGetAudits(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
|
@ -650,6 +668,8 @@ func TestGetAudits(t *testing.T) {
|
|||
|
||||
func TestUserCreateImage(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
b, err := app.CreateProfileImage("Corey Hulen", "eo1zkdr96pdj98pjmq8zy35wba")
|
||||
|
|
@ -674,7 +694,7 @@ func TestUserCreateImage(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
|
|
@ -714,6 +734,8 @@ func TestUserCreateImage(t *testing.T) {
|
|||
|
||||
func TestUserUploadProfileImage(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -723,7 +745,7 @@ func TestUserUploadProfileImage(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if *utils.Cfg.FileSettings.DriverName != "" {
|
||||
|
|
@ -827,6 +849,8 @@ func TestUserUploadProfileImage(t *testing.T) {
|
|||
|
||||
func TestUserUpdate(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -836,7 +860,7 @@ func TestUserUpdate(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1", Roles: ""}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if _, err := Client.UpdateUser(user); err == nil {
|
||||
|
|
@ -866,7 +890,7 @@ func TestUserUpdate(t *testing.T) {
|
|||
|
||||
user2 := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.Login(user2.Email, "passwd1")
|
||||
|
|
@ -881,6 +905,8 @@ func TestUserUpdate(t *testing.T) {
|
|||
|
||||
func TestUserUpdatePassword(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -891,7 +917,7 @@ func TestUserUpdatePassword(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if _, err := Client.UpdateUserPassword(user.Id, "passwd1", "newpasswd1"); err == nil {
|
||||
|
|
@ -955,7 +981,7 @@ func TestUserUpdatePassword(t *testing.T) {
|
|||
|
||||
user2 := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
Client.Login(user2.Email, "passwd1")
|
||||
|
||||
|
|
@ -966,6 +992,8 @@ func TestUserUpdatePassword(t *testing.T) {
|
|||
|
||||
func TestUserUpdateRoles(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -975,12 +1003,12 @@ func TestUserUpdateRoles(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
user2 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
if _, err := Client.UpdateUserRoles(user.Id, ""); err == nil {
|
||||
|
|
@ -999,7 +1027,7 @@ func TestUserUpdateRoles(t *testing.T) {
|
|||
|
||||
user3 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user3, team2)
|
||||
th.LinkUserToTeam(user3, team2)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user3.Id))
|
||||
|
||||
Client.Login(user3.Email, "passwd1")
|
||||
|
|
@ -1030,8 +1058,10 @@ func TestUserUpdateRoles(t *testing.T) {
|
|||
|
||||
func TestUserUpdateRolesMoreCases(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.SystemAdminClient.SetTeamId(th.BasicTeam.Id)
|
||||
LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
|
||||
const BASIC_USER = "system_user"
|
||||
const SYSTEM_ADMIN = "system_user system_admin"
|
||||
|
|
@ -1087,6 +1117,8 @@ func TestUserUpdateRolesMoreCases(t *testing.T) {
|
|||
|
||||
func TestUserUpdateDeviceId(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1094,7 +1126,7 @@ func TestUserUpdateDeviceId(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
|
|
@ -1118,6 +1150,8 @@ func TestUserUpdateDeviceId(t *testing.T) {
|
|||
|
||||
func TestUserUpdateDeviceId2(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1125,7 +1159,7 @@ func TestUserUpdateDeviceId2(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Login(user.Email, "passwd1")
|
||||
|
|
@ -1149,6 +1183,8 @@ func TestUserUpdateDeviceId2(t *testing.T) {
|
|||
|
||||
func TestUserUpdateActive(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -1162,12 +1198,12 @@ func TestUserUpdateActive(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
user2 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
if _, err := Client.UpdateActive(user.Id, false); err == nil {
|
||||
|
|
@ -1185,7 +1221,7 @@ func TestUserUpdateActive(t *testing.T) {
|
|||
|
||||
user3 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team2)
|
||||
th.LinkUserToTeam(user2, team2)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user3.Id))
|
||||
|
||||
Client.Login(user3.Email, "passwd1")
|
||||
|
|
@ -1221,6 +1257,8 @@ func TestUserUpdateActive(t *testing.T) {
|
|||
|
||||
func TestUserPermDelete(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1228,7 +1266,7 @@ func TestUserPermDelete(t *testing.T) {
|
|||
|
||||
user1 := &model.User{Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user1, team)
|
||||
th.LinkUserToTeam(user1, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.Login(user1.Email, "passwd1")
|
||||
|
|
@ -1263,6 +1301,8 @@ func TestUserPermDelete(t *testing.T) {
|
|||
|
||||
func TestSendPasswordReset(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1270,7 +1310,7 @@ func TestSendPasswordReset(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.Logout()
|
||||
|
|
@ -1295,7 +1335,7 @@ func TestSendPasswordReset(t *testing.T) {
|
|||
authData := model.NewId()
|
||||
user2 := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", AuthData: &authData, AuthService: "random"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
if _, err := Client.SendPasswordReset(user2.Email); err == nil {
|
||||
|
|
@ -1310,7 +1350,7 @@ func TestSendPasswordReset(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
//Delete all the messages before check the reset password
|
||||
|
|
@ -1394,6 +1434,8 @@ func TestSendPasswordReset(t *testing.T) {
|
|||
|
||||
func TestUserUpdateNotify(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1403,7 +1445,7 @@ func TestUserUpdateNotify(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1", Roles: ""}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
data := make(map[string]string)
|
||||
|
|
@ -1478,6 +1520,8 @@ func TestUserUpdateNotify(t *testing.T) {
|
|||
|
||||
func TestFuzzyUserCreate(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1503,12 +1547,14 @@ func TestFuzzyUserCreate(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmailToOAuth(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1518,7 +1564,7 @@ func TestEmailToOAuth(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
m := map[string]string{}
|
||||
|
|
@ -1562,6 +1608,8 @@ func TestEmailToOAuth(t *testing.T) {
|
|||
|
||||
func TestOAuthToEmail(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1571,12 +1619,12 @@ func TestOAuthToEmail(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser2 := Client.Must(Client.CreateUser(&user2, "")).Data.(*model.User)
|
||||
LinkUserToTeam(ruser2, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser2, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser2.Id))
|
||||
|
||||
m := map[string]string{}
|
||||
|
|
@ -1615,6 +1663,8 @@ func TestOAuthToEmail(t *testing.T) {
|
|||
|
||||
func TestLDAPToEmail(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1622,7 +1672,7 @@ func TestLDAPToEmail(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
|
@ -1668,6 +1718,8 @@ func TestLDAPToEmail(t *testing.T) {
|
|||
|
||||
func TestEmailToLDAP(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1675,7 +1727,7 @@ func TestEmailToLDAP(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser, rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
|
@ -1732,6 +1784,7 @@ func TestEmailToLDAP(t *testing.T) {
|
|||
|
||||
func TestMeInitialLoad(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if result, err := th.BasicClient.GetInitialLoad(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -1799,6 +1852,8 @@ func TestMeInitialLoad(t *testing.T) {
|
|||
|
||||
func TestGenerateMfaSecret(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1806,7 +1861,7 @@ func TestGenerateMfaSecret(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
Client.Logout()
|
||||
|
|
@ -1826,6 +1881,8 @@ func TestGenerateMfaSecret(t *testing.T) {
|
|||
|
||||
func TestUpdateMfa(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
isLicensed := utils.IsLicensed()
|
||||
|
|
@ -1847,7 +1904,7 @@ func TestUpdateMfa(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
Client.Logout()
|
||||
|
|
@ -1879,6 +1936,8 @@ func TestUpdateMfa(t *testing.T) {
|
|||
|
||||
func TestCheckMfa(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -1888,7 +1947,7 @@ func TestCheckMfa(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
th.LinkUserToTeam(ruser.Data.(*model.User), rteam.Data.(*model.Team))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
if result, err := Client.CheckMfa(user.Email); err != nil {
|
||||
|
|
@ -1905,6 +1964,8 @@ func TestCheckMfa(t *testing.T) {
|
|||
|
||||
func TestUserTyping(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
WebSocketClient, err := th.CreateWebSocketClient()
|
||||
if err != nil {
|
||||
|
|
@ -1994,6 +2055,8 @@ func TestUserTyping(t *testing.T) {
|
|||
|
||||
func TestGetProfilesInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
prevShowEmail := utils.Cfg.PrivacySettings.ShowEmailAddress
|
||||
|
|
@ -2066,6 +2129,8 @@ func TestGetProfilesInChannel(t *testing.T) {
|
|||
|
||||
func TestGetProfilesNotInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
prevShowEmail := utils.Cfg.PrivacySettings.ShowEmailAddress
|
||||
|
|
@ -2101,7 +2166,7 @@ func TestGetProfilesNotInChannel(t *testing.T) {
|
|||
|
||||
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
LinkUserToTeam(user, th.BasicTeam)
|
||||
th.LinkUserToTeam(user, th.BasicTeam)
|
||||
|
||||
th.LoginBasic2()
|
||||
|
||||
|
|
@ -2150,10 +2215,12 @@ func TestGetProfilesNotInChannel(t *testing.T) {
|
|||
|
||||
func TestSearchUsers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
inactiveUser := th.CreateUser(Client)
|
||||
LinkUserToTeam(inactiveUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(inactiveUser, th.BasicTeam)
|
||||
th.SystemAdminClient.Must(th.SystemAdminClient.UpdateActive(inactiveUser.Id, false))
|
||||
|
||||
if result, err := Client.SearchUsers(model.UserSearch{Term: th.BasicUser.Username}); err != nil {
|
||||
|
|
@ -2304,7 +2371,7 @@ func TestSearchUsers(t *testing.T) {
|
|||
privacyEmailPrefix := strings.ToLower(model.NewId())
|
||||
privacyUser := &model.User{Email: privacyEmailPrefix + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1", FirstName: model.NewId(), LastName: "Jimmers"}
|
||||
privacyUser = Client.Must(Client.CreateUser(privacyUser, "")).Data.(*model.User)
|
||||
LinkUserToTeam(privacyUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(privacyUser, th.BasicTeam)
|
||||
|
||||
if result, err := Client.SearchUsers(model.UserSearch{Term: privacyUser.FirstName}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -2484,6 +2551,8 @@ func TestSearchUsers(t *testing.T) {
|
|||
|
||||
func TestAutocompleteUsers(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if result, err := Client.AutocompleteUsers(th.BasicUser.Username); err != nil {
|
||||
|
|
@ -2592,7 +2661,7 @@ func TestAutocompleteUsers(t *testing.T) {
|
|||
|
||||
privacyUser := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1", FirstName: model.NewId(), LastName: "Jimmers"}
|
||||
privacyUser = Client.Must(Client.CreateUser(privacyUser, "")).Data.(*model.User)
|
||||
LinkUserToTeam(privacyUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(privacyUser, th.BasicTeam)
|
||||
|
||||
if result, err := Client.AutocompleteUsersInChannel(privacyUser.FirstName, th.BasicChannel.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -2631,6 +2700,8 @@ func TestAutocompleteUsers(t *testing.T) {
|
|||
|
||||
func TestGetByUsername(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if result, err := Client.GetByUsername(th.BasicUser.Username, ""); err != nil {
|
||||
|
|
@ -2670,6 +2741,8 @@ func TestGetByUsername(t *testing.T) {
|
|||
|
||||
func TestGetByEmail(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
|
||||
if _, respMetdata := Client.GetByEmail(th.BasicUser.Email, ""); respMetdata.Error != nil {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import (
|
|||
|
||||
func TestCreateIncomingHook(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
team := th.SystemAdminTeam
|
||||
|
|
@ -21,7 +23,7 @@ func TestCreateIncomingHook(t *testing.T) {
|
|||
channel2 := th.CreatePrivateChannel(Client, team)
|
||||
channel3 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -90,7 +92,7 @@ func TestCreateIncomingHook(t *testing.T) {
|
|||
}
|
||||
|
||||
Client.Logout()
|
||||
UpdateUserToTeamAdmin(user2, team)
|
||||
th.UpdateUserToTeamAdmin(user2, team)
|
||||
Client.Must(Client.LoginById(user2.Id, user2.Password))
|
||||
Client.SetTeamId(team.Id)
|
||||
|
||||
|
|
@ -120,6 +122,8 @@ func TestCreateIncomingHook(t *testing.T) {
|
|||
|
||||
func TestUpdateIncomingHook(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
|
||||
|
|
@ -128,12 +132,12 @@ func TestUpdateIncomingHook(t *testing.T) {
|
|||
channel3 := th.CreateChannel(Client, team)
|
||||
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
team2 := th.CreateTeam(Client)
|
||||
user3 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user3, team2)
|
||||
UpdateUserToTeamAdmin(user3, team2)
|
||||
th.LinkUserToTeam(user3, team2)
|
||||
th.UpdateUserToTeamAdmin(user3, team2)
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -255,7 +259,7 @@ func TestUpdateIncomingHook(t *testing.T) {
|
|||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
Client.Logout()
|
||||
UpdateUserToTeamAdmin(user2, team)
|
||||
th.UpdateUserToTeamAdmin(user2, team)
|
||||
Client.Must(Client.LoginById(user2.Id, user2.Password))
|
||||
Client.SetTeamId(team.Id)
|
||||
t.Run("UpdateByDifferentUser", func(t *testing.T) {
|
||||
|
|
@ -326,11 +330,13 @@ func createOutgoingWebhook(channelID string, callbackURLs []string, triggerWords
|
|||
|
||||
func TestListIncomingHooks(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
channel1 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -383,11 +389,13 @@ func TestListIncomingHooks(t *testing.T) {
|
|||
|
||||
func TestDeleteIncomingHook(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
channel1 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -454,6 +462,8 @@ func TestDeleteIncomingHook(t *testing.T) {
|
|||
|
||||
func TestCreateOutgoingHook(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
team := th.SystemAdminTeam
|
||||
|
|
@ -461,9 +471,9 @@ func TestCreateOutgoingHook(t *testing.T) {
|
|||
channel1 := th.CreateChannel(Client, team)
|
||||
channel2 := th.CreatePrivateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
user3 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user3, team2)
|
||||
th.LinkUserToTeam(user3, team2)
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -568,11 +578,13 @@ func TestCreateOutgoingHook(t *testing.T) {
|
|||
|
||||
func TestListOutgoingHooks(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
channel1 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -625,6 +637,8 @@ func TestListOutgoingHooks(t *testing.T) {
|
|||
|
||||
func TestUpdateOutgoingHook(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
team := th.SystemAdminTeam
|
||||
|
|
@ -633,9 +647,9 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
|||
channel2 := th.CreatePrivateChannel(Client, team)
|
||||
channel3 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
user3 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user3, team2)
|
||||
th.LinkUserToTeam(user3, team2)
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -732,8 +746,8 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
|||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
Client.Logout()
|
||||
LinkUserToTeam(user3, team)
|
||||
UpdateUserToTeamAdmin(user3, team)
|
||||
th.LinkUserToTeam(user3, team)
|
||||
th.UpdateUserToTeamAdmin(user3, team)
|
||||
Client.Must(Client.LoginById(user3.Id, user3.Password))
|
||||
Client.SetTeamId(team.Id)
|
||||
t.Run("RetainHookCreator", func(t *testing.T) {
|
||||
|
|
@ -807,11 +821,13 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
|||
|
||||
func TestDeleteOutgoingHook(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
channel1 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -878,14 +894,16 @@ func TestDeleteOutgoingHook(t *testing.T) {
|
|||
|
||||
func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
team2 := th.CreateTeam(Client)
|
||||
channel1 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
user3 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user3, team2)
|
||||
th.LinkUserToTeam(user3, team2)
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
|
||||
|
|
@ -957,11 +975,13 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
|||
|
||||
func TestIncomingWebhooks(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
team := th.SystemAdminTeam
|
||||
channel1 := th.CreateChannel(Client, team)
|
||||
user2 := th.CreateUser(Client)
|
||||
LinkUserToTeam(user2, team)
|
||||
th.LinkUserToTeam(user2, team)
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
defer func() {
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ import (
|
|||
|
||||
func TestWebSocket(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
WebSocketClient, err := th.CreateWebSocketClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -177,6 +179,8 @@ func TestWebSocket(t *testing.T) {
|
|||
|
||||
func TestWebSocketEvent(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
WebSocketClient, err := th.CreateWebSocketClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -252,6 +256,8 @@ func TestWebSocketEvent(t *testing.T) {
|
|||
|
||||
func TestCreateDirectChannelWithSocket(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.BasicClient
|
||||
user2 := th.BasicUser2
|
||||
|
||||
|
|
@ -314,7 +320,8 @@ func TestCreateDirectChannelWithSocket(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWebsocketOriginSecurity(t *testing.T) {
|
||||
Setup().InitBasic()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
url := "ws://localhost" + *utils.Cfg.ServiceSettings.ListenAddress
|
||||
|
||||
|
|
@ -372,12 +379,3 @@ func TestWebsocketOriginSecurity(t *testing.T) {
|
|||
|
||||
*utils.Cfg.ServiceSettings.AllowCorsFrom = ""
|
||||
}
|
||||
|
||||
func TestZZWebSocketTearDown(t *testing.T) {
|
||||
// *IMPORTANT* - Kind of hacky
|
||||
// This should be the last function in any test file
|
||||
// that calls Setup()
|
||||
// Should be in the last file too sorted by name
|
||||
time.Sleep(2 * time.Second)
|
||||
TearDown()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package api4
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -46,7 +47,7 @@ type TestHelper struct {
|
|||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
th := &TestHelper{
|
||||
App: app.Global(),
|
||||
App: app.New(),
|
||||
}
|
||||
|
||||
if th.App.Srv == nil {
|
||||
|
|
@ -75,9 +76,7 @@ func setupTestHelper(enterprise bool) *TestHelper {
|
|||
utils.License().Features.SetDefaults()
|
||||
}
|
||||
|
||||
if th.App.Jobs.Store == nil {
|
||||
th.App.Jobs.Store = th.App.Srv.Store
|
||||
}
|
||||
th.App.Jobs.Store = th.App.Srv.Store
|
||||
|
||||
th.Client = th.CreateClient()
|
||||
th.SystemAdminClient = th.CreateClient()
|
||||
|
|
@ -92,13 +91,7 @@ func Setup() *TestHelper {
|
|||
return setupTestHelper(false)
|
||||
}
|
||||
|
||||
func StopServer() {
|
||||
if app.Global().Srv != nil {
|
||||
app.Global().StopServer()
|
||||
}
|
||||
}
|
||||
|
||||
func TearDown() {
|
||||
func (me *TestHelper) TearDown() {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
|
@ -108,13 +101,13 @@ func TearDown() {
|
|||
defer wg.Done()
|
||||
options := map[string]bool{}
|
||||
options[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
|
||||
if result := <-app.Global().Srv.Store.User().Search("", "fakeuser", options); result.Err != nil {
|
||||
if result := <-me.App.Srv.Store.User().Search("", "fakeuser", options); result.Err != nil {
|
||||
l4g.Error("Error tearing down test users")
|
||||
} else {
|
||||
users := result.Data.([]*model.User)
|
||||
|
||||
for _, u := range users {
|
||||
if err := app.Global().PermanentDeleteUser(u); err != nil {
|
||||
if err := me.App.PermanentDeleteUser(u); err != nil {
|
||||
l4g.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
|
@ -123,13 +116,13 @@ func TearDown() {
|
|||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if result := <-app.Global().Srv.Store.Team().SearchByName("faketeam"); result.Err != nil {
|
||||
if result := <-me.App.Srv.Store.Team().SearchByName("faketeam"); result.Err != nil {
|
||||
l4g.Error("Error tearing down test teams")
|
||||
} else {
|
||||
teams := result.Data.([]*model.Team)
|
||||
|
||||
for _, t := range teams {
|
||||
if err := app.Global().PermanentDeleteTeam(t); err != nil {
|
||||
if err := me.App.PermanentDeleteTeam(t); err != nil {
|
||||
l4g.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
|
@ -138,14 +131,14 @@ func TearDown() {
|
|||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if result := <-app.Global().Srv.Store.OAuth().GetApps(0, 1000); result.Err != nil {
|
||||
if result := <-me.App.Srv.Store.OAuth().GetApps(0, 1000); result.Err != nil {
|
||||
l4g.Error("Error tearing down test oauth apps")
|
||||
} else {
|
||||
apps := result.Data.([]*model.OAuthApp)
|
||||
|
||||
for _, a := range apps {
|
||||
if strings.HasPrefix(a.Name, "fakeoauthapp") {
|
||||
<-app.Global().Srv.Store.OAuth().DeleteApp(a.Id)
|
||||
<-me.App.Srv.Store.OAuth().DeleteApp(a.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -153,6 +146,8 @@ func TearDown() {
|
|||
|
||||
wg.Wait()
|
||||
|
||||
me.App.Shutdown()
|
||||
|
||||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
|
|
@ -165,9 +160,9 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
|||
me.BasicChannel2 = me.CreatePublicChannel()
|
||||
me.BasicPost = me.CreatePost()
|
||||
me.BasicUser = me.CreateUser()
|
||||
LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
me.LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
me.BasicUser2 = me.CreateUser()
|
||||
LinkUserToTeam(me.BasicUser2, me.BasicTeam)
|
||||
me.LinkUserToTeam(me.BasicUser2, me.BasicTeam)
|
||||
me.App.AddUserToChannel(me.BasicUser, me.BasicChannel)
|
||||
me.App.AddUserToChannel(me.BasicUser2, me.BasicChannel)
|
||||
me.App.AddUserToChannel(me.BasicUser, me.BasicChannel2)
|
||||
|
|
@ -232,9 +227,10 @@ func (me *TestHelper) CreateUserWithClient(client *model.Client4) *model.User {
|
|||
}
|
||||
|
||||
utils.DisableDebugLogForTest()
|
||||
ruser, _ := client.CreateUser(user)
|
||||
ruser, r := client.CreateUser(user)
|
||||
fmt.Println(r)
|
||||
ruser.Password = "Password1"
|
||||
VerifyUserEmail(ruser.Id)
|
||||
store.Must(me.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
utils.EnableDebugLogForTest()
|
||||
return ruser
|
||||
}
|
||||
|
|
@ -379,10 +375,10 @@ func (me *TestHelper) UpdateActiveUser(user *model.User, active bool) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
err := app.Global().JoinUserToTeam(team, user, "")
|
||||
err := me.App.JoinUserToTeam(team, user, "")
|
||||
if err != nil {
|
||||
l4g.Error(err.Error())
|
||||
l4g.Close()
|
||||
|
|
@ -417,10 +413,6 @@ func GenerateTestId() string {
|
|||
return model.NewId()
|
||||
}
|
||||
|
||||
func VerifyUserEmail(userId string) {
|
||||
store.Must(app.Global().Srv.Store.User().VerifyEmail(userId))
|
||||
}
|
||||
|
||||
func CheckUserSanitization(t *testing.T, user *model.User) {
|
||||
if user.Password != "" {
|
||||
t.Fatal("password wasn't blank")
|
||||
|
|
@ -683,13 +675,13 @@ func cleanupTestFile(info *model.FileInfo) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
|
||||
func (me *TestHelper) MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
if cmr := <-app.Global().Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
|
||||
if cmr := <-me.App.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
|
||||
cm := cmr.Data.(*model.ChannelMember)
|
||||
cm.Roles = "channel_admin channel_user"
|
||||
if sr := <-app.Global().Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
|
||||
if sr := <-me.App.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
|
||||
utils.EnableDebugLogForTest()
|
||||
panic(sr.Err)
|
||||
}
|
||||
|
|
@ -701,11 +693,11 @@ func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
|
||||
func (me *TestHelper) UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id + " " + model.ROLE_TEAM_ADMIN.Id}
|
||||
if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
utils.EnableDebugLogForTest()
|
||||
l4g.Error(tmr.Err.Error())
|
||||
l4g.Close()
|
||||
|
|
@ -715,11 +707,11 @@ func UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
|
||||
func (me *TestHelper) UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id}
|
||||
if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
if tmr := <-me.App.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
|
||||
utils.EnableDebugLogForTest()
|
||||
l4g.Error(tmr.Err.Error())
|
||||
l4g.Close()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
func TestGetBrandImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
_, resp := Client.GetBrandImage()
|
||||
|
|
@ -26,7 +26,7 @@ func TestGetBrandImage(t *testing.T) {
|
|||
|
||||
func TestUploadBrandImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
data, err := readTestFile("test.png")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
func TestCreateChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ func TestCreateChannel(t *testing.T) {
|
|||
|
||||
func TestUpdateChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ func TestUpdateChannel(t *testing.T) {
|
|||
|
||||
func TestPatchChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
patch := &model.ChannelPatch{
|
||||
|
|
@ -317,7 +317,7 @@ func TestPatchChannel(t *testing.T) {
|
|||
|
||||
func TestCreateDirectChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
|
@ -369,7 +369,7 @@ func TestCreateDirectChannel(t *testing.T) {
|
|||
|
||||
func TestCreateGroupChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
|
@ -441,7 +441,7 @@ func TestCreateGroupChannel(t *testing.T) {
|
|||
|
||||
func TestGetChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
channel, resp := Client.GetChannel(th.BasicChannel.Id, "")
|
||||
|
|
@ -490,7 +490,7 @@ func TestGetChannel(t *testing.T) {
|
|||
|
||||
func TestGetDeletedChannelsForTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -537,7 +537,7 @@ func TestGetDeletedChannelsForTeam(t *testing.T) {
|
|||
|
||||
func TestGetPublicChannelsForTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
publicChannel1 := th.BasicChannel
|
||||
|
|
@ -617,7 +617,7 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
|
|||
|
||||
func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
input := []string{th.BasicChannel.Id}
|
||||
|
|
@ -679,7 +679,7 @@ func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
|
|||
|
||||
func TestGetChannelsForTeamForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
channels, resp := Client.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, "")
|
||||
|
|
@ -727,7 +727,7 @@ func TestGetChannelsForTeamForUser(t *testing.T) {
|
|||
|
||||
func TestSearchChannels(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
search := &model.ChannelSearch{Term: th.BasicChannel.Name}
|
||||
|
|
@ -782,7 +782,7 @@ func TestSearchChannels(t *testing.T) {
|
|||
|
||||
func TestDeleteChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
user := th.BasicUser
|
||||
|
|
@ -876,7 +876,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
_, resp = th.SystemAdminClient.DeleteChannel(publicChannel5.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th = Setup().InitBasic().InitSystemAdmin()
|
||||
th.InitBasic().InitSystemAdmin()
|
||||
|
||||
isLicensed := utils.IsLicensed()
|
||||
license := utils.License()
|
||||
|
|
@ -934,8 +934,8 @@ func TestDeleteChannel(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// successful delete by channel admin
|
||||
MakeUserChannelAdmin(user, publicChannel6)
|
||||
MakeUserChannelAdmin(user, privateChannel7)
|
||||
th.MakeUserChannelAdmin(user, publicChannel6)
|
||||
th.MakeUserChannelAdmin(user, privateChannel7)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
_, resp = Client.DeleteChannel(publicChannel6.Id)
|
||||
|
|
@ -952,7 +952,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
th.App.AddUserToChannel(user2, privateChannel7)
|
||||
|
||||
// successful delete by team admin
|
||||
UpdateUserToTeamAdmin(user, team)
|
||||
th.UpdateUserToTeamAdmin(user, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -967,7 +967,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
*utils.Cfg.TeamSettings.RestrictPublicChannelDeletion = model.PERMISSIONS_TEAM_ADMIN
|
||||
*utils.Cfg.TeamSettings.RestrictPrivateChannelDeletion = model.PERMISSIONS_TEAM_ADMIN
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
UpdateUserToNonTeamAdmin(user, team)
|
||||
th.UpdateUserToNonTeamAdmin(user, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -988,8 +988,8 @@ func TestDeleteChannel(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// // cannot delete by channel admin
|
||||
MakeUserChannelAdmin(user, publicChannel6)
|
||||
MakeUserChannelAdmin(user, privateChannel7)
|
||||
th.MakeUserChannelAdmin(user, publicChannel6)
|
||||
th.MakeUserChannelAdmin(user, privateChannel7)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
_, resp = Client.DeleteChannel(publicChannel6.Id)
|
||||
|
|
@ -999,7 +999,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// successful delete by team admin
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1030,8 +1030,8 @@ func TestDeleteChannel(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// cannot delete by channel admin
|
||||
MakeUserChannelAdmin(user, publicChannel6)
|
||||
MakeUserChannelAdmin(user, privateChannel7)
|
||||
th.MakeUserChannelAdmin(user, publicChannel6)
|
||||
th.MakeUserChannelAdmin(user, privateChannel7)
|
||||
sqlstore.ClearChannelCaches()
|
||||
|
||||
_, resp = Client.DeleteChannel(publicChannel6.Id)
|
||||
|
|
@ -1041,7 +1041,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// cannot delete by team admin
|
||||
UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1073,7 +1073,7 @@ func TestDeleteChannel(t *testing.T) {
|
|||
|
||||
func TestRestoreChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
publicChannel1 := th.CreatePublicChannel()
|
||||
|
|
@ -1099,7 +1099,7 @@ func TestRestoreChannel(t *testing.T) {
|
|||
|
||||
func TestGetChannelByName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
channel, resp := Client.GetChannelByName(th.BasicChannel.Name, th.BasicTeam.Id, "")
|
||||
|
|
@ -1145,7 +1145,7 @@ func TestGetChannelByName(t *testing.T) {
|
|||
|
||||
func TestGetChannelByNameForTeamName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
channel, resp := th.SystemAdminClient.GetChannelByNameForTeamName(th.BasicChannel.Name, th.BasicTeam.Name, "")
|
||||
|
|
@ -1176,7 +1176,7 @@ func TestGetChannelByNameForTeamName(t *testing.T) {
|
|||
|
||||
func TestGetChannelMembers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
members, resp := Client.GetChannelMembers(th.BasicChannel.Id, 0, 60, "")
|
||||
|
|
@ -1231,7 +1231,7 @@ func TestGetChannelMembers(t *testing.T) {
|
|||
|
||||
func TestGetChannelMembersByIds(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
cm, resp := Client.GetChannelMembersByIds(th.BasicChannel.Id, []string{th.BasicUser.Id})
|
||||
|
|
@ -1278,7 +1278,7 @@ func TestGetChannelMembersByIds(t *testing.T) {
|
|||
|
||||
func TestGetChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
member, resp := Client.GetChannelMember(th.BasicChannel.Id, th.BasicUser.Id, "")
|
||||
|
|
@ -1325,7 +1325,7 @@ func TestGetChannelMember(t *testing.T) {
|
|||
|
||||
func TestGetChannelMembersForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
members, resp := Client.GetChannelMembersForUser(th.BasicUser.Id, th.BasicTeam.Id, "")
|
||||
|
|
@ -1368,7 +1368,7 @@ func TestGetChannelMembersForUser(t *testing.T) {
|
|||
|
||||
func TestViewChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
view := &model.ChannelView{
|
||||
|
|
@ -1439,7 +1439,7 @@ func TestViewChannel(t *testing.T) {
|
|||
|
||||
func TestGetChannelUnread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -1483,7 +1483,7 @@ func TestGetChannelUnread(t *testing.T) {
|
|||
|
||||
func TestGetChannelStats(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.CreatePrivateChannel()
|
||||
|
||||
|
|
@ -1517,7 +1517,7 @@ func TestGetChannelStats(t *testing.T) {
|
|||
|
||||
func TestGetPinnedPosts(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -1556,7 +1556,7 @@ func TestGetPinnedPosts(t *testing.T) {
|
|||
|
||||
func TestUpdateChannelRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
const CHANNEL_ADMIN = "channel_admin channel_user"
|
||||
|
|
@ -1635,7 +1635,7 @@ func TestUpdateChannelRoles(t *testing.T) {
|
|||
|
||||
func TestUpdateChannelNotifyProps(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
props := map[string]string{}
|
||||
|
|
@ -1685,7 +1685,7 @@ func TestUpdateChannelNotifyProps(t *testing.T) {
|
|||
|
||||
func TestAddChannelMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
|
|
@ -1843,7 +1843,7 @@ func TestAddChannelMember(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
Client.Logout()
|
||||
|
||||
MakeUserChannelAdmin(user, privateChannel)
|
||||
th.MakeUserChannelAdmin(user, privateChannel)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1873,7 +1873,7 @@ func TestAddChannelMember(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
Client.Logout()
|
||||
|
||||
UpdateUserToTeamAdmin(user, team)
|
||||
th.UpdateUserToTeamAdmin(user, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -1912,7 +1912,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
user1 := th.BasicUser
|
||||
user2 := th.BasicUser2
|
||||
team := th.BasicTeam
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
pass, resp := Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser2.Id)
|
||||
|
|
@ -1963,7 +1963,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
CheckNoError(t, resp)
|
||||
|
||||
th.LoginBasic()
|
||||
UpdateUserToNonTeamAdmin(user1, team)
|
||||
th.UpdateUserToNonTeamAdmin(user1, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
|
||||
// Test policy does not apply to TE.
|
||||
|
|
@ -2023,7 +2023,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, user2.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
MakeUserChannelAdmin(user1, privateChannel)
|
||||
th.MakeUserChannelAdmin(user1, privateChannel)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
@ -2048,7 +2048,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
|||
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, user2.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
UpdateUserToTeamAdmin(user1, team)
|
||||
th.UpdateUserToTeamAdmin(user1, team)
|
||||
th.App.InvalidateAllCaches()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
func TestGetClusterStatus(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.GetClusterStatus()
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func TestHelpCommand(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
func TestCreateCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
|
||||
|
|
@ -62,7 +62,7 @@ func TestCreateCommand(t *testing.T) {
|
|||
|
||||
func TestUpdateCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
team := th.BasicTeam
|
||||
|
|
@ -148,7 +148,7 @@ func TestUpdateCommand(t *testing.T) {
|
|||
|
||||
func TestDeleteCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
team := th.BasicTeam
|
||||
|
|
@ -211,7 +211,7 @@ func TestDeleteCommand(t *testing.T) {
|
|||
|
||||
func TestListCommands(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
newCmd := &model.Command{
|
||||
|
|
@ -288,7 +288,7 @@ func TestListCommands(t *testing.T) {
|
|||
|
||||
func TestListAutocompleteCommands(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
newCmd := &model.Command{
|
||||
|
|
@ -348,7 +348,7 @@ func TestListAutocompleteCommands(t *testing.T) {
|
|||
|
||||
func TestRegenToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
|
||||
|
|
@ -383,7 +383,7 @@ func TestRegenToken(t *testing.T) {
|
|||
|
||||
func TestExecuteCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func TestElasticsearchTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.TestElasticsearch()
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
|
@ -20,7 +20,7 @@ func TestElasticsearchTest(t *testing.T) {
|
|||
|
||||
func TestElasticsearchPurgeIndexes(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.PurgeElasticsearchIndexes()
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
func TestCreateEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
@ -143,7 +143,7 @@ func TestCreateEmoji(t *testing.T) {
|
|||
|
||||
func TestGetEmojiList(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
@ -213,7 +213,7 @@ func TestGetEmojiList(t *testing.T) {
|
|||
|
||||
func TestDeleteEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
@ -280,7 +280,7 @@ func TestDeleteEmoji(t *testing.T) {
|
|||
|
||||
func TestGetEmoji(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
@ -309,7 +309,7 @@ func TestGetEmoji(t *testing.T) {
|
|||
|
||||
func TestGetEmojiImage(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
func TestUploadFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.BasicUser
|
||||
|
|
@ -120,7 +120,7 @@ func TestUploadFile(t *testing.T) {
|
|||
|
||||
func TestGetFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ func TestGetFile(t *testing.T) {
|
|||
|
||||
func TestGetFileHeaders(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -234,7 +234,7 @@ func TestGetFileHeaders(t *testing.T) {
|
|||
|
||||
func TestGetFileThumbnail(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ func TestGetFileThumbnail(t *testing.T) {
|
|||
|
||||
func TestGetFileLink(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ func TestGetFileLink(t *testing.T) {
|
|||
|
||||
func TestGetFilePreview(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ func TestGetFilePreview(t *testing.T) {
|
|||
|
||||
func TestGetFileInfo(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -480,7 +480,7 @@ func TestGetFileInfo(t *testing.T) {
|
|||
|
||||
func TestGetPublicFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
func TestCreateJob(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
job := &model.Job{
|
||||
Type: model.JOB_TYPE_DATA_RETENTION,
|
||||
|
|
@ -40,7 +40,7 @@ func TestCreateJob(t *testing.T) {
|
|||
|
||||
func TestGetJob(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
job := &model.Job{
|
||||
Id: model.NewId(),
|
||||
|
|
@ -71,7 +71,7 @@ func TestGetJob(t *testing.T) {
|
|||
|
||||
func TestGetJobs(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
jobType := model.NewId()
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ func TestGetJobs(t *testing.T) {
|
|||
|
||||
func TestGetJobsByType(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
jobType := model.NewId()
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ func TestGetJobsByType(t *testing.T) {
|
|||
|
||||
func TestCancelJob(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
jobs := []*model.Job{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func TestLdapTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.TestLdap()
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
|
@ -20,7 +20,7 @@ func TestLdapTest(t *testing.T) {
|
|||
|
||||
func TestLdapSync(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.SystemAdminClient.SyncLdap()
|
||||
CheckNoError(t, resp)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
func TestCreateOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ func TestCreateOAuthApp(t *testing.T) {
|
|||
|
||||
func TestUpdateOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ func TestUpdateOAuthApp(t *testing.T) {
|
|||
|
||||
func TestGetOAuthApps(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ func TestGetOAuthApps(t *testing.T) {
|
|||
|
||||
func TestGetOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ func TestGetOAuthApp(t *testing.T) {
|
|||
|
||||
func TestGetOAuthAppInfo(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -412,7 +412,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
|||
|
||||
func TestDeleteOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -480,7 +480,7 @@ func TestDeleteOAuthApp(t *testing.T) {
|
|||
|
||||
func TestRegenerateOAuthAppSecret(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
|
|||
|
||||
func TestGetAuthorizedOAuthAppsForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -612,7 +612,7 @@ func TestGetAuthorizedOAuthAppsForUser(t *testing.T) {
|
|||
|
||||
func TestAuthorizeOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -680,7 +680,7 @@ func TestAuthorizeOAuthApp(t *testing.T) {
|
|||
|
||||
func TestDeauthorizeOAuthApp(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import (
|
|||
|
||||
func TestGetOpenGraphMetadata(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
|
||||
enableLinkPreviews := *utils.Cfg.ServiceSettings.EnableLinkPreviews
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ func TestPlugin(t *testing.T) {
|
|||
defer os.RemoveAll(webappDir)
|
||||
|
||||
th := SetupEnterprise().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
enablePlugins := *utils.Cfg.PluginSettings.Enable
|
||||
defer func() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
func TestCreatePost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"}
|
||||
|
|
@ -112,7 +112,7 @@ func testCreatePostWithOutgoingHook(
|
|||
triggerWhen int,
|
||||
) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
user := th.SystemAdminUser
|
||||
team := th.BasicTeam
|
||||
channel := th.BasicChannel
|
||||
|
|
@ -262,7 +262,7 @@ func TestCreatePostWithOutgoingHook_no_content_type(t *testing.T) {
|
|||
|
||||
func TestCreatePostPublic(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"}
|
||||
|
|
@ -307,7 +307,7 @@ func TestCreatePostPublic(t *testing.T) {
|
|||
|
||||
func TestCreatePostAll(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"}
|
||||
|
|
@ -362,7 +362,7 @@ func TestCreatePostAll(t *testing.T) {
|
|||
|
||||
func TestUpdatePost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -441,7 +441,7 @@ func TestUpdatePost(t *testing.T) {
|
|||
|
||||
func TestPatchPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ func TestPatchPost(t *testing.T) {
|
|||
|
||||
func TestPinPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post := th.BasicPost
|
||||
|
|
@ -581,7 +581,7 @@ func TestPinPost(t *testing.T) {
|
|||
|
||||
func TestUnpinPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
pinnedPost := th.CreatePinnedPost()
|
||||
|
|
@ -616,7 +616,7 @@ func TestUnpinPost(t *testing.T) {
|
|||
|
||||
func TestGetPostsForChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post1 := th.CreatePost()
|
||||
|
|
@ -728,7 +728,7 @@ func TestGetPostsForChannel(t *testing.T) {
|
|||
|
||||
func TestGetFlaggedPostsForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
team1 := th.BasicTeam
|
||||
|
|
@ -909,7 +909,7 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
|
|||
|
||||
func TestGetPostsAfterAndBefore(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post1 := th.CreatePost()
|
||||
|
|
@ -993,7 +993,7 @@ func TestGetPostsAfterAndBefore(t *testing.T) {
|
|||
|
||||
func TestGetPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post, resp := Client.GetPost(th.BasicPost.Id, "")
|
||||
|
|
@ -1042,7 +1042,7 @@ func TestGetPost(t *testing.T) {
|
|||
|
||||
func TestDeletePost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
_, resp := Client.DeletePost("")
|
||||
|
|
@ -1080,7 +1080,7 @@ func TestDeletePost(t *testing.T) {
|
|||
|
||||
func TestGetPostThread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "zz" + model.NewId() + "a", RootId: th.BasicPost.Id}
|
||||
|
|
@ -1138,7 +1138,7 @@ func TestGetPostThread(t *testing.T) {
|
|||
|
||||
func TestSearchPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
th.LoginBasic()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1199,7 +1199,7 @@ func TestSearchPosts(t *testing.T) {
|
|||
|
||||
func TestSearchHashtagPosts(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
th.LoginBasic()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1225,7 +1225,7 @@ func TestSearchHashtagPosts(t *testing.T) {
|
|||
|
||||
func TestSearchPostsInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
th.LoginBasic()
|
||||
Client := th.Client
|
||||
|
||||
|
|
@ -1291,12 +1291,12 @@ func TestSearchPostsInChannel(t *testing.T) {
|
|||
|
||||
func TestSearchPostsFromUser(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.LoginTeamAdmin()
|
||||
user := th.CreateUser()
|
||||
LinkUserToTeam(user, th.BasicTeam)
|
||||
th.LinkUserToTeam(user, th.BasicTeam)
|
||||
th.App.AddUserToChannel(user, th.BasicChannel)
|
||||
th.App.AddUserToChannel(user, th.BasicChannel2)
|
||||
|
||||
|
|
@ -1355,7 +1355,7 @@ func TestSearchPostsFromUser(t *testing.T) {
|
|||
|
||||
func TestGetFileInfosForPost(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
fileIds := make([]string, 3, 3)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
func TestGetPreferences(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.LoginBasic()
|
||||
|
|
@ -71,7 +71,7 @@ func TestGetPreferences(t *testing.T) {
|
|||
|
||||
func TestGetPreferencesByCategory(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.LoginBasic()
|
||||
|
|
@ -130,7 +130,7 @@ func TestGetPreferencesByCategory(t *testing.T) {
|
|||
|
||||
func TestGetPreferenceByCategoryAndName(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.LoginBasic()
|
||||
|
|
@ -185,7 +185,7 @@ func TestGetPreferenceByCategoryAndName(t *testing.T) {
|
|||
|
||||
func TestUpdatePreferences(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.LoginBasic()
|
||||
|
|
@ -244,6 +244,7 @@ func TestUpdatePreferences(t *testing.T) {
|
|||
|
||||
func TestUpdatePreferencesWebsocket(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
WebSocketClient, err := th.CreateWebSocketClient()
|
||||
if err != nil {
|
||||
|
|
@ -299,7 +300,7 @@ func TestUpdatePreferencesWebsocket(t *testing.T) {
|
|||
|
||||
func TestDeletePreferences(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.LoginBasic()
|
||||
|
|
@ -346,6 +347,7 @@ func TestDeletePreferences(t *testing.T) {
|
|||
|
||||
func TestDeletePreferencesWebsocket(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
userId := th.BasicUser.Id
|
||||
preferences := &model.Preferences{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
func TestSaveReaction(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
userId := th.BasicUser.Id
|
||||
postId := th.BasicPost.Id
|
||||
|
|
@ -133,7 +133,7 @@ func TestSaveReaction(t *testing.T) {
|
|||
|
||||
func TestGetReactions(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
userId := th.BasicUser.Id
|
||||
user2Id := th.BasicUser2.Id
|
||||
|
|
@ -209,7 +209,7 @@ func TestGetReactions(t *testing.T) {
|
|||
|
||||
func TestDeleteReaction(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
userId := th.BasicUser.Id
|
||||
user2Id := th.BasicUser2.Id
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func TestGetSamlMetadata(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
_, resp := Client.GetSamlMetadata()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
func TestGetUserStatus(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
userStatus, resp := Client.GetUserStatus(th.BasicUser.Id, "")
|
||||
|
|
@ -60,7 +60,7 @@ func TestGetUserStatus(t *testing.T) {
|
|||
|
||||
func TestGetUsersStatusesByIds(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
usersIds := []string{th.BasicUser.Id, th.BasicUser2.Id}
|
||||
|
|
@ -101,7 +101,7 @@ func TestGetUsersStatusesByIds(t *testing.T) {
|
|||
|
||||
func TestUpdateUserStatus(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
toUpdateUserStatus := &model.Status{Status: "online"}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,18 @@ import (
|
|||
"testing"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
app.UseGlobalApp = false
|
||||
}
|
||||
|
||||
func TestGetPing(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
goRoutineHealthThreshold := *utils.Cfg.ServiceSettings.GoroutineHealthThreshold
|
||||
|
|
@ -36,7 +41,7 @@ func TestGetPing(t *testing.T) {
|
|||
|
||||
func TestGetConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
_, resp := Client.GetConfig()
|
||||
|
|
@ -83,7 +88,7 @@ func TestGetConfig(t *testing.T) {
|
|||
|
||||
func TestReloadConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
flag, resp := Client.ReloadConfig()
|
||||
|
|
@ -104,7 +109,7 @@ func TestReloadConfig(t *testing.T) {
|
|||
|
||||
func TestUpdateConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
cfg := th.App.GetConfig()
|
||||
|
|
@ -144,7 +149,7 @@ func TestUpdateConfig(t *testing.T) {
|
|||
|
||||
func TestGetOldClientConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
config, resp := Client.GetOldClientConfig("")
|
||||
|
|
@ -170,7 +175,7 @@ func TestGetOldClientConfig(t *testing.T) {
|
|||
|
||||
func TestGetOldClientLicense(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
license, resp := Client.GetOldClientLicense("")
|
||||
|
|
@ -203,7 +208,7 @@ func TestGetOldClientLicense(t *testing.T) {
|
|||
|
||||
func TestGetAudits(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
audits, resp := th.SystemAdminClient.GetAudits(0, 100, "")
|
||||
|
|
@ -240,7 +245,7 @@ func TestGetAudits(t *testing.T) {
|
|||
|
||||
func TestEmailTest(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
SendEmailNotifications := utils.Cfg.EmailSettings.SendEmailNotifications
|
||||
|
|
@ -269,7 +274,7 @@ func TestEmailTest(t *testing.T) {
|
|||
|
||||
func TestDatabaseRecycle(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
_, resp := Client.DatabaseRecycle()
|
||||
|
|
@ -281,7 +286,7 @@ func TestDatabaseRecycle(t *testing.T) {
|
|||
|
||||
func TestInvalidateCaches(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
flag, resp := Client.InvalidateCaches()
|
||||
|
|
@ -299,7 +304,7 @@ func TestInvalidateCaches(t *testing.T) {
|
|||
|
||||
func TestGetLogs(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
|
|
@ -339,7 +344,7 @@ func TestGetLogs(t *testing.T) {
|
|||
|
||||
func TestPostLog(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
message := make(map[string]string)
|
||||
|
|
@ -358,7 +363,7 @@ func TestPostLog(t *testing.T) {
|
|||
|
||||
func TestUploadLicenseFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
ok, resp := Client.UploadLicenseFile([]byte{})
|
||||
|
|
@ -376,7 +381,7 @@ func TestUploadLicenseFile(t *testing.T) {
|
|||
|
||||
func TestRemoveLicenseFile(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
ok, resp := Client.RemoveLicenseFile()
|
||||
|
|
@ -394,7 +399,7 @@ func TestRemoveLicenseFile(t *testing.T) {
|
|||
|
||||
func TestGetAnalyticsOld(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
rows, resp := Client.GetAnalyticsOld("", "")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
|
||||
func TestCreateTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TEAM_OPEN}
|
||||
|
|
@ -84,7 +84,7 @@ func TestCreateTeam(t *testing.T) {
|
|||
|
||||
func TestGetTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ func TestGetTeam(t *testing.T) {
|
|||
|
||||
func TestGetTeamUnread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
teamUnread, resp := Client.GetTeamUnread(th.BasicTeam.Id, th.BasicUser.Id)
|
||||
|
|
@ -165,7 +165,7 @@ func TestGetTeamUnread(t *testing.T) {
|
|||
|
||||
func TestUpdateTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Description: "Some description", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -263,7 +263,7 @@ func TestUpdateTeam(t *testing.T) {
|
|||
|
||||
func TestPatchTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
||||
|
|
@ -332,7 +332,7 @@ func TestPatchTeam(t *testing.T) {
|
|||
|
||||
func TestSoftDeleteTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN}
|
||||
|
|
@ -374,7 +374,7 @@ func TestSoftDeleteTeam(t *testing.T) {
|
|||
|
||||
func TestPermanentDeleteTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN}
|
||||
|
|
@ -407,7 +407,7 @@ func TestPermanentDeleteTeam(t *testing.T) {
|
|||
|
||||
func TestGetAllTeams(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
team := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: true}
|
||||
|
|
@ -465,7 +465,7 @@ func TestGetAllTeams(t *testing.T) {
|
|||
|
||||
func TestGetTeamByName(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -509,7 +509,7 @@ func TestGetTeamByName(t *testing.T) {
|
|||
|
||||
func TestSearchAllTeams(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
oTeam := th.BasicTeam
|
||||
oTeam.AllowOpenInvite = true
|
||||
|
|
@ -588,7 +588,7 @@ func TestSearchAllTeams(t *testing.T) {
|
|||
|
||||
func TestGetTeamsForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE}
|
||||
|
|
@ -630,7 +630,7 @@ func TestGetTeamsForUser(t *testing.T) {
|
|||
|
||||
func TestGetTeamMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
user := th.BasicUser
|
||||
|
|
@ -667,7 +667,7 @@ func TestGetTeamMember(t *testing.T) {
|
|||
|
||||
func TestGetTeamMembers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
userNotMember := th.CreateUser()
|
||||
|
|
@ -721,7 +721,7 @@ func TestGetTeamMembers(t *testing.T) {
|
|||
|
||||
func TestGetTeamMembersForUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
members, resp := Client.GetTeamMembersForUser(th.BasicUser.Id, "")
|
||||
|
|
@ -759,7 +759,7 @@ func TestGetTeamMembersForUser(t *testing.T) {
|
|||
|
||||
func TestGetTeamMembersByIds(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
tm, resp := Client.GetTeamMembersByIds(th.BasicTeam.Id, []string{th.BasicUser.Id})
|
||||
|
|
@ -797,7 +797,7 @@ func TestGetTeamMembersByIds(t *testing.T) {
|
|||
|
||||
func TestAddTeamMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
otherUser := th.CreateUser()
|
||||
|
|
@ -885,7 +885,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// Update user to team admin
|
||||
UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN
|
||||
utils.SetIsLicensed(true)
|
||||
|
|
@ -911,7 +911,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||
CheckNoError(t, resp)
|
||||
|
||||
// Change permission level to All
|
||||
UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_ALL
|
||||
utils.SetIsLicensed(true)
|
||||
|
|
@ -1010,7 +1010,7 @@ func TestAddTeamMember(t *testing.T) {
|
|||
|
||||
func TestAddTeamMembers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
otherUser := th.CreateUser()
|
||||
|
|
@ -1099,7 +1099,7 @@ func TestAddTeamMembers(t *testing.T) {
|
|||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
// Update user to team admin
|
||||
UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN
|
||||
utils.SetIsLicensed(true)
|
||||
|
|
@ -1125,7 +1125,7 @@ func TestAddTeamMembers(t *testing.T) {
|
|||
CheckNoError(t, resp)
|
||||
|
||||
// Change permission level to All
|
||||
UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
|
||||
th.App.InvalidateAllCaches()
|
||||
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_ALL
|
||||
utils.SetIsLicensed(true)
|
||||
|
|
@ -1141,7 +1141,7 @@ func TestAddTeamMembers(t *testing.T) {
|
|||
|
||||
func TestRemoveTeamMember(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
pass, resp := Client.RemoveTeamMember(th.BasicTeam.Id, th.BasicUser.Id)
|
||||
|
|
@ -1172,7 +1172,7 @@ func TestRemoveTeamMember(t *testing.T) {
|
|||
|
||||
func TestGetTeamStats(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1227,7 +1227,7 @@ func TestGetTeamStats(t *testing.T) {
|
|||
|
||||
func TestUpdateTeamMemberRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -1269,7 +1269,7 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
|
|||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
// user 1 (team admin) demotes system admin (member of a team)
|
||||
LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
|
||||
_, resp = Client.UpdateTeamMemberRoles(th.BasicTeam.Id, th.SystemAdminUser.Id, TEAM_MEMBER)
|
||||
CheckNoError(t, resp)
|
||||
// Note from API v3
|
||||
|
|
@ -1305,7 +1305,7 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
|
|||
|
||||
func TestGetMyTeamsUnread(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.BasicUser
|
||||
|
|
@ -1336,7 +1336,7 @@ func TestGetMyTeamsUnread(t *testing.T) {
|
|||
|
||||
func TestTeamExists(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
@ -1361,7 +1361,7 @@ func TestTeamExists(t *testing.T) {
|
|||
|
||||
func TestImportTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("ImportTeam", func(t *testing.T) {
|
||||
var data []byte
|
||||
|
|
@ -1440,7 +1440,7 @@ func TestImportTeam(t *testing.T) {
|
|||
|
||||
func TestInviteUsersToTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
user1 := GenerateTestEmail()
|
||||
user2 := GenerateTestEmail()
|
||||
|
|
@ -1505,7 +1505,7 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||
|
||||
func TestGetTeamInviteInfo(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
team := th.BasicTeam
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
func TestCreateUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ func TestCreateUser(t *testing.T) {
|
|||
|
||||
func TestCreateUserWithHash(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
t.Run("CreateWithHashHappyPath", func(t *testing.T) {
|
||||
|
|
@ -231,7 +231,7 @@ func TestCreateUserWithHash(t *testing.T) {
|
|||
|
||||
func TestCreateUserWithInviteId(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ func TestCreateUserWithInviteId(t *testing.T) {
|
|||
|
||||
func TestGetMe(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
ruser, resp := Client.GetMe("")
|
||||
|
|
@ -350,7 +350,7 @@ func TestGetMe(t *testing.T) {
|
|||
|
||||
func TestGetUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.CreateUser()
|
||||
|
|
@ -414,7 +414,7 @@ func TestGetUser(t *testing.T) {
|
|||
|
||||
func TestGetUserByUsername(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.BasicUser
|
||||
|
|
@ -475,7 +475,7 @@ func TestGetUserByUsername(t *testing.T) {
|
|||
|
||||
func TestGetUserByEmail(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.CreateUser()
|
||||
|
|
@ -539,7 +539,7 @@ func TestGetUserByEmail(t *testing.T) {
|
|||
|
||||
func TestSearchUsers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
search := &model.UserSearch{Term: th.BasicUser.Username}
|
||||
|
|
@ -728,7 +728,7 @@ func findUserInList(id string, users []*model.User) bool {
|
|||
|
||||
func TestAutocompleteUsers(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
channelId := th.BasicChannel.Id
|
||||
|
|
@ -855,7 +855,7 @@ func TestAutocompleteUsers(t *testing.T) {
|
|||
|
||||
func TestGetProfileImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
||||
|
|
@ -888,6 +888,8 @@ func TestGetProfileImage(t *testing.T) {
|
|||
|
||||
func TestGetUsersByIds(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
|
||||
users, resp := Client.GetUsersByIds([]string{th.BasicUser.Id})
|
||||
|
|
@ -920,6 +922,8 @@ func TestGetUsersByIds(t *testing.T) {
|
|||
|
||||
func TestGetUsersByUsernames(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
|
||||
users, resp := Client.GetUsersByUsernames([]string{th.BasicUser.Username})
|
||||
|
|
@ -952,7 +956,7 @@ func TestGetUsersByUsernames(t *testing.T) {
|
|||
|
||||
func TestUpdateUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.CreateUser()
|
||||
|
|
@ -1008,7 +1012,7 @@ func TestUpdateUser(t *testing.T) {
|
|||
|
||||
func TestPatchUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.CreateUser()
|
||||
|
|
@ -1087,6 +1091,8 @@ func TestPatchUser(t *testing.T) {
|
|||
|
||||
func TestDeleteUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
|
||||
user := th.BasicUser
|
||||
|
|
@ -1117,6 +1123,8 @@ func TestDeleteUser(t *testing.T) {
|
|||
|
||||
func TestUpdateUserRoles(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -1141,6 +1149,8 @@ func TestUpdateUserRoles(t *testing.T) {
|
|||
|
||||
func TestUpdateUserActive(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.Client
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
user := th.BasicUser
|
||||
|
|
@ -1184,7 +1194,7 @@ func TestUpdateUserActive(t *testing.T) {
|
|||
|
||||
func TestGetUsers(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
rusers, resp := Client.GetUsers(0, 60, "")
|
||||
|
|
@ -1226,7 +1236,7 @@ func TestGetUsers(t *testing.T) {
|
|||
|
||||
func TestGetNewUsersInTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
||||
|
|
@ -1255,7 +1265,7 @@ func TestGetNewUsersInTeam(t *testing.T) {
|
|||
|
||||
func TestGetRecentlyActiveUsersInTeam(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
||||
|
|
@ -1284,7 +1294,7 @@ func TestGetRecentlyActiveUsersInTeam(t *testing.T) {
|
|||
|
||||
func TestGetUsersWithoutTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
SystemAdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -1300,7 +1310,7 @@ func TestGetUsersWithoutTeam(t *testing.T) {
|
|||
Password: "Password1",
|
||||
})
|
||||
CheckNoError(t, resp)
|
||||
LinkUserToTeam(user, th.BasicTeam)
|
||||
th.LinkUserToTeam(user, th.BasicTeam)
|
||||
defer th.App.Srv.Store.User().PermanentDelete(user.Id)
|
||||
|
||||
user2, resp := Client.CreateUser(&model.User{
|
||||
|
|
@ -1334,7 +1344,7 @@ func TestGetUsersWithoutTeam(t *testing.T) {
|
|||
|
||||
func TestGetUsersInTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
||||
|
|
@ -1380,7 +1390,7 @@ func TestGetUsersInTeam(t *testing.T) {
|
|||
|
||||
func TestGetUsersNotInTeam(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
|
||||
|
|
@ -1426,7 +1436,7 @@ func TestGetUsersNotInTeam(t *testing.T) {
|
|||
|
||||
func TestGetUsersInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channelId := th.BasicChannel.Id
|
||||
|
||||
|
|
@ -1469,13 +1479,13 @@ func TestGetUsersInChannel(t *testing.T) {
|
|||
|
||||
func TestGetUsersNotInChannel(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
teamId := th.BasicTeam.Id
|
||||
channelId := th.BasicChannel.Id
|
||||
|
||||
user := th.CreateUser()
|
||||
LinkUserToTeam(user, th.BasicTeam)
|
||||
th.LinkUserToTeam(user, th.BasicTeam)
|
||||
|
||||
rusers, resp := Client.GetUsersNotInChannel(teamId, channelId, 0, 60, "")
|
||||
CheckNoError(t, resp)
|
||||
|
|
@ -1510,7 +1520,7 @@ func TestGetUsersNotInChannel(t *testing.T) {
|
|||
|
||||
/*func TestUpdateUserMfa(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
isLicensed := utils.IsLicensed()
|
||||
|
|
@ -1530,7 +1540,7 @@ func TestGetUsersNotInChannel(t *testing.T) {
|
|||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser, _ := Client.CreateUser(&user)
|
||||
LinkUserToTeam(ruser, rteam)
|
||||
th.LinkUserToTeam(ruser, rteam)
|
||||
store.Must(app.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
Client.Logout()
|
||||
|
|
@ -1552,7 +1562,7 @@ func TestGetUsersNotInChannel(t *testing.T) {
|
|||
|
||||
func TestCheckUserMfa(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
required, resp := Client.CheckUserMfa(th.BasicUser.Email)
|
||||
|
|
@ -1609,7 +1619,7 @@ func TestCheckUserMfa(t *testing.T) {
|
|||
|
||||
func TestGenerateMfaSecret(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
_, resp := Client.GenerateMfaSecret(th.BasicUser.Id)
|
||||
|
|
@ -1632,7 +1642,7 @@ func TestGenerateMfaSecret(t *testing.T) {
|
|||
|
||||
func TestUpdateUserPassword(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
password := "newpassword1"
|
||||
|
|
@ -1809,7 +1819,7 @@ func TestUpdateUserPassword(t *testing.T) {
|
|||
|
||||
func TestGetSessions(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.BasicUser
|
||||
|
|
@ -1849,7 +1859,7 @@ func TestGetSessions(t *testing.T) {
|
|||
|
||||
func TestRevokeSessions(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := th.BasicUser
|
||||
|
|
@ -1904,7 +1914,7 @@ func TestRevokeSessions(t *testing.T) {
|
|||
|
||||
func TestAttachDeviceId(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
deviceId := model.PUSH_NOTIFY_APPLE + ":1234567890"
|
||||
|
|
@ -1934,7 +1944,7 @@ func TestAttachDeviceId(t *testing.T) {
|
|||
|
||||
func TestGetUserAudits(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
||||
|
|
@ -1959,7 +1969,7 @@ func TestGetUserAudits(t *testing.T) {
|
|||
|
||||
func TestVerifyUserEmail(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
user := model.User{Email: GenerateTestEmail(), Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.ROLE_SYSTEM_ADMIN.Id + " " + model.ROLE_SYSTEM_USER.Id}
|
||||
|
|
@ -1983,7 +1993,7 @@ func TestVerifyUserEmail(t *testing.T) {
|
|||
|
||||
func TestSendVerificationEmail(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
pass, resp := Client.SendVerificationEmail(th.BasicUser.Email)
|
||||
|
|
@ -2007,7 +2017,7 @@ func TestSendVerificationEmail(t *testing.T) {
|
|||
|
||||
func TestSetProfileImage(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
user := th.BasicUser
|
||||
|
||||
|
|
@ -2058,7 +2068,7 @@ func TestSetProfileImage(t *testing.T) {
|
|||
|
||||
func TestSwitchAccount(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableGitLab := utils.Cfg.GitLabSettings.Enable
|
||||
|
|
@ -2149,7 +2159,7 @@ func TestSwitchAccount(t *testing.T) {
|
|||
|
||||
func TestCreateUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -2223,7 +2233,7 @@ func TestCreateUserAccessToken(t *testing.T) {
|
|||
|
||||
func TestGetUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -2294,7 +2304,7 @@ func TestGetUserAccessToken(t *testing.T) {
|
|||
|
||||
func TestRevokeUserAccessToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
|
|
@ -2342,7 +2352,7 @@ func TestRevokeUserAccessToken(t *testing.T) {
|
|||
|
||||
func TestUserAccessTokenInactiveUser(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
testDescription := "test token"
|
||||
|
|
@ -2369,7 +2379,7 @@ func TestUserAccessTokenInactiveUser(t *testing.T) {
|
|||
|
||||
func TestUserAccessTokenDisableConfig(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
testDescription := "test token"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
func TestCreateIncomingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
|
|
@ -73,7 +73,7 @@ func TestCreateIncomingWebhook(t *testing.T) {
|
|||
|
||||
func TestGetIncomingWebhooks(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
|
|
@ -155,7 +155,7 @@ func TestGetIncomingWebhooks(t *testing.T) {
|
|||
|
||||
func TestGetIncomingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
|
|
@ -203,7 +203,7 @@ func TestGetIncomingWebhook(t *testing.T) {
|
|||
|
||||
func TestDeleteIncomingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
|
|
@ -263,7 +263,7 @@ func TestDeleteIncomingWebhook(t *testing.T) {
|
|||
|
||||
func TestCreateOutgoingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
|
|
@ -316,7 +316,7 @@ func TestCreateOutgoingWebhook(t *testing.T) {
|
|||
|
||||
func TestGetOutgoingWebhooks(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
|
|
@ -425,7 +425,7 @@ func TestGetOutgoingWebhooks(t *testing.T) {
|
|||
|
||||
func TestGetOutgoingWebhook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
|
|
@ -464,7 +464,7 @@ func TestGetOutgoingWebhook(t *testing.T) {
|
|||
|
||||
func TestUpdateIncomingHook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
|
|
@ -585,7 +585,7 @@ func TestUpdateIncomingHook(t *testing.T) {
|
|||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
Client.Logout()
|
||||
UpdateUserToTeamAdmin(th.BasicUser2, th.BasicTeam)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser2, th.BasicTeam)
|
||||
th.LoginBasic2()
|
||||
t.Run("UpdateByDifferentUser", func(t *testing.T) {
|
||||
updatedHook, resp := Client.UpdateIncomingWebhook(createdHook)
|
||||
|
|
@ -622,7 +622,7 @@ func TestUpdateIncomingHook(t *testing.T) {
|
|||
|
||||
team := th.CreateTeamWithClient(Client)
|
||||
user := th.CreateUserWithClient(Client)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
Client.Logout()
|
||||
Client.Login(user.Id, user.Password)
|
||||
t.Run("UpdateToADifferentTeam", func(t *testing.T) {
|
||||
|
|
@ -633,7 +633,7 @@ func TestUpdateIncomingHook(t *testing.T) {
|
|||
|
||||
func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
|
|
@ -674,7 +674,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
|||
|
||||
func TestUpdateOutgoingHook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
|
|
@ -774,7 +774,7 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
|||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
Client.Logout()
|
||||
UpdateUserToTeamAdmin(th.BasicUser2, th.BasicTeam)
|
||||
th.UpdateUserToTeamAdmin(th.BasicUser2, th.BasicTeam)
|
||||
th.LoginBasic2()
|
||||
t.Run("RetainHookCreator", func(t *testing.T) {
|
||||
createdHook.DisplayName = "Basic user 2"
|
||||
|
|
@ -830,7 +830,7 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
|||
|
||||
team := th.CreateTeamWithClient(Client)
|
||||
user := th.CreateUserWithClient(Client)
|
||||
LinkUserToTeam(user, team)
|
||||
th.LinkUserToTeam(user, team)
|
||||
Client.Logout()
|
||||
Client.Login(user.Id, user.Password)
|
||||
t.Run("UpdateToADifferentTeam", func(t *testing.T) {
|
||||
|
|
@ -841,7 +841,7 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
|||
|
||||
func TestDeleteOutgoingHook(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
|
|
@ -903,6 +903,8 @@ func TestDeleteOutgoingHook(t *testing.T) {
|
|||
|
||||
func TestCommandWebhooks(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer th.TearDown()
|
||||
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
cmd := &model.Command{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func TestGetWebrtcToken(t *testing.T) {
|
|||
}
|
||||
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
enableWebrtc := *utils.Cfg.WebrtcSettings.Enable
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
func TestWebSocket(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
defer th.TearDown()
|
||||
WebSocketClient, err := th.CreateWebSocketClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -71,12 +71,3 @@ func TestWebSocket(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestZZWebSocketTearDown(t *testing.T) {
|
||||
// *IMPORTANT* - Kind of hacky
|
||||
// This should be the last function in any test file
|
||||
// that calls Setup()
|
||||
// Should be in the last file too sorted by name
|
||||
time.Sleep(2 * time.Second)
|
||||
StopServer()
|
||||
}
|
||||
|
|
|
|||
34
app/app.go
34
app/app.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/einterfaces"
|
||||
ejobs "github.com/mattermost/mattermost-server/einterfaces/jobs"
|
||||
|
|
@ -44,15 +45,46 @@ var globalApp App = App{
|
|||
Jobs: &jobs.JobServer{},
|
||||
}
|
||||
|
||||
var appCount = 0
|
||||
var initEnterprise sync.Once
|
||||
|
||||
func Global() *App {
|
||||
var UseGlobalApp = true
|
||||
|
||||
// New creates a new App. You must call Shutdown when you're done with it.
|
||||
// XXX: Doesn't necessarily create a new App yet.
|
||||
func New() *App {
|
||||
appCount++
|
||||
|
||||
if !UseGlobalApp {
|
||||
if appCount > 1 {
|
||||
panic("Only one App should exist at a time. Did you forget to call Shutdown()?")
|
||||
}
|
||||
app := &App{
|
||||
Jobs: &jobs.JobServer{},
|
||||
}
|
||||
app.initEnterprise()
|
||||
return app
|
||||
}
|
||||
|
||||
initEnterprise.Do(func() {
|
||||
globalApp.initEnterprise()
|
||||
})
|
||||
return &globalApp
|
||||
}
|
||||
|
||||
func (a *App) Shutdown() {
|
||||
appCount--
|
||||
if appCount == 0 {
|
||||
// XXX: This is to give all of our runaway goroutines time to complete.
|
||||
// We should wrangle them up and remove this.
|
||||
time.Sleep(time.Second)
|
||||
|
||||
if a.Srv != nil {
|
||||
a.StopServer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var accountMigrationInterface func(*App) einterfaces.AccountMigrationInterface
|
||||
|
||||
func RegisterAccountMigrationInterface(f func(*App) einterfaces.AccountMigrationInterface) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ type TestHelper struct {
|
|||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
th := &TestHelper{
|
||||
App: Global(),
|
||||
App: New(),
|
||||
}
|
||||
|
||||
if th.App.Srv == nil {
|
||||
|
|
@ -62,9 +62,9 @@ func Setup() *TestHelper {
|
|||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.BasicTeam = me.CreateTeam()
|
||||
me.BasicUser = me.CreateUser()
|
||||
me.App.LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
me.LinkUserToTeam(me.BasicUser, me.BasicTeam)
|
||||
me.BasicUser2 = me.CreateUser()
|
||||
me.App.LinkUserToTeam(me.BasicUser2, me.BasicTeam)
|
||||
me.LinkUserToTeam(me.BasicUser2, me.BasicTeam)
|
||||
me.BasicChannel = me.CreateChannel(me.BasicTeam)
|
||||
me.BasicPost = me.CreatePost(me.BasicChannel)
|
||||
|
||||
|
|
@ -175,10 +175,10 @@ func (me *TestHelper) CreatePost(channel *model.Channel) *model.Post {
|
|||
return post
|
||||
}
|
||||
|
||||
func (a *App) LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
utils.DisableDebugLogForTest()
|
||||
|
||||
err := a.JoinUserToTeam(team, user, "")
|
||||
err := me.App.JoinUserToTeam(team, user, "")
|
||||
if err != nil {
|
||||
l4g.Error(err.Error())
|
||||
l4g.Close()
|
||||
|
|
@ -189,8 +189,6 @@ func (a *App) LinkUserToTeam(user *model.User, team *model.Team) {
|
|||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func (a *App) TearDown() {
|
||||
if a.Srv != nil {
|
||||
a.StopServer()
|
||||
}
|
||||
func (me *TestHelper) TearDown() {
|
||||
me.App.Shutdown()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,5 +222,7 @@ func (a *App) StopServer() {
|
|||
|
||||
a.ShutDownPlugins()
|
||||
|
||||
a.Srv = nil
|
||||
|
||||
l4g.Info(utils.T("api.server.stop_server.stopped.info"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
func TestCreateWebhookPost(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.App.TearDown()
|
||||
defer th.TearDown()
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
defer func() {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func initDBCommandContext(configFileLocation string) (*app.App, error) {
|
|||
|
||||
utils.ConfigureCmdLineLog()
|
||||
|
||||
a := app.Global()
|
||||
a := app.New()
|
||||
a.NewServer()
|
||||
a.InitStores()
|
||||
if model.BuildEnterpriseReady == "true" {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ func runServer(configFileLocation string) {
|
|||
l4g.Error("Problem with file storage settings: " + err.Error())
|
||||
}
|
||||
|
||||
a := app.Global()
|
||||
a := app.New()
|
||||
defer a.Shutdown()
|
||||
|
||||
a.NewServer()
|
||||
a.InitStores()
|
||||
a.Srv.Router = api.NewRouter()
|
||||
|
|
@ -161,8 +163,6 @@ func runServer(configFileLocation string) {
|
|||
|
||||
a.Jobs.StopSchedulers()
|
||||
a.Jobs.StopWorkers()
|
||||
|
||||
a.StopServer()
|
||||
}
|
||||
|
||||
func runSecurityJob(a *app.App) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ var ApiClient *model.Client
|
|||
var URL string
|
||||
|
||||
func Setup() *app.App {
|
||||
a := app.Global()
|
||||
a := app.New()
|
||||
if a.Srv == nil {
|
||||
utils.TranslationsPreInit()
|
||||
utils.LoadConfig("config.json")
|
||||
|
|
@ -41,9 +41,7 @@ func Setup() *app.App {
|
|||
}
|
||||
|
||||
func TearDown(a *app.App) {
|
||||
if a.Srv != nil {
|
||||
a.StopServer()
|
||||
}
|
||||
a.Shutdown()
|
||||
}
|
||||
|
||||
/* Test disabled for now so we don't requrie the client to build. Maybe re-enable after client gets moved out.
|
||||
|
|
|
|||
Loading…
Reference in a new issue