bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
3416.2.2
by Martin Pool
Change some callers to get file and directory permissions from bzrdir not LockableFiles |
1 |
# Copyright (C) 2005, 2008 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
13 |
# You should have received a copy of the GNU General Public License
|
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
|
|
16 |
||
17 |
||
18 |
"""Tests for bzr setting permissions.
|
|
19 |
||
20 |
Files in the branch control directory (.bzr or .bzr/branch) should inherit
|
|
21 |
the .bzr directory permissions.
|
|
22 |
So if the directory is group writable, the files and subdirs should be as well.
|
|
23 |
"""
|
|
24 |
||
25 |
# TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just
|
|
26 |
# defined by the local umask. This isn't terrible, is it
|
|
27 |
# the truly desired behavior?
|
|
28 |
||
29 |
import os |
|
30 |
import sys |
|
31 |
import stat |
|
32 |
from StringIO import StringIO |
|
33 |
||
34 |
from bzrlib.branch import Branch |
|
35 |
from bzrlib.bzrdir import BzrDir |
|
36 |
from bzrlib.lockable_files import LockableFiles |
|
|
2018.5.99
by Andrew Bennetts
Don't test mode setting for remote branches because they don't do mode setting. |
37 |
from bzrlib.remote import RemoteBranchFormat |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
38 |
from bzrlib.tests import TestCaseWithTransport, TestSkipped |
|
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
39 |
from bzrlib.tests.test_permissions import chmod_r, check_mode_r |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
40 |
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer |
41 |
from bzrlib.transport import get_transport |
|
42 |
from bzrlib.workingtree import WorkingTree |
|
43 |
||
44 |
||
45 |
class TestPermissions(TestCaseWithTransport): |
|
46 |
||
47 |
def test_new_branch(self): |
|
|
2018.5.99
by Andrew Bennetts
Don't test mode setting for remote branches because they don't do mode setting. |
48 |
if isinstance(self.branch_format, RemoteBranchFormat): |
49 |
# Remote branch format have no permission logic in them; there's
|
|
50 |
# nothing to test here.
|
|
51 |
return
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
52 |
if sys.platform == 'win32': |
53 |
raise TestSkipped('chmod has no effect on win32') |
|
54 |
# also, these are BzrBranch format specific things..
|
|
55 |
os.mkdir('a') |
|
56 |
mode = stat.S_IMODE(os.stat('a').st_mode) |
|
57 |
t = self.make_branch_and_tree('.') |
|
58 |
b = t.branch |
|
|
3416.2.2
by Martin Pool
Change some callers to get file and directory permissions from bzrdir not LockableFiles |
59 |
self.assertEqualMode(mode, b.bzrdir._get_dir_mode()) |
60 |
self.assertEqualMode(mode & ~07111, b.bzrdir._get_file_mode()) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
61 |
self.assertEqualMode(mode, b.control_files._dir_mode) |
62 |
self.assertEqualMode(mode & ~07111, b.control_files._file_mode) |
|
63 |
||
64 |
os.mkdir('b') |
|
65 |
os.chmod('b', 02777) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
66 |
b = self.make_branch('b') |
|
3416.2.2
by Martin Pool
Change some callers to get file and directory permissions from bzrdir not LockableFiles |
67 |
self.assertEqualMode(02777, b.bzrdir._get_dir_mode()) |
68 |
self.assertEqualMode(00666, b.bzrdir._get_file_mode()) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
69 |
self.assertEqualMode(02777, b.control_files._dir_mode) |
70 |
self.assertEqualMode(00666, b.control_files._file_mode) |
|
|
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
71 |
check_mode_r(self, 'b/.bzr', 00666, 02777) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
72 |
|
73 |
os.mkdir('c') |
|
74 |
os.chmod('c', 02750) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
75 |
b = self.make_branch('c') |
|
3416.2.2
by Martin Pool
Change some callers to get file and directory permissions from bzrdir not LockableFiles |
76 |
self.assertEqualMode(02750, b.bzrdir._get_dir_mode()) |
|
3416.2.5
by Martin Pool
Correction to branch permissions test |
77 |
self.assertEqualMode(00640, b.bzrdir._get_file_mode()) |
78 |
self.assertEqualMode(02750, b.control_files._dir_mode) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
79 |
self.assertEqualMode(00640, b.control_files._file_mode) |
|
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
80 |
check_mode_r(self, 'c/.bzr', 00640, 02750) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
81 |
|
82 |
os.mkdir('d') |
|
83 |
os.chmod('d', 0700) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
84 |
b = self.make_branch('d') |
|
3416.2.2
by Martin Pool
Change some callers to get file and directory permissions from bzrdir not LockableFiles |
85 |
self.assertEqualMode(0700, b.bzrdir._get_dir_mode()) |
86 |
self.assertEqualMode(0600, b.bzrdir._get_file_mode()) |
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
87 |
self.assertEqualMode(0700, b.control_files._dir_mode) |
88 |
self.assertEqualMode(0600, b.control_files._file_mode) |
|
|
1685.1.17
by John Arbash Meinel
test_permissions.check_mode_r needs to pass a path that the '.' transport can handle |
89 |
check_mode_r(self, 'd/.bzr', 00600, 00700) |