浏览代码

Fix Healthchecks UUID regex

estebanthilliez 1 年之前
父节点
当前提交
cfdc0a1f2a
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      borgmatic/hooks/healthchecks.py
  2. 1 1
      tests/unit/hooks/test_healthchecks.py

+ 1 - 1
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:

+ 1 - 1
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'),