|
@@ -24,7 +24,7 @@ def test_make_extra_environment_maps_options_to_environment():
|
|
|
'PGSSLROOTCERT': 'root.crt',
|
|
|
'PGSSLCRL': 'crl.crl',
|
|
|
}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
|
|
@@ -35,7 +35,7 @@ def test_make_extra_environment_maps_options_to_environment():
|
|
|
|
|
|
def test_make_extra_environment_with_cli_password_sets_correct_password():
|
|
|
database = {'name': 'foo', 'restore_password': 'trustsome1', 'password': 'anotherpassword'}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
|
|
@@ -84,7 +84,7 @@ def test_database_names_to_dump_passes_through_all_without_format():
|
|
|
|
|
|
def test_database_names_to_dump_with_all_and_format_and_dry_run_bails():
|
|
|
database = {'name': 'all', 'format': 'custom'}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').never()
|
|
@@ -94,7 +94,7 @@ def test_database_names_to_dump_with_all_and_format_and_dry_run_bails():
|
|
|
|
|
|
def test_database_names_to_dump_with_all_and_format_lists_databases():
|
|
|
database = {'name': 'all', 'format': 'custom'}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').and_return(
|
|
@@ -109,7 +109,7 @@ def test_database_names_to_dump_with_all_and_format_lists_databases():
|
|
|
|
|
|
def test_database_names_to_dump_with_all_and_format_lists_databases_with_hostname_and_port():
|
|
|
database = {'name': 'all', 'format': 'custom', 'hostname': 'localhost', 'port': 1234}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
@@ -136,7 +136,7 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_hostnam
|
|
|
|
|
|
def test_database_names_to_dump_with_all_and_format_lists_databases_with_username():
|
|
|
database = {'name': 'all', 'format': 'custom', 'username': 'postgres'}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
@@ -161,7 +161,7 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_usernam
|
|
|
|
|
|
def test_database_names_to_dump_with_all_and_format_lists_databases_with_options():
|
|
|
database = {'name': 'all', 'format': 'custom', 'list_options': '--harder'}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
@@ -177,7 +177,7 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_options
|
|
|
|
|
|
def test_database_names_to_dump_with_all_and_format_excludes_particular_databases():
|
|
|
database = {'name': 'all', 'format': 'custom'}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').and_return(
|
|
@@ -193,7 +193,7 @@ def test_database_names_to_dump_with_all_and_psql_command_uses_custom_command():
|
|
|
'format': 'custom',
|
|
|
'psql_command': 'docker exec --workdir * mycontainer psql',
|
|
|
}
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
@@ -246,7 +246,7 @@ def test_dump_data_sources_runs_pg_dump_for_each_database():
|
|
|
'databases/localhost/foo'
|
|
|
).and_return('databases/localhost/bar')
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
@@ -353,7 +353,7 @@ def test_dump_data_sources_with_dry_run_skips_pg_dump():
|
|
|
'databases/localhost/foo'
|
|
|
).and_return('databases/localhost/bar')
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump').never()
|
|
@@ -382,7 +382,7 @@ def test_dump_data_sources_runs_pg_dump_with_hostname_and_port():
|
|
|
'databases/database.example.org/foo'
|
|
|
)
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
@@ -430,7 +430,7 @@ def test_dump_data_sources_runs_pg_dump_with_username_and_password():
|
|
|
'databases/localhost/foo'
|
|
|
)
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
@@ -476,7 +476,7 @@ def test_dump_data_sources_with_username_injection_attack_gets_escaped():
|
|
|
'databases/localhost/foo'
|
|
|
)
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
@@ -519,7 +519,7 @@ def test_dump_data_sources_runs_pg_dump_with_directory_format():
|
|
|
'databases/localhost/foo'
|
|
|
)
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_parent_directory_for_dump')
|
|
@@ -564,7 +564,7 @@ def test_dump_data_sources_runs_pg_dump_with_options():
|
|
|
'databases/localhost/foo'
|
|
|
)
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
@@ -607,7 +607,7 @@ def test_dump_data_sources_runs_pg_dumpall_for_all_databases():
|
|
|
'databases/localhost/all'
|
|
|
)
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
@@ -639,7 +639,7 @@ def test_dump_data_sources_runs_non_default_pg_dump():
|
|
|
'databases/localhost/foo'
|
|
|
)
|
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
@@ -677,7 +677,7 @@ def test_restore_data_source_dump_runs_pg_restore():
|
|
|
hook_config = [{'name': 'foo', 'schemas': None}, {'name': 'bar'}]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -734,7 +734,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_hostname_and_port():
|
|
|
]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -799,7 +799,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_username_and_password():
|
|
|
]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return(
|
|
@@ -873,7 +873,7 @@ def test_restore_data_source_dump_with_connection_params_uses_connection_params_
|
|
|
]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return(
|
|
@@ -955,7 +955,7 @@ def test_restore_data_source_dump_without_connection_params_uses_restore_params_
|
|
|
]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return(
|
|
@@ -1031,7 +1031,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_options():
|
|
|
]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -1088,7 +1088,7 @@ def test_restore_data_source_dump_runs_psql_for_all_database_dump():
|
|
|
hook_config = [{'name': 'all', 'schemas': None}]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -1130,7 +1130,7 @@ def test_restore_data_source_dump_runs_psql_for_plain_database_dump():
|
|
|
hook_config = [{'name': 'foo', 'format': 'plain', 'schemas': None}]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -1184,7 +1184,7 @@ def test_restore_data_source_dump_runs_non_default_pg_restore_and_psql():
|
|
|
]
|
|
|
extract_process = flexmock(stdout=flexmock())
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -1248,7 +1248,7 @@ def test_restore_data_source_dump_runs_non_default_pg_restore_and_psql():
|
|
|
def test_restore_data_source_dump_with_dry_run_skips_restore():
|
|
|
hook_config = [{'name': 'foo', 'schemas': None}]
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -1275,7 +1275,7 @@ def test_restore_data_source_dump_with_dry_run_skips_restore():
|
|
|
def test_restore_data_source_dump_without_extract_process_restores_from_disk():
|
|
|
hook_config = [{'name': 'foo', 'schemas': None}]
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|
|
@@ -1330,7 +1330,7 @@ def test_restore_data_source_dump_without_extract_process_restores_from_disk():
|
|
|
def test_restore_data_source_dump_with_schemas_restores_schemas():
|
|
|
hook_config = [{'name': 'foo', 'schemas': ['bar', 'baz']}]
|
|
|
|
|
|
- flexmock(module.borgmatic.hooks.credential.tag).should_receive(
|
|
|
+ flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential'
|
|
|
).replace_with(lambda value: value)
|
|
|
flexmock(module).should_receive('make_extra_environment').and_return({'PGSSLMODE': 'disable'})
|