mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(webhook): validate events and types, sort events and show delivery URLs
webhook create --events pushh created a webhook that fired on nothing, since Gitea drops unknown events, and unknown types or a Slack webhook without a channel failed with raw HTTP 422 errors. --events and --type now accept only what Gitea knows, list it in help and complete it, and a Slack webhook needs --config channel=. Events came back in a different order on every call; they are sorted now. Webhooks can be told apart again: list, view and JSON show the delivery URL without user information and query, and without the path for chat services whose paths carry tokens; view --reveal-url shows it whole. Tables collapse complete event groups such as pull_request (8). On a terminal, webhook edit no longer needs an authorization flag: since Gitea drops the stored header on every edit and never returns it, it asks for the header again and keeps it, and an empty answer suits webhooks without one. Without a terminal the edit still requires the flags. Edit flags lose the create defaults, the unsupported secret flags are hidden on edit, deletions name the webhook and its scope, and mutations print ✓ lines. terminal.View gains Bodyless for resources without a body. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
8 files changed
+666
-248
No files matched your search
@@ -62,6 +62,18 @@ func TestViewRender(t *testing.T) {
|
||||
Display{TTY: true},
|
||||
"Home\n\nNo description provided\n",
|
||||
},
|
||||
{
|
||||
"bodyless for people",
|
||||
View{Title: "laptop", Fields: []Field{{Label: "Type", Value: "ssh-ed25519"}}, Bodyless: true, URL: "https://example.org/keys"},
|
||||
Display{TTY: true},
|
||||
"laptop\nType: ssh-ed25519\n\nView on Gitea: https://example.org/keys\n",
|
||||
},
|
||||
{
|
||||
"bodyless when piped",
|
||||
View{Title: "laptop", Fields: []Field{{Label: "Type", Value: "ssh-ed25519"}}, Bodyless: true, URL: "https://example.org/keys"},
|
||||
Display{},
|
||||
"title:\tlaptop\ntype:\tssh-ed25519\nurl:\thttps://example.org/keys\n",
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
require.Equal(t, tc.want, tc.view.Render(tc.d))
|
||||
|
||||
Reference in new issue
Block a user