Bug 2180760

Summary: no way to test-fire a webhook when configuring it
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: Hooks and WebhooksAssignee: Oleh Fedorenko <ofedoren>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: medium Docs Contact: Adam Lazik <alazik>
Priority: unspecified    
Version: 6.13.0CC: ahumbe, aruzicka, lhellebr, ofedoren, pcreech
Target Milestone: 6.14.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-foreman_webhooks-3.2.0 Doc Type: Enhancement
Doc Text:
.You can now test-fire a webhook You can now test if a webhook functions correctly by clicking *Test webhook* from the list in the *Actions* column. After you enter a payload and click *Submit*, the webhook triggers.
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-08 14:19:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Evgeni Golov 2023-03-22 08:22:45 UTC
Description of problem:
it's hard to test whether a webhook was correctly configured (in terms of endpoint, authentication, etc) without performing the actual action it is subscribed to

Version-Release number of selected component (if applicable):
6.13.0 (but also all previous containing foreman_webhooks)

How reproducible:
100%

Steps to Reproduce:
1. create a new webhook
2. try to fire it, without performing the action it's subscribed to

Actual results:
not possible

Expected results:
I'd expect at least a way that the right type of request (POST) is sent to the right endpoint using the right authentication method.

It might not contain the correct payload and thus the other side might still reject it, but at least I can see that the overall HTTP call worked.


Additional info:

Comment 1 Brad Buckingham 2023-03-23 14:25:05 UTC
Would you consider this an RFE or defect?

Comment 2 Evgeni Golov 2023-03-23 14:35:14 UTC
I would consider a "test this thing" core functionality that is missing. So a defect I guess

Comment 5 Bryan Kearney 2023-06-19 12:02:50 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32363 has been resolved.

Comment 6 Lukáš Hellebrandt 2023-07-13 13:29:46 UTC
Verified with Sat 6.14.0 snap 6.0.

1) Create a webhook teplate with some data in Administer -> Webhook Teplates
2) Create a webhook using this template, assigned to some action (I used Content View Created) in Administer -> Webhooks. As a target, use some reachable machine and some usable port.
3) On the reachable machine, listen on the specified port:
# echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -v -l 8042
4) In Administer -> Webhooks, in the webhook's row, in the Actions column, open the dropdown menu and click "Test webhook".
5) A popup will open, warning you that no actual data will be rendered from the template and this just tests communication layer. It allows you to enter data manually. I entered "data=testdata".
6) For test purposes, you need to disable Selinux on the Satellite:
# setenforce 0
7) Click Submit

RESULT ON THE LISTENING SERVER:
$ echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -v -l 8042 
Ncat: Version 7.93 ( https://nmap.org/ncat )
Ncat: Listening on :::8042
Ncat: Listening on 0.0.0.0:8042
Ncat: Connection from <IP>.
Ncat: Connection from <IP>:58664.
GET /?data=testdate HTTP/1.1
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
User-Agent: Ruby
Content-Type: application/json
X-Request-Id: 6415e714-600d-499e-a667-994ab48433af
X-Session-Id: 4b7da39c-5b85-4f8f-a2d3-6aa4a77968e8
Connection: close
Host: <IP2>:8042
Content-Length: 14
data=testdata

RESULT ON THE SATELLITE:
A green pop-up notification stating: "Webhook Testhook test was successful"

WHEN THE LISTENING SERVER IS NOT RUNNING, THEN ON SATELLITE:
A red pop-up notification stating: "Error: Webhook test failed: Failed to open TCP connection to <IP>:8042 (Connection refused - connect(2) for "<IP>" port 8042)".
Also, a traceback in production.log.

Also, I verified that the webhook indeed gets executed on the specified action.

Comment 9 errata-xmlrpc 2023-11-08 14:19:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.14 security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6818

Comment 10 Red Hat Bugzilla 2024-03-08 04:25:35 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days