From 17595199daa6b1b8a706fa764f64947e97d577e8 Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Thu, 23 Nov 2023 14:22:02 +0100 Subject: [PATCH] [6.15] negative test for webhook task (#13049) negative test for webhook task (cherry picked from commit 37da211c840f6d92cbdb647140a48c9de5f8fea5) --- tests/foreman/api/test_webhook.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/foreman/api/test_webhook.py b/tests/foreman/api/test_webhook.py index 019ac42484c..1268661515a 100644 --- a/tests/foreman/api/test_webhook.py +++ b/tests/foreman/api/test_webhook.py @@ -172,3 +172,28 @@ def test_positive_event_triggered(self, module_org, target_sat, setting_update): repo.sync() assert_event_triggered(shell, hook.event) target_sat.wait_for_tasks(f'Deliver webhook {hook.name}') + + @pytest.mark.parametrize('setting_update', ['safemode_render=False'], indirect=True) + def test_negative_event_task_failed(self, module_org, target_sat, setting_update): + """Create a webhook with unreachable target and assert the associated task + failed + + :id: d4a49556-9413-46e8-bcb5-7afd0184bdb2 + + :expectedresults: Deliver webhook task fails + + :CaseImportance: High + """ + hook = target_sat.api.Webhooks( + event='actions.katello.repository.sync_succeeded', + http_method='GET', + target_url="http://localhost/target", + ).create() + repo = target_sat.api.Repository( + organization=module_org, content_type='yum', url=settings.repos.yum_0.url + ).create() + with target_sat.session.shell() as shell: + shell.send('foreman-tail') + repo.sync() + assert_event_triggered(shell, hook.event) + target_sat.wait_for_tasks(f'Deliver webhook {hook.name}', must_succeed=False)