Fix error handling when requesting profile image for bad user ID (#8618)

Этот коммит содержится в:
Joram Wilander
2018-04-13 10:57:22 -04:00
коммит произвёл Christopher Speller
родитель ae5e324be8
Коммит 21b1cd44e0
3 изменённых файлов: 9 добавлений и 1 удалений

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

@@ -199,7 +199,8 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
if len(users) == 0 {
c.Err = err
c.Err = model.NewAppError("getProfileImage", "api.user.get_profile_image.not_found.app_error", nil, "", http.StatusNotFound)
return
}
user := users[0]

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

@@ -834,6 +834,9 @@ func TestGetProfileImage(t *testing.T) {
_, resp = Client.GetProfileImage("junk", "")
CheckBadRequestStatus(t, resp)
_, resp = Client.GetProfileImage(model.NewId(), "")
CheckNotFoundStatus(t, resp)
Client.Logout()
_, resp = Client.GetProfileImage(user.Id, "")
CheckUnauthorizedStatus(t, resp)