[REFACTOR] webhook move edit endpoints
This commit is contained in:
parent
635230ca5d
commit
c0dd92e9c5
|
@ -613,9 +613,9 @@ func registerRoutes(m *web.Route) {
|
||||||
m.Post("/{type}/new", repo_setting.WebhookCreate)
|
m.Post("/{type}/new", repo_setting.WebhookCreate)
|
||||||
m.Group("/{id}", func() {
|
m.Group("/{id}", func() {
|
||||||
m.Get("", repo_setting.WebHooksEdit)
|
m.Get("", repo_setting.WebHooksEdit)
|
||||||
|
m.Post("", repo_setting.WebhookUpdate)
|
||||||
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
||||||
})
|
})
|
||||||
m.Post("/{type}/{id:[0-9]+}", repo_setting.WebhookUpdate)
|
|
||||||
}, webhooksEnabled)
|
}, webhooksEnabled)
|
||||||
|
|
||||||
m.Group("/blocked_users", func() {
|
m.Group("/blocked_users", func() {
|
||||||
|
@ -715,9 +715,9 @@ func registerRoutes(m *web.Route) {
|
||||||
m.Post("/delete", admin.DeleteDefaultOrSystemWebhook)
|
m.Post("/delete", admin.DeleteDefaultOrSystemWebhook)
|
||||||
m.Group("/{id}", func() {
|
m.Group("/{id}", func() {
|
||||||
m.Get("", repo_setting.WebHooksEdit)
|
m.Get("", repo_setting.WebHooksEdit)
|
||||||
|
m.Post("", repo_setting.WebhookUpdate)
|
||||||
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
||||||
})
|
})
|
||||||
m.Post("/{type}/{id:[0-9]+}", repo_setting.WebhookUpdate)
|
|
||||||
}, webhooksEnabled)
|
}, webhooksEnabled)
|
||||||
|
|
||||||
m.Group("/{configType:default-hooks|system-hooks}", func() {
|
m.Group("/{configType:default-hooks|system-hooks}", func() {
|
||||||
|
@ -884,9 +884,9 @@ func registerRoutes(m *web.Route) {
|
||||||
m.Post("/{type}/new", repo_setting.WebhookCreate)
|
m.Post("/{type}/new", repo_setting.WebhookCreate)
|
||||||
m.Group("/{id}", func() {
|
m.Group("/{id}", func() {
|
||||||
m.Get("", repo_setting.WebHooksEdit)
|
m.Get("", repo_setting.WebHooksEdit)
|
||||||
|
m.Post("", repo_setting.WebhookUpdate)
|
||||||
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
||||||
})
|
})
|
||||||
m.Post("/{type}/{id:[0-9]+}", repo_setting.WebhookUpdate)
|
|
||||||
}, webhooksEnabled)
|
}, webhooksEnabled)
|
||||||
|
|
||||||
m.Group("/labels", func() {
|
m.Group("/labels", func() {
|
||||||
|
@ -1059,10 +1059,10 @@ func registerRoutes(m *web.Route) {
|
||||||
m.Post("/{type}/new", repo_setting.WebhookCreate)
|
m.Post("/{type}/new", repo_setting.WebhookCreate)
|
||||||
m.Group("/{id}", func() {
|
m.Group("/{id}", func() {
|
||||||
m.Get("", repo_setting.WebHooksEdit)
|
m.Get("", repo_setting.WebHooksEdit)
|
||||||
|
m.Post("", repo_setting.WebhookUpdate)
|
||||||
m.Post("/test", repo_setting.TestWebhook)
|
m.Post("/test", repo_setting.TestWebhook)
|
||||||
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
m.Post("/replay/{uuid}", repo_setting.ReplayWebhook)
|
||||||
})
|
})
|
||||||
m.Post("/{type}/{id:[0-9]+}", repo_setting.WebhookUpdate)
|
|
||||||
}, webhooksEnabled)
|
}, webhooksEnabled)
|
||||||
|
|
||||||
m.Group("/keys", func() {
|
m.Group("/keys", func() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "dingtalk"}}
|
{{if eq .HookType "dingtalk"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://dingtalk.com" (ctx.Locale.Tr "repo.settings.web_hook_name_dingtalk")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://dingtalk.com" (ctx.Locale.Tr "repo.settings.web_hook_name_dingtalk")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/dingtalk/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "dingtalk/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "discord"}}
|
{{if eq .HookType "discord"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://discord.com" (ctx.Locale.Tr "repo.settings.web_hook_name_discord")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://discord.com" (ctx.Locale.Tr "repo.settings.web_hook_name_discord")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/discord/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "discord/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{if eq .HookType "feishu"}}
|
{{if eq .HookType "feishu"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://feishu.cn" (ctx.Locale.Tr "repo.settings.web_hook_name_feishu")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://feishu.cn" (ctx.Locale.Tr "repo.settings.web_hook_name_feishu")}}</p>
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://larksuite.com" (ctx.Locale.Tr "repo.settings.web_hook_name_larksuite")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://larksuite.com" (ctx.Locale.Tr "repo.settings.web_hook_name_larksuite")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/feishu/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "feishu/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "forgejo"}}
|
{{if eq .HookType "forgejo"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_forgejo")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_forgejo")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/forgejo/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "forgejo/new"}}" method="post">
|
||||||
{{template "base/disable_form_autofill"}}
|
{{template "base/disable_form_autofill"}}
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "gitea"}}
|
{{if eq .HookType "gitea"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_gitea")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_gitea")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/gitea/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "gitea/new"}}" method="post">
|
||||||
{{template "base/disable_form_autofill"}}
|
{{template "base/disable_form_autofill"}}
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "gogs"}}
|
{{if eq .HookType "gogs"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_gogs")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_gogs")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/gogs/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "gogs/new"}}" method="post">
|
||||||
{{template "base/disable_form_autofill"}}
|
{{template "base/disable_form_autofill"}}
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "matrix"}}
|
{{if eq .HookType "matrix"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://matrix.org/" (ctx.Locale.Tr "repo.settings.web_hook_name_matrix")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://matrix.org/" (ctx.Locale.Tr "repo.settings.web_hook_name_matrix")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/matrix/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "matrix/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_HomeserverURL}}error{{end}}">
|
<div class="required field {{if .Err_HomeserverURL}}error{{end}}">
|
||||||
<label for="homeserver_url">{{ctx.Locale.Tr "repo.settings.matrix.homeserver_url"}}</label>
|
<label for="homeserver_url">{{ctx.Locale.Tr "repo.settings.matrix.homeserver_url"}}</label>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "msteams"}}
|
{{if eq .HookType "msteams"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://teams.microsoft.com" (ctx.Locale.Tr "repo.settings.web_hook_name_msteams")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://teams.microsoft.com" (ctx.Locale.Tr "repo.settings.web_hook_name_msteams")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/msteams/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "msteams/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "packagist"}}
|
{{if eq .HookType "packagist"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://packagist.org" (ctx.Locale.Tr "repo.settings.web_hook_name_packagist")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://packagist.org" (ctx.Locale.Tr "repo.settings.web_hook_name_packagist")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/packagist/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "packagist/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_Username}}error{{end}}">
|
<div class="required field {{if .Err_Username}}error{{end}}">
|
||||||
<label for="username">{{ctx.Locale.Tr "repo.settings.packagist_username"}}</label>
|
<label for="username">{{ctx.Locale.Tr "repo.settings.packagist_username"}}</label>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "slack"}}
|
{{if eq .HookType "slack"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://slack.com" (ctx.Locale.Tr "repo.settings.web_hook_name_slack")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://slack.com" (ctx.Locale.Tr "repo.settings.web_hook_name_slack")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/slack/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "slack/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "telegram"}}
|
{{if eq .HookType "telegram"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://core.telegram.org/bots" (ctx.Locale.Tr "repo.settings.web_hook_name_telegram")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://core.telegram.org/bots" (ctx.Locale.Tr "repo.settings.web_hook_name_telegram")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/telegram/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "telegram/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_BotToken}}error{{end}}">
|
<div class="required field {{if .Err_BotToken}}error{{end}}">
|
||||||
<label for="bot_token">{{ctx.Locale.Tr "repo.settings.bot_token"}}</label>
|
<label for="bot_token">{{ctx.Locale.Tr "repo.settings.bot_token"}}</label>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{if eq .HookType "wechatwork"}}
|
{{if eq .HookType "wechatwork"}}
|
||||||
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://work.weixin.qq.com" (ctx.Locale.Tr "repo.settings.web_hook_name_wechatwork")}}</p>
|
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://work.weixin.qq.com" (ctx.Locale.Tr "repo.settings.web_hook_name_wechatwork")}}</p>
|
||||||
<form class="ui form" action="{{.BaseLink}}/wechatwork/{{or .Webhook.ID "new"}}" method="post">
|
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "wechatwork/new"}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
|
||||||
|
|
|
@ -193,8 +193,8 @@ func TestRedirectsWebhooks(t *testing.T) {
|
||||||
{from: "/user2/repo1/settings/hooks/" + kind + "/new", to: "/", verb: "POST"},
|
{from: "/user2/repo1/settings/hooks/" + kind + "/new", to: "/", verb: "POST"},
|
||||||
{from: "/admin/system-hooks/" + kind + "/new", to: "/", verb: "POST"},
|
{from: "/admin/system-hooks/" + kind + "/new", to: "/", verb: "POST"},
|
||||||
{from: "/admin/default-hooks/" + kind + "/new", to: "/", verb: "POST"},
|
{from: "/admin/default-hooks/" + kind + "/new", to: "/", verb: "POST"},
|
||||||
{from: "/user2/repo1/settings/hooks/" + kind + "/1", to: "/", verb: "POST"},
|
{from: "/user2/repo1/settings/hooks/1", to: "/", verb: "POST"},
|
||||||
{from: "/admin/hooks/" + kind + "/1", to: "/", verb: "POST"},
|
{from: "/admin/hooks/1", to: "/", verb: "POST"},
|
||||||
}
|
}
|
||||||
for _, info := range redirects {
|
for _, info := range redirects {
|
||||||
req := NewRequest(t, info.verb, info.from)
|
req := NewRequest(t, info.verb, info.from)
|
||||||
|
|
|
@ -52,7 +52,7 @@ func TestNewWebHookLink(t *testing.T) {
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
assert.Equal(t, webhooksLen, htmlDoc.Find(`a[href^="`+baseurl+`/"][href$="/new"]`).Length(), "not all webhooks are listed in the 'new' dropdown on failure")
|
assert.Equal(t, webhooksLen, htmlDoc.Find(`a[href^="`+baseurl+`/"][href$="/new"]`).Length(), "not all webhooks are listed in the 'new' dropdown on failure")
|
||||||
|
|
||||||
resp = session.MakeRequest(t, NewRequestWithValues(t, "POST", baseurl+"/gitea/1", map[string]string{"_csrf": csrfToken}), http.StatusUnprocessableEntity)
|
resp = session.MakeRequest(t, NewRequestWithValues(t, "POST", baseurl+"/1", map[string]string{"_csrf": csrfToken}), http.StatusUnprocessableEntity)
|
||||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||||
assert.Equal(t, webhooksLen, htmlDoc.Find(`a[href^="`+baseurl+`/"][href$="/new"]`).Length(), "not all webhooks are listed in the 'new' dropdown on failure")
|
assert.Equal(t, webhooksLen, htmlDoc.Find(`a[href^="`+baseurl+`/"][href$="/new"]`).Length(), "not all webhooks are listed in the 'new' dropdown on failure")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue