MM-10201: querystring for get slash commands (#8779)

* pass GET slash command payloads through query string

Previously, both GET and POST requests received the payload via the
body, but this was incorrect for GET requests. Now, the payloads for GET
requests is sent via the query string.

* reorder tests for clarity

* switch command tests to use httptest servers

* restore original test command endpoints
Этот коммит содержится в:
Jesse Hallam
2018-05-14 13:24:22 -04:00
коммит произвёл Joram Wilander
родитель 6a9aa855d1
Коммит a1656dffa9
2 изменённых файлов: 137 добавлений и 62 удалений

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

@@ -230,12 +230,14 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
p.Set("response_url", args.SiteURL+"/hooks/commands/"+hook.Id)
}
method := "POST"
var req *http.Request
if cmd.Method == model.COMMAND_METHOD_GET {
method = "GET"
req, _ = http.NewRequest(http.MethodGet, cmd.URL, nil)
req.URL.RawQuery = p.Encode()
} else {
req, _ = http.NewRequest(http.MethodPost, cmd.URL, strings.NewReader(p.Encode()))
}
req, _ := http.NewRequest(method, cmd.URL, strings.NewReader(p.Encode()))
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Token "+cmd.Token)
if cmd.Method == model.COMMAND_METHOD_POST {