api4/license: Return 400 instead of 501 if format is not passed (#19856)

```release-note
NONE
```


Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2022-04-04 10:27:29 +05:30
коммит произвёл GitHub
родитель 326daf1334
Коммит 1cc50ff90c
2 изменённых файлов: 3 добавлений и 3 удалений

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

@@ -31,7 +31,7 @@ func getClientLicense(c *Context, w http.ResponseWriter, r *http.Request) {
format := r.URL.Query().Get("format")
if format == "" {
c.Err = model.NewAppError("getClientLicense", "api.license.client.old_format.app_error", nil, "", http.StatusNotImplemented)
c.Err = model.NewAppError("getClientLicense", "api.license.client.old_format.app_error", nil, "", http.StatusBadRequest)
return
}

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

@@ -38,8 +38,8 @@ func TestGetOldClientLicense(t *testing.T) {
resp, err := client.DoAPIGet("/license/client", "")
require.Error(t, err, "get /license/client did not return an error")
require.Equal(t, http.StatusNotImplemented, resp.StatusCode,
"expected 501 Not Implemented")
require.Equal(t, http.StatusBadRequest, resp.StatusCode,
"expected 400 bad request")
resp, err = client.DoAPIGet("/license/client?format=junk", "")
require.Error(t, err, "get /license/client?format=junk did not return an error")