mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-08-06 16:23:00 +02:00
Add additional test coverage for credential tag (#966).
This commit is contained in:
@@ -309,6 +309,24 @@ def test_ping_monitor_with_connection_error_logs_warning():
|
||||
)
|
||||
|
||||
|
||||
def test_ping_monitor_with_credential_error_logs_warning():
|
||||
hook_config = {'topic': topic}
|
||||
flexmock(module.borgmatic.hooks.credential.tag).should_receive('resolve_credential').and_raise(
|
||||
ValueError
|
||||
)
|
||||
flexmock(module.requests).should_receive('post').never()
|
||||
flexmock(module.logger).should_receive('warning').once()
|
||||
|
||||
module.ping_monitor(
|
||||
hook_config,
|
||||
{},
|
||||
'config.yaml',
|
||||
borgmatic.hooks.monitoring.monitor.State.FAIL,
|
||||
monitoring_log_level=1,
|
||||
dry_run=False,
|
||||
)
|
||||
|
||||
|
||||
def test_ping_monitor_with_other_error_logs_warning():
|
||||
hook_config = {'topic': topic}
|
||||
flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
||||
|
||||
@@ -86,6 +86,23 @@ def test_ping_monitor_with_connection_error_logs_warning():
|
||||
)
|
||||
|
||||
|
||||
def test_ping_monitor_with_credential_error_logs_warning():
|
||||
flexmock(module.borgmatic.hooks.credential.tag).should_receive('resolve_credential').and_raise(
|
||||
ValueError
|
||||
)
|
||||
flexmock(module.requests).should_receive('post').never()
|
||||
flexmock(module.logger).should_receive('warning')
|
||||
|
||||
module.ping_monitor(
|
||||
{'integration_key': 'abc123'},
|
||||
{},
|
||||
'config.yaml',
|
||||
module.monitor.State.FAIL,
|
||||
monitoring_log_level=1,
|
||||
dry_run=False,
|
||||
)
|
||||
|
||||
|
||||
def test_ping_monitor_with_other_error_logs_warning():
|
||||
response = flexmock(ok=False)
|
||||
flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
||||
|
||||
@@ -562,3 +562,25 @@ def test_ping_monitor_push_post_error_bails():
|
||||
monitoring_log_level=1,
|
||||
dry_run=False,
|
||||
)
|
||||
|
||||
|
||||
def test_ping_monitor_credential_error_bails():
|
||||
hook_config = hook_config = {
|
||||
'token': 'ksdjfwoweijfvwoeifvjmwghagy92',
|
||||
'user': '983hfe0of902lkjfa2amanfgui',
|
||||
}
|
||||
|
||||
flexmock(module.borgmatic.hooks.credential.tag).should_receive('resolve_credential').and_raise(
|
||||
ValueError
|
||||
)
|
||||
flexmock(module.requests).should_receive('post').never()
|
||||
flexmock(module.logger).should_receive('warning').once()
|
||||
|
||||
module.ping_monitor(
|
||||
hook_config,
|
||||
{},
|
||||
'config.yaml',
|
||||
borgmatic.hooks.monitoring.monitor.State.FAIL,
|
||||
monitoring_log_level=1,
|
||||
dry_run=False,
|
||||
)
|
||||
|
||||
@@ -520,3 +520,22 @@ def test_ping_monitor_config_itemid_with_username_password_auth_data_and_push_po
|
||||
monitoring_log_level=1,
|
||||
dry_run=False,
|
||||
)
|
||||
|
||||
|
||||
def test_ping_monitor_with_credential_error_bails():
|
||||
hook_config = {'server': SERVER, 'itemid': ITEMID, 'username': USERNAME, 'password': PASSWORD}
|
||||
|
||||
flexmock(module.borgmatic.hooks.credential.tag).should_receive('resolve_credential').and_raise(
|
||||
ValueError
|
||||
)
|
||||
flexmock(module.requests).should_receive('post').never()
|
||||
flexmock(module.logger).should_receive('warning').once()
|
||||
|
||||
module.ping_monitor(
|
||||
hook_config,
|
||||
{},
|
||||
'config.yaml',
|
||||
borgmatic.hooks.monitoring.monitor.State.FAIL,
|
||||
monitoring_log_level=1,
|
||||
dry_run=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user