From cfdc0a1f2a8d5c0f42c239b73c0f8cfbfb4fc73b Mon Sep 17 00:00:00 2001 From: estebanthilliez Date: Mon, 22 Apr 2024 20:44:20 +0200 Subject: [PATCH] Fix Healthchecks UUID regex --- borgmatic/hooks/healthchecks.py | 2 +- tests/unit/hooks/test_healthchecks.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/borgmatic/hooks/healthchecks.py b/borgmatic/hooks/healthchecks.py index c36143d..65afc02 100644 --- a/borgmatic/hooks/healthchecks.py +++ b/borgmatic/hooks/healthchecks.py @@ -60,7 +60,7 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev ) return - ping_url_is_uuid = re.match(r'(\w{4}-?){4}$', hook_config['ping_url']) + ping_url_is_uuid = re.search(r'\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$', ping_url) healthchecks_state = MONITOR_STATE_TO_HEALTHCHECKS.get(state) if healthchecks_state: diff --git a/tests/unit/hooks/test_healthchecks.py b/tests/unit/hooks/test_healthchecks.py index f53c0f5..74afe40 100644 --- a/tests/unit/hooks/test_healthchecks.py +++ b/tests/unit/hooks/test_healthchecks.py @@ -299,7 +299,7 @@ def test_ping_monitor_does_not_add_create_query_parameter_when_create_slug_false def test_ping_monitor_does_not_add_create_query_parameter_when_ping_url_is_uuid(): - hook_config = {'ping_url': 'abcd-efgh-ijkl-mnop', 'create_slug': True} + hook_config = {'ping_url': 'b3611b24-df9c-4d36-9203-fa292820bf2a', 'create_slug': True} flexmock(module.requests).should_receive('post').with_args( f"https://hc-ping.com/{hook_config['ping_url']}", data=''.encode('utf-8'),