From f24cdeff495f56b5440be58344479b4eaad675ac Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Tue, 7 Nov 2023 11:02:15 +0100 Subject: [PATCH] negative test for webhook task --- tests/foreman/api/test_webhook.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/foreman/api/test_webhook.py b/tests/foreman/api/test_webhook.py index 019ac42484c..b76ab718750 100644 --- a/tests/foreman/api/test_webhook.py +++ b/tests/foreman/api/test_webhook.py @@ -172,3 +172,27 @@ 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.tier1 + @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 targete 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' + ).create() + repo = target_sat.api.Repository( + organization=module_org, content_type='yum', url='http://localhost/target' + ).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)