~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_permissions.py

  • Committer: Vincent Ladeuil
  • Date: 2008-08-31 19:19:08 UTC
  • mto: (3668.1.1 trunk) (3703.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 3669.
  • Revision ID: v.ladeuil+lp@free.fr-20080831191908-l4ke1ttjj61sit76
Isolate group sticky bit related tests.

* bzrlib/tests/test_permissions.py:
(TestPermissions.test_new_files_group_sticky_bit): Spliited out
from test_new_files for better defect localization.

* bzrlib/tests/branch_implementations/test_permissions.py:
(TestPermissions.test_new_branch_group_sticky_bit): Splitted out
from test_new_branch for better defect localization.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
                                          ' permission logic')
65
65
        if sys.platform == 'win32':
66
66
            raise tests.TestNotApplicable('chmod has no effect on win32')
67
 
        elif sys.platform == 'darwin':
68
 
            # OS X creates temp dirs with the 'wheel' group, which users are
69
 
            # not likely to be in, and this prevents us from setting the sgid
70
 
            # bit
71
 
            os.chown(self.test_dir, os.getuid(), os.getgid())
72
67
        # also, these are BzrBranch format specific things..
73
68
        os.mkdir('a')
74
69
        mode = stat.S_IMODE(os.stat('a').st_mode)
79
74
        self.assertEqualMode(mode, b.control_files._dir_mode)
80
75
        self.assertEqualMode(mode & ~07111, b.control_files._file_mode)
81
76
 
 
77
        os.mkdir('d')
 
78
        os.chmod('d', 0700)
 
79
        b = self.make_branch('d')
 
80
        self.assertEqualMode(0700, b.bzrdir._get_dir_mode())
 
81
        self.assertEqualMode(0600, b.bzrdir._get_file_mode())
 
82
        self.assertEqualMode(0700, b.control_files._dir_mode)
 
83
        self.assertEqualMode(0600, b.control_files._file_mode)
 
84
        check_mode_r(self, 'd/.bzr', 00600, 00700)
 
85
 
 
86
    def test_new_branch_group_sticky_bit(self):
 
87
        if isinstance(self.branch_format, RemoteBranchFormat):
 
88
            # Remote branch format have no permission logic in them; there's
 
89
            # nothing to test here.
 
90
            raise tests.TestNotApplicable('Remote branches have no'
 
91
                                          ' permission logic')
 
92
        if sys.platform == 'win32':
 
93
            raise tests.TestNotApplicable('chmod has no effect on win32')
 
94
        elif sys.platform == 'darwin':
 
95
            # OS X creates temp dirs with the 'wheel' group, which users are
 
96
            # not likely to be in, and this prevents us from setting the sgid
 
97
            # bit
 
98
            os.chown(self.test_dir, os.getuid(), os.getgid())
 
99
        # also, these are BzrBranch format specific things..
 
100
        t = self.make_branch_and_tree('.')
 
101
        b = t.branch
82
102
        os.mkdir('b')
83
103
        os.chmod('b', 02777)
84
104
        b = self.make_branch('b')
97
117
        self.assertEqualMode(00640, b.control_files._file_mode)
98
118
        check_mode_r(self, 'c/.bzr', 00640, 02750)
99
119
 
100
 
        os.mkdir('d')
101
 
        os.chmod('d', 0700)
102
 
        b = self.make_branch('d')
103
 
        self.assertEqualMode(0700, b.bzrdir._get_dir_mode())
104
 
        self.assertEqualMode(0600, b.bzrdir._get_file_mode())
105
 
        self.assertEqualMode(0700, b.control_files._dir_mode)
106
 
        self.assertEqualMode(0600, b.control_files._file_mode)
107
 
        check_mode_r(self, 'd/.bzr', 00600, 00700)
108
 
 
109
120
    def test_mode_0(self):
110
121
        """Test when a transport returns null permissions for .bzr"""
111
122
        if isinstance(self.branch_format, RemoteBranchFormat):