mirror of https://github.com/borgbackup/borg.git
more tests for --restrict-to-path
especially test that other directory names sharing same name prefix are not allowed.
This commit is contained in:
parent
cba0c3dc59
commit
28cbf24815
|
@ -1305,12 +1305,21 @@ class RemoteArchiverTestCase(ArchiverTestCase):
|
|||
prefix = '__testsuite__:'
|
||||
|
||||
def test_remote_repo_restrict_to_path(self):
|
||||
# restricted to repo directory itself:
|
||||
with patch.object(RemoteRepository, 'extra_test_args', ['--restrict-to-path', self.repository_path]):
|
||||
self.cmd('init', self.repository_location)
|
||||
path_prefix = os.path.dirname(self.repository_path)
|
||||
# restricted to repo directory itself, fail for other directories with same prefix:
|
||||
with patch.object(RemoteRepository, 'extra_test_args', ['--restrict-to-path', self.repository_path]):
|
||||
self.assert_raises(PathNotAllowed, lambda: self.cmd('init', self.repository_location + '_0'))
|
||||
|
||||
# restricted to a completely different path:
|
||||
with patch.object(RemoteRepository, 'extra_test_args', ['--restrict-to-path', '/foo']):
|
||||
self.assert_raises(PathNotAllowed, lambda: self.cmd('init', self.repository_location + '_1'))
|
||||
path_prefix = os.path.dirname(self.repository_path)
|
||||
# restrict to repo directory's parent directory:
|
||||
with patch.object(RemoteRepository, 'extra_test_args', ['--restrict-to-path', path_prefix]):
|
||||
self.cmd('init', self.repository_location + '_2')
|
||||
# restrict to repo directory's parent directory and another directory:
|
||||
with patch.object(RemoteRepository, 'extra_test_args', ['--restrict-to-path', '/foo', '--restrict-to-path', path_prefix]):
|
||||
self.cmd('init', self.repository_location + '_3')
|
||||
|
||||
|
|
Loading…
Reference in New Issue