Fix panic if JSON null value is passed as channel update (#23629)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9c656c25d9
Коммит
3705d7af4d
@@ -125,7 +125,7 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
var channel *model.Channel
|
var channel *model.Channel
|
||||||
err := json.NewDecoder(r.Body).Decode(&channel)
|
err := json.NewDecoder(r.Body).Decode(&channel)
|
||||||
if err != nil {
|
if err != nil || channel == nil {
|
||||||
c.SetInvalidParamWithErr("channel", err)
|
c.SetInvalidParamWithErr("channel", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,6 +250,15 @@ func TestUpdateChannel(t *testing.T) {
|
|||||||
_, resp, err = client.UpdateChannel(directChannel)
|
_, resp, err = client.UpdateChannel(directChannel)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|
||||||
|
t.Run("null value", func(t *testing.T) {
|
||||||
|
r, err := client.DoAPIPut(fmt.Sprintf("/channels"+"/%v", channel.Id), "null")
|
||||||
|
resp := model.BuildResponse(r)
|
||||||
|
defer closeBody(r)
|
||||||
|
|
||||||
|
require.Error(t, err)
|
||||||
|
CheckBadRequestStatus(t, resp)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPatchChannel(t *testing.T) {
|
func TestPatchChannel(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user