Pass query string params to interactive dialog request url (#14366)

Этот коммит содержится в:
Nisheet Sinvhal
2020-06-16 15:01:55 +05:30
коммит произвёл GitHub
родитель e342b5a2f2
Коммит 8c1164d86b
2 изменённых файлов: 14 добавлений и 3 удалений

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

@@ -366,6 +366,7 @@ func (a *App) doPluginRequest(method, rawURL string, values url.Values, body []b
params := make(map[string]string)
params["plugin_id"] = pluginId
r = mux.SetURLVars(r, params)
r.URL.RawQuery = inURL.Query().Encode()
a.ServePluginRequest(w, r)

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

@@ -489,9 +489,13 @@ func TestSubmitInteractiveDialog(t *testing.T) {
plugin.MattermostPlugin
}
func (p *MyPlugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
response := &model.SubmitDialogResponse{
Errors: map[string]string{"name1": "some error"},
func (p *MyPlugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
errReply := "some error"
if r.URL.Query().Get("abc") == "xyz" {
errReply = "some other error"
}
response := &model.SubmitDialogResponse{
Errors: map[string]string{"name1": errReply},
}
w.WriteHeader(http.StatusOK)
_, _ = w.Write(response.ToJson())
@@ -534,6 +538,12 @@ func TestSubmitInteractiveDialog(t *testing.T) {
assert.Nil(t, err)
require.NotNil(t, resp)
assert.Equal(t, "some error", resp.Errors["name1"])
submit.URL = "/plugins/myplugin/myaction?abc=xyz"
resp, err = th.App.SubmitInteractiveDialog(submit)
assert.Nil(t, err)
require.NotNil(t, resp)
assert.Equal(t, "some other error", resp.Errors["name1"])
}
func TestPostActionRelativeURL(t *testing.T) {