From 6c30527c1c594c257164b17ede2382bb5dcec301 Mon Sep 17 00:00:00 2001 From: Krzysztof Szyper Date: Wed, 21 Jul 2021 00:26:07 +0200 Subject: [PATCH] Updated tests in `victorops_test.py` to accommodate new fields passed to alert payload. * Needed by https://github.com/jertel/elastalert2/pull/329 --- docs/source/ruletypes.rst | 2 +- tests/alerters/victorops_test.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/source/ruletypes.rst b/docs/source/ruletypes.rst index c908eee7..992e3fa4 100644 --- a/docs/source/ruletypes.rst +++ b/docs/source/ruletypes.rst @@ -2707,7 +2707,7 @@ Optional: ``victorops_entity_id``: The identity of the incident used by Splunk On-Call (Formerly VictorOps) to correlate incidents throughout the alert lifecycle. If not defined, Splunk On-Call (Formerly VictorOps) will assign a random string to each alert. -``victorops_entity_display_name``: Human-readable name of alerting entity to summarize incidents without affecting the life-cycle workflow. +``victorops_entity_display_name``: Human-readable name of alerting entity to summarize incidents without affecting the life-cycle workflow. Will use `alert_subject` if not set. ``victorops_proxy``: By default ElastAlert will not use a network proxy to send notifications to Splunk On-Call (Formerly VictorOps). Set this option using ``hostname:port`` if you need to use a proxy. only supports https. diff --git a/tests/alerters/victorops_test.py b/tests/alerters/victorops_test.py index e9f750ae..e7be587c 100644 --- a/tests/alerters/victorops_test.py +++ b/tests/alerters/victorops_test.py @@ -36,7 +36,9 @@ def test_victorops(caplog): 'message_type': rule['victorops_message_type'], 'entity_display_name': rule['victorops_entity_display_name'], 'monitoring_tool': 'ElastAlert', - 'state_message': 'Test VictorOps Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n' + 'state_message': 'Test VictorOps Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n', + '@timestamp': '2021-01-01T00:00:00', + 'somefield': 'foobarbaz' } mock_post_request.assert_called_once_with( @@ -76,7 +78,9 @@ def test_victorops_proxy(): 'message_type': rule['victorops_message_type'], 'entity_display_name': rule['victorops_entity_display_name'], 'monitoring_tool': 'ElastAlert', - 'state_message': 'Test VictorOps Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n' + 'state_message': 'Test VictorOps Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n', + '@timestamp': '2021-01-01T00:00:00', + 'somefield': 'foobarbaz' } mock_post_request.assert_called_once_with( @@ -141,7 +145,9 @@ def test_victorops_entity_id(): 'entity_display_name': rule['victorops_entity_display_name'], 'monitoring_tool': 'ElastAlert', 'state_message': 'Test VictorOps Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n', - 'entity_id': '12345' + 'entity_id': '12345', + '@timestamp': '2021-01-01T00:00:00', + 'somefield': 'foobarbaz' } mock_post_request.assert_called_once_with( @@ -186,7 +192,9 @@ def test_victorops_message_type(message_type, except_message_type): 'message_type': except_message_type, 'entity_display_name': rule['victorops_entity_display_name'], 'monitoring_tool': 'ElastAlert', - 'state_message': 'Test VictorOps Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n' + 'state_message': 'Test VictorOps Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n', + '@timestamp': '2021-01-01T00:00:00', + 'somefield': 'foobarbaz' } mock_post_request.assert_called_once_with(