Pass query string params to interactive dialog request url (#14366)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e342b5a2f2
Коммит
8c1164d86b
@@ -366,6 +366,7 @@ func (a *App) doPluginRequest(method, rawURL string, values url.Values, body []b
|
|||||||
params := make(map[string]string)
|
params := make(map[string]string)
|
||||||
params["plugin_id"] = pluginId
|
params["plugin_id"] = pluginId
|
||||||
r = mux.SetURLVars(r, params)
|
r = mux.SetURLVars(r, params)
|
||||||
|
r.URL.RawQuery = inURL.Query().Encode()
|
||||||
|
|
||||||
a.ServePluginRequest(w, r)
|
a.ServePluginRequest(w, r)
|
||||||
|
|
||||||
|
|||||||
@@ -489,9 +489,13 @@ func TestSubmitInteractiveDialog(t *testing.T) {
|
|||||||
plugin.MattermostPlugin
|
plugin.MattermostPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *MyPlugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
|
func (p *MyPlugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
|
||||||
response := &model.SubmitDialogResponse{
|
errReply := "some error"
|
||||||
Errors: map[string]string{"name1": "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.WriteHeader(http.StatusOK)
|
||||||
_, _ = w.Write(response.ToJson())
|
_, _ = w.Write(response.ToJson())
|
||||||
@@ -534,6 +538,12 @@ func TestSubmitInteractiveDialog(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
require.NotNil(t, resp)
|
require.NotNil(t, resp)
|
||||||
assert.Equal(t, "some error", resp.Errors["name1"])
|
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) {
|
func TestPostActionRelativeURL(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user