mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-17 15:32:43 +00:00
Refactor Webhook + Add X-Hub-Signature (#16176)
This PR removes multiple unneeded fields from the `HookTask` struct and adds the two headers `X-Hub-Signature` and `X-Hub-Signature-256`. ## ⚠️ BREAKING ⚠️ * The `Secret` field is no longer passed as part of the payload. * "Breaking" change (or fix?): The webhook history shows the real called url and not the url registered in the webhook (`deliver.go`@129). Close #16115 Fixes #7788 Fixes #11755 Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
0b27b93728
commit
9b1b4b5433
18 changed files with 130 additions and 179 deletions
|
@ -184,6 +184,8 @@ func TestMatrixJSONPayload(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMatrixHookRequest(t *testing.T) {
|
||||
w := &models.Webhook{}
|
||||
|
||||
h := &models.HookTask{
|
||||
PayloadContent: `{
|
||||
"body": "[[user1/test](http://localhost:3000/user1/test)] user1 pushed 1 commit to [master](http://localhost:3000/user1/test/src/branch/master):\n[5175ef2](http://localhost:3000/user1/test/commit/5175ef26201c58b035a3404b3fe02b4e8d436eee): Merge pull request 'Change readme.md' (#2) from add-matrix-webhook into master\n\nReviewed-on: http://localhost:3000/user1/test/pulls/2\n - user1",
|
||||
|
@ -245,7 +247,7 @@ func TestMatrixHookRequest(t *testing.T) {
|
|||
]
|
||||
}`
|
||||
|
||||
req, err := getMatrixHookRequest(h)
|
||||
req, err := getMatrixHookRequest(w, h)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, req)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue