Various APIv4 fixes (#5474)

This commit is contained in:
Joram Wilander
2017-02-20 15:35:02 -05:00
committed by Corey Hulen
parent 5272c0c170
commit a5f8bdd3a0
3 changed files with 7 additions and 1 deletions

View File

@@ -128,6 +128,8 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if utils.GetSiteURL() == "" {
protocol := app.GetProtocol(r)
c.SetSiteURL(protocol + "://" + r.Host)
} else {
c.SetSiteURL(utils.GetSiteURL())
}
w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId)

View File

@@ -19,7 +19,7 @@ func InitTeam() {
BaseRoutes.TeamsForUser.Handle("", ApiSessionRequired(getTeamsForUser)).Methods("GET")
BaseRoutes.Team.Handle("", ApiSessionRequired(getTeam)).Methods("GET")
BaseRoutes.Team.Handle("/stats", ApiHandler(getTeamStats)).Methods("GET")
BaseRoutes.Team.Handle("/stats", ApiSessionRequired(getTeamStats)).Methods("GET")
BaseRoutes.TeamByName.Handle("", ApiSessionRequired(getTeamByName)).Methods("GET")
BaseRoutes.TeamMember.Handle("", ApiSessionRequired(getTeamMember)).Methods("GET")

View File

@@ -278,4 +278,8 @@ func TestGetTeamStats(t *testing.T) {
Client.Login(user.Email, user.Password)
_, resp = Client.GetTeamStats(th.BasicTeam.Id, "")
CheckForbiddenStatus(t, resp)
Client.Logout()
_, resp = Client.GetTeamStats(th.BasicTeam.Id, "")
CheckUnauthorizedStatus(t, resp)
}