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
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
b84736e9b6
Коммит
9bc7af0c57
@@ -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()
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user