Reduce logging data races, fix MySQL test race condition (#7994)

* fix races

* revert unintentional change

* fix test as intended
Этот коммит содержится в:
Chris
2017-12-22 06:09:33 -06:00
коммит произвёл George Goldberg
родитель 5189e8ea10
Коммит 91bfc72a99
54 изменённых файлов: 8 добавлений и 190 удалений

Просмотреть файл

@@ -7,17 +7,13 @@ import (
"net/http"
"strconv"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
"github.com/mssola/user_agent"
)
func (api *API) InitAdmin() {
l4g.Debug(utils.T("api.admin.init.debug"))
api.BaseRoutes.Admin.Handle("/logs", api.ApiAdminSystemRequired(getLogs)).Methods("GET")
api.BaseRoutes.Admin.Handle("/audits", api.ApiAdminSystemRequired(getAllAudits)).Methods("GET")
api.BaseRoutes.Admin.Handle("/config", api.ApiAdminSystemRequired(getConfig)).Methods("GET")

Просмотреть файл

@@ -107,7 +107,6 @@ func Init(a *app.App, root *mux.Router) *API {
api.InitStatus()
api.InitWebrtc()
api.InitReaction()
api.InitDeprecated()
// 404 on any api route before web.go has a chance to serve it
root.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))

Просмотреть файл

@@ -79,7 +79,6 @@ func setupTestHelper(enterprise bool) *TestHelper {
*cfg.RateLimitSettings.Enable = false
cfg.EmailSettings.SendEmailNotifications = true
})
utils.DisableDebugLogForTest()
prevListenAddress := *th.App.Config().ServiceSettings.ListenAddress
if testStore != nil {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = ":0" })
@@ -89,7 +88,6 @@ func setupTestHelper(enterprise bool) *TestHelper {
api4.Init(th.App, th.App.Srv.Router, false)
Init(th.App, th.App.Srv.Router)
wsapi.Init(th.App, th.App.Srv.WebSocketRouter)
utils.EnableDebugLogForTest()
th.App.Srv.Store.MarkSystemRanUnitTests()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = true })

Просмотреть файл

@@ -14,8 +14,6 @@ import (
)
func (api *API) InitChannel() {
l4g.Debug(utils.T("api.channel.init.debug"))
api.BaseRoutes.Channels.Handle("/", api.ApiUserRequired(getChannels)).Methods("GET")
api.BaseRoutes.Channels.Handle("/more/{offset:[0-9]+}/{limit:[0-9]+}", api.ApiUserRequired(getMoreChannelsPage)).Methods("GET")
api.BaseRoutes.Channels.Handle("/more/search", api.ApiUserRequired(searchMoreChannels)).Methods("POST")

Просмотреть файл

@@ -8,15 +8,10 @@ import (
"net/http"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitCommand() {
l4g.Debug(utils.T("api.command.init.debug"))
api.BaseRoutes.Commands.Handle("/execute", api.ApiUserRequired(executeCommand)).Methods("POST")
api.BaseRoutes.Commands.Handle("/list", api.ApiUserRequired(listCommands)).Methods("GET")

Просмотреть файл

@@ -1,15 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package api
import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/utils"
)
// ONLY FOR APIs SCHEDULED TO BE DEPRECATED
func (api *API) InitDeprecated() {
l4g.Debug(utils.T("api.deprecated.init.debug"))
}

Просмотреть файл

@@ -12,17 +12,13 @@ import (
"image/color/palette"
l4g "github.com/alecthomas/log4go"
"github.com/disintegration/imaging"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitEmoji() {
l4g.Debug(utils.T("api.emoji.init.debug"))
api.BaseRoutes.Emoji.Handle("/list", api.ApiUserRequired(getEmoji)).Methods("GET")
api.BaseRoutes.Emoji.Handle("/create", api.ApiUserRequired(createEmoji)).Methods("POST")
api.BaseRoutes.Emoji.Handle("/delete", api.ApiUserRequired(deleteEmoji)).Methods("POST")

Просмотреть файл

@@ -9,7 +9,6 @@ import (
"strconv"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
@@ -31,8 +30,6 @@ var UNSAFE_CONTENT_TYPES = [...]string{
}
func (api *API) InitFile() {
l4g.Debug(utils.T("api.file.init.debug"))
api.BaseRoutes.TeamFiles.Handle("/upload", api.ApiUserRequired(uploadFile)).Methods("POST")
api.BaseRoutes.NeedFile.Handle("/get", api.ApiUserRequiredTrustRequester(getFile)).Methods("GET")

Просмотреть файл

@@ -8,15 +8,11 @@ import (
"net/http"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitGeneral() {
l4g.Debug(utils.T("api.general.init.debug"))
api.BaseRoutes.General.Handle("/client_props", api.ApiAppHandler(getClientConfig)).Methods("GET")
api.BaseRoutes.General.Handle("/log_client", api.ApiAppHandler(logClient)).Methods("POST")
api.BaseRoutes.General.Handle("/ping", api.ApiAppHandler(ping)).Methods("GET")

Просмотреть файл

@@ -4,8 +4,9 @@
package api
import (
"github.com/mattermost/mattermost-server/model"
"testing"
"github.com/mattermost/mattermost-server/model"
)
func TestGetClientProperties(t *testing.T) {

Просмотреть файл

@@ -8,14 +8,11 @@ import (
"io"
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitLicense() {
l4g.Debug(utils.T("api.license.init.debug"))
api.BaseRoutes.License.Handle("/add", api.ApiAdminSystemRequired(addLicense)).Methods("POST")
api.BaseRoutes.License.Handle("/remove", api.ApiAdminSystemRequired(removeLicense)).Methods("POST")
api.BaseRoutes.License.Handle("/client_config", api.ApiAppHandler(getClientLicenceConfig)).Methods("GET")

Просмотреть файл

@@ -6,15 +6,11 @@ package api
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitOAuth() {
l4g.Debug(utils.T("api.oauth.init.debug"))
api.BaseRoutes.OAuth.Handle("/register", api.ApiUserRequired(registerOAuthApp)).Methods("POST")
api.BaseRoutes.OAuth.Handle("/list", api.ApiUserRequired(getOAuthApps)).Methods("GET")
api.BaseRoutes.OAuth.Handle("/app/{client_id}", api.ApiUserRequired(getOAuthAppInfo)).Methods("GET")

Просмотреть файл

@@ -8,7 +8,6 @@ import (
"strconv"
"time"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/model"
@@ -20,8 +19,6 @@ const OPEN_GRAPH_METADATA_CACHE_SIZE = 10000
var openGraphDataCache = utils.NewLru(OPEN_GRAPH_METADATA_CACHE_SIZE)
func (api *API) InitPost() {
l4g.Debug(utils.T("api.post.init.debug"))
api.BaseRoutes.ApiRoot.Handle("/get_opengraph_metadata", api.ApiUserRequired(getOpenGraphMetadata)).Methods("POST")
api.BaseRoutes.NeedTeam.Handle("/posts/search", api.ApiUserRequiredActivity(searchPosts, true)).Methods("POST")

Просмотреть файл

@@ -6,15 +6,11 @@ package api
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitPreference() {
l4g.Debug(utils.T("api.preference.init.debug"))
api.BaseRoutes.Preferences.Handle("/", api.ApiUserRequired(getAllPreferences)).Methods("GET")
api.BaseRoutes.Preferences.Handle("/save", api.ApiUserRequired(savePreferences)).Methods("POST")
api.BaseRoutes.Preferences.Handle("/delete", api.ApiUserRequired(deletePreferences)).Methods("POST")

Просмотреть файл

@@ -6,15 +6,11 @@ package api
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitReaction() {
l4g.Debug(utils.T("api.reaction.init.debug"))
api.BaseRoutes.NeedPost.Handle("/reactions/save", api.ApiUserRequired(saveReaction)).Methods("POST")
api.BaseRoutes.NeedPost.Handle("/reactions/delete", api.ApiUserRequired(deleteReaction)).Methods("POST")
api.BaseRoutes.NeedPost.Handle("/reactions", api.ApiUserRequired(listReactions)).Methods("GET")

Просмотреть файл

@@ -6,15 +6,10 @@ package api
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitStatus() {
l4g.Debug(utils.T("api.status.init.debug"))
api.BaseRoutes.Users.Handle("/status", api.ApiUserRequired(getStatusesHttp)).Methods("GET")
api.BaseRoutes.Users.Handle("/status/ids", api.ApiUserRequired(getStatusesByIdsHttp)).Methods("POST")
}

Просмотреть файл

@@ -10,7 +10,6 @@ import (
"strconv"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/model"
@@ -18,8 +17,6 @@ import (
)
func (api *API) InitTeam() {
l4g.Debug(utils.T("api.team.init.debug"))
api.BaseRoutes.Teams.Handle("/create", api.ApiUserRequired(createTeam)).Methods("POST")
api.BaseRoutes.Teams.Handle("/all", api.ApiUserRequired(getAll)).Methods("GET")
api.BaseRoutes.Teams.Handle("/all_team_listings", api.ApiUserRequired(GetAllTeamListings)).Methods("GET")

Просмотреть файл

@@ -20,8 +20,6 @@ import (
)
func (api *API) InitUser() {
l4g.Debug(utils.T("api.user.init.debug"))
api.BaseRoutes.Users.Handle("/create", api.ApiAppHandler(createUser)).Methods("POST")
api.BaseRoutes.Users.Handle("/update", api.ApiUserRequired(updateUser)).Methods("POST")
api.BaseRoutes.Users.Handle("/update_active", api.ApiUserRequired(updateActive)).Methods("POST")

Просмотреть файл

@@ -6,14 +6,10 @@ package api
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitWebhook() {
l4g.Debug(utils.T("api.webhook.init.debug"))
api.BaseRoutes.Hooks.Handle("/incoming/create", api.ApiUserRequired(createIncomingHook)).Methods("POST")
api.BaseRoutes.Hooks.Handle("/incoming/update", api.ApiUserRequired(updateIncomingHook)).Methods("POST")
api.BaseRoutes.Hooks.Handle("/incoming/delete", api.ApiUserRequired(deleteIncomingHook)).Methods("POST")

Просмотреть файл

@@ -5,14 +5,9 @@ package api
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitWebrtc() {
l4g.Debug(utils.T("api.webrtc.init.debug"))
api.BaseRoutes.Webrtc.Handle("/token", api.ApiUserRequired(webrtcToken)).Methods("POST")
}

Просмотреть файл

@@ -13,7 +13,6 @@ import (
)
func (api *API) InitWebSocket() {
l4g.Debug(utils.T("api.web_socket.init.debug"))
api.BaseRoutes.Users.Handle("/websocket", api.ApiAppHandlerTrustRequester(connect)).Methods("GET")
}

Просмотреть файл

@@ -88,7 +88,6 @@ func setupTestHelper(enterprise bool) *TestHelper {
*cfg.RateLimitSettings.Enable = false
cfg.EmailSettings.SendEmailNotifications = true
})
utils.DisableDebugLogForTest()
prevListenAddress := *th.App.Config().ServiceSettings.ListenAddress
if testStore != nil {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = ":0" })
@@ -97,7 +96,6 @@ func setupTestHelper(enterprise bool) *TestHelper {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = prevListenAddress })
Init(th.App, th.App.Srv.Router, true)
wsapi.Init(th.App, th.App.Srv.WebSocketRouter)
utils.EnableDebugLogForTest()
th.App.Srv.Store.MarkSystemRanUnitTests()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = true })

Просмотреть файл

@@ -6,14 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitBrand() {
l4g.Debug(utils.T("api.brand.init.debug"))
api.BaseRoutes.Brand.Handle("/image", api.ApiHandlerTrustRequester(getBrandImage)).Methods("GET")
api.BaseRoutes.Brand.Handle("/image", api.ApiSessionRequired(uploadBrandImage)).Methods("POST")
}

Просмотреть файл

@@ -8,12 +8,9 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitChannel() {
l4g.Debug(utils.T("api.channel.init.debug"))
api.BaseRoutes.Channels.Handle("", api.ApiSessionRequired(createChannel)).Methods("POST")
api.BaseRoutes.Channels.Handle("/direct", api.ApiSessionRequired(createDirectChannel)).Methods("POST")
api.BaseRoutes.Channels.Handle("/group", api.ApiSessionRequired(createGroupChannel)).Methods("POST")

Просмотреть файл

@@ -6,14 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitCluster() {
l4g.Debug(utils.T("api.cluster.init.debug"))
api.BaseRoutes.Cluster.Handle("/status", api.ApiSessionRequired(getClusterStatus)).Methods("GET")
}

Просмотреть файл

@@ -9,14 +9,10 @@ import (
"strconv"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitCommand() {
l4g.Debug(utils.T("api.command.init.debug"))
api.BaseRoutes.Commands.Handle("", api.ApiSessionRequired(createCommand)).Methods("POST")
api.BaseRoutes.Commands.Handle("", api.ApiSessionRequired(listCommands)).Methods("GET")
api.BaseRoutes.Commands.Handle("/execute", api.ApiSessionRequired(executeCommand)).Methods("POST")

Просмотреть файл

@@ -7,15 +7,11 @@ import (
"net/http"
"strconv"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
"github.com/mssola/user_agent"
)
func (api *API) InitCompliance() {
l4g.Debug(utils.T("api.compliance.init.debug"))
api.BaseRoutes.Compliance.Handle("/reports", api.ApiSessionRequired(createComplianceReport)).Methods("POST")
api.BaseRoutes.Compliance.Handle("/reports", api.ApiSessionRequired(getComplianceReports)).Methods("GET")
api.BaseRoutes.Compliance.Handle("/reports/{report_id:[A-Za-z0-9]+}", api.ApiSessionRequired(getComplianceReport)).Methods("GET")

Просмотреть файл

@@ -5,15 +5,9 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitDataRetention() {
l4g.Debug(utils.T("api.data_retention.init.debug"))
api.BaseRoutes.DataRetention.Handle("/policy", api.ApiSessionRequired(getPolicy)).Methods("GET")
}

Просмотреть файл

@@ -6,14 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitElasticsearch() {
l4g.Debug(utils.T("api.elasticsearch.init.debug"))
api.BaseRoutes.Elasticsearch.Handle("/test", api.ApiSessionRequired(testElasticsearch)).Methods("POST")
api.BaseRoutes.Elasticsearch.Handle("/purge_indexes", api.ApiSessionRequired(purgeElasticsearchIndexes)).Methods("POST")
}

Просмотреть файл

@@ -7,16 +7,11 @@ import (
"net/http"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitEmoji() {
l4g.Debug(utils.T("api.emoji.init.debug"))
api.BaseRoutes.Emojis.Handle("", api.ApiSessionRequired(createEmoji)).Methods("POST")
api.BaseRoutes.Emojis.Handle("", api.ApiSessionRequired(getEmojiList)).Methods("GET")
api.BaseRoutes.Emoji.Handle("", api.ApiSessionRequired(deleteEmoji)).Methods("DELETE")

Просмотреть файл

@@ -9,7 +9,6 @@ import (
"strconv"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
@@ -44,8 +43,6 @@ var MEDIA_CONTENT_TYPES = [...]string{
}
func (api *API) InitFile() {
l4g.Debug(utils.T("api.file.init.debug"))
api.BaseRoutes.Files.Handle("", api.ApiSessionRequired(uploadFile)).Methods("POST")
api.BaseRoutes.File.Handle("", api.ApiSessionRequiredTrustRequester(getFile)).Methods("GET")
api.BaseRoutes.File.Handle("/thumbnail", api.ApiSessionRequiredTrustRequester(getFileThumbnail)).Methods("GET")

Просмотреть файл

@@ -6,13 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
)
func (api *API) InitJob() {
l4g.Info("Initializing job API routes")
api.BaseRoutes.Jobs.Handle("", api.ApiSessionRequired(getJobs)).Methods("GET")
api.BaseRoutes.Jobs.Handle("", api.ApiSessionRequired(createJob)).Methods("POST")
api.BaseRoutes.Jobs.Handle("/{job_id:[A-Za-z0-9]+}", api.ApiSessionRequired(getJob)).Methods("GET")

Просмотреть файл

@@ -6,14 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitLdap() {
l4g.Debug(utils.T("api.ldap.init.debug"))
api.BaseRoutes.LDAP.Handle("/sync", api.ApiSessionRequired(syncLdap)).Methods("POST")
api.BaseRoutes.LDAP.Handle("/test", api.ApiSessionRequired(testLdap)).Methods("POST")
}

Просмотреть файл

@@ -15,8 +15,6 @@ import (
)
func (api *API) InitOAuth() {
l4g.Debug(utils.T("api.oauth.init.debug"))
api.BaseRoutes.OAuthApps.Handle("", api.ApiSessionRequired(createOAuthApp)).Methods("POST")
api.BaseRoutes.OAuthApp.Handle("", api.ApiSessionRequired(updateOAuthApp)).Methods("PUT")
api.BaseRoutes.OAuthApps.Handle("", api.ApiSessionRequired(getOAuthApps)).Methods("GET")

Просмотреть файл

@@ -6,7 +6,6 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
@@ -16,8 +15,6 @@ const OPEN_GRAPH_METADATA_CACHE_SIZE = 10000
var openGraphDataCache = utils.NewLru(OPEN_GRAPH_METADATA_CACHE_SIZE)
func (api *API) InitOpenGraph() {
l4g.Debug(utils.T("api.opengraph.init.debug"))
api.BaseRoutes.OpenGraph.Handle("", api.ApiSessionRequired(getOpenGraphMetadata)).Methods("POST")
}

Просмотреть файл

@@ -9,8 +9,9 @@ import (
"net/http/httptest"
"strings"
"github.com/mattermost/mattermost-server/model"
"testing"
"github.com/mattermost/mattermost-server/model"
)
func TestGetOpenGraphMetadata(t *testing.T) {

Просмотреть файл

@@ -8,15 +8,10 @@ import (
"strconv"
"time"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitPost() {
l4g.Debug(utils.T("api.post.init.debug"))
api.BaseRoutes.Posts.Handle("", api.ApiSessionRequired(createPost)).Methods("POST")
api.BaseRoutes.Post.Handle("", api.ApiSessionRequired(getPost)).Methods("GET")
api.BaseRoutes.Post.Handle("", api.ApiSessionRequired(deletePost)).Methods("DELETE")

Просмотреть файл

@@ -6,14 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitPreference() {
l4g.Debug(utils.T("api.preference.init.debug"))
api.BaseRoutes.Preferences.Handle("", api.ApiSessionRequired(getPreferences)).Methods("GET")
api.BaseRoutes.Preferences.Handle("", api.ApiSessionRequired(updatePreferences)).Methods("PUT")
api.BaseRoutes.Preferences.Handle("/delete", api.ApiSessionRequired(deletePreferences)).Methods("POST")

Просмотреть файл

@@ -6,14 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitReaction() {
l4g.Debug(utils.T("api.reaction.init.debug"))
api.BaseRoutes.Reactions.Handle("", api.ApiSessionRequired(saveReaction)).Methods("POST")
api.BaseRoutes.Post.Handle("/reactions", api.ApiSessionRequired(getReactions)).Methods("GET")
api.BaseRoutes.ReactionByNameForPostForUser.Handle("", api.ApiSessionRequired(deleteReaction)).Methods("DELETE")

Просмотреть файл

@@ -7,14 +7,10 @@ import (
"mime/multipart"
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitSaml() {
l4g.Debug(utils.T("api.saml.init.debug"))
api.BaseRoutes.SAML.Handle("/metadata", api.ApiHandler(getSamlMetadata)).Methods("GET")
api.BaseRoutes.SAML.Handle("/certificate/public", api.ApiSessionRequired(addSamlPublicCertificate)).Methods("POST")

Просмотреть файл

@@ -6,15 +6,10 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitStatus() {
l4g.Debug(utils.T("api.status.init.debug"))
api.BaseRoutes.User.Handle("/status", api.ApiSessionRequired(getUserStatus)).Methods("GET")
api.BaseRoutes.Users.Handle("/status/ids", api.ApiSessionRequired(getUserStatusesByIds)).Methods("POST")
api.BaseRoutes.User.Handle("/status", api.ApiSessionRequired(updateUserStatus)).Methods("PUT")

Просмотреть файл

@@ -16,8 +16,6 @@ import (
)
func (api *API) InitSystem() {
l4g.Debug(utils.T("api.system.init.debug"))
api.BaseRoutes.System.Handle("/ping", api.ApiHandler(getSystemPing)).Methods("GET")
api.BaseRoutes.ApiRoot.Handle("/config", api.ApiSessionRequired(getConfig)).Methods("GET")

Просмотреть файл

@@ -9,9 +9,7 @@ import (
"net/http"
"strconv"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
const (
@@ -19,8 +17,6 @@ const (
)
func (api *API) InitTeam() {
l4g.Debug(utils.T("api.team.init.debug"))
api.BaseRoutes.Teams.Handle("", api.ApiSessionRequired(createTeam)).Methods("POST")
api.BaseRoutes.Teams.Handle("", api.ApiSessionRequired(getAllTeams)).Methods("GET")
api.BaseRoutes.Teams.Handle("/search", api.ApiSessionRequired(searchTeams)).Methods("POST")

Просмотреть файл

@@ -17,8 +17,6 @@ import (
)
func (api *API) InitUser() {
l4g.Debug(utils.T("api.user.init.debug"))
api.BaseRoutes.Users.Handle("", api.ApiHandler(createUser)).Methods("POST")
api.BaseRoutes.Users.Handle("", api.ApiSessionRequired(getUsers)).Methods("GET")
api.BaseRoutes.Users.Handle("/ids", api.ApiSessionRequired(getUsersByIds)).Methods("POST")

Просмотреть файл

@@ -8,15 +8,12 @@ import (
"net/http"
"strings"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitWebhook() {
l4g.Debug(utils.T("api.webhook.init.debug"))
api.BaseRoutes.IncomingHooks.Handle("", api.ApiSessionRequired(createIncomingHook)).Methods("POST")
api.BaseRoutes.IncomingHooks.Handle("", api.ApiSessionRequired(getIncomingHooks)).Methods("GET")
api.BaseRoutes.IncomingHook.Handle("", api.ApiSessionRequired(getIncomingHook)).Methods("GET")

Просмотреть файл

@@ -5,14 +5,9 @@ package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitWebrtc() {
l4g.Debug(utils.T("api.webrtc.init.debug"))
api.BaseRoutes.Webrtc.Handle("/token", api.ApiSessionRequired(webrtcToken)).Methods("GET")
}

Просмотреть файл

@@ -4,8 +4,9 @@
package api4
import (
"github.com/mattermost/mattermost-server/model"
"testing"
"github.com/mattermost/mattermost-server/model"
)
func TestGetWebrtcToken(t *testing.T) {

Просмотреть файл

@@ -13,8 +13,6 @@ import (
)
func (api *API) InitWebSocket() {
l4g.Debug(utils.T("api.web_socket.init.debug"))
api.BaseRoutes.ApiRoot.Handle("/websocket", api.ApiHandlerTrustRequester(connectWebSocket)).Methods("GET")
}

Просмотреть файл

@@ -69,14 +69,12 @@ func setupTestHelper(enterprise bool) *TestHelper {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxUsersPerTeam = 50 })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.RateLimitSettings.Enable = false })
utils.DisableDebugLogForTest()
prevListenAddress := *th.App.Config().ServiceSettings.ListenAddress
if testStore != nil {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = ":0" })
}
th.App.StartServer()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = prevListenAddress })
utils.EnableDebugLogForTest()
th.App.Srv.Store.MarkSystemRanUnitTests()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = true })

Просмотреть файл

@@ -157,11 +157,12 @@ func testUserStoreUpdate(t *testing.T, ss store.Store) {
}
}
u3.Email = model.NewId()
if result := <-ss.User().Update(u3, true); result.Err != nil {
t.Fatal("Update should not have failed")
} else {
newUser := result.Data.([2]*model.User)[0]
if newUser.Email != u3.Email {
if newUser.Email == oldEmail {
t.Fatal("Email should have been updated as the update is trusted")
}
}

Просмотреть файл

@@ -7,12 +7,9 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitStatus() {
l4g.Debug(utils.T("wsapi.status.init.debug"))
api.Router.Handle("get_statuses", api.ApiWebSocketHandler(api.getStatuses))
api.Router.Handle("get_statuses_by_ids", api.ApiWebSocketHandler(api.getStatusesByIds))
}

Просмотреть файл

@@ -4,14 +4,10 @@
package wsapi
import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitSystem() {
l4g.Debug(utils.T("wsapi.system.init.debug"))
api.Router.Handle("ping", api.ApiWebSocketHandler(ping))
}

Просмотреть файл

@@ -4,14 +4,10 @@
package wsapi
import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitUser() {
l4g.Debug(utils.T("wsapi.user.init.debug"))
api.Router.Handle("user_typing", api.ApiWebSocketHandler(api.userTyping))
}

Просмотреть файл

@@ -4,14 +4,10 @@
package wsapi
import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
func (api *API) InitWebrtc() {
l4g.Debug(utils.T("wsapi.webtrc.init.debug"))
api.Router.Handle("webrtc", api.ApiWebSocketHandler(api.webrtcMessage))
}