Introduces issue webhooks (#29664):

* users can set up hooks for issue creation, update and deletion events, for any number of projects
* hooks run in the context of the creating user, and only if the object in question is visible to that user
* the actual HTTP call is done in ActiveJob
* webhook calls are optionally signed the same way GitHub does

Patch by Jens Krämer (user:jkraemer).



git-svn-id: https://svn.redmine.org/redmine/trunk@24034 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2025-10-07 06:49:14 +00:00
parent 824f3844fc
commit d90d192f48
24 changed files with 986 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
# frozen_string_literal: true
require 'test_helper'
class WebhookPayloadTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
fixtures :projects, :users, :trackers, :projects_trackers, :versions,
:issue_statuses, :issue_categories, :issue_relations,
:enumerations, :issues, :journals, :journal_details
setup do
@dlopper = User.find_by_login 'dlopper'
@project = Project.find 'ecookbook'
@issue = @project.issues.first
end
test "issue update payload should contain journal" do
@issue.init_journal(@dlopper)
@issue.subject = "new subject"
@issue.save
p = WebhookPayload.new('issue.updated', @issue, @dlopper)
assert h = p.to_h
assert_equal 'issue.updated', h[:type]
assert j = h.dig(:data, :journal)
assert_equal 'Dave Lopper', j[:user][:name]
assert i = h.dig(:data, :issue)
assert_equal 'new subject', i[:subject], i.inspect
end
test "should compute payload of deleted issue" do
@issue.destroy
p = WebhookPayload.new('issue.deleted', @issue, @dlopper)
assert h = p.to_h
assert_equal 'issue.deleted', h[:type]
assert_nil h.dig(:data, :journal)
assert i = h.dig(:data, :issue)
assert_equal @issue.subject, i[:subject], i.inspect
end
end