Commit 1adfd0e9 authored by Chris's avatar Chris Committed by GitHub

app type transition (#7167)

parent b84bd210
...@@ -67,7 +67,7 @@ func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -67,7 +67,7 @@ func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func getAllAudits(c *Context, w http.ResponseWriter, r *http.Request) { func getAllAudits(c *Context, w http.ResponseWriter, r *http.Request) {
if audits, err := app.GetAudits("", 200); err != nil { if audits, err := c.App.GetAudits("", 200); err != nil {
c.Err = err c.Err = err
return return
} else if HandleEtag(audits.Etag(), "Get All Audits", w, r) { } else if HandleEtag(audits.Etag(), "Get All Audits", w, r) {
...@@ -96,7 +96,7 @@ func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -96,7 +96,7 @@ func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func invalidateAllCaches(c *Context, w http.ResponseWriter, r *http.Request) { func invalidateAllCaches(c *Context, w http.ResponseWriter, r *http.Request) {
err := app.InvalidateAllCaches() err := c.App.InvalidateAllCaches()
if err != nil { if err != nil {
c.Err = err c.Err = err
return return
...@@ -124,7 +124,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -124,7 +124,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func recycleDatabaseConnection(c *Context, w http.ResponseWriter, r *http.Request) { func recycleDatabaseConnection(c *Context, w http.ResponseWriter, r *http.Request) {
app.RecycleDatabaseConnection() c.App.RecycleDatabaseConnection()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w) ReturnStatusOK(w)
} }
...@@ -136,7 +136,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -136,7 +136,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
err := app.TestEmail(c.Session.UserId, cfg) err := c.App.TestEmail(c.Session.UserId, cfg)
if err != nil { if err != nil {
c.Err = err c.Err = err
return return
...@@ -148,7 +148,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -148,7 +148,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func getComplianceReports(c *Context, w http.ResponseWriter, r *http.Request) { func getComplianceReports(c *Context, w http.ResponseWriter, r *http.Request) {
crs, err := app.GetComplianceReports(0, 10000) crs, err := c.App.GetComplianceReports(0, 10000)
if err != nil { if err != nil {
c.Err = err c.Err = err
return return
...@@ -165,7 +165,7 @@ func saveComplianceReport(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -165,7 +165,7 @@ func saveComplianceReport(c *Context, w http.ResponseWriter, r *http.Request) {
job.UserId = c.Session.UserId job.UserId = c.Session.UserId
rjob, err := app.SaveComplianceReport(job) rjob, err := c.App.SaveComplianceReport(job)
if err != nil { if err != nil {
c.Err = err c.Err = err
return return
...@@ -184,7 +184,7 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request ...@@ -184,7 +184,7 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request
return return
} }
job, err := app.GetComplianceReport(id) job, err := c.App.GetComplianceReport(id)
if err != nil { if err != nil {
c.Err = err c.Err = err
return return
...@@ -221,7 +221,7 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -221,7 +221,7 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
teamId := params["id"] teamId := params["id"]
name := params["name"] name := params["name"]
rows, err := app.GetAnalytics(name, teamId) rows, err := c.App.GetAnalytics(name, teamId)
if err != nil { if err != nil {
c.Err = err c.Err = err
return return
...@@ -316,7 +316,7 @@ func adminResetPassword(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -316,7 +316,7 @@ func adminResetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if err := app.UpdatePasswordByUserIdSendEmail(userId, newPassword, c.T("api.user.reset_password.method")); err != nil { if err := c.App.UpdatePasswordByUserIdSendEmail(userId, newPassword, c.T("api.user.reset_password.method")); err != nil {
c.Err = err c.Err = err
return return
} }
...@@ -412,7 +412,7 @@ func samlCertificateStatus(c *Context, w http.ResponseWriter, r *http.Request) { ...@@ -412,7 +412,7 @@ func samlCertificateStatus(c *Context, w http.ResponseWriter, r *http.Request) {
} }
func getRecentlyActiveUsers(c *Context, w http.ResponseWriter, r *http.Request) { func getRecentlyActiveUsers(c *Context, w http.ResponseWriter, r *http.Request) {
if profiles, err := app.GetRecentlyActiveUsersForTeam(c.TeamId); err != nil { if profiles, err := c.App.GetRecentlyActiveUsersForTeam(c.TeamId); err != nil {
c.Err = err c.Err = err
return return
} else { } else {
......
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"github.com/mattermost/platform/store" "github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils" "github.com/mattermost/platform/utils"
...@@ -597,7 +596,7 @@ func TestAdminResetPassword(t *testing.T) { ...@@ -597,7 +596,7 @@ func TestAdminResetPassword(t *testing.T) {
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"} 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) user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
LinkUserToTeam(user, team) LinkUserToTeam(user, team)
store.Must(app.Srv.Store.User().VerifyEmail(user.Id)) store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
if _, err := Client.AdminResetPassword("", "newpwd1"); err == nil { if _, err := Client.AdminResetPassword("", "newpwd1"); err == nil {
t.Fatal("Should have errored - empty user id") t.Fatal("Should have errored - empty user id")
...@@ -619,7 +618,7 @@ func TestAdminResetPassword(t *testing.T) { ...@@ -619,7 +618,7 @@ func TestAdminResetPassword(t *testing.T) {
user2 := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", AuthData: &authData, AuthService: "random"} 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) user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
LinkUserToTeam(user2, team) LinkUserToTeam(user2, team)
store.Must(app.Srv.Store.User().VerifyEmail(user2.Id)) store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
if _, err := Client.AdminResetPassword(user.Id, "newpwd1"); err != nil { if _, err := Client.AdminResetPassword(user.Id, "newpwd1"); err != nil {
t.Fatal(err) t.Fatal(err)
......
...@@ -60,14 +60,14 @@ type Routes struct { ...@@ -60,14 +60,14 @@ type Routes struct {
var BaseRoutes *Routes var BaseRoutes *Routes
func InitRouter() { func InitRouter() {
app.Srv.Router = mux.NewRouter() app.Global().Srv.Router = mux.NewRouter()
app.Srv.Router.NotFoundHandler = http.HandlerFunc(Handle404) app.Global().Srv.Router.NotFoundHandler = http.HandlerFunc(Handle404)
} }
func InitApi() { func InitApi() {
BaseRoutes = &Routes{} BaseRoutes = &Routes{}
BaseRoutes.Root = app.Srv.Router BaseRoutes.Root = app.Global().Srv.Router
BaseRoutes.ApiRoot = app.Srv.Router.PathPrefix(model.API_URL_SUFFIX_V3).Subrouter() BaseRoutes.ApiRoot = app.Global().Srv.Router.PathPrefix(model.API_URL_SUFFIX_V3).Subrouter()
BaseRoutes.Users = BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter() BaseRoutes.Users = BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter()
BaseRoutes.NeedUser = BaseRoutes.Users.PathPrefix("/{user_id:[A-Za-z0-9]+}").Subrouter() BaseRoutes.NeedUser = BaseRoutes.Users.PathPrefix("/{user_id:[A-Za-z0-9]+}").Subrouter()
BaseRoutes.Teams = BaseRoutes.ApiRoot.PathPrefix("/teams").Subrouter() BaseRoutes.Teams = BaseRoutes.ApiRoot.PathPrefix("/teams").Subrouter()
...@@ -111,7 +111,7 @@ func InitApi() { ...@@ -111,7 +111,7 @@ func InitApi() {
InitDeprecated() InitDeprecated()
// 404 on any api route before web.go has a chance to serve it // 404 on any api route before web.go has a chance to serve it
app.Srv.Router.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404)) app.Global().Srv.Router.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))
utils.InitHTML() utils.InitHTML()
......
...@@ -17,6 +17,8 @@ import ( ...@@ -17,6 +17,8 @@ import (
) )
type TestHelper struct { type TestHelper struct {
App *app.App
BasicClient *model.Client BasicClient *model.Client
BasicTeam *model.Team BasicTeam *model.Team
BasicUser *model.User BasicUser *model.User
...@@ -32,7 +34,7 @@ type TestHelper struct { ...@@ -32,7 +34,7 @@ type TestHelper struct {
} }
func SetupEnterprise() *TestHelper { func SetupEnterprise() *TestHelper {
if app.Srv == nil { if app.Global().Srv == nil {
utils.TranslationsPreInit() utils.TranslationsPreInit()
utils.LoadConfig("config.json") utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings) utils.InitTranslations(utils.Cfg.LocalizationSettings)
...@@ -40,17 +42,17 @@ func SetupEnterprise() *TestHelper { ...@@ -40,17 +42,17 @@ func SetupEnterprise() *TestHelper {
*utils.Cfg.RateLimitSettings.Enable = false *utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
utils.License().Features.SetDefaults() utils.License().Features.SetDefaults()
app.NewServer() app.Global().NewServer()
app.InitStores() app.Global().InitStores()
InitRouter() InitRouter()
wsapi.InitRouter() wsapi.InitRouter()
app.StartServer() app.Global().StartServer()
utils.InitHTML() utils.InitHTML()
api4.InitApi(false) api4.InitApi(false)
InitApi() InitApi()
wsapi.InitApi() wsapi.InitApi()
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
app.Srv.Store.MarkSystemRanUnitTests() app.Global().Srv.Store.MarkSystemRanUnitTests()
*utils.Cfg.TeamSettings.EnableOpenServer = true *utils.Cfg.TeamSettings.EnableOpenServer = true
} }
...@@ -59,7 +61,7 @@ func SetupEnterprise() *TestHelper { ...@@ -59,7 +61,7 @@ func SetupEnterprise() *TestHelper {
} }
func Setup() *TestHelper { func Setup() *TestHelper {
if app.Srv == nil { if app.Global().Srv == nil {
utils.TranslationsPreInit() utils.TranslationsPreInit()
utils.LoadConfig("config.json") utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings) utils.InitTranslations(utils.Cfg.LocalizationSettings)
...@@ -70,16 +72,16 @@ func Setup() *TestHelper { ...@@ -70,16 +72,16 @@ func Setup() *TestHelper {
utils.Cfg.EmailSettings.SMTPPort = "2500" utils.Cfg.EmailSettings.SMTPPort = "2500"
utils.Cfg.EmailSettings.FeedbackEmail = "test@example.com" utils.Cfg.EmailSettings.FeedbackEmail = "test@example.com"
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
app.NewServer() app.Global().NewServer()
app.InitStores() app.Global().InitStores()
InitRouter() InitRouter()
wsapi.InitRouter() wsapi.InitRouter()
app.StartServer() app.Global().StartServer()
api4.InitApi(false) api4.InitApi(false)
InitApi() InitApi()
wsapi.InitApi() wsapi.InitApi()
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
app.Srv.Store.MarkSystemRanUnitTests() app.Global().Srv.Store.MarkSystemRanUnitTests()
*utils.Cfg.TeamSettings.EnableOpenServer = true *utils.Cfg.TeamSettings.EnableOpenServer = true
} }
...@@ -100,6 +102,7 @@ func ReloadConfigForSetup() { ...@@ -100,6 +102,7 @@ func ReloadConfigForSetup() {
} }
func (me *TestHelper) InitBasic() *TestHelper { func (me *TestHelper) InitBasic() *TestHelper {
me.App = app.Global()
me.BasicClient = me.CreateClient() me.BasicClient = me.CreateClient()
me.BasicUser = me.CreateUser(me.BasicClient) me.BasicUser = me.CreateUser(me.BasicClient)
me.LoginBasic() me.LoginBasic()
...@@ -119,6 +122,7 @@ func (me *TestHelper) InitBasic() *TestHelper { ...@@ -119,6 +122,7 @@ func (me *TestHelper) InitBasic() *TestHelper {
} }
func (me *TestHelper) InitSystemAdmin() *TestHelper { func (me *TestHelper) InitSystemAdmin() *TestHelper {
me.App = app.Global()
me.SystemAdminClient = me.CreateClient() me.SystemAdminClient = me.CreateClient()
me.SystemAdminUser = me.CreateUser(me.SystemAdminClient) me.SystemAdminUser = me.CreateUser(me.SystemAdminClient)
me.SystemAdminUser.Password = "Password1" me.SystemAdminUser.Password = "Password1"
...@@ -126,7 +130,7 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper { ...@@ -126,7 +130,7 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
me.SystemAdminTeam = me.CreateTeam(me.SystemAdminClient) me.SystemAdminTeam = me.CreateTeam(me.SystemAdminClient)
LinkUserToTeam(me.SystemAdminUser, me.SystemAdminTeam) LinkUserToTeam(me.SystemAdminUser, me.SystemAdminTeam)
me.SystemAdminClient.SetTeamId(me.SystemAdminTeam.Id) me.SystemAdminClient.SetTeamId(me.SystemAdminTeam.Id)
app.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.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) me.SystemAdminChannel = me.CreateChannel(me.SystemAdminClient, me.SystemAdminTeam)
return me return me
...@@ -168,7 +172,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User { ...@@ -168,7 +172,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User {
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
ruser := client.Must(client.CreateUser(user, "")).Data.(*model.User) ruser := client.Must(client.CreateUser(user, "")).Data.(*model.User)
ruser.Password = "Password1" ruser.Password = "Password1"
store.Must(app.Srv.Store.User().VerifyEmail(ruser.Id)) store.Must(app.Global().Srv.Store.User().VerifyEmail(ruser.Id))
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
return ruser return ruser
} }
...@@ -176,7 +180,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User { ...@@ -176,7 +180,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User {
func LinkUserToTeam(user *model.User, team *model.Team) { func LinkUserToTeam(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
err := app.JoinUserToTeam(team, user, "") err := app.Global().JoinUserToTeam(team, user, "")
if err != nil { if err != nil {
l4g.Error(err.Error()) l4g.Error(err.Error())
l4g.Close() l4g.Close()
...@@ -191,7 +195,7 @@ func UpdateUserToTeamAdmin(user *model.User, team *model.Team) { ...@@ -191,7 +195,7 @@ func UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id + " " + model.ROLE_TEAM_ADMIN.Id} tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id + " " + model.ROLE_TEAM_ADMIN.Id}
if tmr := <-app.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil { if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error()) l4g.Error(tmr.Err.Error())
l4g.Close() l4g.Close()
...@@ -205,7 +209,7 @@ func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) { ...@@ -205,7 +209,7 @@ func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id} tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id}
if tmr := <-app.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil { if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error()) l4g.Error(tmr.Err.Error())
l4g.Close() l4g.Close()
...@@ -218,10 +222,10 @@ func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) { ...@@ -218,10 +222,10 @@ func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
func MakeUserChannelAdmin(user *model.User, channel *model.Channel) { func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
if cmr := <-app.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil { if cmr := <-app.Global().Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
cm := cmr.Data.(*model.ChannelMember) cm := cmr.Data.(*model.ChannelMember)
cm.Roles = "channel_admin channel_user" cm.Roles = "channel_admin channel_user"
if sr := <-app.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil { if sr := <-app.Global().Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
panic(sr.Err) panic(sr.Err)
} }
...@@ -236,10 +240,10 @@ func MakeUserChannelAdmin(user *model.User, channel *model.Channel) { ...@@ -236,10 +240,10 @@ func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
func MakeUserChannelUser(user *model.User, channel *model.Channel) { func MakeUserChannelUser(user *model.User, channel *model.Channel) {
utils.DisableDebugLogForTest() utils.DisableDebugLogForTest()
if cmr := <-app.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil { if cmr := <-app.Global().Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
cm := cmr.Data.(*model.ChannelMember) cm := cmr.Data.(*model.ChannelMember)
cm.Roles = "channel_user" cm.Roles = "channel_user"
if sr := <-app.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil { if sr := <-app.Global().Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
utils.EnableDebugLogForTest() utils.EnableDebugLogForTest()
panic(sr.Err) panic(sr.Err)
} }
...@@ -323,7 +327,7 @@ func (me *TestHelper) LoginSystemAdmin() { ...@@ -323,7 +327,7 @@ func (me *TestHelper) LoginSystemAdmin() {
} }
func TearDown() { func TearDown() {
if app.Srv != nil { if app.Global().Srv != nil {
app.StopServer() app.Global().StopServer()
} }
} }
This diff is collapsed.
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
"testing" "testing"
"time" "time"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model" "github.com/mattermost/platform/model"
"github.com/mattermost/platform/store" "github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils" "github.com/mattermost/platform/utils"
...@@ -404,7 +403,7 @@ func TestUpdateChannel(t *testing.T) { ...@@ -404,7 +403,7 @@ func TestUpdateChannel(t *testing.T) {
} }
UpdateUserToTeamAdmin(th.BasicUser, team) UpdateUserToTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
if _, err := Client.UpdateChannel(channel2); err != nil { if _, err := Client.UpdateChannel(channel2); err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -412,7 +411,7 @@ func TestUpdateChannel(t *testing.T) { ...@@ -412,7 +411,7 @@ func TestUpdateChannel(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
UpdateUserToNonTeamAdmin(th.BasicUser, team) UpdateUserToNonTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
MakeUserChannelAdmin(th.BasicUser, channel2) MakeUserChannelAdmin(th.BasicUser, channel2)
MakeUserChannelAdmin(th.BasicUser, channel3) MakeUserChannelAdmin(th.BasicUser, channel3)
...@@ -1188,7 +1187,7 @@ func TestJoinChannelByNameDisabledUser(t *testing.T) { ...@@ -1188,7 +1187,7 @@ func TestJoinChannelByNameDisabledUser(t *testing.T) {
Client.Must(th.BasicClient.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser.Id)) Client.Must(th.BasicClient.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser.Id))
if _, err := app.AddUserToChannel(th.BasicUser, channel1); err == nil { if _, err := th.App.AddUserToChannel(th.BasicUser, channel1); err == nil {
t.Fatal("shoudn't be able to join channel") t.Fatal("shoudn't be able to join channel")
} else { } else {
if err.Id != "api.channel.add_user.to.channel.failed.deleted.app_error" { if err.Id != "api.channel.add_user.to.channel.failed.deleted.app_error" {
...@@ -1406,7 +1405,7 @@ func TestDeleteChannel(t *testing.T) { ...@@ -1406,7 +1405,7 @@ func TestDeleteChannel(t *testing.T) {
UpdateUserToTeamAdmin(th.BasicUser, team) UpdateUserToTeamAdmin(th.BasicUser, team)
Client.Login(th.BasicUser.Email, th.BasicUser.Password) Client.Login(th.BasicUser.Email, th.BasicUser.Password)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
if _, err := Client.DeleteChannel(channel2.Id); err != nil { if _, err := Client.DeleteChannel(channel2.Id); err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -1416,7 +1415,7 @@ func TestDeleteChannel(t *testing.T) { ...@@ -1416,7 +1415,7 @@ func TestDeleteChannel(t *testing.T) {
} }
UpdateUserToNonTeamAdmin(th.BasicUser, team) UpdateUserToNonTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
utils.SetIsLicensed(true) utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}}) utils.SetLicense(&model.License{Features: &model.Features{}})
...@@ -1634,7 +1633,7 @@ func TestAddChannelMember(t *testing.T) { ...@@ -1634,7 +1633,7 @@ func TestAddChannelMember(t *testing.T) {
} }
MakeUserChannelAdmin(user1, channel5) MakeUserChannelAdmin(user1, channel5)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
utils.SetIsLicensed(true) utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}}) utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults() utils.License().Features.SetDefaults()
...@@ -1659,7 +1658,7 @@ func TestAddChannelMember(t *testing.T) { ...@@ -1659,7 +1658,7 @@ func TestAddChannelMember(t *testing.T) {
} }
UpdateUserToTeamAdmin(user1, team) UpdateUserToTeamAdmin(user1, team)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
utils.SetIsLicensed(true) utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}}) utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults() utils.License().Features.SetDefaults()
...@@ -1810,7 +1809,7 @@ func TestRemoveChannelMember(t *testing.T) { ...@@ -1810,7 +1809,7 @@ func TestRemoveChannelMember(t *testing.T) {
} }
MakeUserChannelAdmin(user1, channel5) MakeUserChannelAdmin(user1, channel5)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
utils.SetIsLicensed(true) utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}}) utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults() utils.License().Features.SetDefaults()
...@@ -1835,7 +1834,7 @@ func TestRemoveChannelMember(t *testing.T) { ...@@ -1835,7 +1834,7 @@ func TestRemoveChannelMember(t *testing.T) {
} }
UpdateUserToTeamAdmin(user1, team) UpdateUserToTeamAdmin(user1, team)
app.InvalidateAllCaches() th.App.InvalidateAllCaches()
utils.SetIsLicensed(true) utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}}) utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults() utils.License().Features.SetDefaults()
...@@ -2255,7 +2254,7 @@ func TestGetChannelByName(t *testing.T) { ...@@ -2255,7 +2254,7 @@ func TestGetChannelByName(t *testing.T) {
user2 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Jabba the Hutt", Password: "passwd1"} 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) user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
store.Must(app.Srv.Store.User().VerifyEmail(user2.Id)) store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
Client.SetTeamId(th.BasicTeam.Id) Client.SetTeamId(th.BasicTeam.Id)
...@@ -2314,7 +2313,7 @@ func TestViewChannel(t *testing.T) { ...@@ -2314,7 +2313,7 @@ func TestViewChannel(t *testing.T) {
func TestGetChannelMembersByIds(t *testing.T) { func TestGetChannelMembersByIds(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()