~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2008 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Tests for bzr setting permissions.
29
29
import os
30
30
import sys
31
31
import stat
32
 
from StringIO import StringIO
33
32
 
34
33
from bzrlib import tests
35
 
from bzrlib.branch import Branch
36
 
from bzrlib.bzrdir import BzrDir
37
 
from bzrlib.lockable_files import LockableFiles
 
34
from bzrlib.branch import BzrBranch
 
35
from bzrlib.controldir import ControlDir
38
36
from bzrlib.remote import RemoteBranchFormat
39
 
from bzrlib.tests.test_permissions import chmod_r, check_mode_r
40
 
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
41
 
from bzrlib.transport import get_transport
42
 
from bzrlib.workingtree import WorkingTree
 
37
from bzrlib.tests.test_permissions import check_mode_r
43
38
 
44
39
 
45
40
class _NullPermsStat(object):
64
59
                                          ' permission logic')
65
60
        if sys.platform == 'win32':
66
61
            raise tests.TestNotApplicable('chmod has no effect on win32')
67
 
        # also, these are BzrBranch format specific things..
68
62
        os.mkdir('a')
69
63
        mode = stat.S_IMODE(os.stat('a').st_mode)
70
64
        t = self.make_branch_and_tree('.')
 
65
        # also, these are BzrBranch format specific things..
 
66
        if not isinstance(t.branch, BzrBranch):
 
67
            raise tests.TestNotApplicable(
 
68
                "Only applicable to bzr branches")
71
69
        b = t.branch
72
70
        self.assertEqualMode(mode, b.bzrdir._get_dir_mode())
73
71
        self.assertEqualMode(mode & ~07111, b.bzrdir._get_file_mode())
91
89
                                          ' permission logic')
92
90
        if sys.platform == 'win32':
93
91
            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
 
92
        elif sys.platform == 'darwin' or 'freebsd' in sys.platform:
 
93
            # FreeBSD-based platforms create temp dirs with the 'wheel' group,
 
94
            # which users are not likely to be in, and this prevents us
 
95
            # from setting the sgid bit
98
96
            os.chown(self.test_dir, os.getuid(), os.getgid())
99
 
        # also, these are BzrBranch format specific things..
100
97
        t = self.make_branch_and_tree('.')
101
98
        b = t.branch
 
99
        # also, these are BzrBranch format specific things..
 
100
        if not isinstance(b, BzrBranch):
 
101
            raise tests.TestNotApplicable(
 
102
                "Only applicable to bzr branches")
102
103
        os.mkdir('b')
103
104
        os.chmod('b', 02777)
104
105
        b = self.make_branch('b')
125
126
            raise tests.TestNotApplicable('Remote branches have no'
126
127
                                          ' permission logic')
127
128
        self.make_branch_and_tree('.')
128
 
        bzrdir = BzrDir.open('.')
 
129
        bzrdir = ControlDir.open('.')
129
130
        # Monkey patch the transport
130
131
        _orig_stat = bzrdir.transport.stat
131
132
        def null_perms_stat(*args, **kwargs):