summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-09-15 03:00:11 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-09-15 03:00:11 +0000
commitad458a91dc96e7ba50bff6a45205db69b6befa41 (patch)
tree7cb15a9aeff8a5a5558d40596902ef003ceb5ba4 /rdiff-backup/testing
parent5137df996ccc2faf82a473b16e45d4a371a183f9 (diff)
downloadrdiff-backup-ad458a91dc96e7ba50bff6a45205db69b6befa41.tar.gz
Changed handling of ownership, added --user/group-mapping-file options
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@436 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r--rdiff-backup/testing/commontest.py7
-rw-r--r--rdiff-backup/testing/roottest.py45
2 files changed, 48 insertions, 4 deletions
diff --git a/rdiff-backup/testing/commontest.py b/rdiff-backup/testing/commontest.py
index 4cfac90..e80d699 100644
--- a/rdiff-backup/testing/commontest.py
+++ b/rdiff-backup/testing/commontest.py
@@ -51,11 +51,10 @@ def rdiff_backup(source_local, dest_local, src_dir, dest_dir,
"""
if not source_local:
- src_dir = ("cd test1; ../%s/rdiff-backup --server::../%s" %
- (SourceDir, src_dir))
+ src_dir = ("'cd test1; ../%s --server'::../%s" % (RBBin, src_dir))
if not dest_local:
- dest_dir = ("test2/tmp; ../../%s/rdiff-backup --server::../../%s" %
- (SourceDir, dest_dir))
+ dest_dir = ("'cd test2/tmp; ../../%s --server'::../../%s" %
+ (RBBin, dest_dir))
cmdargs = [RBBin, extra_options]
if not (source_local and dest_local): cmdargs.append("--remote-schema %s")
diff --git a/rdiff-backup/testing/roottest.py b/rdiff-backup/testing/roottest.py
index 73fc4fd..176d4ad 100644
--- a/rdiff-backup/testing/roottest.py
+++ b/rdiff-backup/testing/roottest.py
@@ -14,6 +14,7 @@ Globals.counter = 0
verbosity = 6
log.Log.setverbosity(verbosity)
user = 'ben' # Non-root user to su to
+userid = 500 # id of user above
assert os.getuid() == 0, "Run this test as root!"
def Run(cmd):
@@ -28,6 +29,50 @@ class RootTest(unittest.TestCase):
def testLocal2(self): BackupRestoreSeries(1, 1, self.dirlist2)
def testRemote(self): BackupRestoreSeries(None, None, self.dirlist1)
+ def test_ownership_mapping(self):
+ """Test --user-mapping-file and --group-mapping-file options"""
+ def write_ownership_dir():
+ """Write the directory testfiles/root_mapping"""
+ rp = rpath.RPath(Globals.local_connection,
+ "testfiles/root_mapping")
+ if rp.lstat(): Myrm(rp.path)
+ rp.mkdir()
+ rp1 = rp.append('1')
+ rp1.touch()
+ rp2 = rp.append('2')
+ rp2.touch()
+ rp2.chown(userid, 1) # use groupid 1, usually bin
+ return rp
+
+ def write_mapping_files(dir_rp):
+ """Write user and group mapping files, return paths"""
+ user_map_rp = dir_rp.append('user_map')
+ group_map_rp = dir_rp.append('group_map')
+ user_map_rp.write_string('root:%s\n%s:root' % (user, user))
+ group_map_rp.write_string('0:1')
+ return user_map_rp.path, group_map_rp.path
+
+ def get_ownership(dir_rp):
+ """Return pair (ids of dir_rp/1, ids of dir_rp2) of ids"""
+ rp1, rp2 = map(dir_rp.append, ('1', '2'))
+ assert rp1.isreg() and rp2.isreg(), (rp1.isreg(), rp2.isreg())
+ return (rp1.getuidgid(), rp2.getuidgid())
+
+ in_rp = write_ownership_dir()
+ user_map, group_map = write_mapping_files(in_rp)
+ out_rp = rpath.RPath(Globals.local_connection, 'testfiles/output')
+ if out_rp.lstat(): Myrm(out_rp.path)
+
+ assert get_ownership(in_rp) == ((0,0), (userid, 1)), \
+ get_ownership(in_rp)
+ rdiff_backup(1, 0, in_rp.path, out_rp.path,
+ extra_options = ("--user-mapping-file %s "
+ "--group-mapping-file %s" %
+ (user_map, group_map)))
+ assert get_ownership(out_rp) == ((userid, 1), (0, 1)), \
+ get_ownership(in_rp)
+
+
class HalfRoot(unittest.TestCase):
"""Backing up files where origin is root and destination is non-root"""
def make_dirs(self):