MM-27722 Make sidebar category validation silently reject bad channel IDs (#15324)

* MM-27722 Make sidebar category validation silently reject bad channel IDs

* Call validateSidebarCategories when possible

* Remove blank line

* Stop restarting server between subtests
Этот коммит содержится в:
Harrison Healey
2020-08-31 09:45:50 -04:00
коммит произвёл GitHub
родитель c30fea5f2d
Коммит 9b688ae971
3 изменённых файлов: 277 добавлений и 38 удалений

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

@@ -5405,6 +5405,24 @@ func (c *Client4) CreateSidebarCategoryForTeamForUser(userID, teamID string, cat
return cat, BuildResponse(r)
}
func (c *Client4) UpdateSidebarCategoriesForTeamForUser(userID, teamID string, categories []*SidebarCategoryWithChannels) ([]*SidebarCategoryWithChannels, *Response) {
payload, _ := json.Marshal(categories)
route := c.GetUserCategoryRoute(userID, teamID)
r, appErr := c.doApiPutBytes(route, payload)
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
categories, err := SidebarCategoriesFromJson(r.Body)
if err != nil {
return nil, BuildErrorResponse(r, NewAppError("Client4.UpdateSidebarCategoriesForTeamForUser", "model.utils.decode_json.app_error", nil, err.Error(), r.StatusCode))
}
return categories, BuildResponse(r)
}
func (c *Client4) GetSidebarCategoryOrderForTeamForUser(userID, teamID, etag string) ([]string, *Response) {
route := c.GetUserCategoryRoute(userID, teamID) + "/order"
r, err := c.DoApiGet(route, etag)
@@ -5435,7 +5453,7 @@ func (c *Client4) GetSidebarCategoryForTeamForUser(userID, teamID, categoryID, e
defer closeBody(r)
cat, err := SidebarCategoryFromJson(r.Body)
if err != nil {
return nil, &Response{StatusCode: http.StatusBadRequest, Error: NewAppError(c.GetUserRoute(userID), "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
return nil, BuildErrorResponse(r, NewAppError("Client4.UpdateSidebarCategoriesForTeamForUser", "model.utils.decode_json.app_error", nil, err.Error(), r.StatusCode))
}
return cat, BuildResponse(r)
@@ -5451,7 +5469,7 @@ func (c *Client4) UpdateSidebarCategoryForTeamForUser(userID, teamID, categoryID
defer closeBody(r)
cat, err := SidebarCategoryFromJson(r.Body)
if err != nil {
return nil, &Response{StatusCode: http.StatusBadRequest, Error: NewAppError(c.GetUserRoute(userID), "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
return nil, BuildErrorResponse(r, NewAppError("Client4.UpdateSidebarCategoriesForTeamForUser", "model.utils.decode_json.app_error", nil, err.Error(), r.StatusCode))
}
return cat, BuildResponse(r)