mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-26 19:33:02 +02:00
Fix incorrect use of "--log-json" in the "key change-passphrase" action (#485).
This commit is contained in:
@@ -32,7 +32,6 @@ def change_passphrase(
|
||||
(local_path, 'key', 'change-passphrase')
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ (('--umask', str(umask)) if umask else ())
|
||||
+ ('--log-json',)
|
||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
@@ -66,5 +65,5 @@ def change_passphrase(
|
||||
)
|
||||
|
||||
logger.answer(
|
||||
f"{repository_path}: Don't forget to update your encryption_passphrase option (if needed)",
|
||||
"Don't forget to update your encryption_passphrase option (if needed)",
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ def insert_execute_command_mock(
|
||||
|
||||
def test_change_passphrase_calls_borg_with_required_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'key', 'change-passphrase', '--log-json', 'repo'))
|
||||
insert_execute_command_mock(('borg', 'key', 'change-passphrase', 'repo'))
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -47,7 +47,7 @@ def test_change_passphrase_calls_borg_with_required_flags():
|
||||
|
||||
def test_change_passphrase_calls_borg_with_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg1', 'key', 'change-passphrase', '--log-json', 'repo'))
|
||||
insert_execute_command_mock(('borg1', 'key', 'change-passphrase', 'repo'))
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -64,7 +64,7 @@ def test_change_passphrase_calls_borg_using_exit_codes():
|
||||
borg_exit_codes = flexmock()
|
||||
config = {'borg_exit_codes': borg_exit_codes}
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--log-json', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', 'repo'),
|
||||
config=config,
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
@@ -81,7 +81,7 @@ def test_change_passphrase_calls_borg_using_exit_codes():
|
||||
def test_change_passphrase_calls_borg_with_remote_path_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--remote-path', 'borg1', '--log-json', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', '--remote-path', 'borg1', 'repo'),
|
||||
)
|
||||
|
||||
module.change_passphrase(
|
||||
@@ -98,7 +98,7 @@ def test_change_passphrase_calls_borg_with_umask_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
config = {'umask': '0770'}
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--umask', '0770', '--log-json', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', '--umask', '0770', 'repo'),
|
||||
config=config,
|
||||
)
|
||||
|
||||
@@ -115,7 +115,7 @@ def test_change_passphrase_calls_borg_with_lock_wait_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
config = {'lock_wait': '5'}
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--log-json', '--lock-wait', '5', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', '--lock-wait', '5', 'repo'),
|
||||
config=config,
|
||||
)
|
||||
|
||||
@@ -132,7 +132,7 @@ def test_change_passphrase_calls_borg_with_extra_borg_options():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
config = {'extra_borg_options': {'key_change_passphrase': '--extra "value with space"'}}
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--log-json', '--extra', 'value with space', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', '--extra', 'value with space', 'repo'),
|
||||
config=config,
|
||||
)
|
||||
|
||||
@@ -147,9 +147,7 @@ def test_change_passphrase_calls_borg_with_extra_borg_options():
|
||||
|
||||
def test_change_passphrase_with_log_info_calls_borg_with_info_parameter():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--log-json', '--info', 'repo')
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'key', 'change-passphrase', '--info', 'repo'))
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.change_passphrase(
|
||||
@@ -164,7 +162,7 @@ def test_change_passphrase_with_log_info_calls_borg_with_info_parameter():
|
||||
def test_change_passphrase_with_log_debug_calls_borg_with_debug_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--log-json', '--debug', '--show-rc', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', '--debug', '--show-rc', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
@@ -194,7 +192,7 @@ def test_change_passphrase_with_dry_run_skips_borg_call():
|
||||
def test_change_passphrase_calls_borg_without_passphrase():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--log-json', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', 'repo'),
|
||||
config={'option': 'foo'},
|
||||
)
|
||||
|
||||
@@ -215,7 +213,7 @@ def test_change_passphrase_calls_borg_with_working_directory():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
config = {'working_directory': '/working/dir'}
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--log-json', 'repo'),
|
||||
('borg', 'key', 'change-passphrase', 'repo'),
|
||||
config=config,
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user