diff options
author | Thomas Waldmann <tw@waldmann-edv.de> | 2016-08-02 15:01:30 +0200 |
---|---|---|
committer | Thomas Waldmann <tw@waldmann-edv.de> | 2016-08-18 22:40:50 +0200 |
commit | 28cbf24815649b5dcb453498dae64948abbdf411 (patch) | |
tree | 5ff6bdb2282726dc458e6d9bdb26cb0405da7963 | |
parent | cba0c3dc59304f8c5f84a4ca9335d2cef9893038 (diff) |
more tests for --restrict-to-path
especially test that other directory names sharing same name prefix are not allowed.
-rw-r--r-- | borg/testsuite/archiver.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index f14edd533..1774f347e 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -1305,12 +1305,21 @@ class RemoteArchiverTestCase(ArchiverTestCase): prefix = '__testsuite__:' def test_remote_repo_restrict_to_path(self): - self.cmd('init', self.repository_location) - path_prefix = os.path.dirname(self.repository_path) + # restricted to repo directory itself: + with patch.object(RemoteRepository, 'extra_test_args', ['--restrict-to-path', self.repository_path]): + self.cmd('init', self.repository_location) + # 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') |