コード例 #1
0
ファイル: sql_store_test.go プロジェクト: ttyniwa/platform
func TestSqlStore1(t *testing.T) {
	utils.LoadConfig("config.json")
	utils.Cfg.SqlSettings.Trace = true

	store := NewSqlStore()
	store.Close()

	utils.LoadConfig("config.json")
}
コード例 #2
0
ファイル: sql_store_test.go プロジェクト: ttyniwa/platform
func TestSqlStore3(t *testing.T) {
	defer func() {
		if r := recover(); r == nil {
			t.Fatal("should have been fatal")
		}
	}()

	utils.LoadConfig("config.json")
	utils.Cfg.SqlSettings.DataSource = "missing"
	store = NewSqlStore()

	utils.LoadConfig("config.json")
}
コード例 #3
0
ファイル: mattermost.go プロジェクト: Dahlgren/platform
func main() {

	pwd, _ := os.Getwd()
	fmt.Println("Current working directory is set to " + pwd)

	var config = flag.String("config", "config.json", "path to config file")
	flag.Parse()

	utils.LoadConfig(*config)
	api.NewServer()
	api.InitApi()
	web.InitWeb()
	api.StartServer()

	// If we allow testing then listen for manual testing URL hits
	if utils.Cfg.ServiceSettings.AllowTesting {
		manualtesting.InitManualTesting()
	}

	// wait for kill signal before attempting to gracefully shutdown
	// the running service
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
	<-c

	api.StopServer()
}
コード例 #4
0
ファイル: apitestlib.go プロジェクト: ZJvandeWeg/platform
func Setup() *TestHelper {
	if app.Srv == nil {
		utils.TranslationsPreInit()
		utils.LoadConfig("config.json")
		utils.InitTranslations(utils.Cfg.LocalizationSettings)
		utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
		*utils.Cfg.RateLimitSettings.Enable = false
		utils.Cfg.EmailSettings.SendEmailNotifications = true
		utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
		utils.Cfg.EmailSettings.SMTPPort = "2500"
		utils.Cfg.EmailSettings.FeedbackEmail = "*****@*****.**"
		utils.DisableDebugLogForTest()
		app.NewServer()
		app.InitStores()
		InitRouter()
		app.StartServer()
		InitApi()
		utils.EnableDebugLogForTest()
		app.Srv.Store.MarkSystemRanUnitTests()

		*utils.Cfg.TeamSettings.EnableOpenServer = true
	}

	return &TestHelper{}
}
コード例 #5
0
ファイル: admin.go プロジェクト: no2key/platform
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
	if !c.HasSystemAdminPermissions("getConfig") {
		return
	}

	cfg := model.ConfigFromJson(r.Body)
	if cfg == nil {
		c.SetInvalidParam("saveConfig", "config")
		return
	}

	if len(cfg.ServiceSettings.ListenAddress) == 0 {
		c.SetInvalidParam("saveConfig", "config")
		return
	}

	if cfg.TeamSettings.MaxUsersPerTeam == 0 {
		c.SetInvalidParam("saveConfig", "config")
		return
	}

	// TODO run some cleanup validators

	utils.SaveConfig(utils.CfgFileName, cfg)
	utils.LoadConfig(utils.CfgFileName)
	json := utils.Cfg.ToJson()
	w.Write([]byte(json))
}
コード例 #6
0
ファイル: admin.go プロジェクト: carriercomm/platform
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
	if !c.HasSystemAdminPermissions("getConfig") {
		return
	}

	cfg := model.ConfigFromJson(r.Body)
	if cfg == nil {
		c.SetInvalidParam("saveConfig", "config")
		return
	}

	cfg.SetDefaults()
	utils.Desanitize(cfg)

	if err := cfg.IsValid(); err != nil {
		c.Err = err
		return
	}

	if err := utils.ValidateLdapFilter(cfg); err != nil {
		c.Err = err
		return
	}

	c.LogAudit("")

	utils.SaveConfig(utils.CfgFileName, cfg)
	utils.LoadConfig(utils.CfgFileName)

	rdata := map[string]string{}
	rdata["status"] = "OK"
	w.Write([]byte(model.MapToJson(rdata)))
}
コード例 #7
0
ファイル: admin.go プロジェクト: kernicPanel/platform
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
	if !c.HasSystemAdminPermissions("getConfig") {
		return
	}

	cfg := model.ConfigFromJson(r.Body)
	if cfg == nil {
		c.SetInvalidParam("saveConfig", "config")
		return
	}

	cfg.SetDefaults()

	if err := cfg.IsValid(); err != nil {
		c.Err = err
		return
	}

	c.LogAudit("")

	utils.SaveConfig(utils.CfgFileName, cfg)
	utils.LoadConfig(utils.CfgFileName)
	json := utils.Cfg.ToJson()
	w.Write([]byte(json))
}
コード例 #8
0
func Setup() {
	if store == nil {
		utils.LoadConfig("config.json")
		store = NewSqlStore()

		store.MarkSystemRanUnitTests()
	}
}
コード例 #9
0
ファイル: admin.go プロジェクト: lfbrock/platform
func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
	utils.LoadConfig(utils.CfgFileName)

	// start/restart email batching job if necessary
	InitEmailBatching()

	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
	ReturnStatusOK(w)
}
コード例 #10
0
ファイル: admin.go プロジェクト: stasvovk/platform
func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
	if !c.HasSystemAdminPermissions("reloadConfig") {
		return
	}

	utils.LoadConfig(utils.CfgFileName)
	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
	ReturnStatusOK(w)
}
コード例 #11
0
ファイル: api_test.go プロジェクト: crspeller/platform
func Setup() {
	if Srv == nil {
		utils.LoadConfig("config.json")
		NewServer()
		StartServer()
		InitApi()
		Client = model.NewClient("http://localhost:" + utils.Cfg.ServiceSettings.Port + "/api/v1")
	}
}
コード例 #12
0
ファイル: mattermost.go プロジェクト: ZBoxApp/platform
func main() {

	parseCmds()

	utils.InitTranslations()
	utils.LoadConfig(flagConfigFile)

	if flagRunCmds {
		utils.ConfigureCmdLineLog()
	}

	pwd, _ := os.Getwd()
	l4g.Info(utils.T("mattermost.current_version"), model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash)
	l4g.Info(utils.T("mattermost.entreprise_enabled"), model.BuildEnterpriseReady)
	l4g.Info(utils.T("mattermost.working_dir"), pwd)
	l4g.Info(utils.T("mattermost.config_file"), utils.FindConfigFile(flagConfigFile))

	api.NewServer()
	api.InitApi()
	web.InitWeb()

	if model.BuildEnterpriseReady == "true" {
		api.LoadLicense()
	}

	if !utils.IsLicensed && len(utils.Cfg.SqlSettings.DataSourceReplicas) > 1 {
		l4g.Critical(utils.T("store.sql.read_replicas_not_licensed.critical"))
		time.Sleep(time.Second)
		panic(fmt.Sprintf(utils.T("store.sql.read_replicas_not_licensed.critical")))
	}

	if flagRunCmds {
		runCmds()
	} else {
		api.StartServer()

		// If we allow testing then listen for manual testing URL hits
		if utils.Cfg.ServiceSettings.EnableTesting {
			manualtesting.InitManualTesting()
		}

		setDiagnosticId()
		runSecurityAndDiagnosticsJobAndForget()

		if einterfaces.GetComplianceInterface() != nil {
			einterfaces.GetComplianceInterface().StartComplianceDailyJob()
		}

		// wait for kill signal before attempting to gracefully shutdown
		// the running service
		c := make(chan os.Signal)
		signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
		<-c

		api.StopServer()
	}
}
コード例 #13
0
ファイル: sql_store_test.go プロジェクト: loafoe/platform
func Setup() {
	if store == nil {
		utils.LoadConfig("config.json")
		utils.InitTranslations(utils.Cfg.LocalizationSettings)
		store = NewSqlStore()

		store.MarkSystemRanUnitTests()
	}
}
コード例 #14
0
ファイル: mattermost.go プロジェクト: ChrisOHu/platform
func doLoadConfig(filename string) (err string) {
	defer func() {
		if r := recover(); r != nil {
			err = r.(string)
		}
	}()
	utils.LoadConfig(filename)
	return ""
}
コード例 #15
0
ファイル: mattermost.go プロジェクト: 42wim/platform
func doLoadConfig(filename string) (err string) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Sprintf("%v", r)
		}
	}()
	utils.LoadConfig(filename)
	return ""
}
コード例 #16
0
ファイル: api_test.go プロジェクト: no2key/platform
func Setup() {
	if Srv == nil {
		utils.LoadConfig("config.json")
		utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
		NewServer()
		StartServer()
		InitApi()
		Client = model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress)
	}
}
コード例 #17
0
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
	cfg := model.ConfigFromJson(r.Body)
	if cfg == nil {
		c.SetInvalidParam("saveConfig", "config")
		return
	}

	cfg.SetDefaults()
	utils.Desanitize(cfg)

	if err := cfg.IsValid(); err != nil {
		c.Err = err
		return
	}

	if err := utils.ValidateLdapFilter(cfg); err != nil {
		c.Err = err
		return
	}

	if *utils.Cfg.ClusterSettings.Enable {
		c.Err = model.NewLocAppError("saveConfig", "ent.cluster.save_config.error", nil, "")
		return
	}

	c.LogAudit("")

	//oldCfg := utils.Cfg
	utils.SaveConfig(utils.CfgFileName, cfg)
	utils.LoadConfig(utils.CfgFileName)

	if einterfaces.GetMetricsInterface() != nil {
		if *utils.Cfg.MetricsSettings.Enable {
			einterfaces.GetMetricsInterface().StartServer()
		} else {
			einterfaces.GetMetricsInterface().StopServer()
		}
	}

	// Future feature is to sync the configuration files
	// if einterfaces.GetClusterInterface() != nil {
	// 	err := einterfaces.GetClusterInterface().ConfigChanged(cfg, oldCfg, true)
	// 	if err != nil {
	// 		c.Err = err
	// 		return
	// 	}
	// }

	// start/restart email batching job if necessary
	InitEmailBatching()

	rdata := map[string]string{}
	rdata["status"] = "OK"
	w.Write([]byte(model.MapToJson(rdata)))
}
コード例 #18
0
ファイル: web_test.go プロジェクト: Nodeer/platform
func Setup() {
	if api.Srv == nil {
		utils.LoadConfig("config.json")
		api.NewServer()
		api.StartServer()
		api.InitApi()
		InitWeb()
		URL = "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress
		ApiClient = model.NewClient(URL)
	}
}
コード例 #19
0
ファイル: api_test.go プロジェクト: bitbackofen/platform
func Setup() {
	if Srv == nil {
		utils.LoadConfig("config.json")
		utils.InitTranslations()
		utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
		NewServer()
		StartServer()
		InitApi()
		Client = model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress)

		Srv.Store.MarkSystemRanUnitTests()
	}
}
コード例 #20
0
ファイル: web_test.go プロジェクト: bitbackofen/platform
func Setup() {
	if api.Srv == nil {
		utils.LoadConfig("config.json")
		utils.InitTranslations()
		api.NewServer()
		api.StartServer()
		api.InitApi()
		InitWeb()
		URL = "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress
		ApiClient = model.NewClient(URL)

		api.Srv.Store.MarkSystemRanUnitTests()
	}
}
コード例 #21
0
ファイル: redis_test.go プロジェクト: Dahlgren/platform
func TestRedis(t *testing.T) {
	utils.LoadConfig("config.json")

	c := RedisClient()

	if c == nil {
		t.Fatal("should have a valid redis connection")
	}

	pubsub := c.PubSub()
	defer pubsub.Close()

	m := model.NewMessage(model.NewId(), model.NewId(), model.NewId(), model.ACTION_TYPING)
	m.Add("RootId", model.NewId())

	err := pubsub.Subscribe(m.TeamId)
	if err != nil {
		t.Fatal(err)
	}

	// should be the subscribe success message
	// lets gobble that up
	if _, err := pubsub.Receive(); err != nil {
		t.Fatal(err)
	}

	PublishAndForget(m)

	fmt.Println("here1")

	if msg, err := pubsub.Receive(); err != nil {
		t.Fatal(err)
	} else {

		rmsg := GetMessageFromPayload(msg)

		if m.TeamId != rmsg.TeamId {
			t.Fatal("Ids do not match")
		}

		if m.Props["RootId"] != rmsg.Props["RootId"] {
			t.Fatal("Ids do not match")
		}
	}

	RedisClose()
}
コード例 #22
0
ファイル: mattermost.go プロジェクト: Sageras/platform
func main() {

	parseCmds()

	utils.LoadConfig(flagConfigFile)
	utils.InitTranslations()

	if flagRunCmds {
		utils.ConfigureCmdLineLog()
	}

	pwd, _ := os.Getwd()
	l4g.Info(utils.T("mattermost.current_version"), model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash)
	l4g.Info(utils.T("mattermost.entreprise_enabled"), model.BuildEnterpriseReady)
	l4g.Info(utils.T("mattermost.working_dir"), pwd)
	l4g.Info(utils.T("mattermost.config_file"), utils.FindConfigFile(flagConfigFile))

	api.NewServer()
	api.InitApi()
	web.InitWeb()

	if model.BuildEnterpriseReady == "true" {
		utils.LoadLicense()
	}

	if flagRunCmds {
		runCmds()
	} else {
		api.StartServer()

		// If we allow testing then listen for manual testing URL hits
		if utils.Cfg.ServiceSettings.EnableTesting {
			manualtesting.InitManualTesting()
		}

		setDiagnosticId()
		runSecurityAndDiagnosticsJobAndForget()

		// wait for kill signal before attempting to gracefully shutdown
		// the running service
		c := make(chan os.Signal)
		signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
		<-c

		api.StopServer()
	}
}
コード例 #23
0
ファイル: web_test.go プロジェクト: duzhanyuan/platform
func Setup() {
	if api.Srv == nil {
		utils.TranslationsPreInit()
		utils.LoadConfig("config.json")
		utils.InitTranslations(utils.Cfg.LocalizationSettings)
		api.NewServer(false)
		api.StartServer()
		api.InitApi()
		InitWeb()
		URL = "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress
		ApiClient = model.NewClient(URL)

		api.Srv.Store.MarkSystemRanUnitTests()

		*utils.Cfg.TeamSettings.EnableOpenServer = true
	}
}
コード例 #24
0
ファイル: apitestlib.go プロジェクト: ReinhardHsu/platform
func Setup() *TestHelper {
	if Srv == nil {
		utils.LoadConfig("config.json")
		utils.InitTranslations(utils.Cfg.LocalizationSettings)
		utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
		utils.DisableDebugLogForTest()
		NewServer()
		StartServer()
		InitApi()
		utils.EnableDebugLogForTest()
		Srv.Store.MarkSystemRanUnitTests()

		*utils.Cfg.TeamSettings.EnableOpenServer = true
	}

	return &TestHelper{}
}
コード例 #25
0
ファイル: mattermost.go プロジェクト: mokamo/platform
func main() {

	parseCmds()

	utils.LoadConfig(flagConfigFile)

	if flagRunCmds {
		utils.ConfigureCmdLineLog()
	}

	pwd, _ := os.Getwd()
	l4g.Info("Current version is %v (%v/%v/%v)", model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash)
	l4g.Info("Enterprise Enabled: %t", model.BuildEnterpriseReady)
	l4g.Info("Current working directory is %v", pwd)
	l4g.Info("Loaded config file from %v", utils.FindConfigFile(flagConfigFile))

	api.NewServer()
	api.InitApi()
	web.InitWeb()

	utils.LoadLicense()

	if flagRunCmds {
		runCmds()
	} else {
		api.StartServer()

		// If we allow testing then listen for manual testing URL hits
		if utils.Cfg.ServiceSettings.EnableTesting {
			manualtesting.InitManualTesting()
		}

		setDiagnosticId()
		runSecurityAndDiagnosticsJobAndForget()

		// wait for kill signal before attempting to gracefully shutdown
		// the running service
		c := make(chan os.Signal)
		signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
		<-c

		api.StopServer()
	}
}
コード例 #26
0
ファイル: apitestlib.go プロジェクト: carriercomm/platform
func SetupEnterprise() *TestHelper {
	if Srv == nil {
		utils.LoadConfig("config.json")
		utils.InitTranslations()
		utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
		utils.DisableDebugLogForTest()
		utils.License.Features.SetDefaults()
		NewServer()
		StartServer()
		utils.InitHTML()
		InitApi()
		utils.EnableDebugLogForTest()
		Srv.Store.MarkSystemRanUnitTests()

		*utils.Cfg.TeamSettings.EnableOpenServer = true
	}

	return &TestHelper{}
}
コード例 #27
0
ファイル: apitestlib.go プロジェクト: ZJvandeWeg/platform
func SetupEnterprise() *TestHelper {
	if app.Srv == nil {
		utils.TranslationsPreInit()
		utils.LoadConfig("config.json")
		utils.InitTranslations(utils.Cfg.LocalizationSettings)
		utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
		*utils.Cfg.RateLimitSettings.Enable = false
		utils.DisableDebugLogForTest()
		utils.License.Features.SetDefaults()
		app.NewServer()
		app.InitStores()
		InitRouter()
		app.StartServer()
		utils.InitHTML()
		InitApi()
		utils.EnableDebugLogForTest()
		app.Srv.Store.MarkSystemRanUnitTests()

		*utils.Cfg.TeamSettings.EnableOpenServer = true
	}

	return &TestHelper{}
}
コード例 #28
0
ファイル: mattermost.go プロジェクト: saitodisse/platform
func main() {

	parseCmds()

	utils.LoadConfig(flagConfigFile)

	if flagRunCmds {
		utils.ConfigureCmdLineLog()
	}

	pwd, _ := os.Getwd()
	l4g.Info("Current working directory is %v", pwd)
	l4g.Info("Loaded config file from %v", utils.FindConfigFile(flagConfigFile))

	api.NewServer()
	api.InitApi()
	web.InitWeb()

	if flagRunCmds {
		runCmds()
	} else {
		api.StartServer()

		// If we allow testing then listen for manual testing URL hits
		if utils.Cfg.ServiceSettings.AllowTesting {
			manualtesting.InitManualTesting()
		}

		// wait for kill signal before attempting to gracefully shutdown
		// the running service
		c := make(chan os.Signal)
		signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
		<-c

		api.StopServer()
	}
}
コード例 #29
0
ファイル: sql_store_test.go プロジェクト: Dahlgren/platform
func Setup() {
	if store == nil {
		utils.LoadConfig("config.json")
		store = NewSqlStore()
	}
}