Commit 4e6cc846 authored by Chris's avatar Chris Committed by Harrison Healey

Finally remove utils.Cfg (#8113)

* finally remove utils.Cfg

* fix compile error

* another test compilation fix
parent dce06163
...@@ -5,6 +5,8 @@ package api ...@@ -5,6 +5,8 @@ package api
import ( import (
"fmt" "fmt"
"io"
"io/ioutil"
"net" "net"
"os" "os"
"strings" "strings"
...@@ -24,7 +26,7 @@ import ( ...@@ -24,7 +26,7 @@ import (
type TestHelper struct { type TestHelper struct {
App *app.App App *app.App
originalConfig *model.Config tempConfigPath string
BasicClient *model.Client BasicClient *model.Client
BasicTeam *model.Team BasicTeam *model.Team
...@@ -64,7 +66,22 @@ func StopTestStore() { ...@@ -64,7 +66,22 @@ func StopTestStore() {
} }
func setupTestHelper(enterprise bool) *TestHelper { func setupTestHelper(enterprise bool) *TestHelper {
options := []app.Option{app.DisableConfigWatch} permConfig, err := os.Open(utils.FindConfigFile("config.json"))
if err != nil {
panic(err)
}
defer permConfig.Close()
tempConfig, err := ioutil.TempFile("", "")
if err != nil {
panic(err)
}
_, err = io.Copy(tempConfig, permConfig)
tempConfig.Close()
if err != nil {
panic(err)
}
options := []app.Option{app.ConfigFile(tempConfig.Name()), app.DisableConfigWatch}
if testStore != nil { if testStore != nil {
options = append(options, app.StoreOverride(testStore)) options = append(options, app.StoreOverride(testStore))
} }
...@@ -75,9 +92,9 @@ func setupTestHelper(enterprise bool) *TestHelper { ...@@ -75,9 +92,9 @@ func setupTestHelper(enterprise bool) *TestHelper {
} }
th := &TestHelper{ th := &TestHelper{
App: a, App: a,
tempConfigPath: tempConfig.Name(),
} }
th.originalConfig = th.App.Config().Clone()
th.App.UpdateConfig(func(cfg *model.Config) { th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.TeamSettings.MaxUsersPerTeam = 50 *cfg.TeamSettings.MaxUsersPerTeam = 50
...@@ -176,7 +193,7 @@ func (me *TestHelper) CreateTeam(client *model.Client) *model.Team { ...@@ -176,7 +193,7 @@ func (me *TestHelper) CreateTeam(client *model.Client) *model.Team {
team := &model.Team{ team := &model.Team{
DisplayName: "dn_" + id, DisplayName: "dn_" + id,
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: me.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
} }
...@@ -190,7 +207,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User { ...@@ -190,7 +207,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User {
id := model.NewId() id := model.NewId()
user := &model.User{ user := &model.User{
Email: GenerateTestEmail(), Email: me.GenerateTestEmail(),
Username: "un_" + id, Username: "un_" + id,
Nickname: "nn_" + id, Nickname: "nn_" + id,
Password: "Password1", Password: "Password1",
...@@ -353,8 +370,8 @@ func (me *TestHelper) LoginSystemAdmin() { ...@@ -353,8 +370,8 @@ func (me *TestHelper) LoginSystemAdmin() {
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
} }
func GenerateTestEmail() string { func (me *TestHelper) GenerateTestEmail() string {
if utils.Cfg.EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" { if me.App.Config().EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" {
return strings.ToLower("success+" + model.NewId() + "@simulator.amazonses.com") return strings.ToLower("success+" + model.NewId() + "@simulator.amazonses.com")
} }
return strings.ToLower(model.NewId() + "@dockerhost") return strings.ToLower(model.NewId() + "@dockerhost")
...@@ -365,11 +382,8 @@ func GenerateTestTeamName() string { ...@@ -365,11 +382,8 @@ func GenerateTestTeamName() string {
} }
func (me *TestHelper) TearDown() { func (me *TestHelper) TearDown() {
me.App.UpdateConfig(func(cfg *model.Config) {
*cfg = *me.originalConfig
})
me.App.Shutdown() me.App.Shutdown()
os.Remove(me.tempConfigPath)
if err := recover(); err != nil { if err := recover(); err != nil {
StopTestStore() StopTestStore()
panic(err) panic(err)
......
...@@ -88,8 +88,6 @@ func TestOAuthRegisterApp(t *testing.T) { ...@@ -88,8 +88,6 @@ func TestOAuthRegisterApp(t *testing.T) {
t.Fatal("should have failed. not enough permissions") t.Fatal("should have failed. not enough permissions")
} }
adminOnly := *th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = adminOnly })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
th.LoginBasic() th.LoginBasic()
...@@ -741,9 +739,6 @@ func TestOAuthComplete(t *testing.T) { ...@@ -741,9 +739,6 @@ func TestOAuthComplete(t *testing.T) {
// We are going to use mattermost as the provider emulating gitlab // We are going to use mattermost as the provider emulating gitlab
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true }) th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
adminOnly := *th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = adminOnly })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false }) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
oauthApp := &model.OAuthApp{ oauthApp := &model.OAuthApp{
......
...@@ -66,7 +66,7 @@ func TestCreateTeamSanitization(t *testing.T) { ...@@ -66,7 +66,7 @@ func TestCreateTeamSanitization(t *testing.T) {
team := &model.Team{ team := &model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
} }
...@@ -84,7 +84,7 @@ func TestCreateTeamSanitization(t *testing.T) { ...@@ -84,7 +84,7 @@ func TestCreateTeamSanitization(t *testing.T) {
team := &model.Team{ team := &model.Team{
DisplayName: t.Name() + "_2", DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
} }
...@@ -304,7 +304,7 @@ func TestGetAllTeamsSanitization(t *testing.T) { ...@@ -304,7 +304,7 @@ func TestGetAllTeamsSanitization(t *testing.T) {
if res, err := th.BasicClient.CreateTeam(&model.Team{ if res, err := th.BasicClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}); err != nil { }); err != nil {
...@@ -317,7 +317,7 @@ func TestGetAllTeamsSanitization(t *testing.T) { ...@@ -317,7 +317,7 @@ func TestGetAllTeamsSanitization(t *testing.T) {
if res, err := th.SystemAdminClient.CreateTeam(&model.Team{ if res, err := th.SystemAdminClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_2", DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}); err != nil { }); err != nil {
...@@ -418,7 +418,7 @@ func TestGetAllTeamListingsSanitization(t *testing.T) { ...@@ -418,7 +418,7 @@ func TestGetAllTeamListingsSanitization(t *testing.T) {
if res, err := th.BasicClient.CreateTeam(&model.Team{ if res, err := th.BasicClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
AllowOpenInvite: true, AllowOpenInvite: true,
...@@ -432,7 +432,7 @@ func TestGetAllTeamListingsSanitization(t *testing.T) { ...@@ -432,7 +432,7 @@ func TestGetAllTeamListingsSanitization(t *testing.T) {
if res, err := th.SystemAdminClient.CreateTeam(&model.Team{ if res, err := th.SystemAdminClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_2", DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
AllowOpenInvite: true, AllowOpenInvite: true,
...@@ -665,7 +665,7 @@ func TestUpdateTeamSanitization(t *testing.T) { ...@@ -665,7 +665,7 @@ func TestUpdateTeamSanitization(t *testing.T) {
if res, err := th.BasicClient.CreateTeam(&model.Team{ if res, err := th.BasicClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}); err != nil { }); err != nil {
...@@ -772,7 +772,7 @@ func TestGetMyTeamSanitization(t *testing.T) { ...@@ -772,7 +772,7 @@ func TestGetMyTeamSanitization(t *testing.T) {
if res, err := th.BasicClient.CreateTeam(&model.Team{ if res, err := th.BasicClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}); err != nil { }); err != nil {
...@@ -1192,7 +1192,7 @@ func TestGetTeamByNameSanitization(t *testing.T) { ...@@ -1192,7 +1192,7 @@ func TestGetTeamByNameSanitization(t *testing.T) {
if res, err := th.BasicClient.CreateTeam(&model.Team{ if res, err := th.BasicClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}); err != nil { }); err != nil {
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"os" "os"
...@@ -33,7 +34,7 @@ import ( ...@@ -33,7 +34,7 @@ import (
type TestHelper struct { type TestHelper struct {
App *app.App App *app.App
originalConfig *model.Config tempConfigPath string
Client *model.Client4 Client *model.Client4
BasicUser *model.User BasicUser *model.User
...@@ -73,7 +74,22 @@ func StopTestStore() { ...@@ -73,7 +74,22 @@ func StopTestStore() {
} }
func setupTestHelper(enterprise bool) *TestHelper { func setupTestHelper(enterprise bool) *TestHelper {
options := []app.Option{app.DisableConfigWatch} permConfig, err := os.Open(utils.FindConfigFile("config.json"))
if err != nil {
panic(err)
}
defer permConfig.Close()
tempConfig, err := ioutil.TempFile("", "")
if err != nil {
panic(err)
}
_, err = io.Copy(tempConfig, permConfig)
tempConfig.Close()
if err != nil {
panic(err)
}
options := []app.Option{app.ConfigFile(tempConfig.Name()), app.DisableConfigWatch}
if testStore != nil { if testStore != nil {
options = append(options, app.StoreOverride(testStore)) options = append(options, app.StoreOverride(testStore))
} }
...@@ -84,9 +100,9 @@ func setupTestHelper(enterprise bool) *TestHelper { ...@@ -84,9 +100,9 @@ func setupTestHelper(enterprise bool) *TestHelper {
} }
th := &TestHelper{ th := &TestHelper{
App: a, App: a,
tempConfigPath: tempConfig.Name(),
} }
th.originalConfig = th.App.Config().Clone()
th.App.UpdateConfig(func(cfg *model.Config) { th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.TeamSettings.MaxUsersPerTeam = 50 *cfg.TeamSettings.MaxUsersPerTeam = 50
...@@ -178,11 +194,8 @@ func (me *TestHelper) TearDown() { ...@@ -178,11 +194,8 @@ func (me *TestHelper) TearDown() {
wg.Wait() wg.Wait()
me.App.UpdateConfig(func(cfg *model.Config) {
*cfg = *me.originalConfig
})
me.App.Shutdown() me.App.Shutdown()
os.Remove(me.tempConfigPath)
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
...@@ -262,7 +275,7 @@ func (me *TestHelper) CreateTeamWithClient(client *model.Client4) *model.Team { ...@@ -262,7 +275,7 @@ func (me *TestHelper) CreateTeamWithClient(client *model.Client4) *model.Team {
team := &model.Team{ team := &model.Team{
DisplayName: "dn_" + id, DisplayName: "dn_" + id,
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: me.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
} }
...@@ -276,7 +289,7 @@ func (me *TestHelper) CreateUserWithClient(client *model.Client4) *model.User { ...@@ -276,7 +289,7 @@ func (me *TestHelper) CreateUserWithClient(client *model.Client4) *model.User {
id := model.NewId() id := model.NewId()
user := &model.User{ user := &model.User{
Email: GenerateTestEmail(), Email: me.GenerateTestEmail(),
Username: GenerateTestUsername(), Username: GenerateTestUsername(),
Nickname: "nn_" + id, Nickname: "nn_" + id,
FirstName: "f_" + id, FirstName: "f_" + id,
...@@ -451,8 +464,8 @@ func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) { ...@@ -451,8 +464,8 @@ func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) {
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
} }
func GenerateTestEmail() string { func (me *TestHelper) GenerateTestEmail() string {
if utils.Cfg.EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" { if me.App.Config().EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" {
return strings.ToLower("success+" + model.NewId() + "@simulator.amazonses.com") return strings.ToLower("success+" + model.NewId() + "@simulator.amazonses.com")
} }
return strings.ToLower(model.NewId() + "@dockerhost") return strings.ToLower(model.NewId() + "@dockerhost")
......
...@@ -323,7 +323,7 @@ func TestCreatePostPublic(t *testing.T) { ...@@ -323,7 +323,7 @@ func TestCreatePostPublic(t *testing.T) {
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"} post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"}
user := model.User{Email: GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_USER_ROLE_ID} user := model.User{Email: th.GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_USER_ROLE_ID}
ruser, resp := Client.CreateUser(&user) ruser, resp := Client.CreateUser(&user)
CheckNoError(t, resp) CheckNoError(t, resp)
...@@ -368,7 +368,7 @@ func TestCreatePostAll(t *testing.T) { ...@@ -368,7 +368,7 @@ func TestCreatePostAll(t *testing.T) {
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"} post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"}
user := model.User{Email: GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_USER_ROLE_ID} user := model.User{Email: th.GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_USER_ROLE_ID}
directChannel, _ := th.App.CreateDirectChannel(th.BasicUser.Id, th.BasicUser2.Id) directChannel, _ := th.App.CreateDirectChannel(th.BasicUser.Id, th.BasicUser2.Id)
......
...@@ -91,7 +91,7 @@ func TestCreateTeamSanitization(t *testing.T) { ...@@ -91,7 +91,7 @@ func TestCreateTeamSanitization(t *testing.T) {
team := &model.Team{ team := &model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
} }
...@@ -109,7 +109,7 @@ func TestCreateTeamSanitization(t *testing.T) { ...@@ -109,7 +109,7 @@ func TestCreateTeamSanitization(t *testing.T) {
team := &model.Team{ team := &model.Team{
DisplayName: t.Name() + "_2", DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
} }
...@@ -148,10 +148,10 @@ func TestGetTeam(t *testing.T) { ...@@ -148,10 +148,10 @@ func TestGetTeam(t *testing.T) {
th.LoginTeamAdmin() th.LoginTeamAdmin()
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: false} team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: false}
rteam2, _ := Client.CreateTeam(team2) rteam2, _ := Client.CreateTeam(team2)
team3 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE, AllowOpenInvite: true} team3 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_INVITE, AllowOpenInvite: true}
rteam3, _ := Client.CreateTeam(team3) rteam3, _ := Client.CreateTeam(team3)
th.LoginBasic() th.LoginBasic()
...@@ -178,7 +178,7 @@ func TestGetTeamSanitization(t *testing.T) { ...@@ -178,7 +178,7 @@ func TestGetTeamSanitization(t *testing.T) {
team, resp := th.Client.CreateTeam(&model.Team{ team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}) })
...@@ -359,7 +359,7 @@ func TestUpdateTeamSanitization(t *testing.T) { ...@@ -359,7 +359,7 @@ func TestUpdateTeamSanitization(t *testing.T) {
team, resp := th.Client.CreateTeam(&model.Team{ team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}) })
...@@ -458,7 +458,7 @@ func TestPatchTeamSanitization(t *testing.T) { ...@@ -458,7 +458,7 @@ func TestPatchTeamSanitization(t *testing.T) {
team, resp := th.Client.CreateTeam(&model.Team{ team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}) })
...@@ -492,7 +492,7 @@ func TestSoftDeleteTeam(t *testing.T) { ...@@ -492,7 +492,7 @@ func TestSoftDeleteTeam(t *testing.T) {
defer th.TearDown() defer th.TearDown()
Client := th.Client Client := th.Client
team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN} team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN}
team, _ = Client.CreateTeam(team) team, _ = Client.CreateTeam(team)
ok, resp := Client.SoftDeleteTeam(team.Id) ok, resp := Client.SoftDeleteTeam(team.Id)
...@@ -534,7 +534,7 @@ func TestPermanentDeleteTeam(t *testing.T) { ...@@ -534,7 +534,7 @@ func TestPermanentDeleteTeam(t *testing.T) {
defer th.TearDown() defer th.TearDown()
Client := th.Client Client := th.Client
team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN} team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN}
team, _ = Client.CreateTeam(team) team, _ = Client.CreateTeam(team)
ok, resp := Client.PermanentDeleteTeam(team.Id) ok, resp := Client.PermanentDeleteTeam(team.Id)
...@@ -567,7 +567,7 @@ func TestGetAllTeams(t *testing.T) { ...@@ -567,7 +567,7 @@ func TestGetAllTeams(t *testing.T) {
defer th.TearDown() defer th.TearDown()
Client := th.Client Client := th.Client
team := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: true} team := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: true}
_, resp := Client.CreateTeam(team) _, resp := Client.CreateTeam(team)
CheckNoError(t, resp) CheckNoError(t, resp)
...@@ -627,7 +627,7 @@ func TestGetAllTeamsSanitization(t *testing.T) { ...@@ -627,7 +627,7 @@ func TestGetAllTeamsSanitization(t *testing.T) {
team, resp := th.Client.CreateTeam(&model.Team{ team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
AllowOpenInvite: true, AllowOpenInvite: true,
...@@ -636,7 +636,7 @@ func TestGetAllTeamsSanitization(t *testing.T) { ...@@ -636,7 +636,7 @@ func TestGetAllTeamsSanitization(t *testing.T) {
team2, resp := th.SystemAdminClient.CreateTeam(&model.Team{ team2, resp := th.SystemAdminClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_2", DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
AllowOpenInvite: true, AllowOpenInvite: true,
...@@ -722,10 +722,10 @@ func TestGetTeamByName(t *testing.T) { ...@@ -722,10 +722,10 @@ func TestGetTeamByName(t *testing.T) {
th.LoginTeamAdmin() th.LoginTeamAdmin()
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: false} team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN, AllowOpenInvite: false}
rteam2, _ := Client.CreateTeam(team2) rteam2, _ := Client.CreateTeam(team2)
team3 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE, AllowOpenInvite: true} team3 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_INVITE, AllowOpenInvite: true}
rteam3, _ := Client.CreateTeam(team3) rteam3, _ := Client.CreateTeam(team3)
th.LoginBasic() th.LoginBasic()
...@@ -745,7 +745,7 @@ func TestGetTeamByNameSanitization(t *testing.T) { ...@@ -745,7 +745,7 @@ func TestGetTeamByNameSanitization(t *testing.T) {
team, resp := th.Client.CreateTeam(&model.Team{ team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}) })
...@@ -800,7 +800,7 @@ func TestSearchAllTeams(t *testing.T) { ...@@ -800,7 +800,7 @@ func TestSearchAllTeams(t *testing.T) {
oTeam.UpdateAt = updatedTeam.UpdateAt oTeam.UpdateAt = updatedTeam.UpdateAt
} }
pTeam := &model.Team{DisplayName: "PName", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE} pTeam := &model.Team{DisplayName: "PName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_INVITE}
Client.CreateTeam(pTeam) Client.CreateTeam(pTeam)
rteams, resp := Client.SearchTeams(&model.TeamSearch{Term: oTeam.Name}) rteams, resp := Client.SearchTeams(&model.TeamSearch{Term: oTeam.Name})
...@@ -876,7 +876,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) { ...@@ -876,7 +876,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) {
team, resp := th.Client.CreateTeam(&model.Team{ team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1", DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}) })
...@@ -884,7 +884,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) { ...@@ -884,7 +884,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) {
team2, resp := th.Client.CreateTeam(&model.Team{ team2, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_2", DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(), Name: GenerateTestTeamName(),
Email: GenerateTestEmail(), Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN, Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com", AllowedDomains: "simulator.amazonses.com",
}) })
...@@ -954,7 +954,7 @@ func TestGetTeamsForUser(t *testing.T) { ...@@ -954,7 +954,7 @@ func TestGetTeamsForUser(t *testing.T) {
defer th.TearDown() defer th.TearDown()
Client := th.Client Client := th.Client
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_INVITE} team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_INVITE}
rteam2, _ := Client.CreateTeam(team2) rteam2, _ := Client.CreateTeam(team2)