def test_user_mapping(self):
		"""Test the user mapping file through the DefinedMap class"""
		mapping_string = """
root:bin
bin:root
500:501
0:sync
sync:0"""
		Globals.isdest = 1
		rootid = 0
		binid = pwd.getpwnam('bin')[2]
		syncid = pwd.getpwnam('sync')[2]
		daemonid = pwd.getpwnam('daemon')[2]
		user_group.init_user_mapping(mapping_string)

		assert user_group.UserMap(rootid, 'root') == binid
		assert user_group.UserMap(binid, 'bin') == rootid
		assert user_group.UserMap(0) == syncid
		assert user_group.UserMap(syncid, 'sync') == 0
		assert user_group.UserMap(500) == 501

		assert user_group.UserMap(501) == 501
		assert user_group.UserMap(123, 'daemon') == daemonid

		assert user_group.UserMap.map_acl(29378, 'aoeuth3t2ug89') is None
		assert user_group.UserMap.map_acl(0, 'aoeuth3t2ug89') is syncid

		if 0: code.InteractiveConsole(globals()).interact()
Exemple #2
0
    def test_user_mapping(self):
        """Test the user mapping file through the _DefinedMap class"""
        mapping_string = """
root:bin
bin:root
500:501
0:sync
sync:0"""
        Globals.isdest = 1
        rootid = 0
        binid = pwd.getpwnam('bin')[2]
        syncid = pwd.getpwnam('sync')[2]
        daemonid = pwd.getpwnam('daemon')[2]
        user_group.init_user_mapping(mapping_string)

        assert user_group._user_map(rootid, 'root') == binid
        assert user_group._user_map(binid, 'bin') == rootid
        assert user_group._user_map(0) == syncid
        assert user_group._user_map(syncid, 'sync') == 0
        assert user_group._user_map(500) == 501

        assert user_group._user_map(501) == 501
        assert user_group._user_map(123, 'daemon') == daemonid

        assert user_group._user_map.map_acl(29378, 'aoeuth3t2ug89') is None
        assert user_group._user_map.map_acl(0, 'aoeuth3t2ug89') is syncid

        if 0:
            code.InteractiveConsole(globals()).interact()
Exemple #3
0
 def setUp(self):
     """Start server"""
     Log.setverbosity(5)
     Globals.change_source_perms = 1
     SetConnections.UpdateGlobal('checkpoint_interval', 3)
     user_group.init_user_mapping()
     user_group.init_group_mapping()
    def test_user_mapping(self):
        """Test the user mapping file through the _DefinedMap class"""
        mapping_string = """
root:bin
bin:root
500:501
0:sync
sync:0"""
        Globals.isdest = 1
        rootid = 0
        binid = pwd.getpwnam('bin')[2]
        syncid = pwd.getpwnam('sync')[2]
        daemonid = pwd.getpwnam('daemon')[2]
        user_group.init_user_mapping(mapping_string)

        self.assertEqual(user_group._user_map(rootid, 'root'), binid)
        self.assertEqual(user_group._user_map(binid, 'bin'), rootid)
        self.assertEqual(user_group._user_map(0), syncid)
        self.assertEqual(user_group._user_map(syncid, 'sync'), 0)
        self.assertEqual(user_group._user_map(500), 501)

        self.assertEqual(user_group._user_map(501), 501)
        self.assertEqual(user_group._user_map(123, 'daemon'), daemonid)

        self.assertIsNone(user_group._user_map.map_acl(29378, 'aoeuth3t2ug89'))
        self.assertIs(user_group._user_map.map_acl(0, 'aoeuth3t2ug89'), syncid)

        if 0:
            code.InteractiveConsole(globals()).interact()
 def setUp(self):
     """Start server"""
     Log.setverbosity(5)
     Globals.change_source_perms = 1
     SetConnections.UpdateGlobal("checkpoint_interval", 3)
     user_group.init_user_mapping()
     user_group.init_group_mapping()
	def test_default_mapping(self):
		"""Test the default user mapping"""
		Globals.isdest = 1
		rootid = 0
		binid = pwd.getpwnam('bin')[2]
		syncid = pwd.getpwnam('sync')[2]
		user_group.init_user_mapping()
		assert user_group.UserMap(0) == 0
		assert user_group.UserMap(0, 'bin') == binid
		assert user_group.UserMap(0, 'sync') == syncid
		assert user_group.UserMap.map_acl(0, 'aoeuth3t2ug89') is None
Exemple #7
0
 def test_default_mapping(self):
     """Test the default user mapping"""
     Globals.isdest = 1
     rootid = 0
     binid = pwd.getpwnam('bin')[2]
     syncid = pwd.getpwnam('sync')[2]
     user_group.init_user_mapping()
     assert user_group._user_map(0) == rootid
     assert user_group._user_map(0, 'bin') == binid
     assert user_group._user_map(0, 'sync') == syncid
     assert user_group._user_map.map_acl(0, 'aoeuth3t2ug89') is None
 def test_default_mapping(self):
     """Test the default user mapping"""
     Globals.isdest = 1
     rootid = 0
     binid = pwd.getpwnam('bin')[2]
     syncid = pwd.getpwnam('sync')[2]
     user_group.init_user_mapping()
     self.assertEqual(user_group._user_map(0), rootid)
     self.assertEqual(user_group._user_map(0, 'bin'), binid)
     self.assertEqual(user_group._user_map(0, 'sync'), syncid)
     self.assertIsNone(user_group._user_map.map_acl(0, 'aoeuth3t2ug89'))
Exemple #9
0
import unittest
import os
import io
import pwd
import grp
from rdiff_backup.eas_acls import AccessControlLists, metadata, ACLExtractor, \
    Record2ACL, ACL2Record, ExtendedAttributes, EAExtractor, EA2Record, Record2EA
from rdiff_backup import Globals, rpath, user_group
from commontest import rdiff_backup, abs_test_dir, abs_output_dir, abs_restore_dir, \
    BackupRestoreSeries, CompareRecursive

user_group.init_user_mapping()
user_group.init_group_mapping()
tempdir = rpath.RPath(Globals.local_connection, abs_output_dir)
restore_dir = rpath.RPath(Globals.local_connection, abs_restore_dir)


class EATest(unittest.TestCase):
    """Test extended attributes"""
    sample_ea = ExtendedAttributes(
        (), {
            b'user.empty':
            b'',
            b'user.not_empty':
            b'foobar',
            b'user.third':
            b'hello',
            b'user.binary':
            bytes((0, 1, 2, 140)) + b'/="',
            b'user.multiline':
            b"""This is a fairly long extended attribute.
Exemple #10
0
import unittest, os, time, cStringIO, posix1e, pwd, grp
from commontest import *
from rdiff_backup.eas_acls import *
from rdiff_backup import Globals, rpath, Time, user_group, log

user_group.init_user_mapping()
user_group.init_group_mapping()
tempdir = rpath.RPath(Globals.local_connection, "testfiles/output")
restore_dir = rpath.RPath(Globals.local_connection,
						  "testfiles/restore_out")
log.Log.setverbosity(3)

class EATest(unittest.TestCase):
	"""Test extended attributes"""
	sample_ea = ExtendedAttributes(
		(), {'user.empty':'', 'user.not_empty':'foobar', 'user.third':'hello',
			 'user.binary':chr(0)+chr(1)+chr(2)+chr(140)+'/="',
			 'user.multiline':"""This is a fairly long extended attribute.
			 Encoding it will require several lines of
			 base64.""" + chr(177)*300})
	empty_ea = ExtendedAttributes(())
	ea1 = ExtendedAttributes(('1',), sample_ea.attr_dict.copy())
	ea1.delete('user.not_empty')
	ea2 = ExtendedAttributes(('2',), sample_ea.attr_dict.copy())
	ea2.set('user.third', 'Another random attribute')
	ea3 = ExtendedAttributes(('3',))
	ea4 = ExtendedAttributes(('4',), {'user.deleted': 'File to be deleted'})
	ea_testdir1 = rpath.RPath(Globals.local_connection, "testfiles/ea_test1")
	ea_testdir2 = rpath.RPath(Globals.local_connection, "testfiles/ea_test2")

	def make_temp(self):
Exemple #11
0
 def setUp(self):
     """Start server"""
     Globals.change_source_perms = 1
     Globals.set_all('checkpoint_interval', 3)
     user_group.init_user_mapping()
     user_group.init_group_mapping()